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);
            }
Exemple #2
0
        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));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
 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
     });
 }
Exemple #5
0
        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"));
     }
 }
Exemple #9
0
 public async Task <RequestEngineResult> MarkMovieUnAvailable([FromBody] MovieUpdateModel model)
 {
     return(await MovieRequestEngine.MarkUnavailable(model.Id));
 }
Exemple #10
0
 public async Task <RequestEngineResult> ApproveMovie([FromBody] MovieUpdateModel model)
 {
     return(await MovieRequestEngine.ApproveMovieById(model.Id));
 }
Exemple #11
0
        public async Task <Movie> UpdateAsync(MovieUpdateModel movieUpdateModel)
        {
            await GenreGetService.ValidateAsync(movieUpdateModel);

            return(await MovieDataAccess.UpdateAsync(movieUpdateModel));
        }
Exemple #12
0
        public void UpdateSentiment(MovieUpdateModel movieUpdateVM)
        {
            var sentiment = _mapper.Map <SentimentDTO>(movieUpdateVM);

            _sentimentRepository.Update(sentiment);
        }
Exemple #13
0
        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());
 }
Exemple #15
0
        public async Task <MovieDetailModel> UpdateAsync(string id, MovieUpdateModel obj)
        {
            var entity = _mapper.Map <Movie>(obj);

            return(_mapper.Map <MovieDetailModel>(await _movieRepository.UpdateAsync(id, entity)));
        }