Ejemplo n.º 1
0
        private async void SignInAsync()
        {
            IsBusy  = true;
            IsValid = true;
            bool isValid         = Validate();
            bool isAuthenticated = false;

            if (isValid)
            {
                try
                {
                    isAuthenticated = await _authenticationService.LoginAsync(UserName.Value, Password.Value);
                }
                catch (ServiceAuthenticationException)
                {
                    await DialogService.ShowAlertAsync("Invalid credentials", "Login failure", "Try again");
                }
                catch (Exception ex) when(ex is WebException || ex is HttpRequestException)
                {
                    Debug.WriteLine($"[SignIn] Error signing in: {ex}");
                    await DialogService.ShowAlertAsync("Communication error", "Error", "Ok");
                }
                catch (Exception ex)
                {
                    Debug.WriteLine($"[SignIn] Error signing in: {ex}");
                }

                //isAuthenticated = true;
            }
            else
            {
                IsValid = false;

                bool isValidUser = _userName.Validate();
                if (!isValidUser)
                {
                    await DialogService.ShowAlertAsync("Username should not be empty.", "Error", "Ok");
                }
                else
                {
                    await DialogService.ShowAlertAsync("Password should not be empty.", "Error", "Ok");
                }
            }

            if (isAuthenticated)
            {
                if (Settings.UserType == "DM")
                {
                    // Employer, Go to choose an employee
                    await NavigationService.NavigateToAsync <EmployeeListViewModel>();
                }
                else
                {
                    // Employee, Go straight to Sync page
                    await NavigationService.NavigateToAsync <SyncViewModel>();
                }
            }

            IsBusy = false;
        }
Ejemplo n.º 2
0
 private bool ConfirmPasswordUnfocused()
 {
     _confirmPassword.Validations.Add(new IsCompareRule <string> {
         Text = Password.Value, ValidationMessage = "Password doesn't match."
     });
     return(_confirmPassword.Validate());
 }
Ejemplo n.º 3
0
 private bool EmailUnfocused()
 {
     _email.Validations.Add(new IsEmailRule <string> {
         ValidationMessage = "Email in invalid format."
     });
     return(_email.Validate());
 }
        public bool Validate()
        {
            AddDynamicValidations();

            bool isValidUsername         = _userName.Validate();
            bool isValidPassword         = _password.Validate();
            bool isValidRepeatedPassword = _repeatPassword.Validate();

            return(isValidUsername && isValidPassword && isValidRepeatedPassword);
        }
        public void ValidateFields()
        {
            if ((UserCity.Value == "---Select city---"))
            {
                _userCity.Validate();
            }
            ValidateUserNameCommand.Execute();
            ValidateUserMobile.Execute();
            ValidateUserEmail.Execute();

            CityList = new List <CitysModel>();
        }
        public void ValidateMethod_ShouldClearErrorList_BeforeSearchForNewError()
        {
            MockRule <string> mokRule = new MockRule <string>
            {
                IsValid = true
            };

            _validatableObject.Validations.Add(mokRule);
            _validatableObject.Errors.Add("test");

            _validatableObject.Validate();

            Assert.IsFalse(_validatableObject.Errors.Any());
        }
Ejemplo n.º 7
0
 public override void Validate()
 {
     base.Validate();
     _email.Validate();
     _firstName.Validate();
     _lastName.Validate();
     if (_Roles != null)
     {
         RoleMessage = null;
         if (_Roles.RoleName == Engineer)
         {
             _EUSR.Validate();
         }
         else
         {
             _EUSR.IsValid = true;
         }
     }
     else
     {
         RoleMessage = ResponceCode.applicationErrorHandler("ROLE_REQUIRED");
     }
     Message = (IsAccept == false ? ResponceCode.applicationErrorHandler("ACEEPTSTERMS_REQUIRED") : "");
     _contactNo.Validate();
     this.SetValid();
 }
Ejemplo n.º 8
0
        public bool Validate()
        {
            bool isValidEmail = _email.Validate();
            bool isValidSkype = _skype.Validate();

            return(isValidEmail && isValidSkype);
        }
Ejemplo n.º 9
0
        private bool ValidateUserName()
        {
            bool status = _userName.Validate();

            recheckInput();
            return(status);
        }
Ejemplo n.º 10
0
        private bool ValidatePassword()
        {
            bool status = _password.Validate();

            recheckInput();
            return(status);
        }
Ejemplo n.º 11
0
        public bool Validate()
        {
            bool isValidForename = _forename.Validate();
            bool isValidSurname  = _surname.Validate();

            return(isValidForename && isValidSurname);
        }
Ejemplo n.º 12
0
 public override void Validate()
 {
     base.Validate();
     _userName.Validate();
     _password.Validate();
     this.SetValid();
 }
Ejemplo n.º 13
0
        private bool Validate()
        {
            bool isValidEmail    = _email.Validate();
            bool isValidPassword = _password.Validate();

            return(isValidEmail && isValidPassword);
        }
Ejemplo n.º 14
0
        public override void Validate()
        {
            base.Validate();
            _email.Validate();

            this.SetValid();
        }
        private bool Validate()
        {
            bool isValidDescription = _description.Validate();
            bool isValidRating      = Rating >= 0;

            return(isValidDescription && isValidRating);
        }
