protected void btnNewPrice_Click(object sender, EventArgs e)
        {
            try
            {
                var productVariant = this.ProductService.GetProductVariantById(this.ProductVariantId);
                if (productVariant != null)
                {
                    int customerRoleId = int.Parse(ddlNewCustomerRole.SelectedItem.Value);
                    decimal price = txtNewPrice.Value;
                    var crpp = new CustomerRoleProductPrice()
                    {
                        CustomerRoleId = customerRoleId,
                        ProductVariantId = productVariant.ProductVariantId,
                        Price = price
                    };
                    this.ProductService.InsertCustomerRoleProductPrice(crpp);

                    BindData();
                }
            }
            catch (Exception exc)
            {
                processAjaxError(exc);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates a product price by customer role
        /// </summary>
        /// <param name="customerRoleProductPrice">A product price by customer role</param>
        public void UpdateCustomerRoleProductPrice(CustomerRoleProductPrice customerRoleProductPrice)
        {
            if (customerRoleProductPrice == null)
                throw new ArgumentNullException("customerRoleProductPrice");

            if (!_context.IsAttached(customerRoleProductPrice))
                _context.CustomerRoleProductPrices.Attach(customerRoleProductPrice);

            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(PRODUCTS_PATTERN_KEY);
                _cacheManager.RemoveByPattern(PRODUCTVARIANTS_PATTERN_KEY);
                _cacheManager.RemoveByPattern(TIERPRICES_PATTERN_KEY);
                _cacheManager.RemoveByPattern(CUSTOMERROLEPRICES_PATTERN_KEY);
            }
        }