Пример #1
0
        private async void Guardar()
        {
            this.IsRunning = true;
            this.IsEnabled = false;
            if (string.IsNullOrEmpty(this.Nombre))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe ingresar su Nombre",
                    "Aceptar");

                return;
            }

            if (string.IsNullOrEmpty(this.Apellido))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe ingresar su Apellido",
                    "Aceptar");

                return;
            }

            if (string.IsNullOrEmpty(this.Contraseña))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe ingresar su Contraseña",
                    "Aceptar");

                return;
            }

            if (this.Contraseña.Length < 6)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe ingresar como minimo 6 caracteres",
                    "Aceptar");

                return;
            }


            if (string.IsNullOrEmpty(this.ConfirmarContraseña))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "La contraseña debe ser igual a la anterior",
                    "Aceptar");

                return;
            }


            if (!this.Contraseña.Equals(this.ConfirmarContraseña))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "La contraseña no coinsiden",
                    "Aceptar");

                return;
            }


            if (string.IsNullOrEmpty(this.PaisOrigen))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe ingresar su País de Origen",
                    "Aceptar");

                return;
            }

            if (string.IsNullOrEmpty(this.CiudadOrigen))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe ingresar su Ciudad de Origen",
                    "Aceptar");

                return;
            }

            if (string.IsNullOrEmpty(this.Nacionalidad))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe ingresar su Nacionalidad",
                    "Aceptar");

                return;
            }


            if (string.IsNullOrEmpty(this.Email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe ingresar su Email",
                    "Aceptar");

                return;
            }

            if (!RegexHelper.IsValidEmailAddress(this.Email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe ingresar un correo verdadero",
                    "Aceptar");

                return;
            }

            var DatosUsu = new Usuario
            {
                nombreU      = Nombre,
                apellidoU    = Apellido,
                passwordU    = Contraseña,
                paisOrigen   = PaisOrigen,
                ciudadOrigen = CiudadOrigen,
                nacionalidad = Nacionalidad,
                email        = Email,
            };

            try
            {
                var connection = await this.apiServicio.ValidacionInternet();

                if (!connection.respExitosa)
                {
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert("Error", connection.mensaje, "Aceptar");

                    return;
                }

                Usuario usua = await apiServicio.listaUsu(this.Email);


                if (usua != null)
                {
                    this.IsRunning = false;
                    this.isEnabled = true;

                    await Application.Current.MainPage.DisplayAlert(
                        "Email Existente",
                        "Este email ya esta en uso",
                        "Aceptar");
                }
                else
                {
                    if (usua == null)
                    {
                        await apiServicio.InsertarRegistro(DatosUsu);

                        await Application.Current.MainPage.DisplayAlert(
                            "Mensaje ",
                            "Usuario registrado exitosamente",
                            "Aceptar");

                        this.IsRunning = false;
                        this.isEnabled = true;
                        VistaPrincipal.GetInstancia().Login = new LoginVModelo();
                        await Application.Current.MainPage.Navigation.PushAsync(new LoginPage());
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("HUBO UNA EXCEPTION EN registro de usuario: " + e.Message);
            }
        } //Cierre metodo Guardar
Пример #2
0
        private async void Enviar()
        {
            this.IsRunning = true;
            this.IsEnabled = false;
            if (String.IsNullOrEmpty(this.Email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe ingresar su email",
                    "Aceptar");

                return;
            }
            if (!RegexHelper.IsValidEmailAddress(this.Email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe ingresar un correo verdadero",
                    "Aceptar");

                return;
            }
            var connection = await this.apiServicios.ValidacionInternet();

            if (!connection.respExitosa)
            {
                this.IsRunning = false;
                this.IsEnabled = true;
                await Application.Current.MainPage.DisplayAlert("Error", connection.mensaje, "Aceptar");

                return;
            }
            Usuario usua = await apiServicios.listaUsu(this.Email);


            if (usua != null)
            {
                this.IsRunning = false;
                this.isEnabled = true;


                var url = "https://api20191121075554.azurewebsites.net/".ToString();

                await apiServicios.RecuperarPass(Email, url, "api/RetornoClave", "/enviarClave");

                await Application.Current.MainPage.DisplayAlert(
                    "Mensaje",
                    "Se ha enviado un email a su correo con su contraseña",
                    "Aceptar");

                VistaPrincipal.GetInstancia().Login = new LoginVModelo();
                await Application.Current.MainPage.Navigation.PushAsync(new LoginPage());
            }
            else
            {
                if (usua == null)
                {
                    this.IsRunning = false;
                    this.isEnabled = true;

                    await Application.Current.MainPage.DisplayAlert(
                        "Email Erroneo",
                        "Este email no está registrado.",
                        "Aceptar");
                }
            }
        }