Exemplo n.º 1
0
        public ActionResult Purchased(BuyPageModel model1)
        {
            var filmlol = _db.FilmSet.Where(f => f.FilmID ==
                                            model1.Film.FilmID).FirstOrDefault();

            var fslol = _db.FilmSessionSet.Where(f => f.FilmSessionID ==
                                                 model1.FilmSession.FilmSessionID).FirstOrDefault();

            string[] selectedSeatsIDS = model1.SelectedSeats.Split(' ');
            selectedSeatsIDS = selectedSeatsIDS.Where(s => s != "").ToArray();

            List <Seat> seatslol = new List <Seat>();

            foreach (var item in selectedSeatsIDS)
            {
                int number = int.Parse(item);
                seatslol.Add(_db.SeatSet.Where(s => s.CinemaHall.CinemaHallID == fslol.CinemaHall.CinemaHallID).
                             Where(s => s.SeatNumber == number).FirstOrDefault());
                number = 3;
            }

            foreach (var item in seatslol)
            {
                var ticket = item.SeatTicket.Where(t => t.FilmSession.FilmSessionID ==
                                                   model1.FilmSession.FilmSessionID).FirstOrDefault();
                ticket.Bought = true;
                _db.SaveChanges();
            }



            var model2 = new PurchaseViewModel()
            {
                Film          = filmlol,
                FilmSession   = fslol,
                SelectedSeats = seatslol
            };

            return(View(model2));
        }
Exemplo n.º 2
0
        public ActionResult Buy(int filmID, int sessionID)
        {
            var filmlol = _db.FilmSet.Where(f => f.FilmID == filmID).FirstOrDefault();
            var fslol   = _db.FilmSessionSet.Where(f => f.FilmSessionID == sessionID).FirstOrDefault();


            List <SeatTicket> seatslol = new List <SeatTicket>();


            seatslol.AddRange(_db.SeatTicketSet.Where(t => t.FilmSession.FilmSessionID == fslol.FilmSessionID).AsEnumerable().ToList());


            var model = new BuyPageModel()
            {
                Film          = filmlol,
                FilmSession   = fslol,
                Tickets       = seatslol,
                SelectedSeats = ""
            };

            return(View(model));
        }