Exemplo n.º 1
0
        /// <summary>
        /// Open specific transfer transaction to edit.
        /// </summary>
        /// <param name="transaction">Transaction to edit.</param>
        public void Edit(TransactionDTO transaction)
        {
            transactionId = transaction.Id;

            // Todo: refactor this method!
            var accountsSource1 = accounts1CollectionViewSource.Source as BindableCollection <AccountDTO>;

            if (accountsSource1 != null)
            {
                var selectedAccount1 = accountsSource1.Where(a => a.Id == transaction.Postings[1].Account.Id).Single();
                Accounts1.MoveCurrentTo(selectedAccount1);
            }

            var accountsSource2 = accounts2CollectionViewSource.Source as BindableCollection <AccountDTO>;

            if (accountsSource2 != null)
            {
                var selectedAccount2 = accountsSource2.Where(a => a.Id == transaction.Postings[0].Account.Id).Single();
                Accounts2.MoveCurrentTo(selectedAccount2);
            }

            OperationDate = transaction.Postings[0].Date.ToLocalTime();
            Amount        = transaction.Postings[0].Amount.ToString();
            Comment       = transaction.Comment;

            IsEditMode = true;
        }
Exemplo n.º 2
0
 public void Clear()
 {
     transactionId = null;
     IsEditMode    = false;
     Accounts1.MoveCurrentToFirst();
     Accounts2.MoveCurrentToFirst();
     OperationDate = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Unspecified);
     Amount        = string.Empty;
     Comment       = string.Empty;
 }