//
        // GET: /Events/
        public ActionResult Index()
        {
            var ctx = new TicketMasterEntities();

            var events = ctx.GetEvents();

            return View(events);
        }
        //
        // GET: /Events/

        public ActionResult Index()
        {
            var ctx = new TicketMasterEntities();

            var events = ctx.GetEvents();

            return(View(events));
        }
        public static TicketMasterEntities GetDbContextInstance()
        {
            _dbContext = HttpContext.Current.Application.Get("DBContextObject") != null
                   ? (TicketMasterEntities)HttpContext.Current.Application.Get("DBContextObject")
                   : null;

            if (_dbContext == null)
            {
                _dbContext = new TicketMasterEntities();

                HttpContext.Current.Application.Set("DBContextObject", _dbContext);
            }

            return(_dbContext);
        }
 public ActionResult Booking(Booking booking)
 {
     var ctx = new TicketMasterEntities();
     try
     {
         if (ctx.CreateBooking(booking.EventId, booking.Quantity, booking.CreditCard) < 1)
         {
             ViewBag.Error = "Unable to save booking, no may be no tickets left";
             return View();
         }
         return RedirectToAction("Index");
     }
     catch (Exception ex)
     {
         ViewBag["Error"] = ex.Message;
         return View(booking);
     }
 }
        public ActionResult Booking(Booking booking)
        {
            var ctx = new TicketMasterEntities();

            try
            {
                if (ctx.CreateBooking(booking.EventId, booking.Quantity, booking.CreditCard) < 1)
                {
                    ViewBag.Error = "Unable to save booking, no may be no tickets left";
                    return(View());
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewBag["Error"] = ex.Message;
                return(View(booking));
            }
        }