public IActionResult Delete(int id) { var author = _authorsService.GetAuthor(id); if (author == null) { return(BadRequest()); } _authorsService.DeleteAuthor(author); return(Ok()); }
public async Task <ActionResult <Models.Author> > DeleteAuthor(int id) { if (id == null) { return(StatusCode(StatusCodes.Status404NotFound, "Could not found the ID: " + id)); } var author = await _authorService.DeleteAuthor(id); if (author == null) { return(StatusCode(StatusCodes.Status404NotFound, "Could not found the ID: " + id)); } return(author); }
public ActionResult <bool> DeleteAuthor(int id) { try { var result = authorsService.DeleteAuthor(id); if (!result) { return(StatusCode(StatusCodes.Status500InternalServerError, "cannot delete author")); } return(Ok(result)); } catch (NotFoundItemException ex) { return(NotFound(ex.Message)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }