/// <summary> /// Проверка совместимости с БД /// </summary> /// <param name="ID"></param> /// <param name="DB"></param> public static void Delete(int ID, CinemaModelContainer DB) { List <Seat> se = DB.SessionSet.Find(ID).Seat.ToList(); foreach (Seat z in se) { SeatWork.Delete(z.ID, DB); } DB.SessionSet.Remove(DB.SessionSet.Find(ID)); }
/// <summary> /// Добавление сеанса /// </summary> /// <param name="hall"></param> /// <param name="date"></param> /// <param name="film"></param> /// <param name="price"></param> public static void Add(Hall hall, DateTime date, Film film, short price) { if (Check(hall, date, true, 0)) { Session c = new Session(); c.Film = db.FilmSet.Find(film.ID); c.Hall = db.HallSet.Find(hall.ID); c.Price = price; c.Date = date; 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++) { SeatWork.Add(c.ID, (byte)i, (byte)j, db); } } db.SaveChanges(); } }