/// <summary> /// Get SubAccountRestrictions By SubAccountId /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <List <SubAccountRestrictionUnitDto> > GetAccountList(GetAccountRestrictionInput input) { var cacheItem = await _accountCache.GetAccountCacheItemAsync( CacheKeyStores.CalculateCacheKey(CacheKeyStores.AccountKey, Convert.ToInt32(_customAppSession.TenantId))); var subaccountRestrictioncacheItem = await _subAccountRestrictionCache.GetSubAccountRestrictionCacheItemAsync( CacheKeyStores.CalculateCacheKey(CacheKeyStores.SubAccountRestrictionKey, Convert.ToInt32(_customAppSession.TenantId))); List <SubAccountRestrictionCacheItem> subaccountRestrictions = new List <SubAccountRestrictionCacheItem>(); if (!ReferenceEquals(subaccountRestrictioncacheItem, null)) { subaccountRestrictions = subaccountRestrictioncacheItem.ToList().Where( p => p.IsActive == true && p.SubAccountId == input.SubAccountId.Value).ToList(); } var result = cacheItem.ToList().Where(p => subaccountRestrictions.All(p2 => p2.AccountId != p.AccountId) && p.IsCorporate).ToList(); return(result.Select(item => { var dto = new SubAccountRestrictionUnitDto(); dto.AccountId = item.AccountId; dto.SubAccountId = input.SubAccountId.Value; dto.AccountNumber = item.AccountNumber; dto.SubAccountRestrictionId = 0; dto.Caption = item.Caption; dto.Description = item.Description; return dto; }).ToList()); }
/// <summary> /// Get SubAccountRestrictions By SubAccountId /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <List <SubAccountRestrictionUnitDto> > GetAccountRestrictionList(GetAccountRestrictionInput input) { var query = from subaccountrestriction in _subAccountRestrictionUnitRepository.GetAll() join account in _accountUnitRepository.GetAll() on subaccountrestriction.AccountId equals account.Id select new { subaccountrestriction, Caption = account.Caption, AccountNumber = account.AccountNumber, Description = account.Description }; var subAccountRestrictionList = await query.Where(p => p.subaccountrestriction.SubAccountId == input.SubAccountId && p.subaccountrestriction.IsActive == true).ToListAsync(); return(subAccountRestrictionList.Select(item => { var dto = item.subaccountrestriction.MapTo <SubAccountRestrictionUnitDto>(); dto.SubAccountRestrictionId = item.subaccountrestriction.Id; dto.AccountNumber = item.AccountNumber; dto.Caption = item.Caption; dto.Description = item.Description; return dto; }).ToList()); }