Ejemplo n.º 1
0
        public async Task <ProductAttributesAndFilter> GetProductAttributesAndFilterAsync(FilterBase filters)
        {
            ProductAttributesAndFilter result = new ProductAttributesAndFilter()
            {
                Filters       = filters,
                SortEnumArray = sortEnumArrayProductAttributes
            };
            string keyName = $"Attributes{filters.GetFilterName()}",
                   keyNameAllAttributes = "AllAttributes";
            List <ProductsAttribute> productAttributes = _cacheService.Get <List <ProductsAttribute> >(keyName);

            if (productAttributes == null)
            {
                productAttributes = _cacheService.Get <List <ProductsAttribute> >(keyNameAllAttributes);
                if (productAttributes == null)
                {
                    productAttributes = await _fcdStoreContext.GetAllProductsAttributesAsync();

                    _cacheService.Set <List <ProductsAttribute> >(keyNameAllAttributes, productAttributes);
                }
                if (productAttributes != null && productAttributes.Count > 0)
                {
                    result.ProductAttributes = productAttributes;
                    _dataFiltering.Filtering(result);
                    productAttributes = result.ProductAttributes;
                    _cacheService.Set <List <ProductsAttribute> >(keyName, productAttributes);
                }
            }
            result.ProductAttributes = productAttributes;
            _dataFiltering.SetFilters(result);
            result.ProductAttributes = _dataFiltering.Paginator <ProductsAttribute>(result.ProductAttributes, (int)filters.CountVisablePositions, (int)filters.CurrentPosition);
            return(result);
        }
Ejemplo n.º 2
0
        public async Task <ProductTypeMiniAndFilters> GetProductTypeMinisAsync(FilterBase filters)
        {
            ProductTypeMiniAndFilters result = new ProductTypeMiniAndFilters()
            {
                Filters       = filters,
                SortEnumArray = sortEnumArrayProducts
            };
            string keyName = $"ProductTypeMinis{filters.GetFilterName()}",
                   keyNameAllProductTypeMini        = "ProductTypeMini";
            List <ProductTypeMini> productTypeMinis = _cacheService.Get <List <ProductTypeMini> >(keyName);

            if (productTypeMinis == null)
            {
                productTypeMinis = _cacheService.Get <List <ProductTypeMini> >(keyNameAllProductTypeMini);
                if (productTypeMinis == null || productTypeMinis.Count == 0)
                {
                    productTypeMinis = await _fcdStoreContext.GetProductTypeMinisAsync();

                    _cacheService.Set <List <ProductTypeMini> >(keyNameAllProductTypeMini, productTypeMinis);
                }
                result.ProductTypeMinis = productTypeMinis;
                _dataFiltering.Filtering(result);
                productTypeMinis = result.ProductTypeMinis;
                _cacheService.Set <List <ProductTypeMini> >(keyName, productTypeMinis);
            }
            result.ProductTypeMinis = productTypeMinis;
            _dataFiltering.SetFilters(result);
            result.ProductTypeMinis = _dataFiltering.Paginator <ProductTypeMini>(result.ProductTypeMinis, (int)filters.CountVisablePositions, (int)filters.CurrentPosition);
            return(result);
        }
Ejemplo n.º 3
0
        public async Task <UsersBaseInfoAndFilters> GetUsersAsync(FilterBase filters)
        {
            UsersBaseInfoAndFilters result = new UsersBaseInfoAndFilters
            {
                Filters       = filters,
                SortEnumArray = sortEnumArrayUsers
            };
            string keyName       = $"UserList{filters.GetFilterName()}";
            var    userBaseInfos = _cacheService.Get <List <UserBaseInfo> >(keyName);

            if (userBaseInfos == null)
            {
                userBaseInfos = await _fcdUserAndSignManager.GetUserBaseInfosAsync();

                result.UserBaseInfos = userBaseInfos;
                _dataFiltering.Filtering(result);
                userBaseInfos = result.UserBaseInfos;
                _cacheService.Set <List <UserBaseInfo> >(keyName, userBaseInfos);
            }
            result.UserBaseInfos = userBaseInfos;
            _dataFiltering.SetFilters(result);
            result.UserBaseInfos = _dataFiltering.Paginator <UserBaseInfo>(result.UserBaseInfos, (int)filters.CountVisablePositions, (int)filters.CurrentPosition);
            return(result);
        }