private async void AddButton_Click(object sender, RoutedEventArgs e) { if (LoginBox.Text.Length > 0) { var account = await authCore.GetAccountByLoginAsync(LoginBox.Text); if (account == null) { MessageBox.Show("Account with a given login doesn't exist"); return; } var author = await authorCore.GetAuthorByAccountIdAsync(account.AccountId); if (author == null) { MessageBox.Show("A given account is not an author"); return; } if (await articleCore.SetAuthorForArticleAsync(articleId, author.AuthorId)) { MessageBox.Show("Successfully added new author to article"); Close(); } else { MessageBox.Show("Something went wrong while adding new author to article"); } } else { MessageBox.Show("Login cannot be empty"); } }
private async void InitializeData() { UserCredentials.Author = await authorCore.GetAuthorByAccountIdAsync(UserCredentials.Account.AccountId); ProgressSpin.IsActive = true; await FillConferenceList(); FillUserData(); SetButtonVisibility(false); ProgressSpin.IsActive = false; }
private async void GoToEditAuthor_Click(object sender, RoutedEventArgs e) { if (AuthorBox.Text.Length > 0) { if (await CheckAuthorExistsAsync(AuthorBox.Text)) { var account = await authCore.GetAccountByLoginAsync(AuthorBox.Text); var author = await authorCore.GetAuthorByAccountIdAsync(account.AccountId); AddEditAuthor newAddAuthorWindow = new AddEditAuthor(author, account); newAddAuthorWindow.ShowDialog(); } else { MessageBox.Show("Author doesn't exist"); } } else { MessageBox.Show("Login empty"); } }
public async Task <bool> LoginAsync(LoginModel loginModel) { var path = Properties.Resources.loginPath; var result = await _apiHelper.Post(path, loginModel); if (result != null && result.ResponseType == ResponseType.Success) { UserCredentials.Account = JsonConvert.DeserializeObject <AccountDTO>(result.Content); UserCredentials.Username = loginModel.Login; UserCredentials.Author = await authorCore.GetAuthorByAccountIdAsync(UserCredentials.Account.AccountId); return(true); } else { return(false); } }