예제 #1
0
        public ActionResult Book(int id)
        {
            // Giving the information about the restaurant
            Restaurant restaurant = _restaurantRepo.GetRestaurant(id);

            if (restaurant == null)
            {
                return(RedirectToAction("PageNotFound", "Home"));
            }

            // Creating two dropdowns to pick from
            List <DateTime> day         = _restaurantRepo.GetAllDay(id);
            var             dayListItem = day.Select(x => new SelectListItem()
            {
                Value = x.ToLongDateString(), Text = x.ToLongDateString()
            });

            // Second one is Time
            List <DateTime> time         = _restaurantRepo.GetAllTime(id);
            var             timeListItem = time.Select(x => new SelectListItem()
            {
                Value = x.ToString(), Text = x.ToShortTimeString()
            });

            //Create new Record to use in the View
            OrderItem order = new OrderItem();

            //Passing viewmodel to the View
            ReservationViewModel viewModel = new ReservationViewModel(restaurant, dayListItem, timeListItem, order);

            return(View(viewModel));
        }