示例#1
0
 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"));
 }
示例#2
0
        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"));
        }
示例#3
0
        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"));
            }
        }