public static async Task <List <string> > InPutString(int i)
        {
            string        input       = string.Empty;
            List <string> apiResponse = new List <string>();

            if (i.Equals(_SearchForOneCity))
            {
                OutPut.PrintTitleFrame();
                OutPut.PrintMenuFrame();
                ColorAndStyle.SetTextColor(Colors.Magenta);
                input = EnterStringValue(ColorAndStyle.SetTextPosition("Enter city name: ", menuX, menuY));
                if (input.Equals(string.Empty))
                {
                    return(null);
                }

                apiResponse = OutPut.PrintWeatherCondition(await data.GetAPIResponse(input, i)).ToList();
            }
            else if (i.Equals(_SearchBylongLat))
            {
                OutPut.PrintTitleFrame();
                OutPut.PrintMenuFrame();
                ColorAndStyle.SetTextColor(Colors.Magenta);
                int lon = int.Parse(EnterStringValue(ColorAndStyle.SetTextPosition("Enter lat value: ", menuX, menuY)));
                int lat = int.Parse(EnterStringValue(ColorAndStyle.SetTextPosition("Enter lon value: ", menuX, menuY)));
                Console.Clear();
                apiResponse = OutPut.PrintWeatherCondition(await data.GetAPIResponse(lat, lon)).ToList();
            }
            else if (i.Equals(_SearchForMultipleCities))
            {
                OutPut.PrintTitleFrame();
                OutPut.PrintMenuFrame();
                ColorAndStyle.SetTextColor(Colors.Magenta);
                List <string> apiData = new List <string>();
                foreach (var s in await AddCityNames(i))
                {
                    apiData = OutPut.PrintWeatherCondition(s).ToList();
                    if (!apiData.Contains("404"))
                    {
                        apiResponse.AddRange(apiData);
                    }
                }
            }
            else if (i.Equals(_FourDaysForeCast))
            {
                OutPut.PrintTitleFrame();
                OutPut.PrintMenuFrame();
                ColorAndStyle.SetTextColor(Colors.Magenta);
                apiResponse = OutPut.PrintFourDaysForecast(await data.GetAPIResponse(EnterStringValue(ColorAndStyle.SetTextPosition("Enter City Name: ", menuX, menuY)), i));
            }
            else if (i.Equals(_DailyForCast))
            {
                OutPut.PrintTitleFrame();
                OutPut.PrintMenuFrame();
                ColorAndStyle.SetTextColor(Colors.Magenta);
                apiResponse = OutPut.PrintDailyForecast(await data.GetAPIResponse(EnterStringValue(ColorAndStyle.SetTextPosition("Enter city name: ", menuX, menuY)), i)).ToList();
            }

            return(apiResponse);
        }
Beispiel #2
0
        public static async Task <WeatherData> PopulateWeatherModel(string city)
        {
            FetchData   fetch       = new FetchData();
            WeatherData weatherData = await fetch.GetAPIResponse(city, GrabWeatherData);

            return(weatherData);
        }