Example #1
0
        private async void Login()
        {
            if (String.IsNullOrEmpty(this.Email))
            {
                await Application.Current.MainPage.DisplayAlert("Error", "You must enter an email.", "Accept");

                return;
            }

            if (String.IsNullOrEmpty(this.Password))
            {
                await Application.Current.MainPage.DisplayAlert("Error", "You must enter a password.", "Accept");

                return;
            }

            IsRunning = true;
            IsEnabled = false;
            if (this.Email != "*****@*****.**" || this.Password != "123456")
            {
                IsRunning = false;
                IsEnabled = true;
                await Application.Current.MainPage.DisplayAlert("Error", "Email or Paswword is incorrect.", "Accept");

                this.Password = string.Empty;
                return;
            }
            IsRunning = false;
            IsEnabled = true;

            MainViewModels.Instance().Lands = new LandsViewModels();
            await Application.Current.MainPage.Navigation.PushAsync(new LandsPage());
        }
Example #2
0
        private async void LoadLands()
        {
            this.IsRefreshing = true;
            var connection = await this.apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                this.IsRefreshing = false;
                await Application.Current.MainPage.DisplayAlert("Error", connection.Message, "Accept");

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

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

            if (!resoponse.IsSuccess)
            {
                this.IsRefreshing = false;
                await Application.Current.MainPage.DisplayAlert("Error", resoponse.Message, "Accept");

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

                return;
            }
            MainViewModels.Instance()._landList = (List <Land>)resoponse.Result;
            this.Lands = new ObservableCollection <LandItemViewModel>(
                this.ToLandItemViewModel());
            this.IsRefreshing = false;
        }
Example #3
0
 private IEnumerable <LandItemViewModel> ToLandItemViewModel()
 {
     return(MainViewModels.Instance()._landList.Select(l => new LandItemViewModel
     {
         Alpha2Code = l.Alpha2Code,
         Alpha3Code = l.Alpha3Code,
         AltSpellings = l.AltSpellings,
         Area = l.Area,
         Borders = l.Borders,
         CallingCodes = l.CallingCodes,
         Capital = l.Capital,
         Cioc = l.Cioc,
         Currencies = l.Currencies,
         Demonym = l.Demonym,
         Flag = l.Flag,
         Gini = l.Gini,
         Languages = l.Languages,
         Latlng = l.Latlng,
         Name = l.Name,
         NativeName = l.NativeName,
         NumericCode = l.NumericCode,
         Population = l.Population,
         Region = l.Region,
         RegionalBlocs = l.RegionalBlocs,
         Subregion = l.Subregion,
         Timezones = l.Timezones,
         TopLevelDomain = l.TopLevelDomain,
         Translations = l.Translations,
     }));
 }
Example #4
0
 public static MainViewModels Instance()
 {
     if (_instance == null)
     {
         _instance = new MainViewModels();
     }
     return(_instance);
 }
Example #5
0
 private void LoadBorders()
 {
     this.Borders = new ObservableCollection <Border>();
     foreach (var border in this.Land.Borders)
     {
         var land = MainViewModels.Instance()._landList.
                    Where(l => l.Alpha3Code == (string)border).FirstOrDefault();
         if (land != null)
         {
             this.Borders.Add(new Border
             {
                 Code = land.Alpha3Code,
                 Name = land.Name
             });
         }
     }
 }
Example #6
0
 private async void SelectLand()
 {
     MainViewModels.Instance().Land = new LandViewModel(this);
     await Application.Current.MainPage.Navigation.PushAsync(new LandTabbedPage());
 }