Exemplo n.º 1
0
        // Home Page will get the array of resturants check if fav dish is null and change it if it is then pass a list of strings to the cshtml page
        public IActionResult Index()
        {
            List <string> resturantList = new List <string>();

            foreach (Resturant r in Resturant.GetResturants())
            {
                string?favoriteDish = r.FavDish ?? "It's all tasty!";

                resturantList.Add($"#{r.Rank}: {r.RestName},    Favorite Dish: {favoriteDish},  Address: {r.Address},   Phone: {r.Phone},   Website: {r.Website}");
            }
            return(View(resturantList));
        }
Exemplo n.º 2
0
        public IActionResult Index()
        {
            if (ModelState.IsValid)
            {
                List <string> resturantList = new List <string>();

                foreach (Resturant r in Resturant.GetResturants())
                {
                    //Formating the string to be dispalyed inside of the webpage.
                    resturantList.Add(string.Format("#{0}: {1} <br/> {2} <br/> {3} <br/> {4} <br/> <a href=\"{5}\" target=\"_blank\">Website</a>", r.ResturantRank, r.ResturantName, r.FavroiteDish, r.ResturantAddress, r.ResturantPhone, r.ResturantWebLink));
                }
                ;
                return(View(resturantList));
            }
            else
            {
                return(View());
            }
        }