protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); //Initialize the views tvDate = FindViewById <TextView>(Resource.Id.tv_date); tvDate.Text = string.Format("TODAY, {0}", DateTime.Today.ToString("dd MMMMM yyyy")); tvMaxTemp = FindViewById <TextView>(Resource.Id.tv_maxTemperature); tvMaxTemp.Text = string.Format("max 0\u00B0C "); tvMinTemp = FindViewById <TextView>(Resource.Id.tv_minTemperature); tvMinTemp.Text = string.Format("min 0\u00B0C "); tvCity = FindViewById <TextView>(Resource.Id.tv_city); weatherViewModel = new WeatherViewModel(); UserDialogs.Init(this); UserDialogs.Instance.ShowLoading("Loading data..."); var data = Task.Run(async() => { //Fetch the weather forecast for the day from the weather service await weatherViewModel.GetWeatherForecast(); UpdateFields(); }); UserDialogs.Instance.HideLoading(); }
public override async void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); loadingOverlay = new LoadingOverlay(UIScreen.MainScreen.Bounds, "Loading data..."); View.AddSubview(loadingOverlay); await weatherViewModel.GetWeatherForecast(); loadingOverlay.Hide(); UpdateFields(); }
public JsonResult GetWeather() { WeatherViewModel weather = new WeatherViewModel(); return(Json(weather.GetWeatherForecast(), JsonRequestBehavior.AllowGet)); }