public ActionResult GetObj()
 {
     #region Estados
     List <EstadoList> LstEL = new List <EstadoList>();
     EstadoList        EL    = new EstadoList();
     LstEL.Add(EL = new EstadoList()
     {
         Id = 0, Estado = "En Proceso"
     });
     LstEL.Add(EL = new EstadoList()
     {
         Id = 1, Estado = "Finalizado"
     });
     #endregion
     try
     {
         ProyectoIndex PI = new ProyectoIndex();
         PI = new ProyectoIndex()
         {
             Id          = 0,
             Nombre      = "",
             Descripcion = "",
             FechaInicio = DateTime.Now,
             FechaFin    = DateTime.Now,
             Estado      = 0,
             LstEstado   = LstEL
         };
         return(Ok(PI));
     }
     catch (Exception ex)
     {
         return(BadRequest("Error al obtener el objeto de Proyectos, 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 = "En Proceso"
         });
         LstEL.Add(EL = new EstadoList()
         {
             Id = 1, Estado = "Finalizado"
         });
         #endregion
         ProyectoIndex PI = new ProyectoIndex();
         Proyecto      P  = Context.Proyecto.Where(x => x.Id == id).FirstOrDefault();
         PI = new ProyectoIndex()
         {
             Id          = P.Id,
             Nombre      = P.Nombre,
             Descripcion = P.Descripcion,
             FechaInicio = P.Fecha_Inicio,
             FechaFin    = P.Fecha_Fin,
             Estado      = P.Estado == false ? 0 : 1,
             LstEstado   = LstEL
         };
         return(Ok(PI));
     }
     catch (Exception ex)
     {
         return(BadRequest("Error al obtener el objeto del Proyecto, error: " + ex));
     }
 }
Ejemplo n.º 3
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 = "En Proceso"
            });
            LstEL.Add(EL = new EstadoList()
            {
                Id = 1, Estado = "Finalizado"
            });
            #endregion
            ProyectoIndex      PI    = new ProyectoIndex();
            UsuarioList        UL    = new UsuarioList();
            List <UsuarioList> LstUL = new List <UsuarioList>();
            try
            {
                DB = new SlabEntities();
                DB.Configuration.LazyLoadingEnabled = true;
                response = new Response();
                Rol            R = DB.Rol.Where(y => y.Rol1.ToUpper().Equals("OPERARIO")).FirstOrDefault();
                List <Usuario> U = DB.Usuario.Where(x => x.Rol_Id == R.Id && x.Estado == true).ToList();
                Proyecto       P = id != null?DB.Proyecto.Where(x => x.Id == id).FirstOrDefault() : null;

                if (U != null)
                {
                    foreach (Usuario usr in U)
                    {
                        UL = new UsuarioList()
                        {
                            Id       = usr.Id,
                            Nombre   = usr.Nombre,
                            Apellido = usr.Apellido,
                            Correo   = usr.Correo,
                            Usuario  = usr.Usuario1,
                        };
                        LstUL.Add(UL);
                    }
                }
                PI = new ProyectoIndex()
                {
                    Id          = P != null ? P.Id : 0,
                    Nombre      = P != null ? P.Nombre : "",
                    Descripcion = P != null ? P.Descripcion : "",
                    FechaInicio = P != null ? P.Fecha_Inicio : DateTime.Now,
                    FechaFin    = P != null ? P.Fecha_Fin : DateTime.Now,
                    Estado      = P != null ? P.Estado == false ? 0 : 1 : 0,
                    LstEstado   = LstEL
                };
                response.Successfully = true;
                response.Code         = 200;
                response.Message      = "Consulta realizada con éxito.";
                response.Result       = PI;
            }
            catch (Exception Exc)
            {
                response.Successfully = false;
                response.Code         = 500;
                response.Message      = Exc.Message.ToString();
                response.Result       = null;
            }
            return(response);
        }