コード例 #1
0
ファイル: RolesAD.cs プロジェクト: davecalix-guzman/SIPespire
 public static Roles ObtenerRolPorNombre(string nombreRol)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var rol = dbContext.Roles.FirstOrDefault(x => x.Nombre == nombreRol);
             return(rol);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #2
0
 public static Acciones ObtenerAccionId(int nuevaAccionId)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var accionEncontrada = dbContext.Acciones.FirstOrDefault(x => x.AccionId == nuevaAccionId);
             return(accionEncontrada);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #3
0
 public static Oficinas ObtenerOficinaPorId(int oficinaId)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var oficina = dbContext.Oficinas.FirstOrDefault(x => x.OficinaId == oficinaId);
             return(oficina);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #4
0
ファイル: RolesAD.cs プロジェクト: davecalix-guzman/SIPespire
 public static List <Roles> ObtenerRolesActivos()
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var rolesActivos = dbContext.Roles;
             return(rolesActivos.ToList());
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #5
0
 public static List <RolModuloAcciones> ObtenerAccionesActivas(int rolSeleccionado)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var rolModuloAccionesActivas = dbContext.RolModuloAcciones.Where(x => x.FKRolId == rolSeleccionado);
             return(rolModuloAccionesActivas.ToList());
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #6
0
 public static RolModuloAcciones InsertarAcciones(RolModuloAcciones rolModuloAcciones)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             dbContext.RolModuloAcciones.Add(rolModuloAcciones);
             dbContext.SaveChanges();
             return(rolModuloAcciones);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #7
0
 public static List <Acciones> ObtenerAcciones(bool accionesActivas)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var listadoAcciones = dbContext.Acciones.Include("Modulos").Where(x => x.Estado == accionesActivas);
             return(listadoAcciones.ToList());
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #8
0
ファイル: RolesAD.cs プロジェクト: davecalix-guzman/SIPespire
 public static Roles ObtenerRolPorId(int rolSeleccionado)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var rol = dbContext.Roles.Include("Usuarios1").Include("RolModuloAcciones").FirstOrDefault(x => x.RolId == rolSeleccionado);
             return(rol);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #9
0
 public static List <Acciones> ObtenerAccionesPorModuloId(int moduloId)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var listadoAcciones = dbContext.Acciones.Where(x => x.FKModuloId == moduloId);
             return(listadoAcciones.ToList());
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #10
0
        public static List <Modulos> ObtenerModulos()
        {
            try
            {
                using (var dbContext = new SI_PESPIREEntities())
                {
                    var modulos = dbContext.Modulos;
                    return(modulos.ToList());
                }
            }
            catch (Exception)
            {
                return(null);

                throw;
            }
        }
コード例 #11
0
        public static List <Modulos> ObtenerModulos(bool estado, int menu)
        {
            try
            {
                using (var dbContext = new SI_PESPIREEntities())
                {
                    var modulos = dbContext.Modulos.Where(x => x.Estado == estado && x.ModuloId > menu);
                    return(modulos.ToList());
                }
            }
            catch (Exception)
            {
                return(null);

                throw;
            }
        }
コード例 #12
0
 public static List <RolModuloAcciones> ObtenerAccionesPorRolId(int rolId, bool menu)
 {
     using (var dbContext = new SI_PESPIREEntities())
     {
         try
         {
             var listadoRolModuloAcciones = dbContext.RolModuloAcciones.Include("Acciones")
                                            .Where(x => x.FKRolId == rolId && x.Acciones.Padre == 0 && x.Acciones.Menu == menu).OrderBy(x => x.Acciones.Nombre);
             return(listadoRolModuloAcciones.ToList());
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             throw;
         }
     }
 }
コード例 #13
0
 public static Acciones InsertarNuevaAccion(Acciones nuevaAccion)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             dbContext.Acciones.Add(nuevaAccion);
             dbContext.SaveChanges();
             return(nuevaAccion);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #14
0
 public static Acciones ObtenerAccionPorNombrePorPadre(string nombreAccion, int padre)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var accionEncontrada =
                 dbContext.Acciones.FirstOrDefault(x => x.Nombre == nombreAccion && x.Padre == padre);
             return(accionEncontrada);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #15
0
 public static List <Acciones> ObtenerAccionesPorPadre(int moduloId, int accionId)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var accionesPorPadre =
                 dbContext.Acciones.Where(x => x.FKModuloId == moduloId && x.Padre == accionId);
             return(accionesPorPadre.ToList());
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #16
0
 public static Acciones ActualizarAccion(Acciones accionActualizar)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             dbContext.Entry(accionActualizar).State = EntityState.Modified;
             dbContext.SaveChanges();
             return(accionActualizar);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #17
0
 public static Usuarios ObtenerUsuariosPorNombres(string nombreUsuario)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             //dbContext.Configuration.LazyLoadingEnabled = false;
             var objetoUsuario = dbContext.Usuarios.Include("Roles1").Include("Oficinas")
                                 .FirstOrDefault(x => x.NombreUsuario == nombreUsuario);
             return(objetoUsuario ?? null);
         }
     }
     catch (Exception ex)
     {
         var ee = ex.Message;
         throw;
     }
 }
コード例 #18
0
 public static bool EliminarAccionesParaRol(int rolId)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var ListaParametros = new List <SqlParameter> {
                 new SqlParameter("@rolId", rolId)
             };
             var parametros = ListaParametros.ToArray();
             return(dbContext.Database.ExecuteSqlCommand("DELETE FROM [SI_PESPIRE].[dbo].[ROLMODULOACCIONES] WHERE FKROLID = @rolId", parametros) > 0);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #19
0
ファイル: RolesAD.cs プロジェクト: davecalix-guzman/SIPespire
 public static bool EliminarRegistroRol(Roles rolSeleccionado)
 {
     try
     {
         using (var dbContext = new SI_PESPIREEntities())
         {
             var seEliminoRegistro = false;
             var rolEliminar       = dbContext.Roles.FirstOrDefault(x => x.RolId == rolSeleccionado.RolId);
             if (rolEliminar != null)
             {
                 dbContext.Roles.Remove(rolEliminar);
                 seEliminoRegistro = dbContext.SaveChanges() > 0;
             }
             return(seEliminoRegistro);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }