public bool PostSeance(seance seance) { try { List <seance> ConflictingSeances = ValidatorSeance.IsSeanceConflict(seance, this.GetAllSeanceFromSalle(seance.salle_id, null)); if (ValidatorSeance.IsValide(seance) && ConflictingSeances.Count == 0 && !ValidatorSeance.IsSeanceExiste(seance, this.GetAllSeanceFromSalle(seance.salle_id, null))) { db.seances.Add(seance); db.SaveChanges(); return(true); } else if (ConflictingSeances.Count != 0) { throw new ConflictiongSeanceException(ConflictingSeances); } else if (ValidatorSeance.IsSeanceExiste(seance, this.GetAllSeanceFromSalle(seance.salle_id, null))) { throw new ExistingItemException("seance"); } else { throw new InvalidItemException("seance"); } } catch (Exception e) { throw e; } }
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 })); } }
public seance GetSeance(int?id) { try { if (id != null) { seance seance = db.seances.Find(id); if (seance != null) { return(seance); } else { throw new ItemNotExistException("seance"); } } else { throw new NullIdExecption("seance"); } } catch (Exception e) { throw e; } }
public bool PutSeance(seance seance) { try { int cinemaId = new ManagerSalle().GetSalle(seance.salle_id, null, null).cinema_id; List <seance> ConflictingSeances = ValidatorSeance.IsSeanceConflict(seance, this.GetAllSeanceFromSalle(seance.salle_id, null)); if (ValidatorSeance.IsSeanceExiste(seance, this.GetAllSeanceFromCinema(cinemaId)) && ValidatorSeance.IsValide(seance) && ConflictingSeances.Count == 0) { db.Set <seance>().AddOrUpdate(seance); db.SaveChanges(); return(true); } else if (ConflictingSeances.Count != 0) { throw new ConflictiongSeanceException(ConflictingSeances); } else if (!ValidatorSeance.IsSeanceExiste(seance, this.GetAllSeanceFromCinema(cinemaId))) { throw new ItemNotExistException("seance"); } else { throw new InvalidItemException("seance"); } } catch (Exception e) { throw e; } }
public ActionResult Delete(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //participe participe = db.participe.Find(id); long user_id = GetUserIdByLogin(User.Identity.GetUserName()); var part = from par in db.participe where par.seance_id == id && par.utilisateur_id == user_id select par; participe participe = part.ToList().First(); seance s = db.seance.Find(participe.seance_id); section sec = db.section.Find(s.section_id); discipline d = db.discipline.Find(sec.discipline_id); ViewData["titre"] = "Désinscription à la section " + sec.label + " de la discipline " + d.label; ViewData["texte"] = "Comfirmez votre désinscription à la séance du " + s.jour_de_la_semaine + " de " + HourFormator("" + s.heure_debut) + " à " + HourFormator("" + s.heure_fin); if (participe == null) { return(HttpNotFound()); } return(View(participe)); }
public bool DeleteSeance(int id) { try { if (db.seances.Find(id) != null) { ManagerProgrammation managerProgs = new ManagerProgrammation(); List <programmation> progs = managerProgs.GetAllprogramtionFromSeance(id); for (int i = 0; i < progs.Count; i++) { managerProgs.DeleteProgrammation(progs[i].id); } seance seance = db.seances.Find(id); db.seances.Remove(seance); db.SaveChanges(); return(true); } else { throw new InvalidItemException("seance"); } } catch (Exception e) { throw e; } }
public ActionResult Create([Bind(Include = "seance_id,lieu_id,encadrant_id,jour,heure_debut,heure_fin,section_id")] seance seance) { if (ModelState.IsValid) { db.seance.Add(seance); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.lieu_id = new SelectList(db.lieu, "lieu_id", "lieu_nom", seance.lieu_id); ViewBag.section_id = new SelectList(db.section, "section_id", "description", seance.section_id); var responsables = new List <SelectListItem>(); foreach (utilisateur u in db.utilisateur) { if (u.role_utilisateur == "encadrant") { responsables.Add(new SelectListItem() { Text = u.prenom + " " + u.nom + " " + u.login, Value = "" + u.utilisateur_id }); } } ViewBag.encadrant_id = responsables; var jours = new List <SelectListItem>(); jours.Add(new SelectListItem() { Text = "Lundi", Value = "Lundi" }); jours.Add(new SelectListItem() { Text = "Mardi", Value = "Mardi" }); jours.Add(new SelectListItem() { Text = "Mercredi", Value = "Mercredi" }); jours.Add(new SelectListItem() { Text = "Jeudi", Value = "Jeudi" }); jours.Add(new SelectListItem() { Text = "Vendredi", Value = "Vendredi" }); jours.Add(new SelectListItem() { Text = "Samedi", Value = "Samedi" }); jours.Add(new SelectListItem() { Text = "Dimanche", Value = "Dimanche" }); ViewBag.jour = jours; return(View(seance)); }
public static bool isJourSelected(seance s, string jour) { if (s.jour == jour) { return(true); } return(false); }
public ActionResult Delete(long id) { seance seance = db.seance.Find(id); db.seance.Remove(seance); db.SaveChanges(); return(RedirectToAction("Index")); }
static public List <seance> IsSeanceConflict(seance candidate, List <seance> seances) { List <seance> conflitingOne = seances.Where(seance => !( (candidate.date_debut < seance.date_debut && candidate.date_fin <= seance.date_debut) || (candidate.date_debut >= seance.date_fin && candidate.date_fin > seance.date_fin) ) && candidate.id != seance.id ).ToList(); return(conflitingOne); }
static public bool IsSeanceExiste(seance candidate, List <seance> seances) { List <seance> existingOne = seances.Where(o => o.id == candidate.id).ToList(); if (existingOne.Count != 0) { return(true); } else { return(false); } }
public ActionResult Edit([Bind(Include = "id_film,id_assiciate,seance_id,id_hall,price,movie_format,date,time")] seance seance) { if (ModelState.IsValid) { db.Entry(seance).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_assiciate = new SelectList(db.associate, "associate_id", "age", seance.id_assiciate); ViewBag.id_film = new SelectList(db.film, "film_id", "name_film", seance.id_film); ViewBag.id_hall = new SelectList(db.hall, "holl_id", "name_hall", seance.id_hall); return(View(seance)); }
public static string GetSeancesInfo(long id) { string res = ""; SportAssoEntities db = new SportAssoEntities(); seance s = db.seance.Find(id); section sec = db.section.Find(s.section_id); discipline d = db.discipline.Find(sec.discipline_id); res = d.label + " - " + sec.label + " : " + s.jour_de_la_semaine + " de " + HourFormator("" + s.heure_debut) + " à " + HourFormator("" + s.heure_fin); return(res); }
// 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/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 })); } }
public ActionResult Delete(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } seance seance = db.seance.Find(id); if (seance == null) { return(HttpNotFound()); } return(View(seance)); }
public ActionResult Inscription(long id) { SportAssoEntities db = new SportAssoEntities(); ViewBag.seance_id = id; seance s = db.seance.Find(id); section sec = db.section.Find(s.section_id); discipline d = db.discipline.Find(sec.discipline_id); ViewBag.utilisateur_id = GetUserIdByLogin(User.Identity.GetUserName()); ViewBag.a_payer = false; ViewData["titre"] = "Inscription à la section " + sec.label + " de la discipline " + d.label; ViewData["texte"] = "Comfirmez votre inscription à la séance du " + s.jour_de_la_semaine + " de " + HourFormator("" + s.heure_debut) + " à " + HourFormator("" + s.heure_fin); return(View()); }
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 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 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 "); }
// 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")); } }
// GET: seances/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } seance seance = db.seance.Find(id); if (seance == null) { return(HttpNotFound()); } ViewBag.id_assiciate = new SelectList(db.associate, "associate_id", "age", seance.id_assiciate); ViewBag.id_film = new SelectList(db.film, "film_id", "name_film", seance.id_film); ViewBag.id_hall = new SelectList(db.hall, "holl_id", "name_hall", seance.id_hall); return(View(seance)); }
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")); }
static public bool IsSeanceLongEnought(seance candidate, List <programmation> progs, int timeToAdd) { int time = timeToAdd; foreach (var item in candidate.programmations) { time += item.film.duree; } if (candidate.date_debut.AddMinutes(time) <= candidate.date_fin) { return(true); } else { throw new SeanceToShortException(); } }
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 })); } }
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 })); } }
static public bool IsValide(seance seance) { try { if ( seance.date_debut < seance.date_fin && IsSeanceLongEnought(seance) && PropretyValidation.IsDateValide(seance.date_debut, seance.dateDebutMin, seance.dateDebutMax) && PropretyValidation.IsDateValide(seance.date_debut, seance.dateFinMin, seance.dateFinMax) && PropretyValidation.IsStringValide(seance.titre_seance, seance.titreMin, seance.titreMax) ) { return(true); } else { return(false); } } catch (Exception e) { throw e; } }