public ActionResult Index(string search)
        {
            ViewBag.Message = TempData["Message"];

            var buPrograma = new BuPrograma();
            var programas  = buPrograma.GetAll();

            if (programas != null && !string.IsNullOrEmpty(search))
            {
                programas = programas.Where(x => x.Name.Contains(search));
            }

            if (programas != null)
            {
                var prioridades  = new BuPrioridad().GetAll();
                var estados      = new BuEstado().GetAll();
                var trabajadores = new BuTrabajador().GetAll();
                foreach (var programa in programas)
                {
                    programa.Prioridad   = prioridades.FirstOrDefault(x => x.Id.Equals(programa.PrioridadId));
                    programa.Estado      = estados.FirstOrDefault(x => x.Id.Equals(programa.EstadoId));
                    programa.Responsable = trabajadores.FirstOrDefault(x => x.Id.Equals(programa.ResponsableId));
                }
            }
            else
            {
                programas = new List <Programa>();
            }

            return(View(programas.OrderBy(x => x.Name)));
        }
Exemple #2
0
 public JsonResult GetPrograma(string id)
 {
     if (string.IsNullOrEmpty(id))
     {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(Json(new { Result = "Error" }));
     }
     try
     {
         var programa = new BuPrograma().GetById(int.Parse(id));
         return(Json(programa, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { Result = "Error", Message = ex.Message }));
     }
 }
        public Programa GetPrograma(int id, bool loadStatisticalData)
        {
            var programa = new BuPrograma().GetFullById(id, loadStatisticalData);

            return(programa);
        }