Exemple #1
0
        private async void LoadLands()
        {
            this.IsRefreshing = true;

            var connection = await apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                this.IsRefreshing = false;

                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    connection.Message,
                    Languages.Accept);

                await Application.Current.MainPage.Navigation.PopAsync();

                return;
            }

            var response = await this.apiService.GetList <Land>(
                "http://restcountries.eu",
                "/rest",
                "/v2/all");

            if (!response.IsSuccess)
            {
                this.IsRefreshing = false;

                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    response.Message,
                    Languages.Accept);

                await Application.Current.MainPage.Navigation.PopAsync();

                return;
            }

            MainViewModel.GetInstance().LandsList = (List <Land>)response.Result;
            this.Lands        = new ObservableCollection <LandItemViewModel>(this.ToLandItemViewModel());
            this.IsRefreshing = false;
        }