public IActionResult DeleteArtwork(int id) { Artwork artwork = _artworkRepository.GetBy(id); if (artwork == null) { return(NotFound()); } _artworkRepository.Delete(artwork); _artworkRepository.SaveChanges(); return(NoContent()); }
public async Task <ArtworkResponse> DeleteArtworkAsync(int id) { Artwork existingArtwork = await artworkRepository.FindByIdAsync(id); if (existingArtwork == null) { return(new ArtworkResponse("Artwork does not exist")); } try { artworkRepository.Delete(existingArtwork); await unitOfWork.CompleteAsync(); return(new ArtworkResponse(existingArtwork)); } catch (Exception ex) { return(new ArtworkResponse($"An error occured while deleting artwork {ex.Message}")); } }
public void DeleteArtwork(Artwork artwork) { _artworkrepository.Delete(artwork); SaveArtwork(); }