示例#1
0
        /// <summary>
        /// llama al servicio para mostrar todos los teléfonos ingresados por el usuario y añadirlos a una lista.
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                list = new List <Telefono>();
                if (inf != null)
                {
                    foreach (var dato in inf.telefonos)
                    {
                        //catdir.cp = dato.catalogoDir.cp;
                        list.Add(new Telefono
                        {
                            id       = dato.id,
                            telefono = dato.telefono,
                            lada     = dato.lada,
                            tipo     = dato.tipo
                        });
                    }


                    BindingContext       = list;
                    listView.ItemsSource = list;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Retorna una instancia singleton del cliente de INFINITUS.
        /// </summary>
        /// <param name="cliente">The cliente.</param>
        /// <returns>cliente INFINITUS.</returns>
        public static IINFINITUSClient InfinitusClient(ClienteRest cliente)
        {
            {
                if (infinitusClient == null)
                {
                    lock (syncRoot)
                    {
                        if (infinitusClient != null)
                        {
                            return(infinitusClient);
                        }

                        var client = new INFINITUSClient(
                            new Uri(cliente.Endpoint),
                            // new TokenCredentials(tokenProvider),
                            Token,
                            new WebRequestHandler()
                        {
                            CachePolicy = new RequestCachePolicy(RequestCacheLevel.Default)
                        },
                            new CorrelationHandler());

                        client.SetRetryPolicy(null);

                        infinitusClient = client;
                    }
                }

                return(infinitusClient);
            }
        }
示例#3
0
        /// <summary>
        /// método usado para consumir al servicio de modificar un correo electrónico
        /// </summary>
        void conectar()
        {
            if (string.IsNullOrEmpty(enCorreo.Text) || !Regex.Match(enCorreo.Text, "^(?(\")(\".+?(?<!\\\\)\"@)|(([0-9A-Za-z]((\\.(?!\\.))|[-!#\\$%&'\\*\\+/=\\?\\^`\\{\\}\\|~\\w])*)(?<=[0-9A-Za-z])@))(?(\\[)(\\[(\\d{1,3}\\.){3}\\d{1,3}\\])|(([0-9a-z][-\\w]*[0-9a-z]*\\.)+[a-z0-9][\\-a-z0-9]{0,22}[a-z0-9]))$").Success)
            {
                DisplayAlert("Advertencia", "Introduzca un correo electrónico valido", "OK");
            }
            else
            {
                ClienteRest cliente = new ClienteRest();
                Email       email   = new Email();
                email.id      = ID;
                email.correoe = enCorreo.Text;
                email.tipo    = enTipo.Text;

                cliente.PUT(Constantes.URL_USUARIOS + "/email/actualizar-email", email);
                MessagingCenter.Subscribe <ClienteRest>(this, "OK", (sender) =>
                {
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                    DisplayAlert("Guardado", "¡Correo Modificado con Exito!", "OK");
                    Navigation.PopAsync();
                });

                MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) =>
                {
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                    DisplayAlert("Error", "¡No fué posible modifcar el correo!", "OK");
                });
            }
        }
        /**
         * void llenarPicker()
         * {
         *  Device.BeginInvokeOnMainThread(async () =>
         * {
         *     if (CrossConnectivity.Current.IsConnected)
         *     {
         *         ClienteRest client = new ClienteRest();
         *         var httpclient = await client.GET<TipoAsentamiento>("http://192.168.0.18:8080/api/catalogo-dirs/tipo-asentamiento");
         *         tipoas = new List<string>();
         *         if (httpclient != null)
         *         {
         *
         *             foreach (var dato in httpclient.respuesta)
         *             {
         *                 //tipoas.Add(dato);
         *                 if (!String.IsNullOrEmpty(dato))
         *                 {
         *                     pkTipoAsentamiento.Items.Add(dato);
         *                 }
         *
         *             }
         *
         *
         *
         *             foreach (var nom in tipoas)
         *             {
         *
         *
         *
         *
         *             }
         *         }
         *
         *
         *     }
         *     else { await DisplayAlert("Error de conexion", "No hay coneccion a internet", "ok"); }
         *
         * });
         * }**/



        /// <summary>
        /// evento cuando se presiona la tecla de retorno en el teclado virtual de la entrada enCod "codigo postal"
        /// para consumir al servicio que muestra el catálodo de direcciones correspondiente al código postal ingresado
        /// y llenar automáticamente los campos correspondientes
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        async void algo_Completed(object sender, System.EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("asdasd");
            var cp = ((Entry)sender).Text;

            if (CrossConnectivity.Current.IsConnected)
            {
                ClienteRest cliente = new ClienteRest();
                var         resp    = await cliente.GET <CodigoPostal>(Constantes.URL_USUARIOS + "/catalogo-dirs/mostrarCatalogo/" + cp);

                if (resp != null)
                {
                    pkAsentamiento.IsVisible = true;
                    enColonia.IsVisible      = false;

                    List <string> asentmientos = new List <string>();
                    foreach (var item in resp.respuesta)
                    {
                        asentmientos.Add(item.asentamiento);
                    }
                    pkAsentamiento.ItemsSource = asentmientos;
                    cargaCP                 = true;
                    enCiudad.Text           = resp.respuesta[0].ciudad;
                    enColonia.Text          = resp.respuesta[0].asentamiento;
                    enMunicipio.Text        = resp.respuesta[0].municipio;
                    enEstado.Text           = resp.respuesta[0].estado;
                    enTipoAsentamiento.Text = resp.respuesta[0].tipoasentamiento;
                    enPais.Text             = resp.respuesta[0].pais;
                }
            }
            else
            {
                await DisplayAlert("Error de conexion", "No hay conexión a internet", "ok");
            }
        }
示例#5
0
        /// <summary>
        /// Consume al servicio que obtiene la información del usuario mediante una instancia de la clase CLienteRest
        /// y llena los campos correspondientes
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                if (inf != null)
                {
                    enNombre.Text  = inf.persona.nombre;
                    enPaterno.Text = inf.persona.apaterno;
                    enMaterno.Text = inf.persona.amaterno;
                    enCurp.Text    = inf.persona.curp;
                    persona.id     = inf.persona.id;
                    dtFecha.Date   = DateTime.ParseExact(inf.persona.fechanac, "yyyy-MM-dd", null);
                    for (var i = 0; i < pkEstCvl.Items.Count; i++)
                    {
                        if (pkEstCvl.Items[i].Equals(inf.persona.edoCivil))
                        {
                            pkEstCvl.SelectedIndex = i;
                        }
                    }
                    for (var i = 0; i < pkSexo.Items.Count; i++)
                    {
                        if (pkSexo.Items[i].Equals(inf.persona.sexo))
                        {
                            pkSexo.SelectedIndex = i;
                        }
                    }
                }
            }
        }
