📄 contentinfo.cs
字号:
namespace ASPNET.StarterKit.Communities {
using System;
using System.Data;
using System.Data.SqlClient;
//*********************************************************************
//
// ContentInfo Class
//
// Represents all information about a particular content item.
// This is the base class for the BookInfo, DownloadInfo, PhotoInfo
// ArticleInfo, etc. classes.
//
//*********************************************************************
public class ContentInfo
{
int _contentPageID = -1;
string _title = String.Empty;
string _briefDescription = String.Empty;
DateTime _dateCreated;
DateTime _dateUpdated;
DateTime _dateCommented;
int _sectionID = -1;
string _author = String.Empty;
int _topicID = -1;
string _topicName = String.Empty;
string _topicImage = String.Empty;
int _yourRating = -1;
int _averageRating = -1;
int _viewCount = -1;
int _commentCount = -1;
bool _hasRead = false;
string _remoteAuthor = String.Empty;
//*********************************************************************
//
// ContentInfo Constructor
//
// Initializes content information.
//
//*********************************************************************
public ContentInfo(SqlDataReader dr)
{
// Required fields
_contentPageID = (int)dr["ContentPage_ID"];
_title = (string)dr["ContentPage_Title"];
_briefDescription = (string)dr["ContentPage_Description"];
_dateCreated = (DateTime)dr["ContentPage_DateCreated"];
_sectionID = (int)dr["ContentPage_SectionID"];
_viewCount = (int)dr["ContentPage_ViewCount"];
_commentCount = (int)dr["CommentCount"];
_hasRead = (bool)dr["HasRead"];
_remoteAuthor = (string)dr["RemoteUsername"];
// Optional fields
if (dr["ContentPage_DateUpdated"] != DBNull.Value)
_dateUpdated = (DateTime)dr["ContentPage_DateUpdated"];
if (dr["ContentPage_DateCommented"] != DBNull.Value)
_dateCommented = (DateTime)dr["ContentPage_DateCommented"];
if (dr["Username"] != DBNull.Value)
_author = (string)dr["Username"];
if (dr["Topic_ID"] != DBNull.Value)
_topicID = (int)dr["Topic_ID"];
if (dr["Topic_Name"] != DBNull.Value)
_topicName = (string)dr["Topic_Name"];
if (dr["Topic_Image"] != DBNull.Value)
_topicImage = (string)dr["Topic_Image"];
if (dr["YourRating"] != DBNull.Value)
_yourRating = (int)dr["YourRating"];
if (dr["AverageRating"] != DBNull.Value)
_averageRating = (int)dr["AverageRating"];
}
public ContentInfo()
{
}
//*********************************************************************
//
// ContentPageID Property
//
// Represents the content page ID.
//
//*********************************************************************
public int ContentPageID {
get {return _contentPageID;}
set {_contentPageID = value;}
}
//*********************************************************************
//
// Title Property
//
// Represents the content page Title.
//
//*********************************************************************
public string Title {
get {return _title;}
set {_title = value;}
}
//*********************************************************************
//
// BriefDescription Property
//
// Represents the content page brief description.
//
//*********************************************************************
public string BriefDescription {
get {return _briefDescription;}
set {_briefDescription = value;}
}
//*********************************************************************
//
// DateCreated Property
//
// Represents the date that a content page was added to
// the database.
//
//*********************************************************************
public DateTime DateCreated {
get {return _dateCreated;}
set {_dateCreated = value;}
}
//*********************************************************************
//
// DateUpdated Property
//
// Represents the date that a content page was last updated
//
//*********************************************************************
public DateTime DateUpdated {
get {return _dateUpdated;}
set {_dateUpdated = value;}
}
//*********************************************************************
//
// DateCommented Property
//
// Represents the date that a content page last had a comment added
//
//*********************************************************************
public DateTime DateCommented {
get {return _dateCommented;}
set {_dateCommented = value;}
}
//*********************************************************************
//
// SectionID Property
//
// Represents the section that contains this content page.
//
//*********************************************************************
public int SectionID {
get {return _sectionID;}
set {_sectionID = value;}
}
//*********************************************************************
//
// Author Property
//
// Represents the username of the author of this content page.
//
//*********************************************************************
public string Author {
get {return _author;}
set {_author = value;}
}
//*********************************************************************
//
// TopicID Property
//
// Represents the content page topic ID.
//
//*********************************************************************
public int TopicID {
get {return _topicID;}
set {_topicID = value;}
}
//*********************************************************************
//
// TopicName Property
//
// Represents the content page topic name.
//
//*********************************************************************
public string TopicName {
get {return _topicName;}
set {_topicName = value;}
}
//*********************************************************************
//
// TopicImage Property
//
// Represents the content page topic image.
//
//*********************************************************************
public string TopicImage {
get {return _topicImage;}
set {_topicImage = value;}
}
//*********************************************************************
//
// YourRating Property
//
// Represents the current user's rating of the content page.
//
//*********************************************************************
public int YourRating {
get {return _yourRating;}
set {_yourRating = value;}
}
//*********************************************************************
//
// AverageRating Property
//
// Represents the average rating of the content page.
//
//*********************************************************************
public int AverageRating {
get {return _averageRating;}
set {_averageRating = value;}
}
//*********************************************************************
//
// ViewCount Property
//
// Represents the number of times the content page
// has been requested.
//
//*********************************************************************
public int ViewCount {
get {return _viewCount;}
set {_viewCount = value;}
}
//*********************************************************************
//
// CommentCount Property
//
// Represents the number of comments that have been added to
// the content page.
//
//*********************************************************************
public int CommentCount {
get {return _commentCount;}
set {_commentCount = value;}
}
//*********************************************************************
//
// HasRead Property
//
// True, if the user has previously viewed content.
//
//*********************************************************************
public bool HasRead {
get {return _hasRead;}
set {_hasRead = value;}
}
//*********************************************************************
//
// RemoteAuthor Property
//
// The name of the name remote author of this content.
//
//*********************************************************************
public string RemoteAuthor {
get {return _remoteAuthor;}
set {_remoteAuthor = value;}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -