public IActionResult Edit(int id, EditPostVM editPostModel) { if (!ModelState.IsValid) { return(View(editPostModel)); } if (id != editPostModel.Id || editPostModel.AuthorUserId != User.Id()) { return(NotFound()); } var postModel = _postRepo.GetById(id); postModel.Title = editPostModel.Title; postModel.Body = editPostModel.Body; postModel.UpdatedAt = DateTime.Now; _postRepo.Context().SaveChanges(); return(RedirectToAction(nameof(Manage), new { id })); }