Beispiel #1
0
        /// <summary>
        /// Get SubAccounts List based on OrganizationUnitId
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <SubAccountCacheItem> > GetSubAccountList(AutoSearchInput input)
        {
            var cacheItem = await _subAccountCache.GetSubAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.SubAccountKey, Convert.ToInt32(_customAppSession.TenantId)));

            var subaccountRestrictioncacheItem = await _subAccountRestrictionCache.GetSubAccountRestrictionCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.SubAccountRestrictionKey, Convert.ToInt32(_customAppSession.TenantId)));

            if (input.AccountId == 0 || subaccountRestrictioncacheItem.Count == 0)
            {
                return
                    (cacheItem.ToList()
                     .WhereIf(!string.IsNullOrEmpty(input.Query),
                              p => p.Caption.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                              p.Description.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                              p.SubAccountNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                              p.SearchNo.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).ToList());
            }
            else
            {
                var res = from subaccount in cacheItem.ToList()
                          join subAccountRestriction in subaccountRestrictioncacheItem.Where(p => p.AccountId == input.AccountId)
                          on subaccount.SubAccountId equals subAccountRestriction.SubAccountId
                          select subaccount;
                return(res.ToList().WhereIf(!string.IsNullOrEmpty(input.Query),
                                            p => p.Caption.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                            p.Description.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                            p.SubAccountNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                            p.SearchNo.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).ToList());
            }
        }
Beispiel #2
0
        /// <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());
        }