public bool AddHistoricWeather(HistoricWeatherItem item, DateTime Date, int AirportId) { bool result = true; try { var data = item?.daily?.data?.FirstOrDefault(); if (data != null) { HistoricWeather historicWeather = new HistoricWeather(); historicWeather.Date = Date; historicWeather.Summary = data.summary; historicWeather.Icon = data.icon; historicWeather.PrecipType = data.precipType; historicWeather.PrecipIntensity = Convert.ToDecimal(data.precipIntensity); historicWeather.PrecipProbability = Convert.ToDecimal(data.precipProbability); historicWeather.TemperatureHigh = WeatherHelper.GetCelciusTemperature(Convert.ToDecimal(data.temperatureHigh)); historicWeather.TemperatureLow = WeatherHelper.GetCelciusTemperature(Convert.ToDecimal(data.temperatureLow)); historicWeather.Humidity = Convert.ToDecimal(data.humidity); historicWeather.WindSpeed = Convert.ToDecimal(data.windSpeed); historicWeather.CloudCover = Convert.ToDecimal(data.cloudCover); historicWeather.AirportId = AirportId; _historicWeatherRepo.Add(historicWeather); result = _historicWeatherRepo.Save(); } } catch (Exception e) { result = false; Commons.Logger.GenerateError(e, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AirportId = " + AirportId + " and Date = " + Date); } return(result); }