Exemplo n.º 1
0
        /// <summary>
        /// Get BankAccountList
        /// </summary>
        /// <returns></returns>
        public async Task <List <BankAccountCacheItem> > GetBankAccountList(AutoSearchInput input)
        {
            var bankCacheItemList = await _bankAccountCache.GetBankAccountCacheItemAsync(CacheKeyStores.CalculateCacheKey(CacheKeyStores.BankAccountKey, Convert.ToInt32(_customAppSession.TenantId)));

            return(bankCacheItemList.WhereIf(!string.IsNullOrEmpty(input.Query), p => p.Description.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                             p.BankAccountName.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper()) ||
                                             p.BankAccountNumber.EmptyIfNull().ToUpper().Contains(input.Query.ToUpper())).ToList());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get Bank Accounts Access List By UserId
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <List <BankAccountAccessListUnitDto> > GetBankAccountAccessList(GetUserSecuritySettingsInputUnit input)
        {
            List <BankAccountCacheItem> bankAccountCacheItems = new List <BankAccountCacheItem>();

            AutoSearchInput cacheInput = new AutoSearchInput()
            {
                OrganizationUnitId = input.OrganizationUnitId
            };
            var bankAccountCache = await _bankAccountCache.GetBankAccountCacheItemAsync(
                CacheKeyStores.CalculateCacheKey(CacheKeyStores.BankAccountKey, Convert.ToInt32(_customAppSession.TenantId)));

            var user = await _userManager.GetUserByIdAsync(input.UserId);

            var organizationUnits = await _organizationExtendedUnitManager.GetExtendedOrganizationUnitsAsync(user, input.EntityClassificationId);

            var organizationUnitIds = organizationUnits.Select(ou => ou.Id);
            var strOrgIds           = string.Join(",", organizationUnitIds.ToArray());


            var values = Enum.GetValues(typeof(TypeOfBankAccount)).Cast <TypeOfBankAccount>().Select(x => x)
                         .ToDictionary(u => u.ToDescription(), u => (int)u).Where(u => u.Value >= 1 && u.Value <= 10)
                         .Select(u => u.Key).ToArray();

            var strTypeOfbankAC = string.Join(",", values);

            if (!string.IsNullOrEmpty(strOrgIds))
            {
                if (ReferenceEquals(input.Filters, null))
                {
                    input.Filters = new List <Filters>();
                }
                var orgfilter = new Filters()
                {
                    Property   = "OrganizationUnitId",
                    Comparator = 6,//In Operator
                    SearchTerm = strOrgIds,
                    DataType   = DataTypes.Text
                };
                input.Filters.Add(orgfilter);
            }

            if (!ReferenceEquals(input.Filters, null))
            {
                Func <BankAccountCacheItem, bool> multiRangeExp = null;
                var multiRangeFilters = input.Filters.Where(u => u.IsMultiRange == true).ToList();
                if (multiRangeFilters.Count != 0)
                {
                    multiRangeExp = ExpressionBuilder.GetExpression <BankAccountCacheItem>(Helper.GetMultiRangeFilters(multiRangeFilters), SearchPattern.Or).Compile();
                    input.Filters.RemoveAll(u => u.IsMultiRange == true);
                }

                var filterCondition = ExpressionBuilder.GetExpression <BankAccountCacheItem>(input.Filters).Compile();
                bankAccountCacheItems = bankAccountCache.ToList()
                                        .Where(u => strTypeOfbankAC.Contains(u.TypeOfBankAccountId.ToString()))
                                        .WhereIf(multiRangeFilters.Count != 0, multiRangeExp)
                                        .Where(filterCondition).ToList();
            }

            return(bankAccountCacheItems.Select(item =>
            {
                var dto = new BankAccountAccessListUnitDto
                {
                    BankAccountNumber = item.BankAccountNumber,
                    BankName = item.Description,
                    AccountName = item.BankAccountName,
                    OrganizationUnitId = item.OrganizationUnitId,
                    BankAccountId = item.BankAccountId
                };
                return dto;
            }).ToList());
        }