예제 #1
0
        public ActionResult BookRestaurant(int restaurantId)
        {
            // Create Viewmodel
            RestaurantBooking booking = new RestaurantBooking();

            booking.Events = foodRepository.GetAllFoodEvents(restaurantId);

            Restaurant restaurant = foodRepository.GetRestaurant(restaurantId);

            booking.RestaurantName = restaurant.RestaurantName;
            booking.ChildrenPrice  = restaurant.PriceChildren;
            booking.AdultPrice     = restaurant.PriceAdults;

            // Get the correct timespan:
            TimeSpan timeAtRestaurant = booking.Events.First().EndTime.Subtract(booking.Events.First().StartTime);

            booking.TimeAvailable = String.Format("{0:00}:{1:00}", timeAtRestaurant.Hours, timeAtRestaurant.Minutes);

            // Pass ID value of restaurant:
            booking.RestaurantId = restaurantId;

            return(PartialView("BookEvent", booking));
        }