private async void SaveButton_Click(object sender, RoutedEventArgs e) { if (CustomerComboBox.SelectedItem != null) { var newJob = new JobPOCO { Complete = false, ComponentsUsed = new Dictionary <long, int>(), Description = "" }; await DatabaseProvider.Database.AddJob(newJob); var newCustomerOrder = new CustomerOrderPOCO { LinkedJobId = newJob.Id, CustomerId = MainWindow.AllCustomers.Find(x => $"{x.Id}: {x.FullName}" == (string)CustomerComboBox.SelectedItem).Id, OrderDate = OrderDatePicker.SelectedDate.Value, OrderType = OrderTypeTextBox.Text, OrderDetals = OrderDescriptionTextBox.Text, Completed = false }; await DatabaseProvider.Database.AddCustomerOrder(newCustomerOrder); newJob.Description = $"Относится к заказу #{newCustomerOrder.Id}"; await DatabaseProvider.Database.UpdateJob(newJob); MainWindow.AllJobs.Add(await FullJobPOCO.BuildFullJobDTO(newJob)); MainWindow.AllOrders.Add(await CustomerOrderFullPOCO.BuildCustomerOrderFullDTO(newCustomerOrder)); ((MainWindow)this.Owner).RefreshJobsDataGrid(); ((MainWindow)this.Owner).JobsDataGrid_SelectionChanged(null, null); ((MainWindow)this.Owner).RefreshOrdersDataGrid(); ((MainWindow)this.Owner).CustomerOrdersDatagrid_SelectionChanged(null, null); this.Close(); } }
private async void FillCustomerOrders() { AllOrders = (await Task.WhenAll((await DatabaseProvider.Database.GetAllCustomerOrders()).Select(async x => await CustomerOrderFullPOCO.BuildCustomerOrderFullDTO(x)))).ToList(); var _itemSourceList = new CollectionViewSource() { Source = AllOrders }; ICollectionView orderDatagridItemList = _itemSourceList.View; orderDatagridItemList.Filter = CustomerOrdersDatagridFilter; CustomerOrdersDatagrid.ItemsSource = orderDatagridItemList; }