public ActionResult Index(int?page, string search)
        {
            CustomHelper.setTitulo("Nivel Academico", "Listado");

            List <NivelAcademico> Niveles = new List <NivelAcademico>();

            try
            {
                if (!string.IsNullOrWhiteSpace(search) && search != null)
                {
                    Niveles = new NivelAcademicoBL().Buscar(search, CustomHelper.getColegioId()).ToList();
                }
                else
                {
                    Niveles = new NivelAcademicoBL().ObtenerListado(true, CustomHelper.getColegioId());
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = string.Format("Message: {0} StackTrace: {1}", ex.Message, ex.StackTrace);
                return(View("~/Views/Shared/Error.cshtml"));
            }

            ViewBag.Search = search;

            int pageSize   = 15;
            int pageNumber = (page ?? 1);

            return(View(Niveles.ToPagedList(pageNumber, pageSize)));
        }
        public ActionResult Crear(NivelAcademico modelo, bool activo)
        {
            if (ModelState.IsValid)
            {
                modelo.ColegioId = CustomHelper.getColegioId();
                modelo.Activo    = activo;

                string strMensaje = new NivelAcademicoBL().Guardar(modelo);

                if (strMensaje.Equals("OK"))
                {
                    TempData["Nivel_Academico-Success"] = strMensaje;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", strMensaje);
                }
            }

            string strAtributo = "checked='checked'";

            ViewBag.ActivoSi = activo == true ? strAtributo : "";
            ViewBag.ActivoNo = activo == false ? strAtributo : "";

            return(View(modelo));
        }
Ejemplo n.º 3
0
        private void CargaControles()
        {
            var Niveles  = new NivelAcademicoBL().ObtenerListado(false, CustomHelper.getColegioId());
            var Jornadas = new JornadaBL().ObtenerListado(false, CustomHelper.getColegioId());

            ViewBag.Niveles  = new SelectList(Niveles, "NivelId", "Nombre");
            ViewBag.Jornadas = new SelectList(Jornadas, "JornadaId", "Nombre");
        }
        public ActionResult Editar(long id)
        {
            NivelAcademico NivelAcademicoActual = new NivelAcademicoBL().ObtenerxId(id);

            if (NivelAcademicoActual == null || NivelAcademicoActual.NivelId == 0)
            {
                return(HttpNotFound());
            }

            CustomHelper.setTitulo("Nivel Academico", "Editar");

            string strAtributo = "checked='checked'";

            ViewBag.ActivoSi = NivelAcademicoActual.Activo == true ? strAtributo : "";
            ViewBag.ActivoNo = NivelAcademicoActual.Activo == false ? strAtributo : "";

            return(View(NivelAcademicoActual));
        }