示例#6
0
        public MainPage()
        {
            InitializeComponent();
            btnObter.Clicked += btnObter_Clicked;

            ClienteRest cliente   = new ClienteRest();
            string      resultado = string.Empty;

            try
            {
                resultado = cliente.obterDados(URL_GET);
            }
            catch (Exception)
            {
                lblWelcome.Text = erroDefaul;
                throw new Exception(erroDefaul);
            }
            juri = JsonConvert.DeserializeObject <List <Jurado> >(resultado);
            Jurado jurado = juri.Take(1).FirstOrDefault <Jurado>();

            foreach (Jurado juradoAtual in juri)
            {
                cmbJuri.Items.Add(juradoAtual.ToString());
            }
        }
示例#7
0
        /// <summary>
        /// evento completed que se incia una vez que el usuario presiona la tecla de retorno en el teclado virutual
        /// una vez que termina de escribir los digitos del código postal
        /// este evento llama al servicio que muestra un catálogo de direcciones a partir del código postal ingresado
        /// para poder llenar automáticamente algunos de los campos de direcciones (asentamiento, tipo, ciudad, municipio etc.)
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        async void algo_Completed(object sender, System.EventArgs e)
        {
            var cp = ((Entry)sender).Text;

            if (CrossConnectivity.Current.IsConnected)
            {
                enAsentamiento.IsVisible = false;
                pkAsentamiento.IsVisible = true;

                cargaCP = true;
                ClienteRest cliente = new ClienteRest();
                var         resp    = await cliente.GET <CodigoPostal>(Constantes.URL_USUARIOS + "/catalogo-dirs/mostrarCatalogo/" + cp);

                if (resp != null)
                {
                    pkAsentamiento.Items.Clear();

                    asentmientos = new List <CargaCP>();
                    foreach (var item in resp.respuesta)
                    {
                        asentmientos.Add(new CargaCP
                        {
                            tipo         = item.tipoasentamiento,
                            asentamiento = item.asentamiento,
                            catID        = item.id
                        });
                    }


                    foreach (var asent in asentmientos)
                    {
                        pkAsentamiento.Items.Add(asent.asentamiento);
                    }



                    enCiudad.Text       = resp.respuesta[0].ciudad;
                    enAsentamiento.Text = resp.respuesta[0].asentamiento;
                    enMunicipio.Text    = resp.respuesta[0].municipio;
                    enEstado.Text       = resp.respuesta[0].estado;
                    //enTipoAsentamiento.Text = resp.respuesta[0].tipoasentamiento;
                    //enPais.Text = resp.respuesta[0].pais;
                }
            }
            else
            {
                await DisplayAlert("Error de conexion", "No hay conexión a internet", "ok");
            }
        }
示例#8
0
        /// <summary>
        /// Consume al servicio infoContribuyente para mostrar el nombre en la barra lateral
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                TOKEN = Application.Current.Properties["token"] as string;

                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                if (inf != null)
                {
                    lblNomre.Text = inf.persona.nombre;
                }
            }
        }
        /// <summary>
        /// Este evento corresponde al boton modificar cuando se hace click al boton
        /// primero valida que todos los campos añadidos sean validos y una vez que todo sea correcto
        /// consume al servicio para modificar la información de facturacion.
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void Modificar_Clicked(object sender, System.EventArgs e)
        {
            facturacion.rfc            = enRFC.Text;
            facturacion.nomrazonSocial = enRazon.Text;

            facturacion.direccion = new Modelos.Direccion
            {
                id          = IDDIR,
                catalogoDir = new CatalogoDir {
                    id = IDCATDIR
                }
            };
            ClienteRest client = new ClienteRest();


            if (!(string.IsNullOrEmpty(enRFC.Text)) && !(string.IsNullOrEmpty(enRazon.Text)) && pkCorreo.SelectedIndex > -1 && pkDireccion.SelectedIndex > -1)
            {
                if (!Regex.Match(enRFC.Text, "[A-Z,Ñ,&]{3,4}[0-9]{2}[0-1][0-9][0-3][0-9][A-Z,0-9]?[A-Z,0-9]?[0-9,A-Z]?").Success || enRFC.Text.Length < 12 || enRFC.Text.Length > 13)
                {
                    DisplayAlert("Advertencia", "Introduzca un RFC valido", "OK");
                }
                else
                {
                    client.PUT(Constantes.URL_USUARIOS + "/datos-facturacion/actualizar", facturacion);
                }
            }
            else
            {
                DisplayAlert("Advertencia", "¡Seleccione el resto de campos!", "OK");
            }



            MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) => {
                MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                DisplayAlert("Modificado", "¡Información de facturación modificada con exito!", "OK");
                Navigation.PopAsync();
            });

            MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                DisplayAlert("Error", "¡No fue posible modificar la información actual!", "OK");
                Navigation.PopAsync();
            });
        }
示例#10
0
        /// <summary>
        /// Método asincrono que consume al servicio InfoContribuyente para obtener el nombre del usuario logueado
        /// a su vez muestra en el carrito los items que han sido añadidos al carrito al obtener la cantidad de la
        /// base de datos interna
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                if (inf != null)
                {
                    Nombre.Text = "Bienvenido(a): " + inf.persona.nombre;
                }
            }

            ((App)Application.Current).ResumeAtTodoId = -1;
            var list = await App.Database.GetItemsAsync();

            itemsCarrito.Text = list.Count.ToString();
        }
