public async Task <ActionResult <MovieListDto> > Put(int movieListId, [FromBody] MovieListDto movieListDto) { var userId = int.Parse(User.Identity.Name); var t = movieListDto.name == null; System.Console.WriteLine(t.ToString()); try { MovieList movieList; if (movieListDto.name != null) { movieList = await _movieListService.Update(userId, movieListId, movieListDto.name); } else if (movieListDto.defaultImageUrl != null) { movieList = await _movieListService.UpdateDefaultImage(userId, movieListId, movieListDto.defaultImageUrl); } else { movieList = null; } if (movieList == null) { return(BadRequest(new { message = "Incorrect fields!" })); } else { return(Ok(_entityDtoMapper.Map <MovieListDto> (movieList))); } } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public async Task <ActionResult <MovieListDto> > Create([FromBody] MovieListDto movieListDto) { var movieList = _entityDtoMapper.Map <MovieList> (movieListDto); var userId = int.Parse(User.Identity.Name); try { await _movieListService.Create(userId, movieList); return(Ok(_entityDtoMapper.Map <MovieListDto> (movieList))); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public async Task Handle_IsCheaperMovieReturned_OnlyCheaperMovieIsReturned() { var cheaperMovieId = "fw17835"; //Arrange var cinemaWorldMovieListDto = new MovieListDto { Movies = new List <MovieDto> { new MovieDto { Id = cheaperMovieId, Title = "Avengers" } } }; var cinemaWorldMovie = new Movie { ID = cheaperMovieId, Title = "Avengers", Price = 12 }; var filmWorldMovieListDto = new MovieListDto { Movies = new List <MovieDto> { new MovieDto { Id = "fw124235", Title = "Avengers" } } }; var filmWorldMovie = new Movie { ID = "fw124235", Title = "Avengers", Price = 32 }; var request = new GetCheapestMoviesQuery(); var movieApiClientFake = A.Fake <IMovieApiClient>(); //Setup the calls to CinemaWorld endpoints _ = A.CallTo(() => movieApiClientFake.GetCinemaWorldMovieListAsync(A <CancellationToken> .Ignored)) .Returns(Task.FromResult(cinemaWorldMovieListDto)); _ = A.CallTo(() => movieApiClientFake.GetCinemaWorldMovieDetailAsync(A <string> .Ignored, A <CancellationToken> .Ignored)) .Returns(Task.FromResult(cinemaWorldMovie)); //Setup the calls to MovieWorld enpoints _ = A.CallTo(() => movieApiClientFake.GetFilmWorldMovieListAsync(A <CancellationToken> .Ignored)) .Returns(Task.FromResult(filmWorldMovieListDto)); _ = A.CallTo(() => movieApiClientFake.GetFilmWorldMovieDetailAsync(A <string> .Ignored, A <CancellationToken> .Ignored)) .Returns(Task.FromResult(filmWorldMovie)); _systemUnderTest = new GetCheapestMoviesHandler(movieApiClientFake); //Act var response = await _systemUnderTest.Handle(request, new CancellationToken()); //Assert response.Movies.Should().HaveCount(1); response.Movies.Should().OnlyContain(x => x.ID == cheaperMovieId); }
private void RedirectToData(MovieListDto movie) { this.Navigation.NavigateTo($"/movies/{movie.Id}"); }