示例#1
0
        public ActionResult DeletePost(int id)
        {
            PostBL      postBL   = new PostBL();
            List <Post> postList = postBL.GetPosts();
            Post        post     = postList.Where(u => u.PostId == id).Single();

            postBL.DeletePost(post);

            NewsVM news = new NewsVM();

            news.posts = postBL.GetPosts();
            news.posts.Reverse();

            return(RedirectToAction("News", "Home", news));
        }
示例#2
0
        public ActionResult EditPost(int id)
        {
            PostBL      postBL   = new PostBL();
            List <Post> postList = postBL.GetPosts();
            Post        post     = postList.Where(u => u.PostId == id).Single();

            return(View(post));
        }
示例#3
0
        public ActionResult News()
        {
            PostBL postBL = new PostBL();
            NewsVM news   = new NewsVM();

            news.posts = postBL.GetPosts();
            news.posts.Reverse();
            return(View(news));
        }
示例#4
0
        public ActionResult CommentList(CommentsVM comVM)
        {
            comVM.newComment.date = DateTime.Now;

            CommentBL commentBL = new CommentBL();

            commentBL.AddComment(comVM.newComment);
            int postId = comVM.newComment.PostId;

            comVM.commentsList = commentBL.FindComments(postId);
            comVM.commentsList.Reverse();

            PostBL      postBL = new PostBL();
            List <Post> list   = postBL.GetPosts();
            Post        post   = list.Where(u => u.PostId == postId).Single();

            post.numOfComments += 1;
            postBL.EditPost(post);

            return(PartialView("CommentList", comVM));
        }
示例#5
0
        public ActionResult DeleteComment(int id)
        {
            CommentBL commentBL = new CommentBL();
            Comment   c         = commentBL.GetComments().Where(u => u.CommentId == id).Single();

            commentBL.DeleteComment(c);
            int postId = c.PostId;

            PostBL      postBL = new PostBL();
            List <Post> list   = postBL.GetPosts();
            Post        post   = list.Where(u => u.PostId == postId).Single();

            post.numOfComments -= 1;
            postBL.EditPost(post);

            CommentsVM comVM = new CommentsVM();

            comVM.commentsList = commentBL.FindComments(postId);
            comVM.commentsList.Reverse();

            return(PartialView("CommentList", comVM));
        }