Exemplo n.º 1
0
        private async void resetButton_Click(object sender, RoutedEventArgs e)
        {
            NavigationProvider.ShowLoading();

            try
            {
                Product             selected = (this.productsBox.SelectedItem as Product);
                Domain.ProductReset result   = await ProductProvider.ResetProduct(selected.Number);

                if (result != null && result.Error < 0)
                {
                    string errorDescription = result.ErrorDescription;

                    if (errorDescription == "")
                    {
                        throw new Exception("Error irrecuperable");
                    }

                    else
                    {
                        throw new Exception(errorDescription);
                    }
                }

                else
                {
                    NavigationProvider.NavigateTo <ProductResetResult>(new {
                        RemoveBackEntry = true
                    });
                }
            }

            catch (Exception pEx)
            {
                NavigationProvider.ShowError(new
                {
                    Text            = pEx.Message,
                    BackPage        = this,
                    RemoveBackEntry = true
                });
            }
        }
Exemplo n.º 2
0
        private async void loginButton_Click(object sender, RoutedEventArgs e)
        {
            bool loading = false;

            try
            {
                var currentId       = this.clientIdBox.Text;
                var currentPassword = this.passwordBox.Password;

                if (!Int32.TryParse(currentId, out int id))
                {
                    throw new Exception("Formato de usuario inválido");
                }

                if (!Int32.TryParse(currentPassword, out int password))
                {
                    throw new Exception("Formato de constraseña inválido");
                }

                loading = true;
                NavigationProvider.ShowLoading();

                bool result = await AuthProvider.Login(id, password);

                if (!result)
                {
                    throw new Exception("Comprobar los datos ingresados");
                }

                NavigationProvider.NavigateTo <Main>();
            }

            catch (Exception pEx)
            {
                NavigationProvider.ShowError(new
                {
                    Text            = pEx.Message,
                    BackPage        = this,
                    RemoveBackEntry = loading
                });
            }
        }