コード例 #1
0
        private async void setPassword()
        {
            this.IsRunning = true;

            var passwordQuerry = await App.MobileService.GetTable <User_Password>().Where(p => p.User_Id_FK == userQuery[0].Id).ToListAsync();

            if (string.IsNullOrEmpty(this.Password))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Password.",
                    "Accept");

                this.IsRunning = false;
                return;
            }
            if (this.Password.Length < 7)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Your Password length must be greather than 6.",
                    "Accept");

                this.IsRunning = false;
                return;
            }
            if (!(Password.Equals(RePassword)))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Passwords not match.",
                    "Accept");

                this.IsRunning = false;
                return;
            }

            byte[] encryted = System.Text.Encoding.Unicode.GetBytes(Password);
            var    result   = System.Convert.ToBase64String(encryted);


            User_Password password = new User_Password
            {
                Id         = passwordQuerry[0].Id,
                Password   = result,
                User_Id_FK = userQuery[0].Id
            };

            await App.MobileService.GetTable <User_Password>().UpdateAsync(password);

            await Application.Current.MainPage.DisplayAlert(
                "Done",
                "Password has been changed.",
                "Accept");

            this.ThirdButton = false;
            this.IsRunning   = false;

            MainViewModel.GetInstance().Login = new LoginViewModel(this.Email);
            await Application.Current.MainPage.Navigation.PushAsync(new LoginPage());
        }