public void UpdatePost(UpdatePosts entity) { Posts postToUpdate = this._DbContext.Posts.Find(entity.PostId); postToUpdate.PostContent = entity.PostContent; this._DbContext.SaveChanges(); }
public void UpdatePost([FromBody] UpdatePosts data) { try { _unitOfWork.PostsRepository.UpdatePost(data); } catch (Exception ex) { throw ex; } }
public IActionResult Edit(int id, [Bind("PostId,Title,PostContent")] UpdatePosts post) { if (id != post.PostId) { return(NotFound()); } if (ModelState.IsValid) { _unitOfWork.PostsRepository.UpdatePost(post); return(RedirectToAction(nameof(Index))); } return(View(post)); }