public VideoDTO Patch(int id, [FromBody] JsonPatchDocument <VideoDTO> videoPatch) { //get original video object from the database Video originVideo = videoRepository.GetVideoByID(id); //use automapper to map that to DTO object VideoDTO videoDTO = _mapper.Map <VideoDTO>(originVideo); //apply the patch to that DTO videoPatch.ApplyTo(videoDTO); //use automapper to map the DTO back ontop of the database object _mapper.Map(videoDTO, originVideo); //update video in the database _context.Update(originVideo); _context.SaveChanges(); return(videoDTO); }
public void Save() { context.SaveChanges(); }