示例#11
0
        /// <summary>
        /// llama al servicio para mostrar todas las direcciones ingresadas por el usuario y añadirlos a una lista.
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                var cont = 1;

                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                list = new List <Modelos.infodir>();

                if (inf != null)
                {
                    foreach (var dato in inf.direcciones)
                    {
                        list.Add(new Modelos.infodir
                        {
                            NumerodeDireccion = "Dirección " + cont + ":",
                            id             = dato.id,
                            calle          = dato.calle,
                            numero         = dato.numero,
                            numeroInterior = dato.numeroInterior,
                            tipo           = dato.tipo,

                            cp               = dato.catalogoDir.cp,
                            asentamiento     = dato.catalogoDir.asentamiento,
                            municipio        = dato.catalogoDir.municipio,
                            estado           = dato.catalogoDir.estado,
                            pais             = dato.catalogoDir.pais,
                            tipoasentamiento = dato.catalogoDir.tipoasentamiento,
                            ciudad           = dato.catalogoDir.ciudad,
                            idCat            = dato.catalogoDir.id
                        });
                        cont++;
                        System.Diagnostics.Debug.WriteLine(dato.catalogoDir.municipio);
                    }


                    BindingContext       = list;
                    listView.ItemsSource = list;
                }
            }
        }
示例#12
0
        private void btnObter_Clicked(object sender, EventArgs e)
        {
            ClienteRest cliente   = new ClienteRest();
            string      resultado = string.Empty;

            try
            {
                resultado = cliente.obterDados(URL_GET);
            }
            catch (Exception)
            {
                lblWelcome.Text = erroDefaul;
                throw new Exception(erroDefaul);
            }
            juri = JsonConvert.DeserializeObject <List <Jurado> >(resultado);
            Jurado jurado = juri.Take(1).FirstOrDefault <Jurado>();

            lblWelcome.Text = jurado.nome;
        }
示例#13
0
        /// <summary>
        /// evento que permite seleccionar una direccion de la lista y elegir la opcion de modificarlo o eliminarlo
        /// unicamente en android se hará uso del cuadro de diálogo personalizado ya que en iOS
        /// sus configuraciones nativas no lo requieren. Así mismo consume los servicios correspondientes.
        /// </summary>
        /// <param name="sender">objeto que hace referencia al evento</param>
        /// <param name="e">argumentos que son posibles de obtener apartir del objeto que hace llamada al evento</param>
        async void Agregar_Clicked(object sender, System.EventArgs e)
        {
            if (string.IsNullOrEmpty(enCorreo.Text) || !Regex.Match(enCorreo.Text, "^(?(\")(\".+?(?<!\\\\)\"@)|(([0-9A-Za-z]((\\.(?!\\.))|[-!#\\$%&'\\*\\+/=\\?\\^`\\{\\}\\|~\\w])*)(?<=[0-9A-Za-z])@))(?(\\[)(\\[(\\d{1,3}\\.){3}\\d{1,3}\\])|(([0-9a-z][-\\w]*[0-9a-z]*\\.)+[a-z0-9][\\-a-z0-9]{0,22}[a-z0-9]))$").Success)
            {
                await DisplayAlert("Advertencia", "Introduzca un correo electrónico valido", "OK");
            }
            else
            {
                if (Application.Current.Properties.ContainsKey("token"))
                {
                    ClienteRest cliente = new ClienteRest();
                    var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                    if (inf != null)
                    {
                        AgregarCorreo addemail = new AgregarCorreo();
                        addemail.persona = inf.persona;
                        addemail.email   = new Email
                        {
                            correoe = enCorreo.Text,
                            tipo    = "PERSONAL"
                        };
                        ClienteRest client = new ClienteRest();



                        client.POST(Constantes.URL_USUARIOS + "/email/agregar", addemail, 1);
                        MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) =>
                        {
                            DisplayAlert("Guardado", "¡Correo añadido con exito!", "OK");
                            Navigation.PopAsync();
                            MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                        });

                        MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) =>
                        {
                            DisplayAlert("Error", "¡No fué posible añadir el correo actual", "OK");
                            MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                        });
                    }
                }
            }
        }
        /// <summary>
        /// Este evento corresponde al boton agregar cuando se hace click al boton
        /// primero valida que todos los campos añadidos sean validos y una vez que todo sea correcto
        /// consume al servicio para añadir nueva informacion de facturacion.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void Agregar_Clicked(object sender, System.EventArgs e)
        {
            facturacion.rfc            = enRFC.Text;
            facturacion.nomrazonSocial = enRazon.Text;



            ClienteRest client = new ClienteRest();

            if (!(string.IsNullOrEmpty(enRFC.Text)) && !(string.IsNullOrEmpty(enRazon.Text)) && pkCorreo.SelectedIndex > -1 && pkDireccion.SelectedIndex > -1)
            {
                if (!Regex.Match(enRFC.Text, "[A-Z,Ñ,&]{3,4}[0-9]{2}[0-1][0-9][0-3][0-9][A-Z,0-9]?[A-Z,0-9]?[0-9,A-Z]?").Success || enRFC.Text.Length < 12 || enRFC.Text.Length > 13)
                {
                    DisplayAlert("Advertencia", "Introduzca un RFC valido", "OK");
                }
                else
                {
                    client.POST(Constantes.URL_USUARIOS + "/datos-facturacion/agregar", facturacion, 1);
                }
            }
            else
            {
                DisplayAlert("Advertencia", "Llene y/o seleccione todos los campos", "OK");
            }


            MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) => {
                MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                DisplayAlert("Guardado", "¡Información de facturación añadida con exito!", "OK");
                Navigation.PopAsync();
            });

            MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                DisplayAlert("Error", "¡No fue posible añadir la informació de facturación actual!", "OK");
                Navigation.PopAsync();
            });
        }
示例#15
0
        /// <summary>
        /// LLena el contenido del picker que contiene el tipo de asentamiento al consumir un servicio
        /// que carga los tipos de asentamientos, si el tipo de pantalla es 0 (modificar datos)
        /// muestra automáticamente el tipo de asentamiento que el usuario tenia ingresado
        /// </summary>
        void llenarPicker()
        {
            Device.BeginInvokeOnMainThread(async() =>
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    ClienteRest client = new ClienteRest();
                    var httpclient     = await client.GET <TipoAsentamiento>(Constantes.URL_USUARIOS + "/catalogo-dirs/tipo-asentamiento");
                    tipoas             = new List <string>();
                    if (httpclient != null)
                    {
                        foreach (var dato in httpclient.respuesta)
                        {
                            //tipoas.Add(dato);
                            if (!String.IsNullOrEmpty(dato))
                            {
                                pkTipoAsentamiento.Items.Add(dato);
                            }
                        }

                        if (tipos == 0)
                        {
                            for (var i = 0; i < pkTipoAsentamiento.Items.Count; i++)
                            {
                                if (pkTipoAsentamiento.Items[i].Equals(tipoAsenta))
                                {
                                    pkTipoAsentamiento.SelectedIndex = i;
                                }
                            }
                        }
                    }
                }
                else
                {
                    await DisplayAlert("Error de conexión", "No hay conexión a internet", "ok");
                }
            });
        }
