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;
     }
 }
Esempio n. 2
0
        public bool PostProgrammation(programmation programmation)
        {
            try
            {
                var seance = new ManagerSeance().GetSeance(programmation.id_seance);
                if (ValidatorSeance.IsSeanceLongEnought(seance, new ManagerProgrammation().GetAllprogramtionFromSeance(programmation.id_seance), new ManagerFilm().GetFilm(programmation.id_film).duree))
                {
                    ManagerSeance        manager        = new ManagerSeance();
                    List <programmation> programmations = manager.GetSeance(programmation.id_seance).programmations.ToList();
                    film f = new ManagerFilm().GetFilm(programmation.id_film);

                    if (programmations.Count() == 0 && (f.type_film.typage.ToUpper() == "STANDART" || f.type_film.typage.ToUpper() == "COURT METRAGE"))
                    {
                        programmation.is_primary = true;
                    }

                    else if (programmations.Where(p => p.is_primary).ToList().Count() != 1 &&
                             (f.type_film.typage.ToUpper() == "STANDART" || f.type_film.typage.ToUpper() == "COURT METRAGE"))
                    {
                        programmation.is_primary = true;
                    }
                    db.programmations.Add(programmation);
                    db.SaveChanges();
                    return(true);
                }
                else
                {
                    throw new SeanceToShortException();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
 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 PostContact(contact_info contact_info)
 {
     try
     {
         if (ValidatorContact.IsValide(contact_info))
         {
             db.contact_info.Add(contact_info);
             db.SaveChanges();
             return(true);
         }
         else
         {
             throw new InvalidItemException("contact");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public bool PostCinema(cinema cinema)
 {
     try
     {
         if (!ValidatorCinema.IsCinemaExist(cinema, GetAllCinema()))
         {
             db.cinemas.Add(cinema);
             db.SaveChanges();
             return(true);
         }
         else
         {
             throw new ExistingItemException("cinema");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 6
0
 public bool PostParticipant(participant participant)
 {
     try
     {
         if (ValidatorParticipant.IsValide(participant) && !ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant()))
         {
             db.participants.Add(participant);
             db.SaveChanges();
             return(true);
         }
         else if (ValidatorParticipant.IsParticipantExist(participant, GetAllParticipant()))
         {
             throw new ExistingItemException("participant");
         }
         else
         {
             throw new InvalidItemException("participant");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public bool PostUserType(user_type type)
 {
     try
     {
         if (type.type.Length > 0 && type.type.Length < 11)
         {
             db.user_type.Add(type);
             db.SaveChanges();
             return(true);
         }
         else if (ValidatorUserType.IsUSerTypeExist(type, GetAllUserType()))
         {
             throw new ExistingItemException("user_type");
         }
         else
         {
             throw new InvalidItemException("user_type");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 8
0
 public bool PostFilm(film film)
 {
     try
     {
         if (ValidatorFilm.IsValide(film) && !ValidatorFilm.IsTitleExist(film, GetAllFilmsFrom(film.annee_parution)))
         {
             db.films.Add(film);
             db.SaveChanges();
             return(true);
         }
         else if (ValidatorFilm.IsTitleExist(film, GetAllFilmsFrom(film.annee_parution)))
         {
             throw new ExistingItemException("film");
         }
         else
         {
             throw new InvalidItemException("film");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 9
0
 public bool PostGenre(genre genre)
 {
     try
     {
         if (ValidatorGenre.IsValide(genre) && !ValidatorGenre.IsGenreExist(genre, GetAllGenre()))
         {
             db.genres.Add(genre);
             db.SaveChanges();
             return(true);
         }
         else if (ValidatorGenre.IsGenreExist(genre, GetAllGenre()))
         {
             throw new ExistingItemException("genre");
         }
         else
         {
             throw new InvalidItemException("genre");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 10
0
 public bool PostUser(user user)
 {
     try
     {
         if (ValidatorUser.IsValide(user) && !ValidatorUser.IsUserExist(user, GetAllUser()))
         {
             db.users.Add(user);
             db.SaveChanges();
             return(true);
         }
         else if (ValidatorUser.IsUserExist(user, GetAllUser()))
         {
             throw new ExistingItemException("user");
         }
         else
         {
             throw new InvalidItemException("user");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        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);
        }