public async Task <ListProductCategoryDTO> GetProdCateByParentIDFromMenu(string UserId, int?productTypeId, int?statusTypeId, int parentId = 656)
        {
            var output = new ListProductCategoryDTO();
            var result = await _repoWrapper.ProductCategory.GetMenuProdCateByUser(UserId, productTypeId, statusTypeId, parentId);

            output.Data = _mapper.Map <IEnumerable <ProductCategoryDTO> >(result);
            return(output);
        }
Exemple #2
0
        public async Task <ListProductCategoryDTO> GetProdCateByParentID(string keyword, int?productCategoryId)
        {
            ListProductCategoryDTO output = new ListProductCategoryDTO();
            string apiUrl       = $"/api/v1/ProductCategory/GetProdCateByParentID";
            string paramRequest = $"?keyword={keyword}&parentId={productCategoryId}";
            var    response     = await _client.GetAsync(apiUrl + paramRequest);

            if (response.IsSuccessStatusCode)
            {
                string responseStream = await response.Content.ReadAsStringAsync();

                output = JsonConvert.DeserializeObject <ListProductCategoryDTO>(responseStream);
            }
            return(output);
        }
Exemple #3
0
        public async Task <ListProductCategoryDTO> GetLstMenuByParentId(int parentId)
        {
            ListProductCategoryDTO output = new ListProductCategoryDTO();

            try
            {
                output = await _repoWrapper.ProductCategory.GetLstMenuByParentId(parentId);
            }
            catch (Exception ex)
            {
                _logger.LogError($"HomeController- GetLstMenuByParentId- {parentId} {ex.ToString()}");
            }

            return(output);
        }
        public async Task <ListProductCategoryDTO> GetProdCateByParentID(int?parentId, string keyword = "")
        {
            var output = new ListProductCategoryDTO();
            //var cacheKey = $"ProductCategory_GetProdCateByParentID{keyword}{parentId}";
            //var redisEncode = await _distributedCache.GetStringAsync(cacheKey);
            //if (redisEncode != null)
            //{
            //    output = JsonConvert.DeserializeObject<ListProductCategoryDTO>(redisEncode);
            //}
            //else
            //{
            var result = await _repoWrapper.ProductCategory.GetTopCateByParentId(keyword, parentId);

            output.Data = _mapper.Map <IEnumerable <ProductCategoryDTO> >(result);
            //    await _distributedCache.SetStringAsync(cacheKey, JsonConvert.SerializeObject(output), Utils.Util.RedisOptions());
            //}
            return(output);
        }
Exemple #5
0
        async Task <(ListProductCategoryDTO MenuMachine, ListProductCategoryDTO MenuMaterials, ListProductCategoryDTO MenuServices)> GetCategoryMenu()
        {
            ListProductCategoryDTO MenuMachine   = new ListProductCategoryDTO();
            ListProductCategoryDTO MenuMaterials = new ListProductCategoryDTO();
            ListProductCategoryDTO MenuServices  = new ListProductCategoryDTO();

            try
            {
                var cacheKey    = $"GetMenu-654";
                var redisEncode = await _distributedCache.GetStringAsync(cacheKey);

                if (redisEncode != null)
                {
                    MenuMachine = JsonConvert.DeserializeObject <ListProductCategoryDTO>(redisEncode);
                }
                else
                {
                    MenuMachine = await _repoWrapper.ProductCategory.GetLstMenuByParentId(654);

                    await _distributedCache.SetStringAsync(cacheKey, JsonConvert.SerializeObject(MenuMachine), CommonHelper.RedisOptions());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"ProductController- GetMenu654 {ex.ToString()}");
            }

            try
            {
                var cacheKey    = $"GetMenu-652";
                var redisEncode = await _distributedCache.GetStringAsync(cacheKey);

                if (redisEncode != null)
                {
                    MenuMaterials = JsonConvert.DeserializeObject <ListProductCategoryDTO>(redisEncode);
                }
                else
                {
                    MenuMaterials = await _repoWrapper.ProductCategory.GetLstMenuByParentId(652);

                    await _distributedCache.SetStringAsync(cacheKey, JsonConvert.SerializeObject(MenuMaterials), CommonHelper.RedisOptions());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"ProductController- GetMenu652 {ex.ToString()}");
            }


            try
            {
                var cacheKey    = $"GetMenu-651";
                var redisEncode = await _distributedCache.GetStringAsync(cacheKey);

                if (redisEncode != null)
                {
                    MenuServices = JsonConvert.DeserializeObject <ListProductCategoryDTO>(redisEncode);
                }
                else
                {
                    MenuServices = await _repoWrapper.ProductCategory.GetLstMenuByParentId(651);

                    await _distributedCache.SetStringAsync(cacheKey, JsonConvert.SerializeObject(MenuServices), CommonHelper.RedisOptions());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"ProductController- GetMenuService {ex.ToString()}");
            }

            return(MenuMachine, MenuMaterials, MenuServices);
        }