private async void SaveButton_Click(object sender, EventArgs e)
        {
            DisableErrors();
            if (!CheckInput()) return;

            if (!txtPassword.Password.Equals(txtRepeatPassword.Password))
            {
                MessageBox.Show("The password doesn't match!");
                return;
            }

            var error = false;
            try
            {
                var existingUser = (await Service.GetTable<User>()
                    .Where(t => t.Id == App.User.Id).ToListAsync()).FirstOrDefault();
                existingUser.Password = txtPassword.Password;
                existingUser.Fullname = txtName.Text;
                existingUser.Email = txtEmail.Text;
                existingUser.Address = txtAddress.Text;
                existingUser.PhoneNumber = txtPhone.Text;
                existingUser.Type = (cmbUserType.SelectedItem as NameType).Type;
                await Service.UpdateItemAsync(existingUser);
                App.User = existingUser;

                var settings = new SettingsHelper();
                if (settings.GetRememberMeFromSettings())
                {
                    settings.SetPasswordToSettings(existingUser.Password);
                }
            }
            catch (Exception ex)
            {
                error = true;
            }

            if (error)
            {
                MessageBox.Show("Something went wrong!");
                return;
            }

            if (NavigationService.CanGoBack)
                NavigationService.GoBack();
        }
Пример #2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            SystemTray.IsVisible = true;
            if (!IsInternetConnection())
                return;

            var settings = new SettingsHelper();
            if (!settings.GetRememberMeFromSettings()) return;

            var username = settings.GetUsernameFromSettings();
            var password = settings.GetPasswordFromSettings();

            txtUsername.Text = username;
            txtPassword.Password = password;
            chkRemember.IsChecked = true;

            await Login(username, password, false);
        }