public ActionResult Edit(int id) { var userId = this.User.Identity.GetUserId(); var post = this.writerPosts .GetPostById(id) .FirstOrDefault(); if (userId == post.AuthorId) { var editPostViewModel = new WriterEditPostViewModel { Title = post.Title, Content = post.Content, CategoryId = post.CategoryId, UrlVideo = post.UrlVideo }; ViewBag.SelectedItem = populator.GetSelectedCategories(); return(View(editPostViewModel)); } this.TempData["Message"] = string.Format(GlobalConstants.FailMessage, "! This not your post!"); return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { var post = this.adminPosts .GetPostById(id) .FirstOrDefault(); var editPostViewModel = new AdminEditPostViewModel { Title = post.Title, Content = post.Content, CategoryId = post.CategoryId, Status = post.Status, UrlVideo = post.UrlVideo }; ViewBag.SelectedItem = populator.GetSelectedCategories(); return(View(editPostViewModel)); }