Пример #1
0
        public ActionResult SecondStep(BookingInformationViewModel oudeVM)
        {
            BookingInformationViewModel vm = Session["booking"] as BookingInformationViewModel;
            int counter    = 0;
            int maxPersons = db.Rooms.Find(vm.Performance.CinemaroomId).capacity;

            foreach (Booking b in db.PerformanceList.Find(vm.Performance.PerformanceId).BookingList)
            {
                counter += b.nrOfTickets;
            }
            if (counter + oudeVM.AantalMensen <= maxPersons)
            {
                vm.AantalMensen = oudeVM.AantalMensen;
            }
            else
            {
                return(View("Error"));
            }
            if (oudeVM.Discountcode != null && db.Discounts.Where(d => d.code == oudeVM.Discountcode).First() != null && db.Discounts.Where(d => d.code == oudeVM.Discountcode).First().StartTijd >= DateTime.Now && db.Discounts.Where(d => d.code == oudeVM.Discountcode).First().endDate <= DateTime.Now)
            {
                vm.Discount    = db.Discounts.Where(d => d.code == oudeVM.Discountcode).First();
                vm.TotaalPrijs = ((double)vm.AantalMensen * (double)vm.Movie.price) * ((double)(100 - vm.Discount.percentage) / (double)100);
            }
            else
            {
                vm.TotaalPrijs = (double)vm.AantalMensen * (double)vm.Movie.price;
            }
            Session["booking"] = vm;

            return(View(vm));
        }
Пример #2
0
        public ActionResult ThirdStep(BookingInformationViewModel oudeVM)
        {
            BookingInformationViewModel vm = Session["booking"] as BookingInformationViewModel;

            Session["booking"] = vm;
            Booking booking = new Booking();
            Guest   guest   = new Guest();

            guest.firstName = oudeVM.Guest.firstName;
            guest.suffix    = oudeVM.Guest.suffix;
            guest.lastName  = oudeVM.Guest.lastName;
            guest.adres     = oudeVM.Guest.adres;
            guest.city      = oudeVM.Guest.city;
            guest.postal    = oudeVM.Guest.postal;
            guest           = db.Guests.Add(guest);
            booking.guestId = guest.id;
            vm.Guest        = guest;
            //booking.Guest = db.Guests.Single(p => p.id == (int)1);
            //vm.Guest = booking.Guest;
            booking.nrOfTickets   = vm.AantalMensen;
            booking.totalPrice    = vm.TotaalPrijs;
            booking.PerformanceId = vm.Performance.PerformanceId;
            if (vm.Discount != null)
            {
                booking.DiscountId = vm.Discount.id;
            }
            else
            {
                booking.DiscountId = (int)1;
            }
            vm.Discount = booking.Discount;
            booking     = db.Bookings.Add(booking);
            db.SaveChanges();
            return(View(vm));
        }
Пример #3
0
        public ActionResult FirstStep(int performanceId)
        {
            BookingInformationViewModel vm = new BookingInformationViewModel();

            //vm.Performance = db.PerformanceList.Single(p => p.PerformanceId == performanceId);
            //vm.Movie = db.Movies.Single(p => p.id == vm.Performance.MovieId);
            vm.Performance = db.PerformanceList.Find(performanceId);
            vm.Movie       = vm.Performance.Movie;

            Session["booking"] = vm;


            return(View(vm));
        }