async Task ExecuteLoadUsersCommand() { if (IsBusy) { return; } IsBusy = true; try { Users.Clear(); var users = await UsersDataStore.GetAllAsync(true); foreach (var user in users) { Users.Add(user); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
/// <summary> /// ユーザー一覧を更新する /// </summary> private void RefreshUsers() { Users.Clear(); foreach (var user in UsersDataStore.GetUsers()) { Users.Add(user); } }
private async void UpdateProfile_Clicked(object sender, System.EventArgs e) { string errors = ""; bool hasErrors = false; if (String.IsNullOrEmpty(FirebaseUser.FirstName)) { errors += "Ispunite ime\n"; } if (String.IsNullOrEmpty(FirebaseUser.LastName)) { errors += "Ispunite prezime\n"; } if (String.IsNullOrEmpty(FirebaseUser.Username)) { errors += "Ispunite korisničko ime\n"; } if (String.IsNullOrEmpty(FirebaseUser.PhoneNumber)) { errors += "Ispunite broj mobitela\n"; } if (!String.IsNullOrEmpty(errors)) { hasErrors = true; await App.Current.MainPage.DisplayAlert("Informacija", errors, "OK"); } if (!hasErrors) { var oldUser = (FirebaseUser)JsonConvert.DeserializeObject(Preferences.Get("FirebaseUser", ""), typeof(FirebaseUser)); if (!oldUser.Equals(FirebaseUser)) { bool success = await UsersDataStore.UpdateItemAsync(FirebaseUser); if (success) { Preferences.Clear(); Preferences.Set("FirebaseUser", JsonConvert.SerializeObject(FirebaseUser)); await App.Current.MainPage.DisplayAlert("Informacija", $"Uspješno ste ažurirali profil", "OK"); if (isFirstLogin) { await Navigation.PushAsync(new MainPage()); } else { await Navigation.PushAsync(new MyDashboardPage(), true); } } else { await App.Current.MainPage.DisplayAlert("Greška", $"Dogodila se pogreška pri ažuriranju profila", "OK"); } } } }
public static void UpateModel(ref UsersDataStore target, UserUpdateRequest source) { target.CompanyId = source.CompanyId; target.Email = source.Email; target.FirebaseToken = source.FirebaseToken; target.Password = EncryptionUtil.Encrypt(source.Password); target.Username = source.Username; target.Role = source.Role; }
/// <summary> /// 削除を実行する /// </summary> private void ExecuteDeleteCommand() { if (UsersDataStore.GetUser(SelectedUser.Guid) != null) { UsersDataStore.RemoveUser(SelectedUser); RefreshUsers(); SelectedUser = new User(); } }
public static void UpateModel(ref UsersDataStore target, UserNewRequest source) { target.CompanyId = source.CompanyId; target.Email = source.Email; target.FirebaseToken = source.FirebaseToken; target.Password = source.Password; target.Username = source.Username; target.Role = source.Role; }
public static UsersDataStore ToModel(this UserUpdateRequest target) { var source = new UsersDataStore(); source.CompanyId = target.CompanyId; source.Email = target.Email; source.FirebaseToken = target.FirebaseToken; source.Nid = target.Nid; source.Password = EncryptionUtil.Encrypt(target.Password); source.Username = target.Username; return(source); }
public static UsersDataStore ToModel(this UserNewRequest source) { var target = new UsersDataStore(); target.CompanyId = source.CompanyId; target.Email = source.Email; target.FirebaseToken = source.FirebaseToken; target.Password = EncryptionUtil.Encrypt(source.Password); target.Username = source.Username; target.Role = source.Role; return(target); }
/// <summary> /// 更新を実行する /// </summary> private void ExecuteUpdateCommand() { if (UsersDataStore.GetUser(SelectedUser.Guid) == null) { UsersDataStore.AddUser(SelectedUser); } else { UsersDataStore.UpdateUser(SelectedUser); } RefreshUsers(); SelectedUser = new User(); }
private async void SaveUser() { var isValidPassword = IsValidPassword(); var isValidEmail = IsValidEmail(); if (isValidPassword && isValidEmail) { if (this.User == null) { var user = new User() { Username = Username, Email = Email, Password = Password, }; await UsersDataStore.AddAsync(user); userSaved?.Invoke(user); await Task.Delay(2000); Dialogs.Toast("User created: " + user.Username); } else { var user = this.User; user.Username = Username; user.Email = Email; user.Password = Password; await UsersDataStore.UpdateAsync(user); userSaved?.Invoke(user); await Task.Delay(1000); Dialogs.Toast("Saved " + user.Username); } } else { var n = Environment.NewLine; var allErrors = $@" {String.Join($".{n}", await GetEmailErrors(Email))} {String.Join($".{n}", GetPasswordErrors(Password) )} {String.Join($".{n}", GetConfirmPasswordErrors(Password, ConfirmPassword))}"; await Dialogs.AlertAsync(allErrors, "Error"); } return; }
private async Task <bool> IsUsedEmail(string email) { var users = await UsersDataStore.GetAllAsync(); var user = users.FirstOrDefault(x => x.Email == email); if (user == null) { return(false); } else { return(true); } }
private async void DeleteUser() { if (this.User != null) { var userName = this.User.Username; await UsersDataStore.DeleteAsync(this.User); userDeleted?.Invoke(); await Task.Delay(2000); Dialogs.Toast("Deleted user: " + userName); } return; }
public static UserGetResponse MapTo(this UsersDataStore source) { if (source != null) { var target = new UserGetResponse(); target.CompanyId = source.CompanyId; target.Email = source?.Email.Trim(); target.FirebaseToken = source?.FirebaseToken; target.Nid = source.Nid; target.Password = source.Password.Trim(); target.TimeStamp = source.TimeStamp; target.Username = source.Username.Trim(); target.Role = source.Role; return(target); } return(null); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="regionManager"></param> /// <param name="eventAggregator"></param> public TopPageViewModel(IRegionManager regionManager, IEventAggregator eventAggregator) { // インタフェースを受け取る _regionManager = regionManager; _eventAggregator = eventAggregator; // コマンドを定義 AddUserToSelectedUsersCommand = new DelegateCommand(ExecuteAddUserToSelectedUsersCommand, CanExecuteAddUserToSelectedUsersCommand); AddUserToSelectedUsersCommand.ObservesProperty(() => SelectedUserInAllUsers); RemoveUserFromSelectedUsersCommand = new DelegateCommand(ExecuteRemoveUserFromSelectedUsersCommand, CanExecuteRemoveUserFromSelectedUsersCommand); RemoveUserFromSelectedUsersCommand.ObservesProperty(() => SelectedUserInSelectedUsers); StartCommand = new DelegateCommand(ExecuteStartCommand, CanExecuteStartCommand); StartCommand.ObservesProperty(() => SelectedUsers.Count); ConfigureUsersCommand = new DelegateCommand(ExecuteConfigureUsersCommand); ShowHistoriesCommand = new DelegateCommand(ExecuteShowHistoriesCommand, CanExecuteShowHistoriesCommand); ShowHistoriesCommand.ObservesProperty(() => Sessions.Count); AllUsers = UsersDataStore.GetUsers(); Sessions = SessionsDataStore.GetSessions(); }
private async Task <bool> AccountExist() { bool success = false; var users = await UsersDataStore.GetAllAsync(true); var user = users.FirstOrDefault(x => ( x.Username == Username || x.Email == Username )); if (user == null) { success = false; } else { success = true; } return(success); }
private async Task <bool> IsValidPassword() { bool success = false; var users = await UsersDataStore.GetAllAsync(true); var user = users.FirstOrDefault(x => ( x.Username == Username || x.Email == Username ) && x.Password == Password); if (user == null) { success = false; } else { success = true; } return(success); }
/// <summary> /// 削除が実行可能かどうかを判定する /// </summary> /// <returns></returns> private bool CanExecuteDeleteCommand() { return(SelectedUser != null && UsersDataStore.GetUser(SelectedUser.Guid) != null); }
async Task SaveUser(User user) { Users.Add(user); await UsersDataStore.AddAsync(user); }
public MainWindowViewModel() { // 初期化処理 UsersDataStore.Initialize(); SessionsDataStore.Initialize(); }