public ActionResult Create([Bind(Include = "id,date_debut,date_fin,titre_seance,salle_id,film_id,id_film")] seance seance, string datePickerStart, string timePickerStart, string datePickerFin, string timePickerfin) { string startString = datePickerStart + " " + timePickerStart, endString = datePickerFin + " " + timePickerfin; seance.date_debut = DateTime.Parse(startString); seance.date_fin = DateTime.Parse(endString); try { ManagerSeance manager = new ManagerSeance(); if (ModelState.IsValid) { if (manager.PostSeance(seance)) { return(RedirectToAction("DetailsSalle", "cinemas", new { id = int.Parse(Session[SessionKeys.salleId].ToString()), start = DateTime.Now })); } } ViewBag.film_id = new SelectList(new ManagerFilm().GetAllFilmsFrom(null), "id", "titre"); return(View(seance)); } catch (Exception e) { TempData.Add("Alert", e.Message); return(RedirectToAction("DetailsSalle", "cinemas", new { id = int.Parse(Session[SessionKeys.salleId].ToString()), start = DateTime.Now })); } }
// GET: seancesEJS public ActionResult Index() { ManagerCinema managerCinema = new ManagerCinema(); ManagerSalle managerSalle = new ManagerSalle(); ManagerFilm managerFilm = new ManagerFilm(); ManagerSeance managerSeance = new ManagerSeance(); List <seance> listeSeance = managerSeance.GetAllSeanceFrom(new DateTime(2020, 10, 30)); listeSeance.ForEach(x => x.salle.cinema.salles.Clear()); listeSeance.ForEach(x => x.salle.salle_status.salles.Clear()); listeSeance.ForEach(x => x.programmations.Clear()); listeSeance.ForEach(x => x.salle.seances.Clear()); listeSeance.ForEach(x => x.salle.cinema.contact_info.cinemas.Clear()); listeSeance.ForEach(x => x.salle.cinema.user.contact_info.users.Clear()); listeSeance.ForEach(x => x.salle.cinema.user.cinemas.Clear()); listeSeance.ForEach(x => x.salle.cinema.user.user_status.users.Clear()); listeSeance.ForEach(x => x.salle.cinema.user.user_type.users.Clear()); ViewBag.appointments = managerSeance.GetAllSeanceFrom(new DateTime(2020, 10, 30)); //ViewBag.appointments = GetScheduleData(); ViewBag.Film = managerFilm.GetAllFilms(); List <cinema> listeCinema = managerCinema.GetAllCinema(); listeCinema.ForEach(x => x.salles.Clear()); listeCinema.ForEach(x => x.contact_info = null); listeCinema.ForEach(x => x.contact_info_id = 0); listeCinema.ForEach(x => x.user = null); listeCinema.ForEach(x => x.responsable_user_id = 0); ViewBag.Cinema = listeCinema; //ViewBag.Cinema = managerCinema.GetAllCinema(); List <salle> listeSalle = managerSalle.GetAllSalle(); listeSalle.ForEach(x => x.salle_status.salles.Clear()); listeSalle.ForEach(x => x.seances.Clear()); listeSalle.ForEach(x => x.cinema.salles.Clear()); listeSalle.ForEach(x => x.cinema.contact_info = null); listeSalle.ForEach(x => x.cinema.contact_info_id = 0); listeSalle.ForEach(x => x.cinema.user = null); listeSalle.ForEach(x => x.cinema.responsable_user_id = 0); ViewBag.Salle = listeSalle; //ViewBag.Salle = managerSalle.GetAllSalle(); ViewBag.Resources = new string[] { "Cinema", "Salle" }; return(View(managerSeance.GetAllSeanceFrom(new DateTime(2020, 10, 30)))); }
public ActionResult getRepeat(int id) { try { seance s = new ManagerSeance().GetSeance(id); return(PartialView("PartialRepeatSession", s)); } catch (Exception e) { TempData.Add("Alert", e.Message); return(RedirectToAction("DetailsSalle", "cinemas", new { id = int.Parse(Session[SessionKeys.salleId].ToString()), start = DateTime.Now })); } }
// GET: seances/Delete/5 public ActionResult Delete(int?id) { try { ManagerSeance manager = new ManagerSeance(); seance seance = manager.GetSeance(id); return(PartialView("PartialDeleteSeance", seance)); } catch (Exception e) { TempData.Add("Alert", e.Message); return(RedirectToAction("DetailsSalle", "cinemas", new { id = Session[SessionKeys.salleId] as int?, start = DateTime.Now })); } }
// GET: seancesEJS/Details/5 public ActionResult Details(int?id) { try { ManagerSeance manager = new ManagerSeance(); seance seance = manager.GetSeance(id); return(View(seance)); } catch (Exception e) { //MessageBox.Show(e.Message); return(RedirectToAction("Index", "Home")); } }
// GET: seances/Details/5 public ActionResult Details(int?id) { Session[SessionKeys.seanceId] = id; try { ManagerSeance manager = new ManagerSeance(); seance seance = manager.GetSeance(id); ViewBag.id_film = new SelectList(new ManagerFilm().GetAllFilms(), "id", "titre"); return(View(seance)); } catch (Exception e) { TempData.Add("Alert", e.Message); return(RedirectToAction("Index", "Home")); } }
// GET: seancesEJS/Edit/5 public ActionResult Edit(int?id) { try { ManagerSeance manager = new ManagerSeance(); seance seance = manager.GetSeance(id); ViewBag.film_id = new SelectList(new ManagerFilm().GetAllFilms(), "id", "titre"); ViewBag.salle_id = new SelectList(new ManagerSalle().GetAllSalle(), "id", "id", seance.salle_id); return(View(seance)); } catch (Exception e) { //MessageBox.Show(e.Message); return(RedirectToAction("Index", "Home")); } }
public void NonConflictingSeance() { //Arrange ManagerSeance manager = new ManagerSeance(_context); seance s = new seance() { id = 999, salle_id = 1, titre_seance = "non conflicting seance", date_debut = new DateTime(2021, 1, 1, 8, 0, 0), date_fin = new DateTime(2021, 1, 1, 10, 0, 0) }; DateTime dateToLoad = new DateTime(2021, 1, 1); //Act var testResult3 = ValidatorSeance.IsSeanceConflict(s, manager.GetAllSeanceFromSalle(s.salle_id, dateToLoad)).Count != 0; //Assert Assert.IsFalse(testResult3, "a seance with the same start time was accepted "); }
public void ConflictingSeance_seanceEndToLate() { //Arrange ManagerSeance manager = new ManagerSeance(_context); seance s2 = new seance() { id = 999, salle_id = 1, titre_seance = "conflicting seance", date_debut = new DateTime(2021, 1, 1, 9, 0, 0), date_fin = new DateTime(2021, 1, 1, 11, 0, 0) }; DateTime dateToLoad = new DateTime(2021, 1, 1); //Act var testResult2 = ValidatorSeance.IsSeanceConflict(s2, manager.GetAllSeanceFromSalle(s2.salle_id, dateToLoad)).Count != 0; //Assert Assert.IsTrue(testResult2, "a seance endind after an other started was accepted"); }
public void ConflictingSeance_seanceStartToEarly() { //Arrange ManagerSeance manager = new ManagerSeance(_context); seance s1 = new seance() { id = 999, salle_id = 1, titre_seance = "conflicting seance", date_debut = new DateTime(2021, 1, 1, 11, 0, 0), date_fin = new DateTime(2021, 1, 1, 12, 0, 0) }; DateTime dateToLoad = new DateTime(2021, 1, 1); //Act var testResult1 = ValidatorSeance.IsSeanceConflict(s1, manager.GetAllSeanceFromSalle(s1.salle_id, dateToLoad)).Count != 0; //Assert Assert.IsTrue(testResult1, "a seance starting before an other ended was accepted"); }
public ActionResult DeleteConfirmed(int id) { try { ManagerSeance manager = new ManagerSeance(); seance seance = manager.GetSeance(id); if (manager.DeleteSeance(id)) { return(RedirectToAction("Index", new { id = seance.salle.cinema_id })); } } catch (Exception e) { //MessageBox.Show(e.Message); } return(RedirectToAction("Index", "Home")); }
public ActionResult Edit([Bind(Include = "id,date_debut,date_fin,titre_seance,salle_id,film_id")] seance seance, string command, string titre, int?yearMin, int?yearMax, int?id_type, string datePickerStart, string timePickerStart, string datePickerFin, string timePickerfin) { string startString = datePickerStart + " " + timePickerStart, endString = datePickerFin + " " + timePickerfin; if (command == "Filtre") { return(RedirectToAction("Edit", new { titre = titre, yearMin = yearMin, yearMax = yearMax, id_type = id_type })); } else if (command == "addFilm") { return(RedirectToAction("Edit", new { titre = titre, yearMin = yearMin, yearMax = yearMax, id_type = id_type })); } seance.date_debut = DateTime.Parse(startString); seance.date_fin = DateTime.Parse(endString); try { ManagerSeance managerSeance = new ManagerSeance(); if (ModelState.IsValid) { if (managerSeance.PutSeance(seance)) { return(RedirectToAction("Edit", new { titre = titre, yearMin = yearMin, yearMax = yearMax, id_type = id_type })); } } ViewBag.salle_id = new SelectList(new ManagerSalle().GetAllSalle().Where(s => s.cinema_id == int.Parse(Session[SessionKeys.cinemaId].ToString())), "id", "numero_salle", seance.salle_id); return(RedirectToAction("Edit", new { titre = titre, yearMin = yearMin, yearMax = yearMax, id_type = id_type })); } catch (Exception e) { TempData.Add("Alert", e.Message); return(RedirectToAction("Edit", seance)); } }
// GET: seances/Edit/5 public ActionResult Edit(int?id, string titre, int?yearMin, int?yearMax, int?id_type) { Session["isOnRoom"] = 0; Session[SessionKeys.seanceId] = id; try { ManagerSeance manager = new ManagerSeance(); seance seance = manager.GetSeance(id); ViewBag.id_type = new SelectList(new ManagerTypeFilm().GetAllType_film(), "id", "typage"); ViewBag.films_id = new SelectList(new ManagerFilm().GetFilmFiltre(titre, yearMin, yearMax, id_type), "id", "titre"); ViewBag.filmsFiltred = new List <film>(new ManagerFilm().GetFilmFiltre(titre, yearMin, yearMax, id_type).OrderBy(x => x.titre)); ViewBag.salle_id = new SelectList(new ManagerSalle().GetAllSalle().Where(s => s.cinema_id == int.Parse(Session[SessionKeys.cinemaId].ToString())), "id", "numero_salle", seance.salle_id); return(View(seance)); } catch (Exception e) { TempData.Add("Alert", e.Message); return(RedirectToAction("Index", "Home")); } }
public ActionResult Create([Bind(Include = "id,date_debut,date_fin,titre_seance,salle_id,film_id")] seance seance) { try { ManagerSeance manager = new ManagerSeance(); if (ModelState.IsValid) { if (manager.PostSeance(seance)) { return(RedirectToAction("Index", new { id = seance.salle.cinema_id })); } } ViewBag.film_id = new SelectList(new ManagerFilm().GetAllFilms(), "id", "titre"); ViewBag.salle_id = new SelectList(new ManagerSalle().GetAllSalle(), "id", "commentaire"); return(View(seance)); } catch (Exception e) { //MessageBox.Show(e.Message); return(RedirectToAction("Index", "seance", new { id = seance.salle.cinema_id })); } }
// GET: seances public ActionResult Index(int id, DateTime?start, DateTime?end) { try { ManagerSeance managerSeance = new ManagerSeance(); if (Session[SessionKeys.startDate] != null) { start = Session[SessionKeys.startDate] as DateTime?; } ViewBag.start = start; if (Session[SessionKeys.endDate] != null) { end = Session[SessionKeys.endDate] as DateTime?; } ViewBag.end = end; if (start != null || end != null) { var orders = managerSeance.GetAllSeanceFromCinema(id) .Where(x => x.date_debut > start && x.date_fin < end) .ToList(); return(View(orders)); } else { var orders = managerSeance.GetAllSeanceFromCinema(id); return(View(orders)); } } catch (Exception e) { TempData.Add("Alert", e.Message); return(RedirectToAction("Index", "Home")); } }
public ActionResult DeleteConfirmed(int id) { try { ManagerSeance manager = new ManagerSeance(); seance seance = manager.GetSeance(id); if (manager.DeleteSeance(id)) { return(RedirectToAction("DetailsSalle", "cinemas", new { id = int.Parse(Session[SessionKeys.salleId].ToString()), start = DateTime.Now })); } else { throw new Exception(); } } catch (Exception e) { TempData.Add("Alert", e.Message); Session[SessionKeys.seanceId] = id; Session[SessionKeys.seanceTab] = "Delete"; return(RedirectToAction("DetailsSalle", "cinemas", new { id = int.Parse(Session[SessionKeys.salleId].ToString()), start = DateTime.Now })); } }