Exemplo n.º 1
0
        public ActionResult GetList()
        {
            TareaList        TL    = new TareaList();
            List <TareaList> LstTL = new List <TareaList>();

            try
            {
                List <Tarea> Ta = Context.Tarea.ToList();
                if (Ta.Count > 0)
                {
                    foreach (Tarea T in Ta)
                    {
                        TL = new TareaList()
                        {
                            Id              = T.Id,
                            Nombre          = T.Nombre,
                            Descripcion     = T.Descripcion,
                            Fecha_Ejecucion = T.Fecha_Ejecucion,
                            Id_Proyecto     = T.Id_Proyecto,
                            Proyecto        = Context.Proyecto.Where(x => x.Id == T.Id_Proyecto).Select(x => x.Nombre).FirstOrDefault(),
                            Estado          = T.Estado == false ? 0 : 1,
                            ValEstado       = T.Estado == false ? "Pendiente" : "Realizada"
                        };
                        LstTL.Add(TL);
                    }
                }
                return(Ok(LstTL));
            }
            catch (Exception ex)
            {
                return(BadRequest("Error al obtener el listado de las Tareas, error: " + ex.Message.ToString()));
            }
        }
Exemplo n.º 2
0
        public ActionResult GetListId(int id)
        {
            TareaList TL = new TareaList();

            try
            {
                Tarea T = Context.Tarea.Where(x => x.Id == id).FirstOrDefault();

                TL = new TareaList()
                {
                    Id              = T.Id,
                    Nombre          = T.Nombre,
                    Descripcion     = T.Descripcion,
                    Fecha_Ejecucion = T.Fecha_Ejecucion,
                    Id_Proyecto     = T.Id_Proyecto,
                    Proyecto        = Context.Proyecto.Where(x => x.Id == T.Id_Proyecto).Select(x => x.Nombre).FirstOrDefault(),
                    Estado          = T.Estado == false ? 0 : 1,
                    ValEstado       = T.Estado == false ? "Pendiente" : "Realizada"
                };
                return(Ok(TL));
            }
            catch (Exception ex)
            {
                return(BadRequest("Error al obtener la tarea, error: " + ex.Message.ToString()));
            }
        }
Exemplo n.º 3
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 = "Pendiente"
            });
            LstEL.Add(EL = new EstadoList()
            {
                Id = 1, Estado = "Realizada"
            });
            #endregion
            TareaList        TL    = new TareaList();
            List <TareaList> LstTL = new List <TareaList>();
            try
            {
                DB = new SlabEntities();
                DB.Configuration.LazyLoadingEnabled = true;
                response = new Response();
                List <Proyecto> Pro = DB.Proyecto.ToList();
                List <Tarea>    Tar = id == null?DB.Tarea.ToList() : DB.Tarea.Where(x => x.Id == id).ToList();

                if (Tar.Count > 0)
                {
                    foreach (Tarea T in Tar)
                    {
                        TL = new TareaList()
                        {
                            Id              = T.Id,
                            Nombre          = T.Nombre,
                            Descripcion     = T.Descripcion,
                            Fecha_Ejecucion = T.Fecha_Ejecucion,
                            Id_Proyecto     = T.Id_Proyecto,
                            Proyecto        = Pro.Where(x => x.Id == T.Id_Proyecto).Select(x => x.Nombre).FirstOrDefault(),
                            Estado          = T.Estado == false ? 0 : 1,
                            ValEstado       = T.Estado == false ? "Pendiente" : "Realizada"
                        };
                        LstTL.Add(TL);
                    }
                    response.Message = "";
                    response.Result  = LstTL;
                }
                else
                {
                    response.Message = "No se encontro ninguna tarea";
                    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);
        }