コード例 #1
0
        public IActionResult ProductAddPopup(string btnId, CustomerTagProductModel.AddProductModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
                return AccessDeniedView();

            if (model.SelectedProductIds != null)
            {
                foreach (string id in model.SelectedProductIds)
                {
                    var product = _productService.GetProductById(id);
                    if (product != null)
                    {
                        var customerTagProduct = _customerTagService.GetCustomerTagProduct(model.CustomerTagId, id);
                        if (customerTagProduct == null)
                        {
                            customerTagProduct = new CustomerTagProduct();
                            customerTagProduct.CustomerTagId = model.CustomerTagId;
                            customerTagProduct.ProductId = id;
                            customerTagProduct.DisplayOrder = 0;
                            _customerTagService.InsertCustomerTagProduct(customerTagProduct);
                        }
                    }
                }
            }

            //a vendor should have access only to his products
            ViewBag.RefreshPage = true;
            ViewBag.btnId = btnId;
            return View(model);
        }
コード例 #2
0
        /// <summary>
        /// Delete a customer tag product
        /// </summary>
        /// <param name="customerTagProduct">Customer tag product</param>
        public virtual void DeleteCustomerTagProduct(CustomerTagProduct customerTagProduct)
        {
            if (customerTagProduct == null)
            {
                throw new ArgumentNullException("customerTagProduct");
            }

            _customerTagProductRepository.Delete(customerTagProduct);

            //clear cache
            _cacheManager.RemoveByPattern(string.Format(CUSTOMERTAGPRODUCTS_ROLE_KEY, customerTagProduct.CustomerTagId));
            _cacheManager.RemoveByPattern(PRODUCTS_CUSTOMER_TAG);
            //event notification
            _eventPublisher.EntityDeleted(customerTagProduct);
        }
コード例 #3
0
        /// <summary>
        /// Inserts a customer tag product
        /// </summary>
        /// <param name="customerTagProduct">Customer tag product</param>
        public virtual async Task InsertCustomerTagProduct(CustomerTagProduct customerTagProduct)
        {
            if (customerTagProduct == null)
            {
                throw new ArgumentNullException("customerTagProduct");
            }

            await _customerTagProductRepository.InsertAsync(customerTagProduct);

            //clear cache
            _cacheManager.RemoveByPattern(string.Format(CUSTOMERTAGPRODUCTS_ROLE_KEY, customerTagProduct.CustomerTagId));
            _cacheManager.RemoveByPattern(PRODUCTS_CUSTOMER_TAG);

            //event notification
            await _eventPublisher.EntityInserted(customerTagProduct);
        }
コード例 #4
0
        /// <summary>
        /// Delete a customer tag product
        /// </summary>
        /// <param name="customerTagProduct">Customer tag product</param>
        public virtual async Task DeleteCustomerTagProduct(CustomerTagProduct customerTagProduct)
        {
            if (customerTagProduct == null)
            {
                throw new ArgumentNullException("customerTagProduct");
            }

            await _customerTagProductRepository.DeleteAsync(customerTagProduct);

            //clear cache
            await _cacheManager.RemoveAsync(string.Format(CacheKey.CUSTOMERTAGPRODUCTS_ROLE_KEY, customerTagProduct.CustomerTagId));

            await _cacheManager.RemoveByPrefix(CacheKey.PRODUCTS_CUSTOMER_TAG_PATTERN);

            //event notification
            await _mediator.EntityDeleted(customerTagProduct);
        }
コード例 #5
0
 public virtual void InsertProductModel(CustomerTagProductModel.AddProductModel model)
 {
     foreach (string id in model.SelectedProductIds)
     {
         var product = _productService.GetProductById(id);
         if (product != null)
         {
             var customerTagProduct = _customerTagService.GetCustomerTagProduct(model.CustomerTagId, id);
             if (customerTagProduct == null)
             {
                 customerTagProduct = new CustomerTagProduct();
                 customerTagProduct.CustomerTagId = model.CustomerTagId;
                 customerTagProduct.ProductId     = id;
                 customerTagProduct.DisplayOrder  = 0;
                 _customerTagService.InsertCustomerTagProduct(customerTagProduct);
             }
         }
     }
 }