Exemplo n.º 1
0
        public WeatherDashboardModel Map(WeatherUndergroundModel model)
        {
            var dashboardModel = new WeatherDashboardModel();

            dashboardModel.CurrentCelsius    = model.Current_Observation.Temp_C;
            dashboardModel.CurrentFahrenheit = model.Current_Observation.Temp_F;
            dashboardModel.CurrentSummary    = model.Current_Observation.Weather;
            dashboardModel.Icon     = model.Current_Observation.Icon;
            dashboardModel.IconUrl  = model.Current_Observation.Icon_Url;
            dashboardModel.Forecast = new List <DayDashboard>();
            foreach (var day in model.Forecast.SimpleForecast.ForecastDay.Take(int.Parse(settingsManager.Get(Constants.FORECAST_DEFAULT_SIZE))))
            {
                var dayDashboard = new DayDashboard();
                dayDashboard.Summary        = day.Conditions;
                dayDashboard.LowCelsius     = day.Low.Celsius;
                dayDashboard.LowFahrenheit  = day.Low.Fahrenheit;
                dayDashboard.HighCelsius    = day.High.Celsius;
                dayDashboard.HighFahrenheit = day.High.Fahrenheit;
                dayDashboard.Icon           = day.Icon;
                dayDashboard.IconUrl        = day.Icon_Url;
                dayDashboard.Date           = new DateTime(1970, 1, 1).AddSeconds(day.Date.Epoch);
                dashboardModel.Forecast.Add(dayDashboard);
            }

            return(dashboardModel);
        }
Exemplo n.º 2
0
        public WeatherDashboardModel Map(DarkSkyModel model)
        {
            var dashboardModel = new WeatherDashboardModel();

            dashboardModel.CurrentCelsius    = model.Currently.Temperature;
            dashboardModel.CurrentFahrenheit = model.Currently.Temperature * (decimal)1.8 + 32; //using conversion formula
            dashboardModel.CurrentSummary    = model.Currently.Summary;
            dashboardModel.Icon     = model.Currently.Icon;
            dashboardModel.IconUrl  = null;
            dashboardModel.Forecast = new List <DayDashboard>();
            foreach (var day in model.Daily.Data.Take(int.Parse(settingsManager.Get(Constants.FORECAST_DEFAULT_SIZE))))
            {
                var dayDashboard = new DayDashboard();
                dayDashboard.Summary        = day.Summary;
                dayDashboard.LowCelsius     = day.TemperatureLow;
                dayDashboard.LowFahrenheit  = day.TemperatureLow * (decimal)1.8 + 32;
                dayDashboard.HighCelsius    = day.TemperatureHigh;
                dayDashboard.HighFahrenheit = day.TemperatureHigh * (decimal)1.8 + 32;
                dayDashboard.Icon           = day.Icon;
                dayDashboard.IconUrl        = null;
                dayDashboard.Date           = new DateTime(1970, 1, 1).AddSeconds(day.Time);
                dashboardModel.Forecast.Add(dayDashboard);
            }

            return(dashboardModel);
        }