Ejemplo n.º 16
0
        private bool Validate()
        {
            bool isValidUser     = _userName.Validate();
            bool isValidPassword = _password.Validate();

            return(isValidUser && isValidPassword);
        }
Ejemplo n.º 17
0
        private bool Validate()
        {
            bool isValidUser     = _userMail.Validate();
            bool isValidPassword = _userPassword.Validate();

            return(isValidUser && isValidPassword);
        }
        public void Validate_ShouldRaisePropertyChanged_When_Value_Is_Changed()
        {
            var v = new ValidatableObject <string>();

            v.Validations.Add(new IsNotNullOrEmptyRule <string>("Email must not be empty"));

            v.Validations.Add(new EmailRule <string>()
            {
                ValidationMessage = "You have entered an invalid email"
            });

            bool isPropertyChangedRaised = false;

            v.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName.Equals(nameof(v.Value)))
                {
                    isPropertyChangedRaised = true;
                    v.Validate();
                }
            };

            Assert.True(v.IsValid);
            v.Value = "t";
            Assert.False(v.IsValid);
            Assert.True(isPropertyChangedRaised);
            Assert.Equal("You have entered an invalid email", v.Errors[0]);
        }
Ejemplo n.º 19
0
        private bool Validate()
        {
            bool isValidCardMonth = _cardMonth.Validate();
            bool isValidCardYear  = _cardYear.Validate();

            return(isValidCardMonth && isValidCardYear);
        }
Ejemplo n.º 20
0
        public bool Validate()
        {
            bool isValidFirstName = _firstName.Validate();
            bool isValidLastName  = _lastName.Validate();

            return(isValidFirstName && isValidLastName);
        }
Ejemplo n.º 21
0
        public bool Validate()
        {
            bool isValidCreditCardNumber = _creditCardNumber.Validate();
            bool isValidCreditCardMonth  = _creditCardMonth.Validate();
            bool isCreditCardYear        = _creditCardYear.Validate();

            return(isValidCreditCardNumber && isValidCreditCardMonth && isCreditCardYear);
        }
Ejemplo n.º 22
0
        public void Validate()
        {
            _mail.Validate();
            _iban.Validate();

            EmailIsNotValid();
            IbanIsValid();
        }
        public NewItemPage()
        {
            InitializeComponent();

            Item = new Item
            {
                Text        = "Item name",
                Description = "This is an item description."
            };

            itemText.Validations.Add(new IsNotNullOrEmptyRule <string>
            {
                ValidationMessage = "Item Text cannot be null."
            });
            itemText.Validate();
            BindingContext = this;
        }
Ejemplo n.º 24
0
 public ForgotViewModel()
 {
     _email               = new ValidatableObject <string>();
     SignInCommand        = new Command(() => OnSignIn(), () => !IsBusy);
     ResetPasswordCommand = new Command(() => OnSubmit(), () => !IsBusy);
     ValidateEmailCommand = new Command(() => _email.Validate(), () => this.CanValidate);
     AddValidations();
     this.PropertyChanged += ForgotViewModel_PropertyChanged;
 }
Ejemplo n.º 25
0
        public bool Validate()
        {
            bool isValidHotWaterBulk    = _hotWaterBulk.Validate();
            bool isValidColdWaterBulk   = _coldWaterBulk.Validate();
            bool isValidElectricityBulk = _electricityBulk.Validate();
            bool isValidNote            = _note.Validate();

            return(isValidHotWaterBulk && isValidColdWaterBulk && isValidElectricityBulk && isValidNote);
        }
Ejemplo n.º 26
0
        private async Task <bool> ExecuteSpeciesCommandAsync()
        {
            var buttons = new List <IActionSheetButton>()
            {
                ActionSheetButton.CreateButton("---Select species---", WriteLine, "Select option"),

                ActionSheetButton.CreateCancelButton("Cancel", WriteLine, "Cancel")
            };
            var Species = await _complaintService.GetAllSpecies(_settings.UserId);

            foreach (var item in Species)
            {
                buttons.Add(ActionSheetButton.CreateButton(item.SpeciesName, WriteLine, item.SpeciesName));
            }
            await PageDialogService.DisplayActionSheetAsync("Select species", buttons.ToArray());

            return(_species.Validate());
        }
Ejemplo n.º 27
0
        private bool Validate()
        {
            bool isValidName     = _name.Validate();
            bool isValidEmail    = _email.Validate();
            bool isValidPhone    = _phonenumber.Validate();
            bool isValidUsername = _username.Validate();

            return(isValidName && isValidEmail && isValidPhone && isValidUsername);
        }
Ejemplo n.º 28
0
 public override void Validate()
 {
     base.Validate();
     _oldPassword.Validate();
     _password.Validate();
     _confirmPassword.Validate();
     if (_confirmPassword.Validate())
     {
         if (_password.Value != _confirmPassword.Value)
         {
             ConfirmPassword.Errors.Add(ResponceCode.applicationErrorHandler("CONFIRMPASSWORD_VALID"));
         }
         else
         {
             ConfirmPassword.Errors.Add("");
         }
     }
     this.SetValid();
 }