Esempio n. 1
0
        public CommentDTO GetComments()
        {
            CommentDTO commentDTO = new CommentDTO();

            commentDTO.Comments = commentDAO.GetComments();
            return(commentDTO);
        }
        public PartialViewResult PostComments(int postId)
        {
            IEnumerable <ViewCommentsModel> viewComments = new List <ViewCommentsModel>();

            viewComments = ViewCommentsModel.GetListComments(CommentDAO.GetComments(postId));
            return(PartialView("_Comments", viewComments));
        }
Esempio n. 3
0
        public ActionResult Detail(int id)
        {
            Post           post     = PostDAO.FindId(id);
            List <Comment> comments = CommentDAO.GetComments(id);

            ViewBag.Post     = post;
            ViewBag.Comments = comments;
            return(View());
        }
Esempio n. 4
0
 public ViewPostModel(Post post)
 {
     PostId    = post.PostId;
     PostTitle = post.PostTitle;
     PostBody  = post.PostBody;
     PostDate  = post.PostDate;
     AuthorId  = post.AuthorId;
     Author    = UserDAO.GetUsername(post.AuthorId);
     Comments  = ViewCommentsModel.GetListComments(CommentDAO.GetComments(post.PostId));
 }
        public PartialViewResult AddComment(int PostId, string UserName, string Email, string CommentText)
        {
            int?userId = null;

            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                UserDAO.GetUserId(User.Identity.Name);
            }
            CommentDAO.AddComments(PostId, userId, UserName, Email, CommentText);
            IEnumerable <ViewCommentsModel> viewComments = new List <ViewCommentsModel>();

            viewComments = ViewCommentsModel.GetListComments(CommentDAO.GetComments(PostId));
            return(PartialView("_Comments", viewComments));
        }