public IActionResult Index() { List <string> RestaurantList = new List <string>(); foreach (FavoriteRestaurants r in FavoriteRestaurants.GetFavRestaurants()) { string favdish = r.FavDish ?? "It's all tasty"; RestaurantList.Add(string.Format("#{0}: {1} -- Favorite Dish: {2} -- Address: {3} -- Phone: {4} -- Website: {5}", r.Rank, r.Name, favdish, r.Address, r.Phone, r.Website)); } return(View(RestaurantList)); }
public IActionResult Index() { List <string> restaurantList = new List <string>(); foreach (FavoriteRestaurants f in FavoriteRestaurants.GetFavoriteRestaurants()) { //If favDish is passed in as a null value, set favDish to "it's all tasty!" string?favDish = f.FavDish ?? "It's all tasty!"; //This is a check to make sure that a correct link is passed in for the website. If the website is "coming soon", don't create a link if (f.Website != "Coming Soon") { restaurantList.Add(string.Format($"<b>#{f.Rank}: {f.Name}</b> <br /><b>Favorite Dish:</b> {favDish} <br /><b>Address:</b> {f.Address}" + $" <br /><b>Phone #:</b> {f.Phone} <br /><b>Website:</b> <a href=\"https://{f.Website}\" target=\"_blank\">{f.Website}</a>")); } else { restaurantList.Add(string.Format($"<b>#{f.Rank}: {f.Name}</b> <br /><b>Favorite Dish:</b> {favDish} <br /><b>Address:</b> {f.Address}" + $" <br /><b>Phone #:</b> {f.Phone} <br /><b>Website:</b> <a href=\"#\">{f.Website}</a>")); } } return(View(restaurantList)); }