public IActionResult Details(int id) { var model = restaurantData.Get(id); if (model == null) { return(NotFound()); } return(View(model)); }
public ActionResult Details(int id) { var model = db.Get(id); if (model == null) { return(View("Notfound")); } return(View(model)); }
public IActionResult Detail(int id) { var model = _restaurantData.Get(id); if (model == null) { return(RedirectToAction(nameof(Index))); } return(View(model)); }
public ActionResult Details(int id) { var model = Db.Get(id); if (model == null) { return(View("NotFound")); //Add a view called NotFound and create one } return(View(model)); //Create a scaffolding detail tempalte view and edit }
public ActionResult Details(int id) { Restaurant model = _db.Get(id); if (model == null) { return(View("NotFound")); } return(View(model)); }
public ActionResult Details(int id) // Will associate integer specified in route as id parameter { // We will want to add some logic to check for the existence of a restaurant Id in database so that if it doesn't var model = db.Get(id); // exist, we will fail-soft in some way instead of throwing an exception or crashing if (model == null) { return(View("NotFound")); } return(View(model)); }
public IActionResult Details(int id) { var model = _restaurantdata.Get(id); if (model == null) { return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult Edit(int id) { var model = _restaurantData.Get(id); if (model == null) { return(RedirectToAction("Index")); //redirect to index, select another item } return(View(model)); }
public ActionResult Details(int id) { var model = db.Get(id); if (model == null) { return(View("NotFound"));//RedirectToAction("Index"); } return(View(model)); }
public IActionResult Index() { var model = new HomeIndexViewModel() { Restaurants = _restoData.Get(), CurrentMessage = _greeter.GetMessage() }; return(View(model)); }
public ActionResult Details(int id) { //check IRestaurantData in OdeToFood.Data var model = db.Get(id); if (model == null) { return(View("NotFound")); } return(View(model)); }
public ActionResult Details(int id) // MVC will look for any data that == id { var model = db.Get(id); if (model == null) { // return RedirectToAction("Index"); return(View("NotFound")); } return(View(model)); }
public ActionResult Details(int id) { var model = db.Get(id); if (model == null) { // return RedirectToAction("Index"); return(View("NotFound"));//If you pass the view name it renders that instead of the method view } return(View(model)); }
public ActionResult Details(int id) { var restaurant = _restaurantData.Get(id); if (restaurant == null) { return(View("NotFound")); } return(View(restaurant)); }
public IActionResult Details(int id) { var resto = _restaurantData.Get(id); if (resto == null) { return(RedirectToAction("Index")); } return(View(resto)); }
public IActionResult Edit(int id) { var model = _restaurantData.Get(id); if (model == null) { //return NotFound(); return(RedirectToAction("Index")); } return(View(model)); }
//https://localhost:44397/restaurants/1 public ActionResult Details(int id) { var model = db.Get(id); //??? Handle case where restaurant id is incorrect. Protect it from crashing by redirecting. if (model == null) { //return RedirectToAction("Index"); OR return(View("NotFound")); } return(View(model)); }
// DETAILS of an existing Restaurant public IActionResult Details(int id) { var model = _restaurantData.Get(id); if (model == null) { return(RedirectToAction(nameof(Index))); // Redirect the user to the Index action. Used nameof instead of "" in case we want to refactor Index() //return View("NotFound"); // TODO add a Not Found cshtml VIEW } return(View(model)); }
/// <summary> /// Gives the details of 1 specific resaurant. /// </summary> /// <param name="id"></param> /// <returns></returns> public IActionResult Details(int id) { var model = _restaurantData.Get(id); // Handle null ids. Redirect to our index page if (model == null) { return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Details(int id) { var model = db.Get(id); if (model == null) { return(RedirectToAction("Index")); } else { return(View(model)); } }
public IActionResult Details(int id) { var model = _restaurantData.Get(id); if (model == null) { // return NotFound(); // return RedirectToAction("Index"); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public ActionResult Details(int?id) { if (id == null) { return(RedirectToAction("Index")); } var model = db.Get((int)id); if (model == null) { return(View("NotFound")); } return(View(model)); }
public ActionResult Details(int id) { //id from the URL that is defined int the RouteConfig.cs var model = db.Get(id); if (model == null) { return(View("NotFound")); } else { return(View(model)); } }
// framework will lok for id in the query string and in the data that was extracted from the route (route config parameter) public ActionResult Details(int id) { var model = db.Get(id); // nullchecks if (model == null) { //return RedirectToAction("Index"); // go back to /restaurants return(View("NotFound")); // goes to NotFound.cshtml } return(View(model)); //var model = db.GetAll().Where(x => x.id) }
public Task BindModelAsync(ModelBindingContext bindingContext) { var modelName = bindingContext.BinderModelName ?? "id"; var valueProviderResult = bindingContext.ValueProvider.GetValue(modelName); if (valueProviderResult == ValueProviderResult.None) { return(Task.CompletedTask); } bindingContext.ModelState.SetModelValue(modelName, valueProviderResult); var value = valueProviderResult.FirstValue; int id = 0; if (!int.TryParse(value, out id)) { bindingContext.ModelState .TryAddModelError(modelName, "Restaurant Id must be an integer."); return(Task.CompletedTask); } var result = _restaurantData.Get(id); bindingContext.Result = ModelBindingResult.Success(result); return(Task.CompletedTask); }
//having a parameter here means it will look in the querystring and routing for this id int public ActionResult Details(int id) { var model = db.Get(id); //should check if the model exists rather than inline if's if (model == null) { //go to a different controller //return RedirectToAction("Index"); //return a specific view return(View("NotFound")); } //must have a model return(View(model)); }
public ActionResult Details(int id) { var model = db.Get(id); var viewModel = new ViewModels.RestaurantViewModel(); viewModel.Cuisine = model.Cuisine; viewModel.Name = model.Name; viewModel.Tables = tableController.GetTablesForRestaurant(id); if (model == null) { return(RedirectToAction("Index")); } return(View(viewModel)); }
public IActionResult Edit(int id) { var restaurant = _restaurantData.Get(id); if (restaurant == null) { return(RedirectToAction("Index")); } var model = new RestaurantEditViewModel { Name = restaurant.name, CusineType = restaurant.CusineType, Url = restaurant.Url }; return(View(model)); }
public void OnGet(int restaurantId) { Restaurant = restaurantData.Get(restaurantId); if (Restaurant == null) { NotFound(); } }
public IActionResult OnGet(int id) { Restaurant = _restaurantData.Get(id); if (Restaurant == null) { return(RedirectToAction("Index", "Home")); } return(Page()); }