public bool PostSalle(salle salle) { try { if (salle.commentaire == null) { salle.commentaire = ""; } if (ValidatorSalle.IsValide(salle) && !ValidatorSalle.IsSalleExist(salle, GetAllSalleFromCinema(salle.cinema_id)) && !ValidatorSalle.IsSalleConflict(salle, GetAllSalleFromCinema(salle.cinema_id))) { db.salles.Add(salle); db.SaveChanges(); return(true); } else if (ValidatorSalle.IsSalleExist(salle, GetAllSalleFromCinema(salle.cinema_id))) { throw new ExistingItemException("salle"); } else { throw new InvalidItemException("salle"); } } 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; } }