public bool DeletePost([FromBody] PostOptions postOptions) { if (postOptions != null) { return(_postservices.DeletePost(postOptions.PostId)); } return(false); }
public IActionResult Delete(long id) { if (!_postServices.DeletePost(id)) { return(NotFound()); } return(NoContent()); }
public async Task <IActionResult> Delete(int id) { var result = await postServices.DeletePost(id); var response = new ApiResponse <bool>(result); return(Ok(response)); }
public async Task <IActionResult> DeleteConfirmed(int id, [FromServices] IPostCategoryServices postcategoryServices, [FromServices] ICommentServices commentServices) { await postServices.DeletePost(id); //two steps underneath not necessary Entity frameworks allready solves it, but it was a good exercise ;-) await DeleteExistingPostCategoryEntries(id, postcategoryServices); await DeleteExistingPostCommentEntries(id, commentServices); return(RedirectToAction("Index")); }
public IActionResult DeletePost([FromBody] DeletePostRequest request) { try { if (request == null) { return(BadRequest(new ErrorViewModel { ErrorCode = "400", ErrorMessage = "Please provide input information correctly." })); } if (request.PostId <= 0) { return(BadRequest(new ErrorViewModel { ErrorCode = "400", ErrorMessage = "Post not found" })); } var Post = _postRepository.FindById(request.PostId); if (Post == null) { return(BadRequest(new ErrorViewModel { ErrorCode = "400", ErrorMessage = "Post not found" })); } var response = _postServices.DeletePost(Post); if (response != "OK") { return(BadRequest("Can not execute. Plz contact admin")); } return(Ok(response)); } catch (Exception e) { return(BadRequest(new ErrorViewModel { ErrorCode = "400", ErrorMessage = $"Server Error: {e.Message}" })); } }
public async Task <IActionResult> Delete([FromRoute] int postId) { if (!(postId > 0)) { return(BadRequest("Post Id is Empty")); } var isDeleted = await _postServices.DeletePost(postId); if (isDeleted) { return(NoContent()); } return(NotFound()); }
public IActionResult DeletePost(string id) { postServices.DeletePost(id, User); return(RedirectToAction("SuccessfullAction", "Profiles", new { message = ControllerConstants.SuccessfullyDeletedPostMessage })); }