public async Task <ActionResult> UpdateMovieForDirector(Guid directorId,
                                                                Guid movieId,
                                                                MovieForUpdateDto movie)
        {
            var result = await Mediator.Send(new UpdateMovieForDirectorCommand
                                             { DirectorId = directorId, MovieId = movieId, Movie = movie });

            return(result == true ? (ActionResult)NoContent() : NotFound());
        }
示例#2
0
        public ActionResult Update(MovieForUpdateDto movieForUpdateDto)
        {
            var result = _movieService.Update(movieForUpdateDto);

            if (result.Success)
            {
                return(Ok(result.Message));
            }

            return(BadRequest(result.Message));
        }
示例#3
0
        public async Task <IActionResult> UpdateMovie(int id, MovieForUpdateDto movieForUpdateDto)
        {
            var movie = await _repo.GetMovie(id);

            _mapper.Map(movieForUpdateDto, movie);

            if (await _repo.SaveAll())
            {
                return(CreatedAtRoute("GetMovie", new { id = movie.Id }, movie));
            }

            throw new Exception($"Updating movie {movie.Title} failed on save");
        }
        public IResult Update(MovieForUpdateDto movieForUpdateDto)
        {
            IResult result = BusinessRules.Run(CheckIfMovieIdExists(movieForUpdateDto.Id));

            if (result != null)
            {
                return(result);
            }

            var movie = _movieDal.Get(p => p.Id == movieForUpdateDto.Id);

            movie.UserVote = movieForUpdateDto.Vote;
            movie.Note     = movieForUpdateDto.Note;

            _movieDal.Update(movie);
            return(new SuccessResult(Messages.MovieUpdated));
        }
        public async Task <IActionResult> UpdateMovie(int id, MovieForUpdateDto movieForUpdate)
        {
            if (!_authorizer.IsAdminOrEmployee(User))
            {
                return(Unauthorized());
            }

            var movieFromRepository = await _repo.GetMovie(id);

            _mapper.Map(movieForUpdate, movieFromRepository);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception($"Updating user {id} failed on save");
        }
示例#6
0
        public MoviesControllerTests()
        {
            movieList = new Movie[]
            {
                new Movie {
                    Title = "Anything", Genre = Enums.GenreOfMovie.Crime, Year = 2000
                },
                new Movie {
                    Title = "Anything2", Genre = Enums.GenreOfMovie.Drama, Year = 2001
                },
                new Movie {
                    Title = "Anything3", Genre = Enums.GenreOfMovie.Comedy, Year = 2002
                }
            };

            movieDto = new MovieForUpdateDto {
                Title = "Something", Genre = Enums.GenreOfMovie.Family, Year = 1999
            };
        }
示例#7
0
        public async Task <IActionResult> UpdateMovie(int id, [FromBody] MovieForUpdateDto movieForUpdateDto)
        {
            if (movieForUpdateDto == null)
            {
                return(BadRequest());
            }

            var movie = await _repository.GetMovieAsync(id);

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

            _mapper.Map(movieForUpdateDto, movie);

            await _unitOfWork.CompleteAsync();

            return(NoContent());
        }