public async Task <IActionResult> DeleteArtist([FromRoute] int artistId) { try { var exists = await _artistService.ArtistIdExistsAsync(artistId); if (!exists) { return(NotFound(new ErrorResponse(ErrorMessages.Artist.DoesNotExist))); } var deleted = await _artistService.DeleteArtistAsync(artistId); if (deleted) { return(NoContent()); } return(NotFound(new ErrorResponse(ErrorMessages.Artist.DoesNotExist))); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorResponse(ErrorMessages.Artist.FailedDelete))); } }
public async Task <ActionResult> Delete(int id) { try { await _artistService.DeleteArtistAsync(id).ConfigureAwait(true); } catch (NullReferenceException) { return(NotFound()); } return(NoContent()); }