Esempio n. 1
0
        public ActionResult Book(BookingForm b)
        {
            Event e             = _eventRequester.Get(b.EventId);
            bool  enoughTickets = e.Tickets >= b.TicketsPurchased;

            try
            {
                if (ModelState.IsValid && enoughTickets)
                {
                    G.Booking booking = new G.Booking()
                    {
                        UserId           = b.UserId,
                        EventId          = b.EventId,
                        PurchaseDate     = DateTime.Now,
                        TicketsPurchased = b.TicketsPurchased,
                        TicketsPrice     = b.TicketsPrice,
                        Amount           = b.TicketsPurchased * b.TicketsPrice
                    };
                    return(RedirectToAction(nameof(Payment), new RouteValueDictionary(booking)));
                }

                ViewBag.Message = $"Only {e.Tickets} ticket(s) remaining";
                return(View(b));
            }
            catch
            {
                return(View("Error"));
            }
        }
Esempio n. 2
0
        public ActionResult Payment(G.Booking booking)
        {
            if (!(SessionManager.User is null))
            {
                return(View(new BookingPayment()
                {
                    UserId = booking.UserId,
                    EventId = booking.EventId,
                    PurchaseDate = DateTime.Now,
                    TicketsPurchased = booking.TicketsPurchased,
                    TicketsPrice = booking.TicketsPrice,
                    Amount = booking.Amount
                }));
            }

            ViewBag.Message = "You must be logged in to book";
            return(RedirectToAction("Index", "Auth"));
        }