Exemplo n.º 1
0
        public IActionResult Index(Booking b)
        {
            if (ModelState.IsValid)
            {
                if (b.BookingDate < DateTime.Now)
                {
                    //make sure the users previously selected time and service are selected
                    ViewBag.Service     = b.Service;
                    ViewBag.ServiceTime = b.Time;


                    ViewBag.ErrorMessage = "Booking date must be in the future";
                    ViewBag.Title        = "Book a Table";

                    return(View());
                }

                Booking newBooking = DB.AddBooking(b);
                ViewBag.Title = "Booking Confirmation";
                return(View(newBooking));
            }
            else
            {
                ViewBag.Service = b.Service;
            }
            ViewBag.ServiceTime = b.Time;
            ViewBag.Title       = "Book a Table";
            return(View());
        }
Exemplo n.º 2
0
        public IActionResult NewBooking([FromBody] Booking b)
        {
            Booking newBooking = new Booking();

            newBooking = DB.AddBooking(b);
            if (newBooking == null)
            {
                return(NotFound());
            }
            //add Booking returns booking object with auto Increment
            return(new ObjectResult(newBooking));
        }