private void UpdateOtherComboBox()
        {
            var tempCollection = new ObservableCollection <AccountViewModel>(ChargedAccounts);

            foreach (var account in TargetAccounts)
            {
                if (!tempCollection.Contains(account))
                {
                    tempCollection.Add(account);
                }
            }
            foreach (var account in tempCollection)
            {
                //fills targetaccounts
                if (!TargetAccounts.Contains(account))
                {
                    TargetAccounts.Add(account);
                }

                //fills chargedaccounts
                if (!ChargedAccounts.Contains(account))
                {
                    ChargedAccounts.Add(account);
                }
            }
            ChargedAccounts.Remove(selectedPayment.TargetAccount);
            TargetAccounts.Remove(selectedPayment.ChargedAccount);
        }
Exemple #2
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;
        }
        private void UpdateOtherComboBox()
        {
            ObservableCollection <Account> tempCollection = new ObservableCollection <Account>(ChargedAccounts);

            foreach (Account i in TargetAccounts)
            {
                if (!tempCollection.Contains(i))
                {
                    tempCollection.Add(i);
                }
            }
            foreach (Account i in tempCollection)
            {
                if (!TargetAccounts.Contains(i))//fills targetaccounts
                {
                    TargetAccounts.Add(i);
                }

                if (!ChargedAccounts.Contains(i))//fills chargedaccounts
                {
                    ChargedAccounts.Add(i);
                }
            }
            ChargedAccounts.Remove(selectedPayment.TargetAccount);
            TargetAccounts.Remove(selectedPayment.ChargedAccount);
        }
Exemple #4
0
        public override async Task Initialize()
        {
            await base.Initialize().ConfigureAwait(true);

            SelectedPayment.ChargedAccount = ChargedAccounts.FirstOrDefault();

            if (SelectedPayment.IsTransfer)
            {
                SelectedItemChangedCommand.Execute();
                SelectedPayment.TargetAccount = TargetAccounts.FirstOrDefault();
            }
        }
Exemple #5
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);
        }
Exemple #6
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));
        }
Exemple #7
0
        protected override async Task Initialize()
        {
            Title = PaymentTypeHelper.GetViewTitleForType(PaymentType, false);
            SelectedPayment.Type = PaymentType;

            await base.Initialize();

            SelectedPayment.ChargedAccount = ChargedAccounts.FirstOrDefault();

            if (SelectedPayment.IsTransfer)
            {
                SelectedItemChangedCommand.Execute(null);
                SelectedPayment.TargetAccount = TargetAccounts.FirstOrDefault();
            }
        }
Exemple #8
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;
        }
        private void PrepareEdit()
        {
            IsTransfer = SelectedPayment.IsTransfer;
            // set the private amount property. This will get properly formatted and then displayed.
            amount     = SelectedPayment.Amount;
            Recurrence = SelectedPayment.IsRecurring
                ? SelectedPayment.RecurringPayment.Recurrence
                : PaymentRecurrence.Daily;
            EndDate = SelectedPayment.IsRecurring
                ? SelectedPayment.RecurringPayment.EndDate
                : DateTime.Now;
            IsEndless = !SelectedPayment.IsRecurring || SelectedPayment.RecurringPayment.IsEndless;

            // we have to set the AccountViewModel objects here again to ensure that they are identical to the
            // objects in the AccountViewModel collections.
            selectedPayment.ChargedAccount =
                ChargedAccounts.FirstOrDefault(x => x.Id == selectedPayment.ChargedAccountId);
            selectedPayment.TargetAccount =
                TargetAccounts.FirstOrDefault(x => x.Id == selectedPayment.TargetAccountId);
        }
 public AccountSelectViewModel this[int accountTypeId] {
     get { return(TargetAccounts.Single(x => x.AccountType.Id == accountTypeId)); }
 }