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

            var buPortafolio = new BuPortafolio();
            var portafolios  = buPortafolio.GetAll();

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

            if (portafolios != null)
            {
                var categorias   = new BuCategoriaComponente().GetAll();
                var prioridades  = new BuPrioridad().GetAll();
                var estados      = new BuEstado().GetAll();
                var trabajadores = new BuTrabajador().GetAll();
                foreach (var portafolio in portafolios)
                {
                    portafolio.CategoriaComponente = categorias.FirstOrDefault(x => x.Id.Equals(portafolio.CategoriaComponenteId));
                    portafolio.Prioridad           = prioridades.FirstOrDefault(x => x.Id.Equals(portafolio.PrioridadId));
                    portafolio.Estado      = estados.FirstOrDefault(x => x.Id.Equals(portafolio.EstadoId));
                    portafolio.Responsable = trabajadores.FirstOrDefault(x => x.Id.Equals(portafolio.ResponsableId));
                }
            }
            else
            {
                portafolios = new List <Portafolio>();
            }

            return(View(portafolios.OrderBy(x => x.Name)));
        }
Example #2
0
        public ActionResult Index(string search)
        {
            ViewBag.Message = TempData["Message"];

            var buCategoriaComponente = new BuCategoriaComponente();
            var categoriaComponentes  = string.IsNullOrEmpty(search) ? buCategoriaComponente.GetAll() : buCategoriaComponente.GetMany(x => x.Name.Contains(search));

            return(View(categoriaComponentes.OrderBy(x => x.Name)));
        }
Example #3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var buCategoriaComponente = new BuCategoriaComponente();
            var categoriaComponente   = buCategoriaComponente.GetById(id.Value);

            if (categoriaComponente == null)
            {
                return(HttpNotFound());
            }

            return(View(categoriaComponente));
        }
Example #4
0
 public ActionResult Edit([Bind(Include = "Id,Name,Description,Remark")] CategoriaComponente categoriaComponente)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var buCategoriaComponente = new BuCategoriaComponente();
             buCategoriaComponente.Update(categoriaComponente);
             TempData["Message"] = "Message: La operación se realizó satisfactoriamente.";
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception e)
     {
         ViewBag.ErrorMessage = $"Error Message: {e.Message}";
     }
     return(View(categoriaComponente));
 }
Example #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            var buCategoriaComponente = new BuCategoriaComponente();
            var categoriaComponente   = buCategoriaComponente.GetById(id);

            if (categoriaComponente == null)
            {
                return(HttpNotFound());
            }
            try
            {
                buCategoriaComponente.Delete(id);
                TempData["Message"] = "Message: La operación se realizó satisfactoriamente.";
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ViewBag.ErrorMessage = $"Error Message: {e.Message}";
            }

            return(View(categoriaComponente));
        }