예제 #1
0
        public void Create(int accountId, DateTime date)
        {
            DisplayName = "New Transfer";

            transactionId = null;
            InitSourceAccounts();
            InitTargetAccounts();

            var sourceAccount = accountsRepository.ByKey(accountId);

            SourceAccounts.MoveCurrentTo(sourceAccount);
            prevSourceAccont = (AccountDTO)SourceAccounts.CurrentItem;

            var targetAccount = accountsRepository.Entities.Where(dto => dto.AssetTypeId == sourceAccount.AssetTypeId).Skip(1).FirstOrDefault();

            if (targetAccount != null)
            {
                TargetAccounts.MoveCurrentTo(targetAccount);
                prevTargetAccont = (AccountDTO)TargetAccounts.CurrentItem;
            }

            OperationDate   = date;
            Amount          = string.Empty;
            AmountIsFocused = true;
            Comment         = string.Empty;

            IsEditMode = false;
        }
예제 #2
0
        private void InitSourceAccounts()
        {
            sourceAccountsViewSource.Source = accountsRepository.Entities.ToList();

            if (!SourceAccounts.IsEmpty)
            {
                SourceAccounts.MoveCurrentToFirst();
            }
        }
예제 #3
0
        public override int GetHashCode()
        {
            int hash = 17;

            unchecked
            {
                hash = hash * 23 + Type.GetHashCode();
                hash = SourceAccounts.OrderBy(x => x).Aggregate(hash, (current, acc) => current * 23 + acc.GetHashCode());
                hash = TargetAccounts.OrderBy(x => x).Aggregate(hash, (current, acc) => current * 23 + acc.GetHashCode());
            }
            return(hash);
        }
예제 #4
0
        public override bool Equals(object obj)
        {
            var other = obj as ColumnDefinition;

            if (other?.Type != Type)
            {
                return(false);
            }

            return(SourceAccounts.Compare(other.SourceAccounts) &&
                   TargetAccounts.Compare(other.TargetAccounts));
        }
예제 #5
0
        /// <summary>
        /// Open specific transfer to edit.
        /// </summary>
        /// <param name="transfer">Transfer to edit.</param>
        /// <param name="firstAccountId">First account of the transfer.</param>
        public void Edit(TransferDTO transfer, int firstAccountId)
        {
            DisplayName = "Edit Transfer";
            InitSourceAccounts();
            InitTargetAccounts();

            transactionId = transfer.Id;

            var        firstAccount  = accountsRepository.ByKey(firstAccountId);
            AccountDTO secondAccount = null;

            if (transfer.SecondAccountId.HasValue)
            {
                secondAccount = accountsRepository.ByKey(transfer.SecondAccountId.Value);
            }

            if (transfer is IncomingTransferDTO)
            {
                Amount = transfer.Amount.ToString();

                TargetAccounts.MoveCurrentTo(firstAccount);

                if (secondAccount != null)
                {
                    SourceAccounts.MoveCurrentTo(secondAccount);
                }
            }
            else if (transfer is OutgoingTransferDTO)
            {
                Amount = (-transfer.Amount).ToString();
                SourceAccounts.MoveCurrentTo(firstAccount);

                if (secondAccount != null)
                {
                    TargetAccounts.MoveCurrentTo(secondAccount);
                }
            }

            AmountIsFocused = true;

            prevSourceAccont = (AccountDTO)SourceAccounts.CurrentItem;
            prevTargetAccont = (AccountDTO)TargetAccounts.CurrentItem;

            OperationDate = transfer.Date.ToLocalTime();
            Comment       = transfer.Comment;

            IsEditMode = true;
        }