示例#16
0
        /// <summary>
        /// llama al servicio para mostrar todos los datos de facturacíon ingresadas por el usuario y añadirlos a una lista.
        /// </summary>>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                ClienteRest cliente = new ClienteRest();



                var inf = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                //list = new List<DatosFacturacion>();

                lista = new List <MostrarDatosFacturacion>();



                if (inf != null)
                {
                    foreach (var dato in inf.datosFacturacion)
                    {
                        lista.Add(new MostrarDatosFacturacion
                        {
                            id             = dato.id,
                            rfc            = dato.rfc,
                            email          = dato.email.correoe,
                            nomrazonSocial = dato.nomrazonSocial,
                            direccion      = dato.direccion.catalogoDir.tipoasentamiento + " " + dato.direccion.catalogoDir.asentamiento + ", " + dato.direccion.calle + " " + dato.direccion.numero,
                            idDireccion    = dato.direccion.id,
                            idCatDir       = dato.direccion.catalogoDir.id,
                            calle          = dato.direccion.calle
                        });
                    }
                    BindingContext       = lista;
                    listView.ItemsSource = lista;
                }
            }
        }
        /// <summary>
        /// consume al servicio que contiene la información del usuario para mostrarla y pueda ser seleccionada como datos de facturación
        /// entre este información se encuentra sus direcciones y correos añadidos
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                var cont = 1;

                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                listDir   = new List <Modelos.infodir>();
                listEmail = new List <Email>();


                if (inf != null)
                {
                    foreach (var dato in inf.direcciones)
                    {
                        listDir.Add(new Modelos.infodir
                        {
                            NumerodeDireccion = "Dirección " + cont + ":",
                            id             = dato.id,
                            calle          = dato.calle,
                            numero         = dato.numero,
                            numeroInterior = dato.numeroInterior,
                            tipo           = dato.tipo,

                            cp               = dato.catalogoDir.cp,
                            asentamiento     = dato.catalogoDir.asentamiento,
                            municipio        = dato.catalogoDir.municipio,
                            estado           = dato.catalogoDir.estado,
                            pais             = dato.catalogoDir.pais,
                            tipoasentamiento = dato.catalogoDir.tipoasentamiento,
                            ciudad           = dato.catalogoDir.ciudad,
                            idCat            = dato.catalogoDir.id
                        });

                        cont++;
                    }



                    foreach (var dato in inf.email)
                    {
                        listEmail.Add(new Email
                        {
                            id      = dato.id,
                            correoe = dato.correoe,
                            tipo    = dato.tipo,
                        });
                    }

                    System.Diagnostics.Debug.WriteLine(listEmail.Count);
                    foreach (var corr in listEmail)
                    {
                        pkCorreo.Items.Add(corr.correoe);
                    }

                    //System.Diagnostics.Debug.WriteLine(listEmail[3].id);



                    foreach (var dir in listDir)
                    {
                        pkDireccion.Items.Add(dir.asentamiento + " " + dir.calle + " " + dir.numero);
                    }


                    facturacion.id      = ID;
                    facturacion.persona = inf.persona;


                    if (tipos == 0)
                    {
                        for (var i = 0; i < pkCorreo.Items.Count; i++)
                        {
                            if (pkCorreo.Items[i].Equals(email))
                            {
                                pkCorreo.SelectedIndex = i;
                            }
                        }


                        for (var i = 0; i < pkDireccion.Items.Count; i++)
                        {
                            if (pkDireccion.Items[i].Contains(direccion))
                            {
                                pkDireccion.SelectedIndex = i;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Este método valida que las entradas de texto sean correctas,si no es así notifica al usuario
        /// una vez que sean correctas consume al servicio para modificar la contraseña
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                TOKEN = Application.Current.Properties["token"] as string;

                contraseña psw = new contraseña();

                bool auth = false, auth2 = false, auth3 = false;
                psw.contrasenaNueva  = enPsw.Text;
                psw.contrasenaActual = enPsw0.Text;
                ClienteRest client = new ClienteRest();
                if (!String.IsNullOrEmpty(enPsw.Text) && !(enPsw.Text.Length < 8))
                {
                    auth = true;
                }
                else
                {
                    auth = false;
                    await DisplayAlert("Error", "Contraseña incorrecta, deben ser al menos 8 caracteres", "ok");
                }
                if (!(string.IsNullOrEmpty(enPsw2.Text)))
                {
                    if (enPsw2.Text.Equals(enPsw.Text))
                    {
                        auth2 = true;
                    }
                    else
                    {
                        auth2 = false;
                        await DisplayAlert("Error", "Las Contraseñas No Concuerdan", "OK");
                    }
                }


                if (!(String.IsNullOrEmpty(enPsw0.Text)))
                {
                    auth3 = true;
                }
                else
                {
                    await DisplayAlert("Error", "Introduzca su contraseña actual", "OK");

                    auth3 = false;
                }



                if (auth && auth2 && auth3)
                {
                    HttpResponseMessage response;

                    string ContentType = "application/json";     // or application/xml
                    var    jsonstring  = JsonConvert.SerializeObject(psw);

                    //jsonstring = jsonstring.Substring(1, jsonstring.Length - 2);
                    System.Diagnostics.Debug.WriteLine(jsonstring);

                    try
                    {
                        HttpClient clients = new HttpClient();
                        clients.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", TOKEN);

                        response = await clients.PutAsync(Constantes.URL_USUARIOS + "/usuarios/actualizar-contrasena", new StringContent(jsonstring, Encoding.UTF8, ContentType));

                        var y = await response.Content.ReadAsStringAsync();

                        System.Diagnostics.Debug.WriteLine(y);


                        if (response.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            await DisplayAlert("Guardado", "¡Contraseña modificada con exito!", "OK");

                            await Navigation.PopAsync();
                        }

                        else
                        {
                            var resp = JsonConvert.DeserializeObject <Respuesta>(y);

                            await DisplayAlert("Error", resp.respuesta, "OK");
                        }
                    }
                    catch (HttpRequestException ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.InnerException.Message);
                        await DisplayAlert("Error", "No fué posible contectarse al servidor intente mas tarde", "OK");
                    }
                }
            }
        }
示例#19
0
        /// <summary>
        /// este método valida que los campos ingresados en las entradas sean correctos antes de consumir al servicio
        /// de añadir una nueva dirección, en caso contrario se notifica al usuario
        /// </summary>
        async void Añadir()
        {
            bool a1 = false, a2 = false, a3 = false, a4 = false, a5 = false, a6 = false, a7 = false;


            if (ValidarVacio(enCalle.Text) || !Regex.Match(enCalle.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚüÜ\s0-9]+$").Success)
            {
                await DisplayAlert("Campo no valida", "Introduza una calle válida", "Ok");

                a1 = false;
            }
            else
            {
                a1 = true;
            }

            if (ValidarVacio(enNumero.Text) || !Regex.Match(enNumero.Text, "^[a-zA-Z0-9/-]*$").Success)
            {
                await DisplayAlert("Campo no valido", "Introduza una número válido", "Ok");

                a2 = false;
            }
            else
            {
                a2 = true;
            }


            if (ValidarVacio(enCP.Text) || enCP.Text.Length < 5)
            {
                await  DisplayAlert("Campo no valido", "Introduza una código postal válido", "Ok");

                a3 = false;
            }
            else
            {
                a3 = true;
            }


            if (!(pkTipoAsentamiento.SelectedIndex > -1))
            {
                await DisplayAlert("Campo vacio", "selecciona un tipo de asentamiento", "ok");

                a4 = false;
            }
            else
            {
                a4 = true;
            }

            if (ValidarVacio(enMunicipio.Text) || !Regex.Match(enMunicipio.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚ\s0-9]+$").Success)
            {
                await  DisplayAlert("Campo incorrecto", "Introduzca un municipio valido", "ok");

                a5 = false;
            }
            else
            {
                a5 = true;
            }

            if (ValidarVacio(enEstado.Text) || !Regex.Match(enEstado.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚÜü\s0-9]+$").Success)
            {
                await DisplayAlert("Campo vacio", "Introduzca un estado valido", "ok");

                a6 = false;
            }
            else
            {
                a6 = true;
            }
            if (!(pkAsentamiento.SelectedIndex > -1))
            {
                await DisplayAlert("Campo vacio", "seleccione su asentamiento", "ok");

                a7 = false;
            }
            else
            {
                a7 = true;
            }

            if (a1 && a2 && a3 && a4 && a5 && a6 && a7)
            {
                ClienteRest cliente = new ClienteRest();
                Modelos.AgregarDireccion agredire = new Modelos.AgregarDireccion();
                var inf = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                if (inf != null)
                {
                    agredire.persona = new Persona
                    {
                        id       = inf.persona.id,
                        nombre   = inf.persona.nombre,
                        apaterno = inf.persona.apaterno,
                        amaterno = inf.persona.amaterno,
                        curp     = inf.persona.curp,
                        edoCivil = inf.persona.edoCivil,
                        sexo     = inf.persona.sexo,
                        fechanac = inf.persona.fechanac
                    };


                    agredire.direccion = new Modelos.Direccion()
                    {
                        calle          = enCalle.Text,
                        numero         = enNumero.Text,
                        numeroInterior = enNumeroInterior.Text,
                        catalogoDir    = new CatalogoDir()
                        {
                            id               = (cargaCP)?cargaID.ToString():null,
                            asentamiento     = pkAsentamiento.Items[pkAsentamiento.SelectedIndex],
                            tipoasentamiento = pkTipoAsentamiento.Items[pkTipoAsentamiento.SelectedIndex],
                            cp               = enCP.Text,
                            ciudad           = enCiudad.Text,
                            municipio        = enMunicipio.Text,
                            estado           = enEstado.Text,
                            pais             = pkpais.Items[pkpais.SelectedIndex]
                        }
                    };
                }



                cliente.POST(Constantes.URL_USUARIOS + "/direccion/agregar", agredire, 1);

                MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) =>
                {
                    DisplayAlert("Guardado", "¡Direccion Añadida con Exito!", "OK");
                    Navigation.PopAsync();
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                });
                MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                    DisplayAlert("Advertencia", "¡No fué posible añadir la dirección actual!", "error");
                    Navigation.PopAsync();
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                });
            }
        }
        /// <summary>
        /// evento click del botón agregar para consumir al servicio de agregar un nuevo teléfono
        /// </summary>
        /// <param name="sender">objeto que hace referencia al evento</param>
        /// <param name="e">argumentos que son posibles de obtener apartir del objeto que hace llamada al evento</param>
        async void Agregar_Clicked(object sender, System.EventArgs e)
        {
            ClienteRest cliente = new ClienteRest();
            var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

            if (inf != null)
            {
                Modelos.ModificarTelefono modtel = new Modelos.ModificarTelefono();


                modtel.persona = inf.persona;
                bool auth = false, auth2 = false, auth3 = false;


                modtel.telefono = new Telefono
                {
                    tipo     = pkTipo.Items[pkTipo.SelectedIndex],
                    telefono = enTelefono.Text,
                    lada     = enLada.Text
                };

                ClienteRest client = new ClienteRest();
                if (!String.IsNullOrEmpty(enTelefono.Text) && !(enTelefono.Text.Length < 7) && !(enTelefono.Text.Length > 10))
                {
                    auth = true;
                }
                else
                {
                    auth = false;
                    await DisplayAlert("Error", "Teléfono Invalido", "ok");
                }


                if (!String.IsNullOrEmpty(enLada.Text) && !(enTelefono.Text.Length < 2))
                {
                    auth2 = true;
                }
                else
                {
                    auth2 = false;
                    await DisplayAlert("Error", "LADA incorrecta", "ok");
                }


                if (pkTipo.SelectedIndex > -1)
                {
                    auth3 = true;
                }
                else
                {
                    auth3 = false;
                    await DisplayAlert("Error", "Seleccione el tipo de teléfono", "ok");
                }

                if (auth && auth2 && auth3)
                {
                    client.POST(Constantes.URL_USUARIOS + "/telefono/agregar", modtel, 1);
                    MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) => {
                        DisplayAlert("Guardado", "¡Teléfono Añadido con Exito!", "OK");
                        MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                        Navigation.PopAsync();
                    });

                    MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                        DisplayAlert("Error", "¡No fué posible añadir el Teléfono!", "OK");
                        MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                    });
                }
            }
        }
        /// <summary>
        /// método usado para consumir al servicio de modificar un teléfono, primero valida si los campos ingresados sean correctos
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                if (inf != null)
                {
                    Telefono modtel;


                    // modtel.persona = inf.persona;
                    bool auth = false, auth2 = false;


                    modtel = new Telefono
                    {
                        id       = ID,
                        tipo     = pkTipo.Items[pkTipo.SelectedIndex],
                        telefono = enTelefono.Text,
                        lada     = enLada.Text
                    };

                    ClienteRest client = new ClienteRest();
                    if (!String.IsNullOrEmpty(enTelefono.Text) && !(enTelefono.Text.Length < 7) && !(enTelefono.Text.Length > 10))
                    {
                        auth = true;
                    }
                    else
                    {
                        auth = false;
                        await DisplayAlert("Error", "Teléfono Invalido", "ok");
                    }


                    if (!String.IsNullOrEmpty(enLada.Text) && !(enLada.Text.Length < 2))
                    {
                        auth2 = true;
                    }
                    else
                    {
                        auth2 = false;
                        await DisplayAlert("Error", "LADA incorrecta", "ok");
                    }

                    if (auth && auth2)
                    {
                        client.PUT(Constantes.URL_USUARIOS + "/telefonos/modificar", modtel);
                        MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) => {
                            DisplayAlert("Guardado", "¡Teléfono Modificado con Exito!", "OK");
                            MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                            Navigation.PopAsync();
                        });

                        MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                            DisplayAlert("Error", "¡No fué posible Modificar el Teléfono!", "OK");
                            MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                        });
                    }
                }
            }
        }
