public void GetNumOfDaysWithWeatherType(MainEnum weatherType, long cityId) { CityId = cityId; //Create Request GET(https://openweathermap.org/data/2.5/forecast/daily/?appid=b6907d289e10d714a6e88b30761fae22&id=2147714&units=metric) CreateRequest(); //Parse the response ParseForecastDailyResponse(); var daysList = WeatherAnalysys.GetDaysWithWeatherType(forecastDailyResponse, weatherType); //Optional logging to log... Console.WriteLine(string.Format("The number of days in {0} where the forecast is {1} in the next 2 weeks is: {2}", forecastDailyResponse.City.Name, EnumHelper.GetDescription(weatherType), daysList.Count)); LogDaysData(daysList); }
/// <summary> /// Returns a list of days with a certain weather type (like clear, rain etc...) /// </summary> /// <param name="forecastDailyResponse">The JsonDeserialized response object of 'Forecast Daily'</param> /// <param name="weatherType">Type of weather as 'MainEnum' Enum (like clear, rain etc...)</param> /// <returns></returns> public static List <ForcastByDay> GetDaysWithWeatherType(ForecastDailyResponse forecastDailyResponse, MainEnum weatherType) { List <ForcastByDay> days = forecastDailyResponse.List.Where(x => x.Weather[0].Main.Equals(EnumHelper.GetDescription(weatherType))).ToList(); return(days); }