public ActionResult GuardarReserva(int cursoId, int alumnoId, string silla, string seleccion) { ReservaAlumnoViewModel reservaViewModel = new ReservaAlumnoViewModel(); try { reservaViewModel.CursoId = cursoId; reservaViewModel.AlumnoId = alumnoId; int sillaId = this.fachadaSillaReserva.BuscarSilla(silla); if (ModelState.IsValid && cursoId > 0 && alumnoId > 0) { if (seleccion == "sillaDisponible") { this.Guardar(reservaViewModel, sillaId); ViewBag.DivSillasDisplay = "normal"; ViewBag.Mensaje = "Chair Selected"; ViewBag.BtnAgregarAlumnoHidden = true; } else if (seleccion == "sillaSeleccionada") { this.Borrar(reservaViewModel, sillaId); ViewBag.BtnAgregarAlumnoHidden = false; } } else { ViewBag.Mensaje = "Must choose a course and a student."; } int reservaId = Convert.ToInt32(Session["ReservaId"]); reservaViewModel.Sillas = RetornarSillas(); reservaViewModel.AlumnoNombre = this.fachadaAlumno.BuscarAlumnoId(reservaViewModel.AlumnoId).NombreAlumno; reservaViewModel.Sillas = this.RetornarDisponibilidad(reservaViewModel.CursoId, reservaId, reservaViewModel.Sillas); ViewBag.CursoId = new SelectList(fachadaCurso.ListarCursosTodos(), "CursoId", "NombreCurso", reservaViewModel.CursoId); ViewBag.DivSillasDisplay = "normal"; ViewBag.AlumnosDisplay = "none"; } catch (Exception ex) { string mensaje = ConfigurarExcepcion(ex); this.tecsoLogger.LogMessage(mensaje, true, true, EnumTipoMensaje.ERROR); ViewBag.Error = mensaje; } return(View("NuevaReserva", reservaViewModel)); }
public ActionResult NuevaReserva(ReservaAlumnoViewModel reservaAlumnoViewModel) { try { ViewBag.CursoId = new SelectList(this.fachadaCurso.ListarCursosActivos(), "CursoId", "NombreCurso"); ViewBag.AlumnosDisplay = "none"; if (reservaAlumnoViewModel.CursoId > 0) { Alumno alumno = this.fachadaAlumno.BuscarAlumnoId(reservaAlumnoViewModel.AlumnoId); reservaAlumnoViewModel.AlumnoNombre = alumno.NombreAlumno; int reservaId = this.fachadaReservaAlumno.BuscarReservaCursoAlumno(reservaAlumnoViewModel.CursoId, reservaAlumnoViewModel.AlumnoId).ReservaAlumnoId; Session["ReservaId"] = reservaId; reservaAlumnoViewModel.Sillas = this.RetornarSillas(); reservaAlumnoViewModel.Sillas = this.RetornarDisponibilidad(reservaAlumnoViewModel.CursoId, reservaId, reservaAlumnoViewModel.Sillas); ViewBag.SillasDisplay = "normal"; ViewBag.BtnAgregarAlumnoHidden = true; } else { Session["ReservaId"] = null; reservaAlumnoViewModel = new ReservaAlumnoViewModel(); reservaAlumnoViewModel.Sillas = this.RetornarSillas(); ViewBag.SillasDisplay = "none"; ViewBag.BtnAgregarAlumnoHidden = false; } } catch (Exception ex) { string mensaje = ConfigurarExcepcion(ex); this.tecsoLogger.LogMessage(mensaje, true, true, EnumTipoMensaje.ERROR); ViewBag.Error = mensaje; } return(View(reservaAlumnoViewModel)); }
private void Guardar(ReservaAlumnoViewModel reservaAlumnoViewModel, int sillaId) { try { int reservaId = Convert.ToInt32(Session["ReservaId"]); if (reservaId > 0) { SillaReserva sillaReservaAnt = this.fachadaSillaReserva.RetornarSillaPorReserva(reservaId); if (sillaReservaAnt != null) { this.fachadaSillaReserva.EliminarSillaReserva(sillaReservaAnt.SillaReservaId); } } else { reservaId = this.fachadaReservaAlumno.InsertarReserva(new DTOReservaAlumno { dtoAlumno = new DTOAlumno { AlumnoId = reservaAlumnoViewModel.AlumnoId }, dtoCurso = new DTOCurso { CursoId = reservaAlumnoViewModel.CursoId } }); Session["ReservaId"] = reservaId; } this.fachadaSillaReserva.InsertarSillaReserva(new DTOSillaReserva { dtoReserva = new DTOReservaAlumno { ReservaId = reservaId }, dtoSilla = new DTOSilla { SillaId = sillaId } }); } catch (Exception) { throw; } }
private void Borrar(ReservaAlumnoViewModel reservaViewModel, int sillaId) { try { int reservaId = Convert.ToInt32(Session["ReservaId"]); SillaReserva sillareserva = this.fachadaSillaReserva.BuscarSillaReserva(reservaId, sillaId); this.fachadaSillaReserva.EliminarSillaReserva(sillareserva.SillaReservaId); this.fachadaReservaAlumno.EliminarReserva(reservaId); Session["ReservaId"] = null; ViewBag.Mensaje = "Chair Free"; } catch (Exception) { throw; } }