Пример #1
0
 public void RemoveScheduledTransaction(ScheduledTransaction scheduledTransaction)
 {
     if (ScheduledTransactions.Remove(scheduledTransaction))
     {
         RaiseDatabaseChanged();
     }
 }
Пример #2
0
        public void Remove(ModelBase obj)
        {
            if (obj is Account)
            {
                Accounts.Remove(obj as Account);

                var transactionIds = Transactions.SelectMany(t => t.Details).Where(t => t.AccountId == ((Account)obj).Id).Select(t => t.TransactionId);

                foreach (var transId in transactionIds)
                {
                    Remove(Transactions.FirstOrDefault(t => t.Id == transId));
                }

                foreach (var schedTrans in ScheduledTransactions.Where(t => t.FromAccountId == ((Account)obj).Id || t.ToAccountId == ((Account)obj).Id).ToList())
                {
                    Remove(schedTrans);
                }
            }
            else if (obj is Transaction)
            {
                Transactions.Remove(obj as Transaction);

                foreach (var detail in TransactionDetails.Where(t => t.TransactionId == ((Transaction)obj).Id).ToList())
                {
                    Remove(detail);
                }
            }
            else if (obj is TransactionDetail)
            {
                TransactionDetails.Remove(obj as TransactionDetail);
            }
            else if (obj is Receipt)
            {
                Receipts.Remove(obj as Receipt);
            }
            else if (obj is ScheduledTransaction)
            {
                ScheduledTransactions.Remove(obj as ScheduledTransaction);

                foreach (var detail in ScheduledTransactionDetails.Where(t => t.ScheduledTransactionId == ((ScheduledTransaction)obj).Id).ToList())
                {
                    Remove(detail);
                }
            }
            else if (obj is ScheduledTransactionDetail)
            {
                ScheduledTransactionDetails.Remove(obj as ScheduledTransactionDetail);
            }
            else if (obj is Category)
            {
                Categories.Remove(obj as Category);
            }
            else if (obj is Product)
            {
                Products.Remove(obj as Product);
            }
        }