Esempio n. 1
0
        public async Task <MovieModel> CreateMovieAsync(int productionId, MovieModel movieModel)
        {
            await validateProduction(productionId);

            var movieEntity = _mapper.Map <MovieEntity>(movieModel);

            movieEntity.Production = new ProductionEntity {
                Id = productionId
            };
            _libraryRepository.CreateMovie(movieEntity);
            var saveResult = await _libraryRepository.SaveChangesAsync();

            if (!saveResult)
            {
                throw new Exception("Save error");
            }
            var model = _mapper.Map <MovieModel>(movieEntity);

            model.ProductionId = productionId;
            return(model);
        }