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; }
/// <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; }