public async Task <IActionResult> DeleteGenreById(int id)
        {
            try
            {
                if (await _movieService.ExistMoviesWithGenreIds(new List <int>()
                {
                    id
                }))
                {
                    return(Problem("Este gênero possui filme cadastrado! Não é possível excluir!"));
                }
                var genre = await _genreService.GetGenreById(id);

                if (genre != null)
                {
                    await _genreService.DeleteGenre(genre);

                    return(Ok());
                }
                return(NotFound());
            }
            catch (Exception ex)
            {
                return(Problem(ex.Message));
            }
        }
Пример #2
0
        public ActionResult Delete(int genreId)
        {
            var genre = genreService.GetGenreById(genreId);

            genreService.DeleteGenre(genre);

            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult Delete(int id)
        {
            var model = genreService.GetGenre(id);

            genreService.DeleteGenre(model);

            return(RedirectToAction("Index"));
        }
Пример #4
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            _genreService.DeleteGenre(new DeleteGenreRequest {
                Id = id
            });

            return(RedirectToAction("Index"));
        }
        public void DeleteGenre_ReceivesValidParameter_DeletesEntity()
        {
            //assign
            Genre genreEntity = new Genre()
            {
                Id = 1, Name = "Genre"
            };

            genreRepositoryMoq.Setup((p) => p.GetSingleAsync(It.IsAny <Expression <Func <Genre, bool> > >()))
            .Returns(Task.FromResult(genreEntity));

            //act
            service.DeleteGenre(1);

            //assert
            genreRepositoryMoq.Verify(p => p.Delete(It.IsAny <Genre>()), Times.Once);
            unitofworkMoq.Verify(p => p.CommitAsync(), Times.Once);
        }
        public IActionResult DeleteGenre(Guid genreID)
        {
            bool deleted = genreService.DeleteGenre(genreID);

            if (deleted == false)
            {
                return(NotFound());
            }

            return(NoContent());
        }
Пример #7
0
        public async Task <IActionResult> Delete(int id)
        {
            var result = await _genreService.DeleteGenre(id);

            if (result.IsSuccess == false)
            {
                return(NotFound(result));
            }

            return(Ok(result));
        }
Пример #8
0
        public IActionResult Delete(int id)
        {
            GenreDto genreDtoObj = _genreService.DeleteGenre(id);

            if (genreDtoObj == null)
            {
                return(BadRequest("Failed to delete genre!"));
            }

            return(Ok(genreDtoObj));
        }
Пример #9
0
        public async Task <IActionResult> Delete(Guid id)
        {
            try
            {
                await _genreService.DeleteGenre(id);

                return(RedirectToAction(nameof(Index)));
            }
            catch (GenreNotFoundException)
            {
                return(NotFound());
            }
        }
Пример #10
0
        public IActionResult DeleteGenre(long id)
        {
            try
            {
                GenreService.DeleteGenre(id);
            }
            catch (ArgumentException e)
            {
                log.LogError("The genre with the id :" + id + " does not exist." + e.Message);
                return(NotFound(StatusCodes.Status404NotFound));
            }

            return(Ok(StatusCodes.Status200OK));
        }
Пример #11
0
        public HttpResponseMessage Remove(HttpRequestMessage request, int id)
        {
            HttpResponseMessage response = null;

            var genre = genreService.GetGenre(id);

            if (genre == null)
            {
                response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
            else
            {
                genreService.DeleteGenre(genre);
                response = request.CreateResponse(HttpStatusCode.OK);
            }

            return(response);
        }
Пример #12
0
        public async Task <IActionResult> Delete(int id)
        {
            var result = await _genreService.DeleteGenre(id);

            if (result.IsSuccessful)
            {
                return(Ok());
            }
            else
            {
                if (result.Payload != null)
                {
                    return(StatusCode(500, result.Message));
                }
                else
                {
                    return(BadRequest(result.Message));
                }
            }
        }
        public IHttpActionResult Delete(int id)
        {
            var loggedUserId = HttpContext.Current.GetOwinContext().GetUserId();

            var request = new DeleteGenreRequest()
            {
                RequestToken = Guid.NewGuid(),
                UserId       = loggedUserId,
                Id           = id
            };

            var genresResponse = _genreService.DeleteGenre(request);

            if (!genresResponse.Success)
            {
                return(BadRequest(genresResponse.Message));
            }

            return(Ok());
        }
Пример #14
0
        // GET: Language/Delete/5
        public ActionResult Delete(int id)
        {
            DeleteGenreRequest request = new DeleteGenreRequest()
            {
                GenreId = id
            };
            DeleteGenreResponse response = _genreService.DeleteGenre(request);

            if (response.Success)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                GenreListPageViewModel model = new GenreListPageViewModel();
                model.Success = false;
                model.Message = response.Message;
                return(View("Index", model));
            }
        }
