public async Task <Response <PeliculaDTO> > UpdateAsync(int Id, PeliculaCreateDTO peliculaCreateCreateDTO) { var response = new Response <PeliculaDTO>(); try { var peliculaDB = await _peliculasDomain.ExistAsync(Id); if (peliculaDB != null) { peliculaDB = _mapper.Map(peliculaCreateCreateDTO, peliculaDB); if (peliculaCreateCreateDTO.Poster != null) { using (var memoryStream = new MemoryStream()) { await peliculaCreateCreateDTO.Poster.CopyToAsync(memoryStream); var contenido = memoryStream.ToArray(); var extension = Path.GetExtension(peliculaCreateCreateDTO.Poster.FileName); peliculaDB.Poster = await _almacenadorArhivos.EditarArchivo(contenido, extension, _contenedor, peliculaDB.Poster, peliculaCreateCreateDTO.Poster.ContentType); } } peliculaDB = await _peliculasDomain.UpdateAsync(peliculaDB); response.Data = _mapper.Map <PeliculaDTO>(peliculaDB); if (response.Data != null) { response.IsSuccess = true; response.Message = "Registro Actualizado!!!"; } } else { response.IsSuccess = true; response.Message = "Registro no existe!!!"; } } catch (Exception ex) { response.Message = ex.Message; } return(response); }
public async Task <Response <ActorDTO> > UpdateAsync(int Id, ActorCreateDTO actorCreateCreateDTO) { var response = new Response <ActorDTO>(); try { var actorDB = await _actoresDomain.ExistAsync(Id); if (actorDB != null) { actorDB = _mapper.Map(actorCreateCreateDTO, actorDB); if (actorCreateCreateDTO.Foto != null) { using (var memoryStream = new MemoryStream()) { await actorCreateCreateDTO.Foto.CopyToAsync(memoryStream); var contenido = memoryStream.ToArray(); var extension = Path.GetExtension(actorCreateCreateDTO.Foto.FileName); actorDB.Foto = await _almacenadorArhivos.EditarArchivo(contenido, extension, _contenedor, actorDB.Foto, actorCreateCreateDTO.Foto.ContentType); } } actorDB = await _actoresDomain.UpdateAsync(actorDB); response.Data = _mapper.Map <ActorDTO>(actorDB); if (response.Data != null) { response.IsSuccess = true; response.Message = "Registro Actualizado!!!"; } } else { response.IsSuccess = true; response.Message = "Registro no existe!!!"; } } catch (Exception ex) { response.Message = ex.Message; } return(response); }