public void ConnectToAccount(AccountCredentialsModel credentials) { var model = new AccountModel(credentials); Config.Instance.AddAccount(credentials); var accountVM = new AccountExpItemVM(model, _main); this.RootItems.Add(accountVM); }
public void AddAccount(AccountCredentialsModel credentials) { this.DocDbAccounts.Add(new SavedAccountModel { Credentials = credentials }); this.saveToFile(); }
private async void bOk_Click(object sender, RoutedEventArgs e) { try { this.bOk.IsEnabled = false; if (_existingCredentials != null) { this._existingCredentials.Endpoint = this.tbEndpoint.Text; this._existingCredentials.Key = this.tbKey.Text; if (this._action != null) this._action(this._existingCredentials); else if (this._actionAsync != null) await this._actionAsync(this._existingCredentials); } else { var credModel = new AccountCredentialsModel(this.tbEndpoint.Text, this.tbKey.Text); if (this._action != null) this._action(credModel); else if (this._actionAsync != null) await this._actionAsync(credModel); } this.DialogResult = true; } catch(Exception ex) { MessageBox.Show(ex.Message); this.bOk.IsEnabled = true; } }
private DocDbAccountCredentialsDlg(AccountCredentialsModel credentials, Func<AccountCredentialsModel, Task> actionAsync) { this._actionAsync = actionAsync; this._existingCredentials = credentials; InitializeComponent(); this.tbEndpoint.Text = credentials.Endpoint; this.tbKey.Text = credentials.Key; }
public void ChangeAccountCredentials(string oldEndpoint, AccountCredentialsModel newCredentials) { var found = this.DocDbAccounts.FirstOrDefault(sam => sam.Credentials.Endpoint == oldEndpoint); if (found != null) { found.Credentials = newCredentials; saveToFile(); } }
public AccountModel(AccountCredentialsModel credentials) : base(new DocumentClient(new Uri(credentials.Endpoint), credentials.Key)) { Credentials = credentials; }
public static void ShowDialog(AccountCredentialsModel existingCreds, Func<AccountCredentialsModel, Task> action) { new DocDbAccountCredentialsDlg(existingCreds, action).ShowDialog(); }