예제 #1
0
        public dynamic Index(int?id)
        {
            EstadoList         EL    = new EstadoList();
            List <EstadoList>  LstEL = new List <EstadoList>();
            TareaIndex         TI    = new TareaIndex();
            ProyectList        PL    = new ProyectList();
            List <ProyectList> LstPL = new List <ProyectList>();

            try
            {
                DB = new SlabEntities();
                DB.Configuration.LazyLoadingEnabled = true;
                response     = new Response();
                LstEL.Add(EL = new EstadoList()
                {
                    Id = 0, Estado = "Pendiente"
                });
                LstEL.Add(EL = new EstadoList()
                {
                    Id = 1, Estado = "Realizada"
                });
                List <Proyecto> P = DB.Proyecto.ToList();
                List <Usuario>  U = DB.Usuario.ToList();
                Tarea           T = id != null?DB.Tarea.Where(x => x.Id == id).FirstOrDefault() : null;

                if (P != null)
                {
                    foreach (Proyecto p in P)
                    {
                        PL = new ProyectList()
                        {
                            Id          = p.Id,
                            Nombre      = p.Nombre,
                            Descripcion = p.Descripcion,
                            FechaInicio = p.Fecha_Inicio,
                            FechaFin    = p.Fecha_Fin,
                            Id_Operario = p.Id_Operario,
                            Operario    = U.Where(x => x.Id == p.Id_Operario).Select(x => x.Nombre + ' ' + x.Apellido).FirstOrDefault(),
                            Estado      = p.Estado,
                            ValEstado   = p.Estado == false ? "En Proceso" : "Finalizado"
                        };
                        LstPL.Add(PL);
                    }
                }
                TI = new TareaIndex()
                {
                    Id              = T != null ? T.Id : 0,
                    Nombre          = T != null ? T.Nombre : "",
                    Descripcion     = T != null ? T.Descripcion : "",
                    Fecha_Ejecucion = T != null ? T.Fecha_Ejecucion : DateTime.Now,
                    Id_Proyecto     = T != null ? T.Id_Proyecto : 0,
                    LstProyecto     = LstPL,
                    Estado          = T != null ? T.Estado == false ? 0 : 1 : 0,
                    ListaEstado     = LstEL
                };
                response.Successfully = true;
                response.Code         = 200;
                response.Message      = "Consulta realizada con éxito.";
                response.Result       = TI;
            }
            catch (Exception Exc)
            {
                response.Successfully = false;
                response.Code         = 500;
                response.Message      = Exc.Message.ToString();
                response.Result       = null;
            }
            return(response);
        }
예제 #2
0
        public dynamic List(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
            ProyectList        PL    = new ProyectList();
            List <ProyectList> LstPL = new List <ProyectList>();
            try
            {
                DB = new SlabEntities();
                DB.Configuration.LazyLoadingEnabled = true;
                response = new Response();
                List <Usuario>  Usr = DB.Usuario.ToList();
                List <Proyecto> Pro = id == null?DB.Proyecto.ToList() : DB.Proyecto.Where(x => x.Id == id).ToList();

                if (Pro.Count > 0)
                {
                    foreach (Proyecto P in Pro)
                    {
                        PL = new ProyectList()
                        {
                            Id          = P.Id,
                            Nombre      = P.Nombre,
                            Descripcion = P.Descripcion,
                            FechaInicio = P.Fecha_Inicio,
                            FechaFin    = P.Fecha_Fin,
                            Id_Operario = P.Id_Operario,
                            Operario    = Usr.Where(x => x.Id == P.Id_Operario).Select(x => x.Nombre + ' ' + x.Apellido).FirstOrDefault(),
                            Estado      = P.Estado,
                            ValEstado   = P.Estado == false ? "En Proceso" : "Finalizado"
                        };
                        LstPL.Add(PL);
                    }
                    response.Message = "";
                    response.Result  = LstPL;
                }
                else
                {
                    response.Message = "No se encontro ningun Proyecto";
                    response.Result  = null;
                }
                response.Successfully = true;
                response.Code         = 200;
            }
            catch (Exception Exc)
            {
                response.Successfully = false;
                response.Code         = 500;
                response.Message      = Exc.Message.ToString();
                response.Result       = null;
            }
            return(response);
        }