コード例 #1
0
 public async Task<IActionResult> productList(int categoryId = 0 , string productName = null)
 {
     var user = _userService.getIdentityUserByUserNameOrPhoneNumber(userName: User.Identity.Name);
     var vendor = await _roleService.IsUserInSpecificRole(user.Id, "Vendor");
     var admin = await _roleService.IsUserInSpecificRole(user.Id, "Admin");
     var vendorId = (vendor == true && !admin) ? user.Id : null; 
     var products = _productService.getProductByCategoryIdList(categoryId, productName, vendorId:vendorId);
     var productsModel = _productModelFactory.getProductModelList(products);
     var productListModel = new ProductsListModel();
     productListModel.ProductsModel = productsModel;
     return View("~/Admin/Views/Product/Product.cshtml",productListModel);
 }
コード例 #2
0
        public IActionResult Index(int categoryId = 0)
        {
            var key1 = String.Format(CacheEventConsumer.getProductByCategoryKey, categoryId, User.Identity.Name);
            List <ProductModel> productModels;

            if (!_memoryCache.TryGetValue(key1, out productModels))
            {
                var productslist = _productService.getProductByCategoryIdList(categoryId: categoryId, publish: false);
                _memoryCache.Set(key1, _productModelFactory.getProductModelList(productslist));
            }
            productModels = _memoryCache.Get(key1) as List <ProductModel>;
            return(View(productModels));
        }