示例#22
0
        /// <summary>
        /// evento click al presionar el boton guardar, verifica que los campos añadidos sean correctos antes de
        /// consumir el servicio para modificarlos
        /// </summary>
        /// <param name="sender">objeto que hace referencia al evento</param>
        /// <param name="e">argumentos que son posibles de obtener apartir del objeto que hace llamada al evento</param>
        void modificar_Clicked(object sender, System.EventArgs e)
        {
            Boolean a1 = false, a2 = false, a3 = false;

            if (string.IsNullOrEmpty(enCurp.Text) || !Regex.Match(enCurp.Text, "[A-Z][A,E,I,O,U,X][A-Z]{2}[0-9]{2}[0-1][0-9][0-3][0-9][M,H][A-Z]{2}[B,C,D,F,G,H,J,K,L,M,N,Ñ,P,Q,R,S,T,V,W,X,Y,Z]{3}[0-9,A-Z][0-9]").Success)
            {
                DisplayAlert("Campo incorrecto", "Introduzca un CURP valido", "ok");
                a1 = false;
            }
            else
            {
                a1 = true;
            }


            if (string.IsNullOrEmpty(enNombre.Text) || !Regex.Match(enNombre.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚ\s]+$").Success)
            {
                DisplayAlert("Campo incorrecto", "Introduzca un nombre valido", "ok");
                a2 = false;
            }
            else
            {
                a2 = true;
            }
            if (string.IsNullOrEmpty(enPaterno.Text) || !Regex.Match(enPaterno.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚ\s]+$").Success)
            {
                DisplayAlert("Campo incorrecto", "Introduzca un apellido valido", "ok");
                a3 = false;
            }
            else
            {
                a3 = true;
            }



            if (a1 && a2 && a3)
            {
                ClienteRest client = new ClienteRest();

                persona.nombre   = enNombre.Text;
                persona.apaterno = enPaterno.Text;
                persona.amaterno = enMaterno.Text;
                persona.curp     = enCurp.Text;
                persona.sexo     = pkSexo.Items[pkSexo.SelectedIndex];
                persona.edoCivil = pkEstCvl.Items[pkEstCvl.SelectedIndex];
                persona.fechanac = dtFecha.Date.ToString("yyyy-MM-dd");

                enNombre.IsEnabled  = false;
                enPaterno.IsEnabled = false;
                enMaterno.IsEnabled = false;
                enCurp.IsEnabled    = false;
                dtFecha.IsEnabled   = false;
                pkSexo.IsEnabled    = false;
                pkEstCvl.IsEnabled  = false;



                client.PUT(Constantes.URL_USUARIOS + "/personas/actualizar", persona);

                MessagingCenter.Subscribe <ClienteRest>(this, "OK", (send) =>
                {
                    DisplayAlert("Guardado", "¡Datos Modificados con Exito!", "OK");
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                    btnGuardar.IsEnabled          = false;
                    btnModificar.IsEnabled        = true;
                    btnModificar.BackgroundColor  = Color.FromHex("#5CB85C");
                    btnContraseña.IsEnabled       = true;
                    btnContraseña.BackgroundColor = Color.FromHex("#3f85bd");

                    btnGuardar.BackgroundColor = Color.Silver;
                });

                MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                    DisplayAlert("Error", "¡No fue posible modifcar los datos!", "OK");
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                    btnGuardar.IsEnabled          = false;
                    btnModificar.IsEnabled        = true;
                    btnModificar.BackgroundColor  = Color.FromHex("#5CB85C");
                    btnGuardar.BackgroundColor    = Color.Silver;
                    btnContraseña.IsEnabled       = true;
                    btnContraseña.BackgroundColor = Color.FromHex("#3f85bd");
                });
            }
            else
            {
                btnGuardar.IsEnabled          = true;
                btnModificar.IsEnabled        = false;
                btnGuardar.BackgroundColor    = Color.FromHex("#5CB85C");
                btnModificar.BackgroundColor  = Color.Silver;
                btnContraseña.IsEnabled       = true;
                btnContraseña.BackgroundColor = Color.FromHex("#3f85bd");
            }
        }
