using WeatherClient.Models;
using WeatherClient.ViewModels;

namespace WeatherClient
{
    public partial class MainPage : ContentPage
    {
        private WeatherViewModel _context;

        public MainPage()
        {
            InitializeComponent();
        }

        private async void btnRefresh_Clicked(object sender, EventArgs e)
        {
            btnRefresh.IsEnabled = false;
            actIsBusy.IsRunning = true;

            WeatherData weatherData = await Services.WeatherServer.GetWeather(txtPostalCode.Text);
            _context = new WeatherViewModel() { WeatherData = weatherData };
            BindingContext = _context;

            btnRefresh.IsEnabled = true;
            actIsBusy.IsRunning = false;
        }
    }

}
