コード例 #1
0
 private IEnumerable <LandItemVistaModelo> ToLandItem()
 {
     return(MainVistaModelo.ObtenerInstancia().listaPaises.Select(l => new LandItemVistaModelo
     {
         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 void CargaBorders()
        {
            this.Borders = new ObservableCollection <Border>();
            foreach (var border in this.Lan.Borders)
            {
                var land = MainVistaModelo.ObtenerInstancia().listaPaises
                           .Where(p => p.Alpha3Code == border).
                           FirstOrDefault();

                if (land != null)
                {
                    this.Borders.Add(new Border
                    {
                        Code = land.Alpha3Code,
                        Name = land.Name,
                    });
                }
            }
        }
コード例 #3
0
        private async void CargaLand()
        {
            this.IsRefreshing = true;

            var revisaconexion = await this.apiServicio.CheckConnection();

            if (!revisaconexion.Exito)
            {
                this.IsRefreshing = false;
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    revisaconexion.Mensaje,
                    "Aceptar");

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

                return;
            }

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

            if (!respuesta.Exito)
            {
                this.IsRefreshing = false;
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    respuesta.Mensaje,
                    "Aceptar");

                return;
            }

            MainVistaModelo.ObtenerInstancia().listaPaises = (List <Land>)respuesta.Resultado;
            this.Land = new ObservableCollection <LandItemVistaModelo>(
                this.ToLandItem());
            this.IsRefreshing = false;
        }
コード例 #4
0
 private async void SelectLand()
 {
     MainVistaModelo.ObtenerInstancia().Lan = new LanVistaModelo(this);
     await Application.Current.MainPage.Navigation.PushAsync(new LandTabbedPage());
 }
コード例 #5
0
        private async void Login()
        {
            if (string.IsNullOrEmpty(this.Email))
            {
                await Application.Current.MainPage.DisplayAlert("" +
                                                                "Error"
                                                                , "Es necesario ingresar su E-Mail"
                                                                , "Aceptar"
                                                                );

                return;
            }
            if (string.IsNullOrEmpty(this.Password))
            {
                await Application.Current.MainPage.DisplayAlert("" +
                                                                "Error"
                                                                , "Es necesario ingresar su contraseña"
                                                                , "Aceptar"
                                                                );

                return;
            }

            this.Run        = true;
            this.Habilitado = false;

            var checaConect = await this.apiServicio.CheckConnection();

            if (!checaConect.Exito)
            {
                this.Run        = false;
                this.Habilitado = true;

                await Application.Current.MainPage.DisplayAlert("" +
                                                                "Error"
                                                                , checaConect.Mensaje
                                                                , "Aceptar"
                                                                );

                return;
            }

            var token = await this.apiServicio.GetToken(
                "https://acuasolapi.azurewebsites.net"
                , this.Email
                , this.Password
                );

            if (token == null)
            {
                this.Run        = false;
                this.Habilitado = true;

                await Application.Current.MainPage.DisplayAlert("" +
                                                                "Error"
                                                                , "Ocurrio un error al intentar acceder, favor de intentar mas tarde"
                                                                , "Aceptar"
                                                                );

                return;
            }

            if (string.IsNullOrEmpty(token.AccessToken))
            {
                this.Run        = false;
                this.Habilitado = true;

                await Application.Current.MainPage.DisplayAlert("" +
                                                                "Error"
                                                                , token.ErrorDescription
                                                                , "Aceptar"
                                                                );

                this.Password = string.Empty;
                return;
            }

            var mainVistaModelo = MainVistaModelo.ObtenerInstancia();

            mainVistaModelo.Token = token;
            mainVistaModelo.Home  = new HomeVistaModelo();
            await Application.Current.MainPage.Navigation.PushAsync(new HomePage());

            this.Run        = false;
            this.Habilitado = true;

            this.Email    = string.Empty;
            this.Password = string.Empty;
        }