// Adding a movie to a database public MovieDtoOutput InsertMovie(MovieDtoInput inputMovie) { // List of new Actor objects (still dto to remain some fields) refering to the movie ICollection <ActorDtoInput> actorsDtoInput = inputMovie.NewActorInstances; ICollection <ActorDtoInputExisting> actorDtoInputExistings = inputMovie.ExistingActorGuids; Movie movieToInsert = _mapper.Map <Movie>(inputMovie); // Mapping the related entities to the Movie Movie movie = InsertMovieHelper.MapRelational(movieToInsert, actorsDtoInput, actorDtoInputExistings, _mapper); _movieRepo.Insert(movie); UnitOfWork.SaveChanges(); return(_mapper.Map <MovieDtoOutput>(GetMovieDtoById(movie.MovieId))); }
public ActionResult <MovieDtoOutput> AddMovie([FromBody] MovieDtoInput inputMovie) { MovieDtoOutput movieCreated = _movieProcess.InsertMovie(inputMovie); return(CreatedAtRoute("GetMovieById", new { movieId = movieCreated.MovieId }, movieCreated)); }