public async Task DeleteGenre(string name)
        {
            try
            {
                Genre g1 = await GetGenre(name);

                if (g1.Name != null)
                {
                    await _genreRep.DeleteGenre(g1);
                }
            }
            catch (Exception e)
            {
                if (e is GenreException ||
                    e is DALException)
                {
                    await GeneralLibraryLogic.SaveToLogFile(e.ToString());

                    throw new BLLGenreException("Cannot delete a genre atm try again later or call a manager");
                }
                else
                {
                    await GeneralLibraryLogic.SaveToLogFile(e.ToString());

                    throw new LibraryException("Unknown error inform a manager!");
                }
            }
        }
Exemple #2
0
        public IActionResult Delete(long genreId)
        {
            Genre deletedGenre = _repository.DeleteGenre(genreId);

            if (deletedGenre != null)
            {
                TempData["message"] = $"Жанр под названием \"{deletedGenre.Name}\" был успешно удален!";
            }
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult <GenreDTO> > DeleteGenre(int id)
        {
            if (id <= 0)
            {
                return(BadRequest());
            }
            await _genreRepository.DeleteGenre(id);

            return(NoContent());
        }
Exemple #4
0
        public async Task <ActionResult <GenreDTO> > DeleteGenre(int id)
        {
            var genreResult = await _genrerepository.DeleteGenre(id).ConfigureAwait(false);

            if (genreResult == null)
            {
                return(NotFound());
            }

            return(genreResult);
        }
Exemple #5
0
        public string Remove(int id)
        {
            genreRepository.DeleteGenre(id);
            genreRepository.Save();

            var albums = unitOfWork.AlbumRepository.GetAlbumsByGenreId(id);

            unitOfWork.AlbumRepository.DeleteRange(albums);
            unitOfWork.Save();

            return(string.Empty);
        }
Exemple #6
0
 public IActionResult Delete(int id)
 {
     try
     {
         var isDeleted = genreRepository.DeleteGenre(id);
         return(Ok(isDeleted));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public ActionResult DeleteMovie(int id)
        {
            Genre genre = _repo.GetGenreById(id);

            if (genre == null)
            {
                return(NotFound());
            }
            _repo.DeleteGenre(genre);
            _repo.SaveChanges();

            return(NoContent());
        }
        public async Task <ActionResult> Delete(int id)
        {
            var genre = await genreRepository.GetGenre(id);

            if (genre == null)
            {
                return(NotFound());
            }

            await genreRepository.DeleteGenre(id);

            return(NoContent());
        }
Exemple #9
0
        public async Task <IHttpActionResult> DeleteGenre(int id)
        {
            Genre genre = await rep.GetGenreAsync(id);

            if (genre == null)
            {
                return(NotFound());
            }

            rep.DeleteGenre(id);
            await rep.SaveAsync();

            return(Ok(genre));
        }
Exemple #10
0
        public IActionResult DeleteGenre(int id)
        {
            if (!genreRepo.GenreExists(id))
            {
                return(NotFound());
            }
            var genreObj = genreRepo.GetGenre(id);

            if (!genreRepo.DeleteGenre(genreObj))
            {
                ModelState.AddModelError("", $"Doslo je do greske u izmjeni {genreObj.GenreName}");
                return(StatusCode(500, ModelState));
            }
            return(NoContent());
        }
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var genreFromRepo = await _genreRepository.GetGenreByIdAsync(new Guid(id));

            if (genreFromRepo != null)
            {
                _genreRepository.DeleteGenre(genreFromRepo);
                await _genreRepository.SaveAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemple #12
0
        public async Task <IActionResult> DeleteGenreAsync(
            [FromRoute, SwaggerParameter(Description = "Id of genre to delete", Required = true)] Guid genreId)
        {
            var genreToDelete = await _genreRepository.GetGenreByIdAsync(genreId);

            if (genreToDelete == null)
            {
                NotFound();
            }

            _genreRepository.DeleteGenre(genreToDelete);

            if (!await _genreRepository.SaveChangesAsync())
            {
                _logger.LogError($"Deleting genre: {genreId} failed on save");
            }

            return(NoContent());
        }
        public IActionResult DeleteGenre(Guid genreId)
        {
            if (!_genreRepo.GenreExist(genreId))
            {
                _logger.LogError($"Genre with id: {genreId} was not found");
                return(NotFound());
            }

            var genreObj = _genreRepo.GetGenre(genreId);

            if (!_genreRepo.DeleteGenre(genreObj))
            {
                _logger.LogError($"An error occured when deleting record {genreObj.Name}");
                ModelState.AddModelError("", $"Something went wrong when deleting the record {genreObj.Name}");
                return(StatusCode(500, ModelState));
            }

            _logger.LogInformation($"{genreObj.Name} was successfully deleted from the database");
            return(NoContent());
        }
        public async Task <IActionResult> DeleteGenre(string id)
        {
            try
            {
                if (!Guid.TryParse(id, out Guid genreId))
                {
                    throw new GuidException("Invalid id", this.GetType().Name, "DeleteGenre", "400");
                }
                await _genreRepository.DeleteGenre(id);

                return(NoContent());
            }
            catch (MovieMindException e)
            {
                if (e.MovieMindError.Status.Equals("404"))
                {
                    return(NotFound(e.MovieMindError));
                }
                else
                {
                    return(BadRequest(e.MovieMindError));
                }
            }
        }
Exemple #15
0
        public bool DeleteGenre([FromForm] int GenreID)
        {
            var rezult = _genreRepository.DeleteGenre(GenreID);

            return(rezult);
        }
 public void Delete(int genreId)
 {
     _genreRepository.DeleteGenre(genreId);
 }
 public IActionResult Delete(int id)
 {
     Repository.DeleteGenre(id);
     return(RedirectToAction("List"));
 }
 public bool DeleteGenre(Guid genreID)
 {
     return(genreRepository.DeleteGenre(genreID));
 }
Exemple #19
0
 public void DeleteGenre(int id)
 {
     _genreRepository.DeleteGenre(id);
 }
Exemple #20
0
 public bool DeleteGenre(System.Int32 GenreId)
 {
     return(_iGenreRepository.DeleteGenre(GenreId));
 }
Exemple #21
0
 public void DeleteGenre(Genre genre)
 {
     genreRepo.DeleteGenre(genre);
 }