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> /// Look up in <paramref name="repository"/> for the <see cref="AccountDTO"/> by the <paramref name="id"/> key. /// If nothing found, null will be returned. /// </summary> /// <param name="id">Account unique ID.</param> /// <param name="repository">Repository to lookup in.</param> /// <returns>Found account instance or null otherwise.</returns> public static AccountDTO LookupIn(this int?id, IAccountsRepository repository) { return(id.HasValue ? repository.ByKey(id.Value) : null); }