Esempio n. 1
0
        async void SubmitLogin(object sender, EventArgs args)
        {
            if (loading.IsRunning == false)
            {
                loading.IsRunning = true;

                Console.WriteLine("login action");

                List <ValidationModel> validations = new List <ValidationModel>();

                List <ConstraintsModel> constraintsModel = new List <ConstraintsModel>();

                constraintsModel.Add(new ConstraintsModel(Constants.NOT_EMPTY_DATA));

                validations.Add(new ValidationModel("Usuario:", username.Text, constraintsModel));

                validations.Add(new ValidationModel("Contraseña:", password.Text, constraintsModel));

                var validationResult = FormValidation.ValidateFields(validations, this);

                if (validationResult)
                {
                    if (await App.restServices.login(username.Text, password.Text))
                    {
                        loading.IsRunning = false;
                        await Navigation.PushAsync(new Menu());
                    }
                    else
                    {
                        loading.IsRunning = false;
                    }
                }
                else
                {
                    loading.IsRunning = false;
                }
            }
        }