//public tblAnio RetrieveByAnioTexto(int anio) //{ // tblAnio Result = null; // using (var r = new Repository<tblAnio>()) // { // Result = r.Retrieve(p => p.anio == anio); // } // return Result; //} public tblServicio RetrieveServicioByID(int id) { tblServicio Result = null; using (var r = new Repository <tblServicio>()) { Result = r.Retrieve(p => p.idservicios == id); } return(Result); }
// GET: Servicios/Edit/5 public ActionResult Edit(int id) { var serBLL = new ServiciosBLL(); tblServicio objSer = serBLL.RetrieveServicioByID(id); var areaBLL = new AreasBLL(); List <tblArea> listaAreas = areaBLL.RetrieveAll(); ViewBag.idArea = new SelectList(listaAreas, "idArea", "nombreArea", objSer.idArea); return(View(objSer)); }
public bool Delete(int id) { bool Result = false; tblServicio obj = RetrieveServicioByID(id); if (obj != null) { using (var r = new Repository <tblServicio>()) { Result = r.Delete(obj); } } else { throw (new Exception("El servicio seleccionada no se pudo eliminar.")); } return(Result); }
public ActionResult Edit(tblServicio servicio) { var serBLL = new ServiciosBLL(); ActionResult Result = null; try { if (ModelState.IsValid) { serBLL.Update(servicio); Result = RedirectToAction("Index"); } } catch { return(View()); } return(Result); }
public bool Update(tblServicio t) { bool Result = false; using (var r = new Repository <tblServicio>()) { tblServicio ba = r.Retrieve(p => p.idservicios == t.idservicios && p.serviciosNombre == t.serviciosNombre && p.idArea == t.idArea); if (ba == null) { Result = r.Update(t); } else { throw (new Exception("No se pudo actualizar el servicio seleccionado.")); } } return(Result); }
public tblServicio Create(tblServicio t) { tblServicio Result = null; using (var r = new Repository <tblServicio>()) { tblServicio ba = r.Retrieve(p => p.idservicios != t.idservicios && p.serviciosNombre == t.serviciosNombre && p.idArea == t.idArea); if (ba == null) { Result = r.Create(t); } else { throw (new Exception("El servicio ya existe.")); } } return(Result); }
public JsonResult DeleteServicio(int id) { var serBLL = new ServiciosBLL(); wmJsonResult objJson = new wmJsonResult(); try { tblServicio servicio = serBLL.RetrieveServicioByID(id); if (servicio != null) { bool banderita = serBLL.Delete(id); if (banderita == true) { objJson.bandera = true; objJson.mensaje = "El Servicio se eliminó correctamente"; } else { objJson.bandera = false; objJson.mensaje = "El Servicio NO se eliminó correctamente"; } } else { objJson.bandera = false; objJson.mensaje = "El Servicio no se encontró"; } } catch { objJson.bandera = false; objJson.mensaje = "Ocurrio una excepcion al eliminar el Servicio"; } return(Json(objJson, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(tblServicio servicio) { var serBLL = new ServiciosBLL(); ActionResult Result = null; try { if (ModelState.IsValid) { serBLL.Create(servicio); Result = RedirectToAction("Index"); } else { Result = RedirectToAction("Index"); } } catch { Result = RedirectToAction("Index"); } return(Result); }