Ejemplo n.º 1
0
        // GET: Summary
        public ActionResult SummaryView()
        {
            CinemaViewModel model = (CinemaViewModel)TempData["model"];

            if (model.GetAllTicketsQuantity() <= 0)
            {
                TempData["model"] = model;
                return(RedirectToAction("RateOverview", "Rate"));
            }
            if (model.TotalFreeSeats() < model.GetAllTicketsQuantity())
            {
                ViewBag.seatError = "U heeft meer tickets besteld dan dat er stoelen zijn.";
                TempData["model"] = model;
                return(RedirectToAction("RateOverview", "Rate"));
            }
            ViewBag.Base64 = @"data:image/gif;base64," + Convert.ToBase64String(model.SelectedFilm.Image);

            var context = new EFDbContext();
            var ass     = new AutomaticSeatSelection();

            var occupiedSeats = new List <Seat>();

            foreach (Seat s in context.Seats.ToList())
            {
                Ticket t = context.Tickets.ToList().Find(ti => ti.SeatID == s.SeatID && ti.ShowingID == model.SelectedShowing.ShowingID);

                if (t == null)
                {
                    continue;
                }

                if (s.SeatID != t.SeatID)
                {
                    continue;
                }
                occupiedSeats.Add(s);
            }

            if (model.SeatCoordList.Count == 0)
            {
                model.SeatCoordList = ass.CalculateSeats(model.SelectedShowing.Room, model.GetAllTicketsQuantity(), occupiedSeats);
            }

            model.SeatSelectionGUI = ass.VisualizeSeats(model.SelectedShowing.Room, occupiedSeats, model.SeatCoordList);

            TempData["model"] = model;
            return(View("SummaryView", model));
        }
Ejemplo n.º 2
0
        public void GetAllTickektsQuantityTest()
        {
            //arrange
            var        model    = new CinemaViewModel();
            int        quantity = 2;
            TicketType tt       = model.StudentTicketOrder.GetTicketType();
            TicketType ttSenior = model.SeniorTicketOrder.GetTicketType();

            //act
            model.SetTicketQuantity(quantity, tt);
            model.SetTicketQuantity(quantity, ttSenior);

            int allTickets = model.GetAllTicketsQuantity();

            //assert
            Assert.AreEqual(4, allTickets);
        }