Exemplo n.º 1
0
 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;
     }
 }
Exemplo n.º 2
0
        private Dictionary <seance, List <seance> > PostManySeance(List <seance> seances, List <programmation> progs, ref List <int> ids)
        {
            //cinema_dbEntities localdb = new cinema_dbEntities();
            Dictionary <seance, List <seance> > conflict = new Dictionary <seance, List <seance> >();

            using (cinema_dbEntities localdb = new cinema_dbEntities())
            {
                foreach (var item in seances)
                {
                    try
                    {
                        List <seance> ConflictingSeances = ValidatorSeance.IsSeanceConflict(item, this.GetAllSeanceFromSalle(item.salle_id, null));
                        if (ValidatorSeance.IsValide(item) && ConflictingSeances.Count == 0 && !ValidatorSeance.IsSeanceExiste(item, this.GetAllSeanceFromSalle(item.salle_id, null)))
                        {
                            localdb.seances.Add(item);
                        }
                        else if (ConflictingSeances.Count != 0)
                        {
                            throw new ConflictiongSeanceException(ConflictingSeances);
                        }
                        else if (ValidatorSeance.IsSeanceExiste(item, this.GetAllSeanceFromSalle(item.salle_id, null)))
                        {
                            throw new ExistingItemException("seance");
                        }
                        else
                        {
                            throw new InvalidItemException("seance");
                        }
                    }
                    catch (ConflictiongSeanceException e)
                    {
                        conflict[item] = (List <seance>)e.Data[0];
                    }
                }
                localdb.SaveChanges();
            }

            foreach (var item in seances)
            {
                ids.Add(db.seances.Where(s => s.date_debut == item.date_debut && s.date_fin == item.date_fin && s.salle_id == item.salle_id).ToList()[0].id);
            }
            return(conflict);
        }
Exemplo n.º 3
0
 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;
     }
 }