Ejemplo n.º 1
0
        public async Task <AnimeResponse> DeleteAsync(int id)
        {
            var existingAnime = await _animeRepository.FindByIdAsync(id);

            if (existingAnime == null)
            {
                return(new AnimeResponse("Anime not found."));
            }

            try
            {
                _animeRepository.Remove(existingAnime);
                await _unitOfWork.CompleteAsync();

                return(new AnimeResponse(existingAnime));
            }
            catch (Exception ex)
            {
                // Do some logging stuff
                return(new AnimeResponse($"An error occurred when deleting the Anime: {ex.Message}"));
            }
        }