Пример #15
0
 public ActionResult Delete(int id)
 {
     _genreService.DeleteGenre(id);
     return(Ok());
 }
Пример #16
0
 public ActionResult DeleteConfirmed(Guid id)
 {
     genreService.DeleteGenre(id);
     return(RedirectToAction("Index"));
 }
Пример #17
0
        public async Task <IActionResult> Delete(int id)
        {
            await genreService.DeleteGenre(id);

            return(StatusCode(204, "Genre was deleted"));
        }
Пример #18
0
        private static void TestGenreService()
        {
            List <int> list = new List <int>();

            genreService  = Container.Resolve <IGenreService>();
            clientService = Container.Resolve <IClientService>();

            //Create
            genreService.CreateGenre(new GenreDTO
            {
                Name       = "Metalcore",
                Info       = "Metalcore is a broad fusion genre of extreme metal and hardcore punk. The word is a blend of the names of the two genres. Metalcore is noted for its use of breakdowns, which are slow, intense passages that are conducive to moshing.",
                IsOfficial = true,
                CreatorID  = clientID,
            });
            genreService.CreateGenre(new GenreDTO
            {
                Name       = "Indie pop",
                Info       = "Indie pop is a subgenre of alternative rock or indie rock[1] and a subculture[2] that originated in the United Kingdom in the late 1970s. The style is inspired by punk's DIY ethic and related ideologies, and it generated a thriving fanzine, label, and club and gig circuit.",
                IsOfficial = true,
                CreatorID  = clientID
            });

            //GetGenreIdByName
            genreID = genreService.GetGenreIdByName("Metalcore");
            int indieID = genreService.GetGenreIdByName("Indie pop");

            list.Add(genreID);
            list.Add(indieID);
            Console.WriteLine(list.Count() == 2 ? "ClientService - GetGenreIdByName - OK" : "ClientService - GetGenreIdByName - FAIL");



            //GetGenreById
            GenreDTO metalcore = genreService.GetGenre(genreID);

            Console.WriteLine(metalcore.Name == "Metalcore" ? "GenreService - GetGenreById - OK" : "GenreService - GetGenreById - FAIL");

            //ListAllGenres01
            //var genres = genreService.ListAllGenres(new GenreFilter { ArtistID = artistID }, 1);
            //Console.WriteLine(genres.TotalResultCount == 1 ? "GenreService - TestListAllGenres01 - OK" : "GenreService - TestListAllGenres01 - FAIL");

            //ListAllGenres02
            var genres2 = genreService.ListAllGenres();

            Console.WriteLine(genres2.Count() == 2 ? "GenreService - ListAllGenres02 - OK" : "GenreService - ListAllGenres02 - FAIL");

            //EditGenre
            metalcore.Name = "Metal Core";
            genreService.EditGenre(metalcore);
            GenreDTO bfmvFromDB = genreService.GetGenre(metalcore.ID);

            Console.WriteLine(bfmvFromDB.Name == "Metal Core" ? "GenreService - TestEditGenre - OK" : "GenreService - TestEditGenre - FAIL");

            //DeleteGenre
            genreService.DeleteGenre(indieID);
            int violaIDFromDB = genreService.GetGenreIdByName("Viola Martinsson");

            Console.WriteLine(violaIDFromDB < 1 ? "GenreService - TestDeleteGenre - OK" : "GenreService - TestDeleteGenre - FAIL");

            //GetCreator
            ClientDTO creator = genreService.GetCreator(metalcore.ID);

            Console.WriteLine(creator.ID == clientID ? "GenreService - GetCreator - OK" : "GenreService - GetCreator - FAIL");
        }
Пример #19
0
        public ActionResult Delete(int id)
        {
            genreService.DeleteGenre(id);

            return(RedirectToAction(nameof(Index)));
        }
Пример #20
0
 public void DeleteGenre(int id)
 {
     genreService.DeleteGenre(id);
 }
Пример #21
0
 protected override Func <ServiceOperationResult> DeleteEntityAndReturnOperationResult(Genre genre, bool onlyChangeFlag = true)
 {
     return(() => _genreService.DeleteGenre(genre, onlyChangeFlag));
 }
Пример #22
0
 public void Delete(int id)
 {
     _genre.DeleteGenre(id);
 }
Пример #23
0
 public IHttpActionResult Delete(long id)
 {
     _genreService.DeleteGenre(id);
     return(Ok());
 }
Пример #24
0
 public ActionResult Delete(int id)
 {
     _genreService.DeleteGenre(id);
     return(RedirectToAction("Index"));
 }
Пример #25
0
        public async Task <IActionResult> DeleteGenre(string id)
        {
            await _service.DeleteGenre(id);

            return(Ok());
        }