/// <summary> /// Guarda los documentos que se cargan para los folios de aviso de llegada /// </summary> /// <param name="files"></param> /// <returns></returns> public bool GuardarArchivosFolioAvisoLlegada(List <DocumentoPosteado> files) { try { using (SamContext ctx = new SamContext()) { foreach (DocumentoPosteado f in files) { int tipoArchivoId = ctx.Sam3_TipoArchivo.Where(x => x.Nombre == f.TipoArchivoPaseSalida && x.Activo).Select(x => x.TipoArchivoID) .AsParallel().SingleOrDefault(); Sam3_Rel_FolioAvisoLlegada_Documento nuevoDoc = new Sam3_Rel_FolioAvisoLlegada_Documento(); nuevoDoc.Activo = true; nuevoDoc.DocumentoID = 0; nuevoDoc.DocGuid = f.DocGuid; nuevoDoc.Extencion = f.Extencion; nuevoDoc.FechaModificacion = DateTime.Now; nuevoDoc.FolioAvisoLlegadaID = f.FolioAvisoLlegadaID.Value; nuevoDoc.Nombre = f.FileName; nuevoDoc.Url = f.Path; nuevoDoc.UsuarioModificacion = f.UserId; nuevoDoc.TipoArchivoID = tipoArchivoId; nuevoDoc.ContentType = f.ContentType; ctx.Sam3_Rel_FolioAvisoLlegada_Documento.Add(nuevoDoc); } ctx.SaveChanges(); return(true); } } catch (Exception ex) { //-----------------Agregar mensaje al Log ----------------------------------------------- LoggerBd.Instance.EscribirLog(ex); //-----------------Agregar mensaje al Log ----------------------------------------------- return(false); } }
/// <summary> /// Elimina logicamente un documento de aviso de llegada /// </summary> /// <param name="documentoID"></param> /// <param name="usuario"></param> /// <returns></returns> public object EliminarDocumentoAvisoLlegada(int documentoID, Sam3_Usuario usuario) { try { using (SamContext ctx = new SamContext()) { Sam3_Rel_FolioAvisoLlegada_Documento docDb = ctx.Sam3_Rel_FolioAvisoLlegada_Documento .Where(x => x.Rel_FolioAvisoLlegada_DocumentoID == documentoID).AsParallel().SingleOrDefault(); docDb.Activo = false; docDb.FechaModificacion = DateTime.Now; docDb.UsuarioModificacion = usuario.UsuarioID; ctx.SaveChanges(); TransactionalInformation result = new TransactionalInformation(); result.ReturnMessage.Add("Ok"); result.ReturnCode = 200; result.ReturnStatus = false; result.IsAuthenicated = true; return(result); } } catch (Exception ex) { //-----------------Agregar mensaje al Log ----------------------------------------------- LoggerBd.Instance.EscribirLog(ex); //-----------------Agregar mensaje al Log ----------------------------------------------- TransactionalInformation result = new TransactionalInformation(); result.ReturnMessage.Add(ex.Message); result.ReturnCode = 500; result.ReturnStatus = false; result.IsAuthenicated = true; return(result); } }