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 bool PutContact(contact_info contact_info) { try { if (ValidatorContact.IsContactExist(contact_info, GetAllContact()) && ValidatorContact.IsValide(contact_info)) { db.Entry(contact_info).State = EntityState.Modified; db.Set <contact_info>().AddOrUpdate(contact_info); db.SaveChanges(); return(true); } else if (!ValidatorContact.IsContactExist(contact_info, GetAllContact())) { throw new ItemNotExistException("contact"); } else { throw new InvalidItemException("contact"); } } catch (Exception e) { throw e; } }
public bool PutCinema(cinema cinema) { try { if (ValidatorCinema.IsCinemaExist(cinema, GetAllCinema())) { //db.Entry(cinema).State = EntityState.Modified; db.Set <cinema>().AddOrUpdate(cinema); db.SaveChanges(); return(true); } else { throw new ItemNotExistException("cinema"); } } catch (Exception e) { throw e; } }
public bool PutSalle(salle salle) { try { var salles = GetAllSalleFromCinema(salle.cinema_id); var state = db.Entry(salle).State; if (salle.commentaire == null) { salle.commentaire = ""; } if (ValidatorSalle.IsSalleExist(salle, salles) && ValidatorSalle.IsValide(salle) && !ValidatorSalle.IsSalleContainSeance(salle) && !ValidatorSalle.IsSalleConflict(salle, GetAllSalleFromCinema(salle.cinema_id))) { db.Set <salle>().AddOrUpdate(salle); //db.Entry(salle).State = EntityState.Modified; db.SaveChanges(); return(true); } else if (ValidatorSalle.IsSalleContainSeance(salle)) { throw new SalleHaveSeanceException(); } else if (!ValidatorSalle.IsSalleExist(salle, GetAllSalleFromCinema(salle.cinema_id))) { throw new ItemNotExistException("salle"); } else { throw new InvalidItemException("salle"); } } catch (Exception e) { throw e; } }
public bool PutFilm(film film) { try { if (!(ValidatorFilm.IsFilmExist(film, GetAllFilmsFrom(film.annee_parution))) && ValidatorFilm.IsValide(film)) { db.Set <film>().AddOrUpdate(film); db.SaveChanges(); return(true); } else if (!ValidatorFilm.IsFilmExist(film, GetAllFilmsFrom(film.annee_parution))) { throw new ItemNotExistException("film"); } else { throw new InvalidItemException("film"); } } catch (Exception e) { throw e; } }