Esempio n. 1
0
        public bool FinalizarTraslado(TRASLADO Traslado, INGRESO Ingreso, TRASLADO_DETALLE Traslado_Detalle)
        {
            try
            {
                using (TransactionScope transaccion = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                }))
                {
                    var ListaTrasladoInternos = new cTrasladoDetalle().ObtenerTrasladoInternos(Traslado.ID_TRASLADO, Traslado.ID_CENTRO).AsEnumerable();
                    foreach (var Interno in ListaTrasladoInternos)
                    {
                        var cama = new CAMA()
                        {
                            ID_CENTRO   = Interno.INGRESO.CAMA.ID_CENTRO,
                            ID_EDIFICIO = Interno.INGRESO.CAMA.ID_EDIFICIO,
                            ID_SECTOR   = Interno.INGRESO.CAMA.ID_SECTOR,
                            ID_CELDA    = Interno.INGRESO.CAMA.ID_CELDA,
                            ID_CAMA     = Interno.INGRESO.CAMA.ID_CAMA,
                            ESTATUS     = "S"
                        };
                        Context.CAMA.Attach(cama);
                        Context.Entry(cama).Property(x => x.ESTATUS).IsModified = true;
                    }

                    Context.TRASLADO.Attach(Traslado);
                    Context.Entry(Traslado).Property(x => x.ID_ESTATUS).IsModified  = true;
                    Context.Entry(Traslado).Property(x => x.RESPONSABLE).IsModified = Traslado.RESPONSABLE != null;

                    Context.INGRESO.Attach(Ingreso);
                    Context.Entry(Ingreso).Property(x => x.ID_ESTATUS_ADMINISTRATIVO).IsModified = true;

                    Context.TRASLADO_DETALLE.Attach(Traslado_Detalle);
                    Context.Entry(Traslado_Detalle).Property(x => x.ID_ESTATUS).IsModified = true;
                    Context.Entry(Traslado_Detalle).Property(x => x.EGRESO_FEC).IsModified = true;
                    Context.Entry(Traslado_Detalle).Property(x => x.ID_ESTATUS_ADMINISTRATIVO).IsModified = true;
                    Context.Entry(Traslado_Detalle).Property(x => x.ID_INCIDENCIA_TRASLADO).IsModified    = true;
                    Context.Entry(Traslado_Detalle).Property(x => x.INCIDENCIA_OBSERVACION).IsModified    = true;

                    Context.SaveChanges();
                    transaccion.Complete();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }
Esempio n. 2
0
 public bool InsertarNuevaUbicacion(INGRESO_UBICACION Entity, EXCARCELACION EntityExc = null, TRASLADO_DETALLE EntityTra = null, ADUANA_INGRESO EntityAduana_Ingreso = null)
 {
     try
     {
         using (TransactionScope transaccion = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions()
         {
             IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
         }))
         {
             Entity.ID_CONSEC = ObtenerConsecutivo <int>(Entity.ID_CENTRO, Entity.ID_ANIO, Entity.ID_IMPUTADO, Entity.ID_INGRESO);
             Context.INGRESO_UBICACION.Add(Entity);
             if (EntityExc != null)
             {
                 Context.EXCARCELACION.Attach(EntityExc);
                 Context.Entry(EntityExc).Property(x => x.ID_ESTATUS).IsModified = true;
             }
             else if (EntityTra != null)
             {
                 Context.TRASLADO_DETALLE.Attach(EntityTra);
                 Context.Entry(EntityTra).Property(x => x.ID_ESTATUS).IsModified = true;
             }
             else if (EntityAduana_Ingreso != null)
             {
                 Context.ADUANA_INGRESO.Attach(EntityAduana_Ingreso);
                 Context.Entry(EntityAduana_Ingreso).Property(x => x.INTERNO_NOTIFICADO).IsModified = true;
             }
             Context.SaveChanges();
             transaccion.Complete();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw new ApplicationException(ex.Message + " " + (ex.InnerException != null ? ex.InnerException.InnerException.Message : ""));
     }
 }