public async Task CreateAsync_MovieValidationFailed_ThrowsError() { // Arrange var fixture = new Fixture(); var movie = new MovieUpdateModel(); var expected = fixture.Create <string>(); var genreGetService = new Mock <IGenreGetService>(); genreGetService .Setup(x => x.ValidateAsync(movie)) .Throws(new InvalidOperationException(expected)); var movieDataAccess = new Mock <IMovieDataAccess>(); var movieGetService = new MovieCreateService(movieDataAccess.Object, genreGetService.Object); // Act var action = new Func <Task>(() => movieGetService.CreateAsync(movie)); // Assert await action.Should().ThrowAsync <InvalidOperationException>().WithMessage(expected); movieDataAccess.Verify(x => x.InsertAsync(movie), Times.Never); }
public async Task <Movie> InsertAsync(MovieUpdateModel movieUpdateModel) { var result = await this.Context.AddAsync(this.Mapper.Map <DataAccess.Entities.Movie>(movieUpdateModel)); await this.Context.SaveChangesAsync(); return(this.Mapper.Map <Movie>(result.Entity)); }
public async Task <Movie> UpdateAsync(MovieUpdateModel movieUpdateModel) { var existing = await this.Get(movieUpdateModel); var result = this.Mapper.Map(movieUpdateModel, existing); this.Context.Update(result); await this.Context.SaveChangesAsync(); return(this.Mapper.Map <Movie>(result)); }
public static Movie ToModel(this MovieUpdateModel viewModel) { return(new Movie { Id = viewModel.Id, Title = viewModel.Title, ImgUrl = viewModel.ImgUrl, Stars = viewModel.Stars, Storyline = viewModel.Storyline, Genre = viewModel.Genre, MovieTypeId = viewModel.MovieTypeId }); }
public IActionResult Update(MovieUpdateModel movieUpdateModel) { Movie movie = _mapper.Map <Movie>(movieUpdateModel); foreach (var actor in movieUpdateModel.Actors) { ActorMovie actor1 = new ActorMovie(); actor1.Actor = _actorRepository.GetById(actor); movie.Actors.Add(actor1); } MovieResponseModel movieResponse = _mapper.Map <MovieResponseModel>(_movieRepository.Update(movie)); return(Ok(movieResponse)); }
public async Task <IActionResult> Update([FromForm] MovieUpdateModel movie) { var picName = ""; var videoName = ""; var ifExist = await _movieRepo.GetMovieById(movie.id); if (ifExist == null) { return(NotFound()); } if (movie.Picture != null) { picName = saveFile(movie.Picture); } if (movie.Picture == null) { picName = ifExist.Picture; } if (movie.video != null) { videoName = saveFile(movie.video); } if (movie.video == null) { videoName = ifExist.MovieLink; } var model = new Movie { Id = movie.id, Title = movie.Title, Description = movie.Description, Picture = picName, MovieLink = videoName }; await _movieRepo.Update(model); return(Ok()); }
public async Task CreateAsync_MovieValidationSucceed_CreatesScreening() { // Arrange var movie = new MovieUpdateModel(); var expected = new Movie(); var genreGetService = new Mock <IGenreGetService>(); genreGetService.Setup(x => x.ValidateAsync(movie)); var movieDataAccess = new Mock <IMovieDataAccess>(); movieDataAccess.Setup(x => x.InsertAsync(movie)).ReturnsAsync(expected); var movieGetService = new MovieCreateService(movieDataAccess.Object, genreGetService.Object); // Act var result = await movieGetService.CreateAsync(movie); // Assert result.Should().Be(expected); }
public IActionResult Update(MovieUpdateModel movie) { if (ModelState.IsValid) { try { _moviesService.Update(movie.ToModel()); return(RedirectToAction("ManageMovies", new { UpdateMEssage = "Movie updated sucessfully" })); } catch (NotFoundException ex) { return(RedirectToAction("ManageMovies", new { ErrorMessage = ex.Message })); } catch (Exception) { return(RedirectToAction("InternalError", "Info")); } } else { return(RedirectToAction("InternalError", "Info")); } }
public async Task <RequestEngineResult> MarkMovieUnAvailable([FromBody] MovieUpdateModel model) { return(await MovieRequestEngine.MarkUnavailable(model.Id)); }
public async Task <RequestEngineResult> ApproveMovie([FromBody] MovieUpdateModel model) { return(await MovieRequestEngine.ApproveMovieById(model.Id)); }
public async Task <Movie> UpdateAsync(MovieUpdateModel movieUpdateModel) { await GenreGetService.ValidateAsync(movieUpdateModel); return(await MovieDataAccess.UpdateAsync(movieUpdateModel)); }
public void UpdateSentiment(MovieUpdateModel movieUpdateVM) { var sentiment = _mapper.Map <SentimentDTO>(movieUpdateVM); _sentimentRepository.Update(sentiment); }
public void UpdateMovie(MovieUpdateModel movieUpdateVM) { var movie = _mapper.Map <MovieDTO>(movieUpdateVM); _movieRepository.Update(movie); }
public IActionResult UpdateMovieInfo([FromBody] MovieUpdateModel movie) { _movieViewConverter.UpdateMovie(movie); _movieViewConverter.UpdateSentiment(movie); return(new EmptyResult()); }
public async Task <MovieDetailModel> UpdateAsync(string id, MovieUpdateModel obj) { var entity = _mapper.Map <Movie>(obj); return(_mapper.Map <MovieDetailModel>(await _movieRepository.UpdateAsync(id, entity))); }