private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var index = MainPivot.SelectedIndex; var selectedItem = index == 0 ? ListView.SelectedItem : PlantOrderListView.SelectedItem; if (selectedItem is PlantOrderModel plantOrder) { if (index == 1 && DivisionComboBox.SelectedItem is DivisionModel division) { var session = new ProjectPlantOrderSession() { PlantOrder = plantOrder, Division = division }; await ProductionCollection.Add(session); Division = division; Result = plantOrder; } else if (index == 0) { var session = ProductionCollection.Find(plantOrder); if (session != null) { Division = session.Division; Result = session.PlantOrder; } } } else { args.Cancel = true; } }
public Task <bool> Remove(ProjectPlantOrderSession session) { if (PlantOrderSession.Remove(session)) { return(Save()); } return(Task.FromResult(false)); }
public Task <bool> Add(ProjectPlantOrderSession session) { if (!PlantOrderSession.Exists(x => x.PlantOrder.Number == session.PlantOrder.Number)) { PlantOrderSession.Add(session); return(Save()); } return(Task.FromResult(false)); }