Exemplo n.º 1
0
        public void UI()
        {
            List <Country> prueba = apiCountries.GetByCurrency("cop");

            Console.WriteLine(prueba[0].ToString());

            while (true)
            {
                DisplayMenu();
                int option = RequestUserInfo.OptionSelectedMenu();
                switch (option)
                {
                case 1:
                    List <Country> totalCountries = apiCountries.GetAll();
                    printCountries.PrintStatisticCountry(null, null, statistics, "average", totalCountries);
                    break;

                case 2:
                    DisplayOptionsListCountries();
                    int            optionListSelected = RequestUserInfo.OptionSelectedListCountries();
                    List <Country> _listCountriesInfo = new List <Country>();
                    if (optionListSelected == 1)
                    {
                        string language = RequestUserInfo.OptionSelectedLanguage();
                        _listCountriesInfo = apiCountries.GetByLanguage(language);
                    }
                    else if (optionListSelected == 2)
                    {
                        string currency = RequestUserInfo.OptionSelectedCurrency();
                        _listCountriesInfo = apiCountries.GetByCurrency(currency);
                    }
                    else if (optionListSelected == 3)
                    {
                        string region = RequestUserInfo.OptionSelectedRegion();
                        _listCountriesInfo = apiCountries.GetByRegion(region);
                    }
                    else if (optionListSelected == 4)
                    {
                        _listCountriesInfo = apiCountries.GetAll();
                    }
                    printCountries.PrintInfoCountries(_listCountriesInfo);
                    printCountries.PrintTotalPopulation(_listCountriesInfo, statistics);
                    break;

                case 3:
                    DisplayOptionsGetStatisticsCountries();
                    string stadistic = Console.ReadLine();
                    DisplaySelectCountry1();
                    string  nameCountry1 = RequestUserInfo.OptionSelectedNameCountry();
                    Country?country1     = apiCountries.GetByName(nameCountry1)[0];

                    if (stadistic == "density")
                    {
                        DisplaySelectCountry2();
                        string  nameCountry2 = RequestUserInfo.OptionSelectedNameCountry();
                        Country?country2     = apiCountries.GetByName(nameCountry2)[0];
                        printCountries.PrintStatisticCountry(country1, country2, statistics, stadistic, null);
                    }
                    else
                    {
                        printCountries.PrintStatisticCountry(country1, null, statistics, stadistic, null);
                    }
                    break;

                case 4:
                    DisplayOptionsInfoCountry();
                    int            optionSearchInfoCountry = RequestUserInfo.OptionSelectedSearchInfoCountry();
                    List <Country> _country = new List <Country>();
                    if (optionSearchInfoCountry == 1)
                    {
                        string nameCountry = RequestUserInfo.OptionSelectedNameCountry();
                        _country = apiCountries.GetByName(nameCountry);
                    }
                    else if (optionSearchInfoCountry == 2)
                    {
                        string capital = RequestUserInfo.OptionSelectedCapital();
                        _country = apiCountries.GetByCapital(capital);
                    }
                    else if (optionSearchInfoCountry == 3)
                    {
                        string code = RequestUserInfo.OptionSelectedCode();
                        _country = apiCountries.GetByCode(code);
                    }
                    printCountries.PrintInfoCountries(_country);
                    break;

                case 5:
                    DisplayOptionsSortListCountries();
                    int            optionListSelectedSort = RequestUserInfo.OptionSelectedListCountries();
                    List <Country> _listCountries         = new List <Country>();
                    if (optionListSelectedSort == 1)
                    {
                        _listCountries = apiCountries.GetAll();
                    }
                    else if (optionListSelectedSort == 2)
                    {
                        string languageSelected = RequestUserInfo.OptionSelectedLanguage();
                        _listCountries = apiCountries.GetByLanguage(languageSelected);
                    }
                    else if (optionListSelectedSort == 3)
                    {
                        string currency = RequestUserInfo.OptionSelectedCurrency();
                        _listCountries = apiCountries.GetByCurrency(currency);
                    }
                    else if (optionListSelectedSort == 4)
                    {
                        string region = RequestUserInfo.OptionSelectedRegion();
                        _listCountries = apiCountries.GetByRegion(region);
                    }
                    DisplayOptionsSortingListCountries();
                    int            optionSortingList = RequestUserInfo.OptionSelectedListCountries();
                    List <Country> sortList          = statistics.SortingOfCountries(_listCountries, optionSortingList);
                    printCountries.PrintSortingListCountries(sortList, optionSortingList);
                    break;

                default:
                    PrintError();
                    break;
                }
            }
        }