public ActionResult UserDeletePost(int postId) { using (BlogDbContext db = new BlogDbContext()) { var username = User.Identity.Name; if (CheckMethods.IsUsersPost(postId, username)) { DeletePost(postId); return(RedirectToAction("Profile", "Account")); } } return(RedirectToAction("AccessDenied", "Error")); }
public ActionResult UserUpdatePost(int postId, string title, string content) { using (BlogDbContext db = new BlogDbContext()) { var username = User.Identity.Name; if (CheckMethods.IsUsersPost(postId, username)) { InsertMethods.UpdatePost(postId, title, content); return(RedirectToAction("ShowPost", "MainPage", new { postId })); } } return(RedirectToAction("AccessDenied", "Error")); }
public ActionResult OpenUserUpdatePost(int postid) { using (BlogDbContext db = new BlogDbContext()) { var username = User.Identity.Name; if (CheckMethods.IsUsersPost(postid, username)) { ViewData["Layout"] = GetMethods.GetLayout(User.Identity.Name); var post = db.Posts.FirstOrDefault(p => p.PostId == postid); return(View("~/Views/User/UserUpdatePost.cshtml", post)); } return(RedirectToAction("AccessDenied", "Error")); } }