예제 #1
0
 public DataManager()
 {
     cont = new Model1Container();
     BR   = new BookingRepository(cont);
     CShR = new CashierRepository(cont);
     CR   = new CinemaRepository(cont);
     FR   = new FilmRepository(cont);
     HR   = new HallRepository(cont);
     SR   = new SeatRepository(cont);
     SsR  = new SessionRepository(cont);
     TR   = new TicketRepository(cont);
 }
        /// <summary>
        /// Проверка совместимости с БД
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="DB"></param>
        public void Delete(int ID)
        {
            List <Seat> se = db.SessionSet.Find(ID).Seat.ToList();

            foreach (Seat z in se)
            {
                SeatRepository c = new SeatRepository(db);
                c.Delete(z.ID);
            }
            db.SessionSet.Remove(db.SessionSet.Find(ID));
            db.SaveChanges();
        }
        /// <summary>
        /// Добавление сеанса
        /// </summary>
        /// <param name="hall"></param>
        /// <param name="date"></param>
        /// <param name="film"></param>
        /// <param name="price"></param>
        public void Add(int hall, DateTime date, int film, short price)
        {
            Session c = new Session();

            c.Film  = db.FilmSet.Find(film);
            c.Hall  = db.HallSet.Find(hall);
            c.Price = price;
            c.Time  = date;
            db.SessionSet.Add(c);
            db.SaveChanges();
            for (int i = 1; i <= c.Hall.AmountOfRow; i++)
            {
                for (int j = 1; j <= c.Hall.AmountOfSeats; j++)
                {
                    SeatRepository l = new SeatRepository(db);
                    l.Add(c.ID, (byte)i, (byte)j);
                }
            }
            db.SaveChanges();
        }