public async Task<bool> PostSoftware(SoftwareDetailDto software) { HttpResponseMessage response = await _client.PostAsJsonAsync<SoftwareDetailDto>("api/Softwares", software); if (!response.IsSuccessStatusCode) { string responseMessage = await response.Content.ReadAsStringAsync(); _logger.Error(responseMessage); return false; } return true; }
private async void btnSave_Click(object sender, RoutedEventArgs e) { SoftwareDetailDto software = new SoftwareDetailDto() { Name = txtName.Text, ManufacturerId = ((ManufacturerDto)cmbManufacturer.SelectedItem).Id, GenreId = (int)cmbGenre.SelectedItem, Description = null }; bool? success; using (var client = new SoftwaresClient(Global.Properties.BaseUrl)) { success = await client.PostSoftware(software); } if (success == null) { throw new NotImplementedException(); } if (!success.HasValue) { throw new NotImplementedException(); } if (!success.Value) { throw new NotImplementedException(); } this.Close(); }