public int RegistrarSocioFincaCertificacion(RegistrarActualizarSocioFincaCertificacionRequestDTO request, IFormFile file) { var AdjuntoBl = new AdjuntarArchivosBL(_fileServerSettings); byte[] fileBytes = null; SocioFincaCertificacion socioFinca = _Mapper.Map <SocioFincaCertificacion>(request); socioFinca.FechaRegistro = DateTime.Now; socioFinca.UsuarioRegistro = request.Usuario; 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 } //Adjuntos socioFinca.NombreArchivo = file.FileName; ResponseAdjuntarArchivoDTO response = AdjuntoBl.AgregarArchivo(new RequestAdjuntarArchivosDTO() { filtros = new AdjuntarArchivosDTO() { archivoStream = fileBytes, filename = file.FileName, }, pathFile = _fileServerSettings.Value.FincasCertificacion }); socioFinca.PathArchivo = _fileServerSettings.Value.FincasCertificacion + "\\" + response.ficheroReal; } } //if (file != null) //{ // if (file.Length > 0) // { // //Adjuntos // socioFinca.NombreArchivo = file.FileName; // ResponseAdjuntarArchivoDTO response = AdjuntoBl.AgregarArchivo(new RequestAdjuntarArchivosDTO() // { // filtros = new AdjuntarArchivosDTO() // { // archivoStream = fileBytes, // filename = file.FileName, // }, // pathFile = _fileServerSettings.Value.FincasCertificacion // }); // socioFinca.PathArchivo = _fileServerSettings.Value.FincasCertificacion + "\\" + response.ficheroReal; // } //} int affected = _ISocioFincaRepository.Insertar(socioFinca); return(affected); }