public IActionResult OnGet(int restaurantId) { Restaurant = restaurantData.GetByID(restaurantId); if (Restaurant == null) { return(RedirectToPage("./NotFound")); } return(Page()); }
// Rename from void to IActionResult public IActionResult OnGet(int restaurantId) { Restaurant = restaurantData.GetByID(restaurantId); if (Restaurant == null) { return(RedirectToPage("./NotFound")); // Redirect if null } return(Page()); // Return the page that is built in the cshtml file }
public ActionResult OnGet(int RestaurantId) // Getting the Restaurant ID from the Route { restaurant = restaurantData.GetByID(RestaurantId); if (restaurant == null) { return(RedirectToAction("./NotFound", RestaurantId)); } return(Page()); }
public IActionResult OnGet(int RestaurantID) { //Restaurant = new Restaurant(); Restaurant = restaurantData.GetByID(RestaurantID); if (Restaurant == null) { return(RedirectToPage("./NotFound")); } return(Page()); }
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()); }
// OnGet is when the page is requested, the id is in the URL, the restaurant id is passed as an argument by the cshtml first line public IActionResult OnGet(int?restaurantId) { Cuisines = htmlHelper.GetEnumSelectList <CuisineType>(); // Data binding for the drop down select, look at the htmlHelper that populates the variable // If null, add new restaurant, otherwise edit existing restaurant if (restaurantId.HasValue) { Restaurant = restaurantData.GetByID(restaurantId.Value); } else { Restaurant = new Restaurant(); } if (Restaurant == null) { return(RedirectToPage("./NotFound")); } return(Page()); }
public void OnGet(int RestaurantId) { restaurant = irestaurantData.GetByID(RestaurantId); // 1-With the ID passed from the route, get the single Restaurant to be deleted. // 2-Show the Single Restaurant }
public IActionResult Details(int id) { var model = _resto.GetByID(id); return(View(model)); }