private async void btnSave_Click(object sender, EventArgs e) { btnSave.Enabled = false; btnCancel.Enabled = false; saveProgress.Visible = true; // Gathers information from form var authorPost = new AuthorPost { FirstName = tbFirstName.Text, LastName = tbLastName.Text, Biography = tbBio.Text, }; if (int.TryParse(tbYearBirth.Text, out var yearBirth)) { authorPost.YearBirth = yearBirth; } if (int.TryParse(tbYearDeath.Text, out var yearDeath)) { authorPost.YearDeath = yearDeath; } // Updates existing author await _client.CreateAuthor(authorPost); }
public async Task <bool> CreateAuthor(AuthorPost author) { var content = BuildContent(author); var response = await PostAsync("authors/", content); return(response.IsSuccessStatusCode); }
private async void button2_Click(object sender, EventArgs e) { // Gathers information from form var authorPost = new AuthorPost { Id = _authorId, FirstName = tbFirstName.Text, LastName = tbLastName.Text, Biography = tbBio.Text, }; if (int.TryParse(tbYearBirth.Text, out var yearBirth)) { authorPost.YearBirth = yearBirth; } if (int.TryParse(tbYearDeath.Text, out var yearDeath)) { authorPost.YearDeath = yearDeath; } // Updates existing author await _client.UpdateAuthor(authorPost); }