コード例 #1
0
        /// <summary>
        /// Inserts a shipping method
        /// </summary>
        /// <param name="shippingMethod">Shipping method</param>
        public void InsertShippingMethod(ShippingMethod shippingMethod)
        {
            if (shippingMethod == null)
            {
                throw new ArgumentNullException("shippingMethod");
            }

            shippingMethod.Name        = CommonHelper.EnsureNotNull(shippingMethod.Name);
            shippingMethod.Name        = CommonHelper.EnsureMaximumLength(shippingMethod.Name, 100);
            shippingMethod.Description = CommonHelper.EnsureNotNull(shippingMethod.Description);
            shippingMethod.Description = CommonHelper.EnsureMaximumLength(shippingMethod.Description, 2000);



            _context.ShippingMethods.AddObject(shippingMethod);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(SHIPPINGMETHODS_PATTERN_KEY);
            }
        }
コード例 #2
0
        public ShippingMethod SaveInfo()
        {
            ShippingMethod shippingMethod = this.ShippingService.GetShippingMethodById(this.ShippingMethodId);

            if (shippingMethod != null)
            {
                shippingMethod.Name = txtName.Text;
                shippingMethod.Description =  txtDescription.Text;
                shippingMethod.DisplayOrder = txtDisplayOrder.Value;
                this.ShippingService.UpdateShippingMethod(shippingMethod);
            }
            else
            {
                shippingMethod = new ShippingMethod()
                {
                    Name = txtName.Text,
                    Description = txtDescription.Text,
                    DisplayOrder = txtDisplayOrder.Value
                };
                this.ShippingService.InsertShippingMethod(shippingMethod);
            }

            return shippingMethod;
        }
コード例 #3
0
        /// <summary>
        /// Updates the shipping method
        /// </summary>
        /// <param name="shippingMethod">Shipping method</param>
        public void UpdateShippingMethod(ShippingMethod shippingMethod)
        {
            if (shippingMethod == null)
                throw new ArgumentNullException("shippingMethod");

            shippingMethod.Name = CommonHelper.EnsureNotNull(shippingMethod.Name);
            shippingMethod.Name = CommonHelper.EnsureMaximumLength(shippingMethod.Name, 100);
            shippingMethod.Description = CommonHelper.EnsureNotNull(shippingMethod.Description);
            shippingMethod.Description = CommonHelper.EnsureMaximumLength(shippingMethod.Description, 2000);

            if (!_context.IsAttached(shippingMethod))
                _context.ShippingMethods.Attach(shippingMethod);

            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(SHIPPINGMETHODS_PATTERN_KEY);
            }
        }