/// <summary> /// Retrieve specific accounts by ID. /// </summary> /// <param name="accountId">Account ID to retrieve.</param> /// <returns>Account data transfer object.</returns> public AccountDTO GetAccount(int accountId) { using (var mc = new ModelContainer(GetPersonalConnection(UserName))) { var accountMapper = ObjectMapperManager.DefaultInstance.GetMapper <Account, AccountDTO>(AccountMapper.AccountMappingConfigurator); var result = accountMapper.Map(ModelHelper.GetAccountById(mc, accountId)); return(AccountMapper.SetUTCforAccountNullableDates(result)); } }
/// <summary> /// Retrieve all accounts for user. /// </summary> /// <returns>All accounts.</returns> public IList <AccountDTO> GetAllAccounts() { using (var mc = new ModelContainer(GetPersonalConnection(UserName))) { var accountMapper = ObjectMapperManager.DefaultInstance.GetMapper <Account, AccountDTO>(AccountMapper.AccountMappingConfigurator); var result = mc.Accounts.Include("AssetType") .Where(a => !a.IsSystem && !a.IsClosed) .OrderBy(a => a.Created) .ToList() .Select(accountMapper.Map) .ToList(); foreach (var account in result) { AccountMapper.SetUTCforAccountNullableDates(account); } return(result); } }