using System.Collections.Generic;

namespace ynhtm.Theme.Template.Post
{
    using DBUtility;

    /// <summary>
    /// 评论页模板。
    /// </summary>
    public abstract class Comment : TemplateList<Model.Post, Model.Comment>
    {
        protected override List<Model.Comment> GetList(ref int recordCount)
        {
            var setting = new BLL.Setting();
            var settingItem = setting.Get();
            var comment = new BLL.Comment();
            var order = "ORDER BY " + DAL.Comment.SQL_TABLE + "." + DAL.Comment.COMMENTID + (settingItem.CommentSort == 1 ? " DESC" : " ASC");
            return comment.GetList(ref recordCount, this.PageSize, this.PageIndex, DbBase.GetQuery().BracketBegin().Equal(DAL.Comment.SQL_TABLE + "." + DAL.Comment.ISAUDIT, true).Or().Equal(DAL.Comment.SQL_TABLE + "." + DAL.Comment.IPADDR, this.Request.UserHostAddress).BracketEnd().And().Equal(DAL.Comment.SQL_TABLE + "." + DAL.Comment.POSTID, this.Model.PostID), order).ToList<Model.Comment>(DAL.Comment.FillItem);
        }
    }
}
