Exemplo n.º 1
0
 public ActionResult Index(DateCheckViewModel model)
 {
     using (var repo = new BookingRepository())
     {
         var available = new BookingChecker().CheckBookingAvailable(model.Date, repo);
         if (!available)
         {
             string message = $"There are no more bookings available for the selected date {model.Date.ToShortDateString()}";
             ModelState.AddModelError("Date", message);
             return(RedirectToAction(nameof(MessageBooking), new { Message = message }));
         }
         if (ModelState.IsValid)
         {
             return(RedirectToAction(nameof(CreateBooking), new { Date = model.Date }));
         }
         return(View(model));
     }
 }
Exemplo n.º 2
0
        public IActionResult DateCheck()
        {
            DateTime today = DateTime.UtcNow;

            var vm = new DateCheckViewModel
            {
                Halls = this.hallsServices.AllHalls()
                        .Select(h => new SelectListItem
                {
                    Text     = h.Name,
                    Value    = h.Id.ToString(),
                    Selected = false
                }).ToList(),
                Date            = null,
                CurrentDateTime = today,
                HallsPriceList  = this.hallsServices.AllHallsPriceList()
            };


            return(View(vm));
        }