Exemplo n.º 1
0
        public static async Task <bool> PostAutenticar(Usuarios.Usuarios_PostBindingModel model)
        {
            string json = model.Stringify();

            json = await PostAPI("api/Usuarios/Autenticar", json);

            try
            {
                JsonValue jsonValue = JsonValue.Parse(json);

                return(jsonValue.GetBoolean());
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Error al procesar los datos obtenidos", NotifyType.ErrorMessage);

                return(false);
            }
        }
Exemplo n.º 2
0
        private async void Launch_Click(object sender, RoutedEventArgs e)
        {
            Launch.IsEnabled = false;

            this.NotifyUser("Autenticando", NotifyType.StatusMessage);

            try
            {
                Models.Usuarios.Usuarios_PostBindingModel model = new Models.Usuarios.Usuarios_PostBindingModel();
                model.Usuario    = txtUsuario.Text.ToUpper();
                model.Contrasena = txtContrasena.Password;

                Common.APIClient.Usuario = model.Usuario;

                bool Autenticado = await Models.UsuariosModel.PostAutenticar(model);

                if (Autenticado)
                {
                    Frame rootFrame = Window.Current.Content as Frame;
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e);
                }
                else
                {
                    this.NotifyUser("El usuario o la contraseña son incorrectos.", NotifyType.ErrorMessage);
                }
            }
            catch (Exception Error)
            {
                this.NotifyUser(Error.Message, NotifyType.ErrorMessage);
            }
            finally
            {
                Launch.IsEnabled = true;
            }
        }