Exemplo n.º 1
0
        public void UpdateShowComment(ShowComment model)
        {
            ShowComment showComment = context.ShowComments.SingleOrDefault(u => u.Id == model.Id);

            if (showComment != null)
            {
                context.Entry(showComment).CurrentValues.SetValues(model);
                context.SaveChangesAsync();
            }
        }
Exemplo n.º 2
0
        }//首页,page实现分页

        public List <ShowComment> GetBlogComment(int id)
        {
            //评论模块
            var temp = repository.GetCommitsByTextID(id);
            var cmt  = new List <ShowComment>();
            int i    = 1;

            foreach (var item in temp)
            {
                var tmp = new ShowComment();
                tmp.Name    = repository.GetUserByAccount(item.Account).Name;
                tmp.Date    = item.CommentChangeDate.ToString("yyyy-MM-dd") + "  " + item.CommentChangeDate.ToShortTimeString();
                tmp.Account = item.Account;
                tmp.Content = item.CommentText;
                tmp.Id      = item.CommmentID;
                tmp.Num     = i;
                cmt.Add(tmp);
                i++;
            }
            return(cmt);
        }//根据文章id,获取文章的评论
Exemplo n.º 3
0
        public List <ShowComment> GetNewCommit(int n)//获取最新评论,参数n为获取的评论数量
        {
            var blog        = repository.GetTextsAll();
            var commit      = repository.GetCommentsAll();
            var Ctime_list  = commit.OrderByDescending(m => m.CommentChangeDate).Take(n).ToList();
            var CommentList = new List <ShowComment>();
            var users       = repository.GetUsersAll();

            foreach (var item in Ctime_list)
            {
                var textT = blog.Where(m => m.TextID == item.TextID).ToList();
                var NameC = users.Where(m => m.Account == item.Account).ToList();
                var tempC = new ShowComment
                {
                    TextID    = item.TextID,
                    Content   = item.CommentText,
                    TextTitle = textT[0].TextTitle,
                    Name      = NameC[0].Name,
                    Date      = item.CommentChangeDate.ToString()
                };
                CommentList.Add(tempC);
            }
            return(CommentList);
        }
Exemplo n.º 4
0
 public void UpdateShowComment(ShowComment model)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public void AddShowComment(ShowComment model)
 {
     context.ShowComments.Add(model);
     context.SaveChangesAsync();
 }