示例#1
0
        public IActionResult DeleteArtwork(int id)
        {
            Artwork artwork = _artworkRepository.GetBy(id);

            if (artwork == null)
            {
                return(NotFound());
            }
            _artworkRepository.Delete(artwork);
            _artworkRepository.SaveChanges();
            return(NoContent());
        }
示例#2
0
        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}"));
            }
        }
示例#3
0
 public void DeleteArtwork(Artwork artwork)
 {
     _artworkrepository.Delete(artwork);
     SaveArtwork();
 }