public WeatherPageViewModel()
        {
            zipRequest     = new ZippoRequest();
            oneCallRequest = new OneCallRequest();

            hourlyChartCelsiusVm    = new HourlyChartViewModel(TemperatureFormat.Celsius);
            hourlyChartFahrenheitVm = new HourlyChartViewModel(TemperatureFormat.Fahrenheit);
            currentWeatherVm        = new CurrentWeatherViewModel();
            dayWeatherViewModels    = new ObservableCollection <DayWeatherViewModel>();

            for (int i = 0; i < NumberOfDailyEntries; i++)
            {
                var dayWeatherVm = new DayWeatherViewModel();
                dayWeatherViewModels.Add(dayWeatherVm);
            }

            HasError     = true;
            ErrorMessage = "No zip code requested.";

            if (IsInDesignMode)
            {
                HasError     = false;
                ErrorMessage = "Weather page error message.";
            }
        }
        public FavoritesBoxViewModel(string zipCode)
        {
            this.zipCode = zipCode;
            oneCallRequest = new OneCallRequest();
            zipRequest = new ZippoRequest();

            UpdateZip();
        }
Example #3
0
        public void UpdateCurrentWeather(OneCallRequest oneCallRequest, ZippoRequest zipCodeRequest)
        {
            LastUpdateTime = string.Format("{0:hh:mm:ss tt}", oneCallRequest.RequestDateTime);
            CurrentWeather currentWeather = oneCallRequest.OneCall.CurrentWeather;
            Weather        weather        = currentWeather.WeatherEntries[0];
            Temperature    temperature    = new Temperature(currentWeather.TemperatureCelsius, TemperatureFormat.Celsius);
            Place          place          = zipCodeRequest.Details.Places[0];

            City  = place.CityName;
            State = place.State;
            TemperatureFahrenheit = string.Format("{0:0.00}º F", temperature.Fahrenheit);
            TemperatureCelsius    = string.Format("{0:0.00}º C", temperature.Celsius);
            IconUrl = weather.GetIconUrl();
        }