public ActionResult EditPost(Post p, string text, string text_lng) { if (p.upload != null) { string filename = System.IO.Path.GetFileName(p.upload.FileName); p.upload.SaveAs(Server.MapPath("~/Assets/img/bg-img/" + filename)); p.image = "/Assets/img/bg-img/" + filename; } p.date = DateTime.Now; p.text = text; p.text_lng = text_lng; PostBL postBL = new PostBL(); postBL.EditPost(p); return(RedirectToAction("News", "Home")); }
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)); }