示例#23
0
        /// <summary>
        /// evento del boton registrar valida que todos los campos ingresados sean correctos
        /// y en caso afirmativo consume al servicio de dar de alta un nuevo usuario
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        async void registrar_Clicked(object sender, System.EventArgs e)
        {
            bool a1 = false, a2 = false, a3 = false, a4 = false, a5 = false, a6 = false, a7 = false, a8 = false, a9 = false, a10 = false, a11 = true, a12 = false;
            bool comodin = true, comodin2 = true, com = false, com2 = false;

            if (!string.IsNullOrEmpty(enCiudad.Text))
            {
                if (!Regex.Match(enCiudad.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚ\s0-9]+$").Success)
                {
                    enCiudad.ErrorText = "Introduza una ciudad valida";
                    await DisplayAlert("Advertencia", "Introduza una ciudad valida", "OK");

                    comodin = false;
                }
                else
                {
                    enCiudad.ErrorText = "";
                    comodin            = true;
                }
            }
            else
            {
                comodin = true;
            }

            if (!string.IsNullOrEmpty(enNumInt.Text))
            {
                if (!Regex.Match(enNumInt.Text, "^[a-zA-Z0-9/-]*$").Success)
                {
                    comodin2 = false;
                }
                else
                {
                    comodin2 = true;
                }
            }
            else
            {
                comodin2 = true;
            }



            if (!string.IsNullOrEmpty(enLADA2.Text))
            {
                if (enLADA2.Text.Length < 2)
                {
                    com = false;
                    await DisplayAlert("Advertencia", "LADA incorrecta", "OK");

                    enLADA2.ErrorText = "LADA";
                }
                else
                {
                    com = true;
                    enLADA2.ErrorText = "";
                }
            }
            else
            {
                com = false;
                enLADA2.ErrorText = "";
            }


            if (!string.IsNullOrEmpty(enCelular.Text))
            {
                if (enCelular.Text.Length < 7 || enCelular.Text.Length > 10)
                {
                    com2 = false;
                    enCelular.ErrorText = "Celular incorrecto";
                    await DisplayAlert("Advertencia", "Celular incorrecto", "OK");
                }
                else
                {
                    com2 = true;
                    enCelular.ErrorText = "";
                }
            }
            else
            {
                com2 = false;
                enCelular.ErrorText = "";
            }


            if (string.IsNullOrEmpty(enColonia.Text) || !Regex.Match(enColonia.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚüÜ\s0-9]+$").Success)
            {
                enColonia.ErrorText = "Introduzca un asentamiento valido";
                await DisplayAlert("Advertencia", "Introduzca un asentamiento valido", "OK");

                a1 = false;
            }
            else
            {
                enColonia.ErrorText = "";
                a1 = true;
            }

            if (ValidarVacio(enDomicilio.Text) || !Regex.Match(enDomicilio.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚüÜ\s0-9]+$").Success)
            {
                enDomicilio.ErrorText = "Introduzca una calle valida";
                await DisplayAlert("Advertencia", "Introduzca una calle valida", "OK");

                a2 = false;
            }
            else
            {
                enDomicilio.ErrorText = "";
                a2 = true;
            }
            if (ValidarVacio(enNumero.Text) || !Regex.Match(enNumero.Text, "^[a-zA-Z0-9/-]*$").Success)
            {
                lblnum.TextColor = Xamarin.Forms.Color.Red;
                a3 = false;
            }
            else
            {
                lblnum.TextColor = Xamarin.Forms.Color.Black;
                a3 = true;
            }

            if (ValidarVacio(enCod.Text) || enCod.Text.Length < 5)
            {
                lblCod.TextColor = Xamarin.Forms.Color.Red;
                a4 = false;
            }
            else
            {
                lblCod.TextColor = Xamarin.Forms.Color.Black;
                a4 = true;
            }


            if (ValidarVacio(enTipoAsentamiento.Text) || !Regex.Match(enTipoAsentamiento.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚ\s0-9]+$").Success)
            {
                enTipoAsentamiento.ErrorText = "Introduzca un tipo valido";
                await DisplayAlert("Advertencia", "Introduzca un tipo valido", "OK");

                a5 = false;
            }
            else
            {
                enTipoAsentamiento.ErrorText = "";
                a5 = true;
            }

            if (ValidarVacio(enEstado.Text) || !Regex.Match(enEstado.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚÜü\s0-9]+$").Success)
            {
                enEstado.ErrorText = "Introduzca un estado valido";
                await DisplayAlert("Advertencia", "Introduzca un estado valido", "OK");

                a6 = false;
            }
            else
            {
                enEstado.ErrorText = "";
                a6 = true;
            }

            if (ValidarVacio(enPais.Text))
            {
                enPais.ErrorText = "Introduzca su país";
                await DisplayAlert("Advertencia", "Introduzca su país", "OK");

                a7 = false;
            }
            else
            {
                enPais.ErrorText = "";
                a7 = true;
            }
            if (ValidarVacio(enTelefono.Text) || enTelefono.Text.Length < 7 || enTelefono.Text.Length > 10)
            {
                await DisplayAlert("Sin número telefónico valido", "Deslice la pantalla para ver todas las opciones", "OK");

                enTelefono.ErrorText = "Introduzca un teléfono valido";
                a8 = false;
            }
            else
            {
                enTelefono.ErrorText = "";
                a8 = true;
            }

            if (ValidarVacio(enMunicipio.Text) || !Regex.Match(enMunicipio.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚ\s0-9]+$").Success)
            {
                await DisplayAlert("Advertencia", "Introduzca un municipio valido", "OK");

                enMunicipio.ErrorText = "Introduzca un municipio valido";
                a9 = false;
            }
            else
            {
                enMunicipio.ErrorText = "";
                a9 = true;
            }

            if (ValidarVacio(enLADA.Text) || enLADA.Text.Length < 2)
            {
                await DisplayAlert("Advertencia", "LADA incorrecta", "OK");

                enLADA.ErrorText = "LADA";
                a10 = false;
            }
            else
            {
                enLADA.ErrorText = "";
                a10 = true;
            }

            if (cargaCP)
            {
                if (!(pkAsentamiento.SelectedIndex > -1))
                {
                    await DisplayAlert("Campo vacio", "seleccione su asentamiento", "ok");

                    a11 = false;
                }
                else
                {
                    a11 = true;
                }
            }

            if (a1 && a2 && a3 && a4 && a5 && a6 && a7 && a8 && a9 && a10 && comodin && comodin2 && a11)
            {
                var asentamiento =
                    user.direccion = new Direccion
                {
                    calle          = enDomicilio.Text,
                    numero         = enNumero.Text,
                    numeroInterior = enNumInt.Text,
                    tipo           = "DOMICILIO",

                    catalogoDir = new CatalogoDir
                    {
                        asentamiento     = (cargaCP)?pkAsentamiento.Items[pkAsentamiento.SelectedIndex]:enColonia.Text,
                        cp               = enCod.Text,
                        ciudad           = enCiudad.Text,
                        estado           = enEstado.Text,
                        municipio        = enMunicipio.Text,
                        tipoasentamiento = enTipoAsentamiento.Text,
                        pais             = enPais.Text
                    }
                };



                user.telefono = new List <Telefono>();


                user.telefono.Add(new Telefono
                {
                    telefono = enTelefono.Text,
                    lada     = enLADA.Text,
                    tipo     = "FIJO"
                });

                if (com && com2)
                {
                    user.telefono.Add(new Telefono
                    {
                        telefono = enCelular.Text,
                        lada     = enLADA2.Text,
                        tipo     = "MOVIL"
                    });
                }



                //System.Diagnostics.Debug.WriteLine(JsonConvert.SerializeObject(user));

                ClienteRest cliente = new ClienteRest();

                cliente.POST(Constantes.URL_USUARIOS + "/registrar?movil=true&tramitta=false", user, 1);


                MessagingCenter.Subscribe <ClienteRest>(this, "OK", async(Sender) =>
                {
                    await DisplayAlert("Guardado", "Usuario registrado con exito", "Ok");
                    await DisplayAlert("Información", "Verifique su correo electrónico para iniciar sesión", "Ok");
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                    await Navigation.PopToRootAsync();
                });
                MessagingCenter.Subscribe <ClienteRest>(this, "error", async(Sender) =>
                {
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                    await DisplayAlert("Error", "No fue posible dar de alta al usuario, posiblemente que este correo ya esta registrado o el servidor esta fuera de línea", "Ok");
                    Application.Current.Properties["calle"]            = enDomicilio.Text;
                    Application.Current.Properties["numero"]           = enNumero.Text;
                    Application.Current.Properties["numeroInterior"]   = enNumInt.Text;
                    Application.Current.Properties["asentamiento"]     = (cargaCP) ? pkAsentamiento.Items[pkAsentamiento.SelectedIndex] : enColonia.Text;
                    Application.Current.Properties["cp"]               = enCod.Text;
                    Application.Current.Properties["ciudad"]           = enCiudad.Text;
                    Application.Current.Properties["estado"]           = enEstado.Text;
                    Application.Current.Properties["municipio"]        = enMunicipio.Text;
                    Application.Current.Properties["tipoAsentamiento"] = enTipoAsentamiento.Text;
                    Application.Current.Properties["pais"]             = enPais.Text;
                    Application.Current.Properties["telefono"]         = enTelefono.Text;
                    Application.Current.Properties["lada"]             = enLADA.Text;
                    Application.Current.Properties["celular"]          = enCelular.Text;
                    Application.Current.Properties["lada2"]            = enLADA2.Text;



                    await Application.Current.SavePropertiesAsync();
                });
                //await Navigation.PopToRootAsync();
            }
        }
示例#24
0
        /// <summary>
        /// Este método permite verificar que el texto introducido en las entradas sea correcto antes de consumir el servicio para
        /// modificar los datos de facturación. enc aso contrario notifica al usuario
        /// </summary>
        void Modificar()
        {
            bool a1 = false, a2 = false, a3 = false, a4 = false, a5 = false, a6 = false, a7 = false, a8 = true;


            if (ValidarVacio(enCalle.Text) || !Regex.Match(enCalle.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚüÜ\s0-9]+$").Success)
            {
                DisplayAlert("Campo no valida", "Introduza una calle válida", "Ok");
                a1 = false;
            }
            else
            {
                a1 = true;
            }

            if (ValidarVacio(enNumero.Text) || !Regex.Match(enNumero.Text, "^[a-zA-Z0-9/-]*$").Success)
            {
                DisplayAlert("Campo no valido", "Introduza una número valido", "Ok");
                a2 = false;
            }
            else
            {
                a2 = true;
            }


            if (ValidarVacio(enCP.Text) || enCP.Text.Length < 5)
            {
                DisplayAlert("Campo no valido", "Introduza una código postal valido", "Ok");
                a3 = false;
            }
            else
            {
                a3 = true;
            }


            if (!(pkTipoAsentamiento.SelectedIndex > -1))
            {
                DisplayAlert("Campo vacio", "selecciona un tipo de asentamiento", "ok");
                a4 = false;
            }
            else
            {
                a4 = true;
            }

            if (ValidarVacio(enMunicipio.Text) || !Regex.Match(enMunicipio.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚÜü\s0-9]+$").Success)
            {
                DisplayAlert("Campo vacio", "Introduzca un municipio valido", "ok");
                a5 = false;
            }
            else
            {
                a5 = true;
            }

            if (ValidarVacio(enEstado.Text) || !Regex.Match(enEstado.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚÜü\s0-9]+$").Success)
            {
                DisplayAlert("Campo incorrecto", "Introduzaca un estado valido", "ok");
                a6 = false;
            }
            else
            {
                a6 = true;
            }

            if (ValidarVacio(enAsentamiento.Text))
            {
                DisplayAlert("Campo vacio", "Introduzaca un asentamiento", "ok");
                a7 = false;
            }
            else
            {
                a7 = true;
            }

            if (cargaCP)
            {
                if (!(pkAsentamiento.SelectedIndex > -1))
                {
                    DisplayAlert("Campo vacio", "seleccione su asentamiento", "ok");
                    a8 = false;
                }
                else
                {
                    a8 = true;
                }
            }

            if (a1 && a2 && a3 && a4 && a5 && a6 && a7 && a8)
            {
                ClienteRest client = new ClienteRest();

                Modelos.Direccion dir = new Modelos.Direccion();

                dir.id             = ID;
                dir.calle          = enCalle.Text;
                dir.numero         = enNumero.Text;
                dir.numeroInterior = enNumeroInterior.Text;
                dir.catalogoDir    = new CatalogoDir()
                {
                    id               = catID,
                    asentamiento     = (cargaCP)?pkAsentamiento.Items[pkAsentamiento.SelectedIndex]:enAsentamiento.Text,
                    tipoasentamiento = pkTipoAsentamiento.Items[pkTipoAsentamiento.SelectedIndex],
                    cp               = enCP.Text,
                    ciudad           = enCiudad.Text,
                    municipio        = enMunicipio.Text,
                    estado           = enEstado.Text,
                    pais             = pkpais.Items[pkpais.SelectedIndex]
                };


                client.PUT(Constantes.URL_USUARIOS + "/direccion/actualizar", dir);

                MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) => {
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                    DisplayAlert("Guardado", "¡Direccion Modificada con Exito!", "OK");
                    Navigation.PopAsync();
                });


                MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                    DisplayAlert("Advertencia", "¡No fue posible modificar la dirección actual!", "OK");
                    Navigation.PopAsync();
                });
            }
        }