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)); }
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)); }
public ActionResult News() { PostBL postBL = new PostBL(); NewsVM news = new NewsVM(); news.posts = postBL.GetPosts(); news.posts.Reverse(); return(View(news)); }
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)); }
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)); }