public async Task <IActionResult> Delete(string postId) { var deleteResult = await _postRepo.DeletePost(postId); return(RedirectToAction("Index", "PostManager", new { PostDeleted = deleteResult })); }
public ActionResult DeletePost(Guid id) { if (_postRepo.DeletePost(id)) { return(Ok("Post was deleted")); } return(BadRequest("Some problem occured during deletion the post")); }
public async Task <ActionResult> DeletePost(int id) { var postModelFromRepo = await _repository.GetPostByIdAsync(id); if (postModelFromRepo == null) { return(NotFound()); } _repository.DeletePost(postModelFromRepo); await _repository.SaveChangesAsync(); return(NoContent()); }
public async Task<IActionResult> DeletePost(int id){ try { await _repo.DeletePost(id); if(await _repo.SaveChangesAsync()){ return Ok("Postagem deletada"); } return BadRequest("Não foi possível adicionar a postagem"); } catch (System.Exception) { return BadRequest("Não foi possível adicionar a postagem"); } }
public async void DeletePost(string content) { int userId = Int32.Parse(content); await _postRepo.DeletePost(userId); }