예제 #1
0
        public CountryDetail GetCountry(string countryCode)
        {
            //owner?
            // https://docs.microsoft.com/en-us/dotnet/api/system.web.httpcontext.user?view=netframework-4.8
            // https://docs.microsoft.com/en-us/dotnet/api/system.security.claims.claim?view=netcore-3.1

            var user = User.Identity.Name;
            int id   = -1;

            foreach (var claim in User.Claims)
            {
                if (claim.Type == "sub")
                {
                    id = int.Parse(claim.Value);
                }
            }

            System.Diagnostics.Debug.WriteLine("".PadRight(20, '-') + " from GetCounty " + "".PadRight(20, '-'));
            System.Diagnostics.Debug.WriteLine("User: "******"User id: " + id);

            Country country = countryDAO.GetCountry(countryCode);

            CountryDetail countryDetail = new CountryDetail(country);

            //get news
            NewsAPIService newsAPIService = new NewsAPIService();

            countryDetail = newsAPIService.GetCountry(countryDetail);

            return(countryDetail);
        }
예제 #2
0
        public CountryDetail GetCountry(string countryCode)
        {
            Country country = countryDao.GetCountry(countryCode);

            CountryDetail countryDetail = new CountryDetail(country);

            //get news
            NewsAPIService newsAPIService = new NewsAPIService();

            countryDetail = newsAPIService.GetCountry(countryDetail);

            return(countryDetail);
        }
예제 #3
0
        private MenuOptionResult SelectACountry()
        {
            string countryCode = GetString("Enter the Country Code: ");

            // TODO 08: Lookup the country (GetCountryByCode) and pass that into the country submenu
            Country country = countryDAO.GetCountry(countryCode);

            if (country == null)
            {
                Console.WriteLine($"Sorry, country '{countryCode}' does not exist.");
                return(MenuOptionResult.WaitAfterMenuSelection);
            }

            // Code was found, invoke the Country menu
            // TODO 09: Pass countryDAO into country menu.  We are going to need a CityDAO also!
            CountryMenu menu = new CountryMenu(country);

            menu.Show();
            return(MenuOptionResult.DoNotWaitAfterMenuSelection);
        }