Esempio n. 1
0
        public IActionResult OnGet(int?restaurantId)  // question mark means that the parameter might be null
        {
            Cuisine = htmlHelper.GetEnumSelectList <CuisineType>();

            if (restaurantId.HasValue)
            {
                Restaurant = restaurantData.GetById(restaurantId.Value);
            }
            else
            {
                Restaurant = new Restaurant();
            }


            if (Restaurant == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            return(Page());
        }
Esempio n. 2
0
        public IActionResult OnGet(int?restaurantId)
        {
            Cuisines = htmlHelper.GetEnumSelectList <CuisineType>();

            if (restaurantId.HasValue)
            {
                Restaurant = restaurantData.GetById(restaurantId.Value);
            }
            else
            {
                Restaurant = new Restaurant();
            }


            if (Restaurant == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            return(Page());
        }
Esempio n. 3
0
        public IActionResult OnGet(int?restaurantId)
        {
            if (restaurantId.HasValue)
            {
                Restaurant = _restaurantData.GetById(restaurantId.Value);
            }
            else
            {
                Restaurant = new Restaurant
                {
                    Cuisine = CuisineType.None
                };
            }

            if (Restaurant == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            return(Page());
        }
Esempio n. 4
0
        public IActionResult OnGet(int?restaurantId)
        {
            Cuisines = htmlHelper.GetEnumSelectList <CuisineType>();

            //First look @ the UID for the restaurant
            if (restaurantId.HasValue)
            {
                Restaurant = restaurantData.GetById(restaurantId.Value);
            }
            else
            {
                Restaurant = new Restaurant();
            }

            //That will return the Restaurnt object (if any)
            if (Restaurant == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            return(Page()); //Object exists
        }
        // The '?' on the type declaration of the parameter means that it can be null

        public IActionResult OnGet(int?restaurantId)
        {
            // Don't forget that these Cuisines need to be populated on every type of HTTP request
            // This is because ASP.NetCore is stateless - you are responsible for setting up your state!
            Cuisines = htmlHelper.GetEnumSelectList <CuisineType>();
            if (restaurantId.HasValue)
            {
                // Since we're using a nullable operator, we have to use .HasValue and if it does, use .Value to get it
                Restaurant = restaurantData.GetById(restaurantId.Value);
            }
            else
            {
                Restaurant = new Restaurant();
            }
            // If restaurant is not found, redirect to the not found page
            if (Restaurant == null)
            {
                return(RedirectToPage("./NotFound"));
            }
            // Otherwise render the related view (Detail.cshtml)
            return(Page());
        }
Esempio n. 6
0
 public IActionResult OnGet(int?restaurantId)
 {
     Cuisines = _htmlHelper.GetEnumSelectList <Restaurant.CuisineType>();
     if (restaurantId.HasValue)
     {
         Restaurant = _restaurantData.GetById(restaurantId.Value);
     }
     else
     {
         Restaurant = new Restaurant()
         {
             //Cuisine = Restaurant.CuisineType.None,
             //Location = "",
             //Name = "",
             //Id = 4
         };
     }
     if (Restaurant == null)
     {
         return(RedirectToPage("./NotFound"));
     }
     return(Page());
 }
Esempio n. 7
0
        public IActionResult OnGet(int?id)
        {
            if (id != null)
            {
                Restaurant = RestaurantData.GetById(id.Value);

                if (Restaurant == null)
                {
                    return(RedirectToPage("./NotFound"));
                }
            }
            else
            {
                Restaurant = new Restaurant
                {
                    Cuisine = CuisineType.None
                };
            }

            Cuisines = htmlHelper.GetEnumSelectList <CuisineType>();

            return(Page());
        }
Esempio n. 8
0
        //return type is changed from void to IActionResult
        //the ? after int means its ok if it is null. doesnt need a restaurant id
        //this is so we can use this same page to post a new restaurant. instead of only editing
        public IActionResult OnGet(int?restaurantId)
        {
            //we can use Cuisines over on our view to make our select list. using Model.Cuisines
            Cuisines = htmlHelper.GetEnumSelectList <CuisineType>();

            //we will only go get the restaurant if the id is not null.
            if (restaurantId.HasValue)
            {
                //the restaurant is what happens when we go to restaurantData and get the restaurant with the specific id
                Restaurant = restaurantData.GetById(restaurantId.Value);
            }
            else
            {
                //if the id is null, then it means the user is trying to create a new
                //restaurant. so we make a new one for them
                Restaurant = new Restaurant();
            }

            if (Restaurant == null)
            {
                return(RedirectToPage("./NotFound"));
            }
            return(Page());
        }
 public Restaurant Get(int id)
 {
     return(_resto.GetById(id));
 }
Esempio n. 10
0
 public void OnGet(int restaurantId)
 {
     Restaurant = restaurantData.GetById(restaurantId);
 }
Esempio n. 11
0
 public IActionResult OnGet(int restaurantId)
 {
     Restaurant = restaurantData.GetById(restaurantId);
     return(Restaurant is null?RedirectToPage("./NotFound") : Page());
 }
Esempio n. 12
0
        public IActionResult Details(int id)
        {
            var model = _resto.GetById(id);

            return(View(model));
        }
Esempio n. 13
0
 public void OnGet(int RestaurantId)
 {
     Restaurant = _RestaurantData.GetById(RestaurantId);
     //return Restaurant == null ? RedirectToPage("./NotFound") : (IActionResult)Page();
 }
        // GET: Restaurant/Details/5
        public async Task <ActionResult> Details(int id)
        {
            var model = await _resto.GetById(id.ToString());

            return(View(model));
        }
Esempio n. 15
0
 public IActionResult OnGet(int?RestaurantId)
 {
     Restaurant = RestaurantId.HasValue ? _RestaurantData.GetById(RestaurantId.Value) : new Restaurant();
     //return Restaurant == null ? RedirectToPage("./NotFound") : (IActionResult)Page();
     return(Page());
 }
Esempio n. 16
0
 public IActionResult OnGet(int restaurantId)
 {
     Restaurant = _restaurant.GetById(restaurantId);
     return(Restaurant == null ? (ActionResult)RedirectToPage("./NotFound") : Page());
 }