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(); }
private async Task LoadContent() { using (var client = new ManufacturersClient(Global.Properties.BaseUrl)) { Global.Content.Manufacturers = await client.GetManufacturers(); } using (var client = new SoftwaresClient(Global.Properties.BaseUrl)) { Global.Content.Softwares = await client.GetSoftwares(); } }
private async void btnDeleteSoftware_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show( "Do you really want to delete this software? \n All licenses of this software will deleted too.", "Are you sure?", MessageBoxButton.YesNo ); if (result == MessageBoxResult.No) { return; } bool success = false; using (var client = new SoftwaresClient(Global.Properties.BaseUrl)) { // TODO get software id from anywhere else success = await client.DeleteSoftware(((SoftwareDto)lst1.SelectedItem).Id); } if (!success) { return; } Thread.Sleep(1000); RefreshData(); }
private async void ShowSoftwareDetails(SoftwareDto sw) { if (!UserLoggedIn()) { if (!Login()) { return; } } SoftwareDetailDto software = null; using (var client = new SoftwaresClient(Global.Properties.BaseUrl)) { software = await client.GetSoftware(sw.Id); } if (software == null) { return; } SoftwareDetailGrid.Visibility = System.Windows.Visibility.Visible; lblTitle.Content = sw.ToString(); txtManufacturer.Text = software.ManufacturerName; txtName.Text = software.Name; txtGenre.Text = software.GenreName; txtDescription.Text = software.Description; DataGrid1.ItemsSource = software.Licenses; menuSoftwareNewLicense.IsEnabled = true; menuSoftwareDelete.IsEnabled = true; }