示例#1
0
        public MovieDTO Patch(int id, [FromBody] JsonPatchDocument <MovieDTO> moviePatch)
        {
            //get original movie object from the database
            Movie originMovie = movieRepository.GetMovieByID(id);
            //use automapper to map that to DTO object
            MovieDTO movieDTO = _mapper.Map <MovieDTO>(originMovie);

            //apply the patch to that DTO
            moviePatch.ApplyTo(movieDTO);
            //use automapper to map the DTO back ontop of the database object
            _mapper.Map(movieDTO, originMovie);
            //update video in the database
            _context.Update(originMovie);
            _context.SaveChanges();
            return(movieDTO);
        }
示例#2
0
 public void Save()
 {
     context.SaveChanges();
 }