// GET: Nivel/Edit/5 public ActionResult Edit(int id) { var lvlBLL = new NivelBLL(); tblNivel objlvl = lvlBLL.RetrieveNivelByID(id); return(View(objlvl)); }
//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); }
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); }
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); }
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); }
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); }
// 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)); }
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); }