public ActionResult ApprovePost([FromQuery] int postId) { var result = _postRepository.ApprovePost(postId); if (result.IsError) { return(BadRequest(result.Message)); } return(Ok()); }
public object Approve(int id) { try { var post = _postRepository.GetById(id); if (post == null) { throw new Exception("Post no found."); } _postRepository.ApprovePost(id); return(new { message = "Post Approved." }); } catch (Exception ex) { return(BadRequest(new { message = "Error approving post.", error = ex.Message })); } }
public IActionResult ApprovePost(int id) { _postRepository.ApprovePost(id); return(RedirectToAction("AdminView", "Posts")); }