/// <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); } }
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; }
/// <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); } }