コード例 #1
0
 private IEnumerable <LandItemViewModel> ToLandItemViewModel()
 {
     return(MainViewModels.GetInstance().LandsList.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,
     }));
 }
コード例 #2
0
        private async void Login()
        {
            if (string.IsNullOrEmpty(this.Email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    Languages.EmailValidation,
                    Languages.Aceptar);

                return;
            }

            if (string.IsNullOrEmpty(this.Password))
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    Languages.PasswordValidation,
                    Languages.Aceptar);

                return;
            }

            this.IsRunning = true;
            this.IsEnabled = false;

            var connection = await this.apiservice.CheckConnection();

            if (!connection.IsSuccess)
            {
                this.IsRunning = false;
                this.IsEnabled = true;
                await Application.Current.MainPage.DisplayAlert(Languages.Error, connection.Message, Languages.Aceptar);

                return;
            }

            var url   = Application.Current.Resources["UrlAPI"].ToString();
            var token = await this.apiservice.GetToken(url, this.Email, this.Password);

            if (token == null || string.IsNullOrEmpty(token.AccessToken))
            {
                this.IsRunning = false;
                this.IsEnabled = true;
                await Application.Current.MainPage.DisplayAlert(Languages.Error, Languages.SomethingWrong, Languages.Aceptar);

                return;
            }

            Settings.TokeType     = token.TokenType;
            Settings.AccessToken  = token.AccessToken;
            Settings.IsRemembered = this.IsRemembered;

            MainViewModels.GetInstance().Products = new ProductsViewModel();
            Application.Current.MainPage = new ProductsPage();

            this.IsRunning = false;
            this.IsEnabled = true;
        }
コード例 #3
0
ファイル: LandViewModels.cs プロジェクト: nchantre/Sales-
 private void LoadBorders()
 {
     this.Borders = new ObservableCollection <Border>();
     foreach (var border in this.Land.Borders)
     {
         var land = MainViewModels.GetInstance().LandsList.
                    Where(l => l.Alpha3Code == border).
                    FirstOrDefault();
         if (land != null)
         {
             this.Borders.Add(new Border
             {
                 Code = land.Alpha3Code,
                 Name = land.Name,
             });
         }
     }
 }
コード例 #4
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 response = await this.apiService.GetList <Land>(
                "https://restcountries.eu",
                "/rest",
                "/v2/all");

            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    response.Message,
                    "Accept");

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

                return;
            }

            MainViewModels.GetInstance().LandsList = (List <Land>)response.Result;
            this.Lands = new ObservableCollection <LandItemViewModel>(
                this.ToLandItemViewModel( ));
            this.IsRefreshing = false;
        }
コード例 #5
0
ファイル: LoginViewModels.cs プロジェクト: nchantre/Sales-
        private async void login()
        {
            if (string.IsNullOrEmpty(this.TxtEmail))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an email",
                    "Accept");

                return;
            }
            //################################################
            if (string.IsNullOrEmpty(this.TxtPassword))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Password",
                    "Accept");

                return;
            }
            //##########################################################
            if (this.TxtEmail != "uno" || this.TxtPassword != "1234")
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Email or Password incorrec.",
                    "Accept");

                this.TxtPassword = string.Empty;
                this.TxtEmail    = string.Empty;
                return;
            }

            /* var connection = await this.apiService.CheckConnection();
             * if (!connection.IsSuccess)
             * {
             *   await Application.Current.MainPage.DisplayAlert(
             *        "Error",
             *        connection.Message,
             *        "Accept");
             *   return;
             * }
             * var token = await this.apiService.GetToken(
             *   "https://landsapi1.azurewebsites.net/",
             *   this.TxtEmail,
             *   this.TxtPassword);
             * if (token == null)
             * {
             *   await Application.Current.MainPage.DisplayAlert(
             *        "Error",
             *        "Something was wrong",
             *        "Accept");
             *   return;
             *
             *
             * }
             * if (string.IsNullOrEmpty(token.AccessToken))
             * {
             *   await Application.Current.MainPage.DisplayAlert(
             *        "Error",
             *        token.ErrorDescription,
             *        "Accept");
             *   return;
             *
             *
             * }*/

            var mainViewModel = MainViewModels.GetInstance();

            //mainViewModel.Token = token;
            // MainViewModels.GetInstance().Lands = new LandsViewModels();
            mainViewModel.Lands = new LandsViewModels();
            await Application.Current.MainPage.Navigation.PushAsync(new LandsPage());

            this.TxtPassword = string.Empty;
            this.TxtEmail    = string.Empty;
        }
コード例 #6
0
 private async void EditProduct()
 {
     MainViewModels.GetInstance().EditProduct = new EditProductViewModel(this);
     await Application.Current.MainPage.Navigation.PushAsync(new EditProductPage());
 }
コード例 #7
0
ファイル: LandItemViewModel.cs プロジェクト: nchantre/Sales-
 private async void SelectLand()
 {
     MainViewModels.GetInstance().Land = new LandViewModels(this);
     await Application.Current.MainPage.Navigation.PushAsync(new LandTabbedPage());
 }