public async Task <IActionResult> Delete(int id) { if (!User.Identity.IsAuthenticated) { throw new AuthenticationException(); } var result = await _cardsService.DeleteCard(id); var response = new ApiResponse <bool>(result); return(Ok(response)); }
public async Task <IActionResult> DeleteCard(int cardId) { try { await cardsService.DeleteCard(cardId); } catch (ArgumentException) { return(BadRequest()); } return(NoContent()); }
public async Task <IActionResult> DeleteCard(string id) { try { await _cardsService.DeleteCard(id); return(Ok("Card has been deleted")); } catch (Exception ex) { var errorMessage = "There was an error while trying to list Word Cards from MongoDB"; return(BadRequest(errorMessage + "\n" + ex)); } }