Ejemplo n.º 1
0
        // GET: Nivel/Edit/5
        public ActionResult Edit(int id)
        {
            var      lvlBLL = new NivelBLL();
            tblNivel objlvl = lvlBLL.RetrieveNivelByID(id);

            return(View(objlvl));
        }
Ejemplo n.º 2
0
        //public tblAnio RetrieveByAnioTexto(int anio)
        //{
        //    tblAnio Result = null;
        //    using (var r = new Repository<tblAnio>())
        //    {
        //        Result = r.Retrieve(p => p.anio == anio);
        //    }
        //    return Result;
        //}


        public tblNivel RetrieveNivelByID(int id)
        {
            tblNivel Result = null;

            using (var r = new Repository <tblNivel>())
            {
                Result = r.Retrieve(p => p.idNivel == id);
            }
            return(Result);
        }
Ejemplo n.º 3
0
        public bool Delete(int id)
        {
            bool     Result = false;
            tblNivel obj    = RetrieveNivelByID(id);

            if (obj != null)
            {
                using (var r = new Repository <tblNivel>())
                {
                    Result = r.Delete(obj);
                }
            }
            else
            {
                throw (new Exception("El nivel seleccionada no se pudo eliminar."));
            }

            return(Result);
        }
Ejemplo n.º 4
0
        public ActionResult Edit(tblNivel nivel)
        {
            var          lvlBLL = new NivelBLL();
            ActionResult Result = null;

            try
            {
                if (ModelState.IsValid)
                {
                    lvlBLL.Update(nivel);
                    Result = RedirectToAction("Index");
                }
            }
            catch
            {
                return(View());
            }
            return(Result);
        }
Ejemplo n.º 5
0
        public bool Update(tblNivel t)
        {
            bool Result = false;

            using (var r = new Repository <tblNivel>())
            {
                tblNivel ba = r.Retrieve(p => p.idNivel == t.idNivel &&
                                         p.nivelNombre == t.nivelNombre);

                if (ba == null)
                {
                    Result = r.Update(t);
                }
                else
                {
                    throw (new Exception("No se pudo actualizar el nivel seleccionado."));
                }
            }
            return(Result);
        }
Ejemplo n.º 6
0
        public tblNivel Create(tblNivel t)
        {
            tblNivel Result = null;

            using (var r = new Repository <tblNivel>())
            {
                tblNivel ba = r.Retrieve(p => p.idNivel != t.idNivel &&
                                         p.nivelNombre == t.nivelNombre);

                if (ba == null)
                {
                    Result = r.Create(t);
                }
                else
                {
                    throw (new Exception("El nivel ya existe."));
                }
            }
            return(Result);
        }
Ejemplo n.º 7
0
        // GET: Nivel/Delete/5
        public JsonResult DeleteNivel(int id)
        {
            var          lvlBLL  = new NivelBLL();
            wmJsonResult objJson = new wmJsonResult();

            try
            {
                tblNivel nivel = lvlBLL.RetrieveNivelByID(id);

                if (nivel != null)
                {
                    bool banderita = lvlBLL.Delete(id);

                    if (banderita == true)
                    {
                        objJson.bandera = true;
                        objJson.mensaje = "El nivel se eliminó correctamente";
                    }
                    else
                    {
                        objJson.bandera = false;
                        objJson.mensaje = "El nivel NO se eliminó correctamente";
                    }
                }
                else
                {
                    objJson.bandera = false;
                    objJson.mensaje = "El nivel no se encontró";
                }
            }
            catch
            {
                objJson.bandera = false;
                objJson.mensaje = "Ocurrio una excepcion al eliminar elnivel";
            }

            return(Json(objJson, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 8
0
        public ActionResult Create(tblNivel nivel)
        {
            var          lvlBLL = new NivelBLL();
            ActionResult Result = null;

            try
            {
                if (ModelState.IsValid)
                {
                    lvlBLL.Create(nivel);
                    Result = RedirectToAction("Index");
                }
                else
                {
                    Result = RedirectToAction("Index");
                }
            }
            catch
            {
                Result = RedirectToAction("Index");
            }
            return(Result);
        }