public CustomerRole SaveInfo() { CustomerRole customerRole = this.CustomerService.GetCustomerRoleById(this.CustomerRoleId); if (customerRole != null) { customerRole.Name = txtName.Text; customerRole.FreeShipping = cbFreeShipping.Checked; customerRole.TaxExempt = cbTaxExempt.Checked; customerRole.Active = cbActive.Checked; this.CustomerService.UpdateCustomerRole(customerRole); } else { customerRole = new CustomerRole() { Name = txtName.Text, FreeShipping = cbFreeShipping.Checked, TaxExempt = cbTaxExempt.Checked, Active = cbActive.Checked }; this.CustomerService.InsertCustomerRole(customerRole); } return customerRole; }
/// <summary> /// Updates the customer role /// </summary> /// <param name="customerRole">Customer role</param> public void UpdateCustomerRole(CustomerRole customerRole) { if (customerRole == null) throw new ArgumentNullException("customerRole"); customerRole.Name = CommonHelper.EnsureNotNull(customerRole.Name); customerRole.Name = CommonHelper.EnsureMaximumLength(customerRole.Name, 255); if (!_context.IsAttached(customerRole)) _context.CustomerRoles.Attach(customerRole); _context.SaveChanges(); if (this.CacheEnabled) { _cacheManager.RemoveByPattern(CUSTOMERROLES_PATTERN_KEY); } }