Esempio n. 1
0
        public void SaveInfo(int cusId)
        {
            Customer customer = CustomerManager.GetCustomerById(cusId);

            if (customer != null)
            {
                List <int> selectedCustomerRoleIds = this.CustomerRoleMappingControl.SelectedCustomerRoleIds;
                var        existingCustomerRoles   = customer.CustomerRoles;

                var allCustomerRoles = CustomerManager.GetAllCustomerRoles();
                foreach (CustomerRole customerRole in allCustomerRoles)
                {
                    if (selectedCustomerRoleIds.Contains(customerRole.CustomerRoleId))
                    {
                        if (existingCustomerRoles.Find(cr => cr.CustomerRoleId == customerRole.CustomerRoleId) == null)
                        {
                            CustomerManager.AddCustomerToRole(customer.CustomerId, customerRole.CustomerRoleId);
                        }
                    }
                    else
                    {
                        if (existingCustomerRoles.Find(cr => cr.CustomerRoleId == customerRole.CustomerRoleId) != null)
                        {
                            CustomerManager.RemoveCustomerFromRole(customer.CustomerId, customerRole.CustomerRoleId);
                        }
                    }
                }
            }
        }
        public void SaveInfo(int cusId)
        {
            Customer customer = CustomerManager.GetCustomerById(cusId);

            if (customer != null)
            {
                foreach (CustomerRole customerRole in customer.CustomerRoles)
                {
                    CustomerManager.RemoveCustomerFromRole(customer.CustomerId, customerRole.CustomerRoleId);
                }
                foreach (int customerRoleId in CustomerRoleMappingControl.SelectedCustomerRoleIds)
                {
                    CustomerManager.AddCustomerToRole(customer.CustomerId, customerRoleId);
                }
            }
        }
Esempio n. 3
0
        public void SaveInfo()
        {
            Customer customer = CustomerManager.GetCustomerByID(this.CustomerID);

            if (customer != null)
            {
                foreach (CustomerRole customerRole in CustomerManager.GetCustomerRolesByCustomerID(customer.CustomerID))
                {
                    CustomerManager.RemoveCustomerFromRole(customer.CustomerID, customerRole.CustomerRoleID);
                }
                foreach (int customerRoleID in CustomerRoleMappingControl.SelectedCustomerRoleIDs)
                {
                    CustomerManager.AddCustomerToRole(customer.CustomerID, customerRoleID);
                }
            }
        }