public bool Update(tblEvento t) { bool Result = false; using (var r = new Repository <tblEvento>()) { tblEvento ba = r.Retrieve(p => p.nombreEvento == t.nombreEvento && p.descripcionEvento == t.descripcionEvento && p.fechaEvento == t.fechaEvento && p.horaInicio == t.horaInicio && p.horaFinal == t.horaFinal && p.idAula == t.idAula && p.idColaborador == t.idColaborador && p.idNivel == t.idNivel ); if (ba == null) { Result = r.Update(t); } else { throw (new Exception("No se pudo actualizar el evento seleccionado.")); } } return(Result); }
public tblEvento Create(tblEvento t) { tblEvento Result = null; using (var r = new Repository <tblEvento>()) { tblEvento ba = r.Retrieve(p => p.nombreEvento == t.nombreEvento && p.descripcionEvento == t.descripcionEvento && p.fechaEvento == t.fechaEvento && p.horaInicio == t.horaInicio && p.horaFinal == t.horaFinal && p.idAula == t.idAula && p.idColaborador == t.idColaborador && p.idNivel == t.idNivel && p.idEvento != t.idEvento); if (ba == null) { Result = r.Create(t); } else { throw (new Exception("El evento ya existe.")); } } return(Result); }
//public tblAnio RetrieveByAnioTexto(int anio) //{ // tblAnio Result = null; // using (var r = new Repository<tblAnio>()) // { // Result = r.Retrieve(p => p.anio == anio); // } // return Result; //} public tblEvento RetrievEventoByID(int id) { tblEvento Result = null; using (var r = new Repository <tblEvento>()) { Result = r.Retrieve(p => p.idEvento == id); } return(Result); }
public bool Delete(int id) { bool Result = false; tblEvento obj = RetrievEventoByID(id); if (obj != null) { using (var r = new Repository <tblEvento>()) { Result = r.Delete(obj); } } else { throw (new Exception("El aula seleccionada no se pudo eliminar.")); } return(Result); }
public ActionResult Edit(tblEvento evento) { var eveBLL = new EventoBLL(); ActionResult Result = null; try { if (ModelState.IsValid) { eveBLL.Update(evento); Result = RedirectToAction("Index"); } } catch { return(View()); } return(Result); }
///<summary> ///Agregar registro a tblEvento por idEvento /// </summary> public bool agregarEvento(string nombre, string objetivo, string rutaIcono, DateTime fvi, DateTime fvf, DateTime fri, DateTime frf, string rutaPlantilla, string tipoEvento, string estado) { bool agrego = false; try { using (var db = new SeguimientoPermanenciaEntities()) { //Validar que el nombre del evento no exista model.listaEventos = (from ev in db.tblEvento where ev.nombre == nombre select ev).ToList(); if (model.listaEventos.Count != 0) { return(false); } tblEvento newEvento = new tblEvento() { nombre = nombre, objetivo = objetivo, rutaIcono = rutaIcono, fVigenciaInicio = fvi, fVigenciaFin = fvf, fRegistroInicio = fri, fRegistroFin = frf, rutaPlantillaExcel = rutaPlantilla, tipoEvento = tipoEvento, estado = estado, }; db.tblEvento.Add(newEvento); db.SaveChanges(); } agrego = true; } catch (Exception) { agrego = false; } return(agrego); }
// GET: Eventos/Edit/5 public ActionResult Edit(int id) { var eveBLL = new EventoBLL(); tblEvento objEve = eveBLL.RetrievEventoByID(id); var aulaBLL = new AulaBLL(); List <tblAula> listaAulas = aulaBLL.RetrieveAll(); ViewBag.idAula = new SelectList(listaAulas, "idAula", "nombreAula", objEve.idAula); var colaboradorBLL = new ColaboradorBLL(); List <tblColaboradore> listacolaborador = colaboradorBLL.RetrieveAll(); ViewBag.idColaborador = new SelectList(listacolaborador, "idcolaborador", "nombreColaborador", objEve.idColaborador); var nivelBLL = new NivelBLL(); List <tblNivel> listaNivel = nivelBLL.RetrieveAll(); ViewBag.idNivel = new SelectList(listaNivel, "idNivel", "nivelNombre", objEve.idNivel); return(View(objEve)); }
// GET: Eventos/Delete/5 public JsonResult DeleteEventos(int id) { var eveBLL = new EventoBLL(); wmJsonResult objJson = new wmJsonResult(); try { tblEvento evento = eveBLL.RetrievEventoByID(id); if (evento != null) { bool banderita = eveBLL.Delete(id); if (banderita == true) { objJson.bandera = true; objJson.mensaje = "El evento se eliminó correctamente"; } else { objJson.bandera = false; objJson.mensaje = "El evento NO se eliminó correctamente"; } } else { objJson.bandera = false; objJson.mensaje = "El evento no se encontró"; } } catch { objJson.bandera = false; objJson.mensaje = "Ocurrio una excepcion al eliminar el evento"; } return(Json(objJson, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(tblEvento evento) { var eveBLL = new EventoBLL(); ActionResult Result = null; try { if (ModelState.IsValid) { eveBLL.Create(evento); Result = RedirectToAction("Index"); } else { Result = RedirectToAction("Index"); } } catch { Result = RedirectToAction("Index"); } return(Result); }