public async Task <ActionResult> Put(int id, [FromForm] MovieCreateDTO movieCreateDTO) { var movie = await _context.Movies .Include(x => x.MoviesActors) .Include(x => x.MoviesGenders) .FirstOrDefaultAsync(x => x.Id == id); if (movie == null) { return(NotFound()); } movie = _mapper.Map(movieCreateDTO, movie); if (movieCreateDTO.Poster != null) { using (var memoryStream = new MemoryStream()) { await movieCreateDTO.Poster.CopyToAsync(memoryStream); var content = memoryStream.ToArray(); var extension = Path.GetExtension(movieCreateDTO.Poster.FileName); movie.Image = await _filesStore.EditFile(content, extension, _container, movie.Image, movieCreateDTO.Poster.ContentType); } } AssignActorsOrder(movie); await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult> Put(int id, [FromForm] ActorCreateDTO actorCreateDTO) { var actor = await _context.Actors.FirstOrDefaultAsync(x => x.Id == id); if (actor == null) { return(NotFound()); } actor = _mapper.Map(actorCreateDTO, actor); if (actorCreateDTO.Image != null) { using (var memoryStream = new MemoryStream()) { await actorCreateDTO.Image.CopyToAsync(memoryStream); var content = memoryStream.ToArray(); var extension = Path.GetExtension(actorCreateDTO.Image.FileName); actor.Image = await _filesStore.EditFile(content, extension, _container, actor.Image, actorCreateDTO.Image.ContentType); } } await _context.SaveChangesAsync(); return(NoContent()); }