public ActionResult GetObj()
 {
     #region Estados
     List <EstadoList> LstEL = new List <EstadoList>();
     EstadoList        EL    = new EstadoList();
     LstEL.Add(EL = new EstadoList()
     {
         Id = 0, Estado = "Inactivo"
     });
     LstEL.Add(EL = new EstadoList()
     {
         Id = 1, Estado = "Activo"
     });
     #endregion
     try
     {
         UsuarioIndex UI = new UsuarioIndex();
         UI = new UsuarioIndex()
         {
             Id           = 0,
             Nombre       = "",
             Apellido     = "",
             UserName     = "",
             Correo       = "",
             Estado       = 0,
             ListaEstados = LstEL
         };
         return(Ok(UI));
     }
     catch (Exception ex)
     {
         return(BadRequest("Error al obtener el objeto de Usuarios, error: " + ex));
     }
 }
 public ActionResult GetObj(int id)
 {
     try
     {
         #region Estados
         List <EstadoList> LstEL = new List <EstadoList>();
         EstadoList        EL    = new EstadoList();
         LstEL.Add(EL = new EstadoList()
         {
             Id = 0, Estado = "Inactivo"
         });
         LstEL.Add(EL = new EstadoList()
         {
             Id = 1, Estado = "Activo"
         });
         #endregion
         UsuarioIndex UI = new UsuarioIndex();
         Usuario      U  = Context.Usuario.Where(x => x.Id == id).FirstOrDefault();
         UI = new UsuarioIndex()
         {
             Id           = U.Id,
             Nombre       = U.Nombre,
             Apellido     = U.Apellido,
             UserName     = U.UserName,
             Correo       = U.Correo,
             Estado       = U.Estado == false ? 0 : 1,
             ListaEstados = LstEL
         };
         return(Ok(UI));
     }
     catch (Exception ex)
     {
         return(BadRequest("Error al obtener el objeto de Usuarios, error: " + ex));
     }
 }
Exemplo n.º 3
0
        public static UsuarioIndex CrearIndex(Usuario usuario)
        {
            var obj = new UsuarioIndex();

            obj.UsuarioId       = usuario.UsuarioId;
            obj.UserName        = usuario.UserName;
            obj.UserPassword    = usuario.UserPassword;
            obj.EsAdministrador = usuario.EsAdministrador;
            obj.Estado          = usuario.EsAdministrador;

            return(obj);
        }
Exemplo n.º 4
0
        public dynamic Index(int?id)
        {
            #region Estados
            List <EstadoList> LstEL = new List <EstadoList>();
            EstadoList        EL    = new EstadoList();
            LstEL.Add(EL = new EstadoList()
            {
                Id = 0, Estado = "Inactivo"
            });
            LstEL.Add(EL = new EstadoList()
            {
                Id = 1, Estado = "Activo"
            });
            #endregion
            UsuarioIndex        UI   = new UsuarioIndex();
            List <UsuarioIndex> LstI = new List <UsuarioIndex>();
            try
            {
                DB = new SlabEntities();
                DB.Configuration.LazyLoadingEnabled = true;
                response = new Response();
                Usuario U = id != null?DB.Usuario.Where(x => x.Id == id).FirstOrDefault() : null;

                UI = new UsuarioIndex()
                {
                    Id           = U != null ? U.Id : 0,
                    Nombre       = U != null ? U.Nombre : "",
                    Apellido     = U != null ? U.Apellido : "",
                    Usuario      = U != null ? U.Usuario1 : "",
                    Correo       = U != null ? U.Correo : "",
                    Estado       = 0,
                    ListaEstados = LstEL
                };
                response.Successfully = true;
                response.Code         = 200;
                response.Message      = "Consulta realizada con éxito.";
                response.Result       = UI;
            }
            catch (Exception Exc)
            {
                response.Successfully = false;
                response.Code         = 500;
                response.Message      = Exc.Message.ToString();
                response.Result       = null;
            }
            return(response);
        }
Exemplo n.º 5
0
        public ActionResult PaginadorIndex(int pagina = 1)
        {
            var cantidadRegistros = 5;

            using (var db = new inventarioEntities1())
            {
                var usuarios = db.usuario.OrderBy(x => x.id).Skip((pagina - 1) * cantidadRegistros)
                               .Take(cantidadRegistros).ToList();

                var totalRegistros = db.usuario.Count();
                var modelo         = new UsuarioIndex();
                modelo.Usuarios          = usuarios;
                modelo.ActualPage        = pagina;
                modelo.Total             = totalRegistros;
                modelo.RecordsPage       = cantidadRegistros;
                modelo.ValuesQueryString = new RouteValueDictionary();

                return(View(modelo));
            }
        }