public IActionResult Eliminar(RegistrarActualizarNotaIngresoPlantaDocumentoAdjuntoRequestDTO request) { Guid guid = Guid.NewGuid(); _log.RegistrarEvento($"{guid}{Environment.NewLine}{JsonConvert.SerializeObject(request)}"); RegistrarActualizarNotaIngresoPlantaDocumentoAdjuntoResponseDTO response = new RegistrarActualizarNotaIngresoPlantaDocumentoAdjuntoResponseDTO(); try { response.Result.Data = _NotaIngresoPlantaDocumentoAdjuntoService.EliminarNotaIngresoPlantaDocumentoAdjunto(request); response.Result.Success = true; } catch (ResultException ex) { response.Result = new Result() { Success = true, ErrCode = ex.Result.ErrCode, Message = ex.Result.Message }; } catch (Exception ex) { response.Result = new Result() { Success = false, Message = "Ocurrio un problema en el servicio, intentelo nuevamente." }; _log.RegistrarEvento(ex, guid.ToString()); } _log.RegistrarEvento($"{guid}{Environment.NewLine}{JsonConvert.SerializeObject(response)}"); return(Ok(response)); }
public int EliminarNotaIngresoPlantaDocumentoAdjunto(RegistrarActualizarNotaIngresoPlantaDocumentoAdjuntoRequestDTO request) { ConsultaNotaIngresoPlantaDocumentoAdjuntoPorId NotaIngresoPlantaNotaIngresoPlantaDocumentoAdjunto = _INotaIngresoPlantaDocumentoAdjuntoRepository.ConsultarNotaIngresoPlantaDocumentoAdjuntoPorId(request.NotaIngresoPlantaDocumentoAdjuntoId); var AdjuntoBl = new AdjuntarArchivosBL(_fileServerSettings); int affected = _INotaIngresoPlantaDocumentoAdjuntoRepository.Eliminar(request.NotaIngresoPlantaDocumentoAdjuntoId); EliminarArchivoAdjuntoDTO adjunto = new EliminarArchivoAdjuntoDTO(); adjunto.pathFile = NotaIngresoPlantaNotaIngresoPlantaDocumentoAdjunto.Path; if (!string.IsNullOrEmpty(NotaIngresoPlantaNotaIngresoPlantaDocumentoAdjunto.Path)) { AdjuntoBl.EliminarArchivo(adjunto); } return(affected); }
public int RegistrarNotaIngresoPlantaDocumentoAdjunto(RegistrarActualizarNotaIngresoPlantaDocumentoAdjuntoRequestDTO request, IFormFile file) { NotaIngresoPlantaDocumentoAdjunto socioNotaIngresoPlanta = _Mapper.Map <NotaIngresoPlantaDocumentoAdjunto>(request); socioNotaIngresoPlanta.FechaRegistro = DateTime.Now; socioNotaIngresoPlanta.UsuarioRegistro = request.Usuario; var AdjuntoBl = new AdjuntarArchivosBL(_fileServerSettings); byte[] fileBytes = null; if (file != null) { if (file.Length > 0) { using (var ms = new MemoryStream()) { file.CopyTo(ms); fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); // act on the Base64 data } socioNotaIngresoPlanta.Nombre = file.FileName; ResponseAdjuntarArchivoDTO response = AdjuntoBl.AgregarArchivo(new RequestAdjuntarArchivosDTO() { filtros = new AdjuntarArchivosDTO() { archivoStream = fileBytes, filename = file.FileName, }, pathFile = _fileServerSettings.Value.NotaIngresoPlantasDocumentoAdjunto }); socioNotaIngresoPlanta.Path = _fileServerSettings.Value.NotaIngresoPlantasDocumentoAdjunto + "\\" + response.ficheroReal; } } //if (file != null) //{ // if (file.Length > 0) // { // //Adjuntos // socioNotaIngresoPlanta.Nombre = file.FileName; // ResponseAdjuntarArchivoDTO response = AdjuntoBl.AgregarArchivo(new RequestAdjuntarArchivosDTO() // { // filtros = new AdjuntarArchivosDTO() // { // archivoStream = fileBytes, // filename = file.FileName, // }, // pathFile = _fileServerSettings.Value.NotaIngresoPlantasCertificacion // }); // socioNotaIngresoPlanta.Path = _fileServerSettings.Value.NotaIngresoPlantasCertificacion + "\\" + response.ficheroReal; // } //} int affected = _INotaIngresoPlantaDocumentoAdjuntoRepository.Insertar(socioNotaIngresoPlanta); return(affected); }