Exemple #1
0
        private async void CashTransactionsGrid_OnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            //here we set the trade selected in the picker popup
            if ((string)e.Column.Header == "Trade")
            {
                if (e.EditAction == DataGridEditAction.Commit)
                {
                    var ct            = (CashTransaction)CashTransactionsGrid.SelectedItem;
                    var items         = CtGridTradePickerListBox.Items.Cast <CheckListItem <Trade> >().ToList();
                    var selectedTrade = items.FirstOrDefault(x => x.IsChecked);

                    if (selectedTrade == null)
                    {
                        await TradesRepository.RemoveCashTransaction(ct.Trade, ct).ConfigureAwait(true);
                    }
                    else
                    {
                        await TradesRepository.AddCashTransaction(selectedTrade.Item, ct).ConfigureAwait(true);
                    }
                }
                await Context.SaveChangesAsync().ConfigureAwait(true);

                CashTransactionsGridTradePickerPopup.IsOpen = false;
            }
        }