//displayed on welcome (index) page, is the list of 5 provo restaurants public IActionResult Index() { List <string> TopRestaurants = new List <string>(); foreach (Restaurants r in Restaurants.GetRestaurants()) { //allows for some variables to be left blank #nullable enable string?RestaurantsFavDish = r.RestaurantsFavDish ?? "It's all tasty!"; string?RestaurantsPhone = r.RestaurantsPhone; string?RestaurantsWebsite = r.RestaurantsWebsite; #nullable disable
public IActionResult Index() { List <string> restaurantList = new List <string>(); foreach (Restaurants r in Restaurants.GetRestaurants()) { string FavoriteDish = r.FavoriteDish ?? "It's all tasty"; restaurantList.Add($"#{r.Rank}: {r.RestaurantName} - {FavoriteDish} - {r.Address} - {r.Phone} - {r.Link} "); } return(View(restaurantList)); }
//output the prepopulated array to the index view public IActionResult Index() { List <string> restaurantList; restaurantList = new List <string>(); foreach (Restaurants r in Restaurants.GetRestaurants()) { restaurantList.Add($"Rank:{r.RestaurantRanking} || stars {r.RestaurantName} || {r.FavoriteDish} || {r.Address} || {r.RestaurantPhone} || {r.WebsiteLink}"); } return(View(restaurantList)); }
public IActionResult Index() { List <string> RestaurantsList = new List <string>(); foreach (Restaurants r in Restaurants.GetRestaurants()) { int?RestaurantRanking = r.RestaurantsRanking; RestaurantsList.Add(string.Format("#{0}: {1} {2} {3} {4} {5}", r.RestaurantsRanking, r.RestaurantName, r.FavoriteDish, r.Address, r.Phone, r.Website)); } return(View(RestaurantsList)); }
public IActionResult Index() { List <string> restaurantList = new List <string>(); //angle brackets indicate type, followed by name. first part is declaration of variable, right side is instantiation foreach (Restaurants r in Restaurants.GetRestaurants()) { if (r.WebLink == "Coming soon") //remove hyperlink if it says coming soon { restaurantList.Add(string.Format("Rank: #{0} <br/> Restaurant: {1} <br/> Favorite Dish: {2} <br/> Address: {3} <br/> Phone: {4} <br/> Website: {5}", r.RestaurantRanking, r.RestaurantName, r.FavDish, r.Address, r.Phone, r.WebLink)); } else { restaurantList.Add(string.Format("Rank: #{0} <br/> Restaurant: {1} <br/> Favorite Dish: {2} <br/> Address: {3} <br/> Phone: {4} <br/> Website: <a target=\"_blank\" href=\"{5}\">{5}</a>", r.RestaurantRanking, r.RestaurantName, r.FavDish, r.Address, r.Phone, r.WebLink)); //acts based off of positions } } return(View(restaurantList)); //taking bandlist and passing it to view }
public IActionResult Index() { List <string> restaurantList = new List <string>(); // For loop to grab each hardcoded item with in the list. Sets formatting and order for html display foreach (Restaurants r in Restaurants.GetRestaurants()) { // If statement to check if the dish has been left empty or null. Assigns the value of "It's tasty" if true if (r.Dish == null) { r.Dish = "It's all tasty!"; } else { } // Format the output string restaurantList.Add(string.Format("#{0}: {1} - Best Dish: {2} - Address: {3} - Phone: {4} - Website: {5}", r.Rank, r.Name, r.Dish, r.Address, r.Phone, r.Website)); } return(View(restaurantList)); }