private void ucSelectCustomer_Changed(object sender, EventArgs e) { // Check permissions if (ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, true)) { // Load value form dynamic control string values = null; if (ucSelectCustomer != null) { values = ValidationHelper.GetString(ucSelectCustomer.GetValue("OnlineMarketingValue"), null); } if (!String.IsNullOrEmpty(values)) { // Store users one by one string[] customerIds = values.Split(';'); int currentSiteID = SiteContext.CurrentSiteID; foreach (string customerId in customerIds) { // Check if user ID is valid int customerIdInt = ValidationHelper.GetInteger(customerId, 0); if (customerIdInt <= 0) { continue; } // Only allow adding customers on the same site as contact or registered customers var customer = BaseAbstractInfoProvider.GetInfoById(PredefinedObjectType.CUSTOMER, customerIdInt); if ((customer == null) || ((customer.Generalized.ObjectSiteID != currentSiteID) && !customer.IsGlobal)) { continue; } // Add new relation int parentId = (ci.ContactMergedWithContactID == 0) ? ci.ContactID : ci.ContactMergedWithContactID; ContactMembershipInfoProvider.SetRelationship(customerIdInt, MemberTypeEnum.EcommerceCustomer, ci.ContactID, parentId, true); ci = ContactInfoProvider.GetContactInfo(contactId); } // When contact was merged then refresh complete page if ((ci != null) && (ci.ContactMergedWithContactID > 0)) { Page.Response.Redirect(RequestContext.URL.ToString(), true); } else { gridElem.ReloadData(); } } } }
private void UniSelector_OnItemsSelected(object sender, EventArgs e) { // Check permissions if (ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, true)) { string values = ValidationHelper.GetString(selectUser.UniSelector.Value, null); if (!String.IsNullOrEmpty(values)) { // Store users one by one string[] userIds = values.Split(';'); foreach (string userId in userIds) { // Check if user ID is valid int userIdInt = ValidationHelper.GetInteger(userId, 0); if (userIdInt <= 0) { continue; } // Add new relation int parentId = (ci.ContactMergedWithContactID == 0) ? ci.ContactID : ci.ContactMergedWithContactID; ContactMembershipInfoProvider.SetRelationship(userIdInt, MemberTypeEnum.CmsUser, ci.ContactID, parentId, true); // When contact was merged update contact info ci = ContactInfoProvider.GetContactInfo(contactId); } // When contact was merged then refresh complete page if ((ci != null) && (ci.ContactMergedWithContactID > 0)) { Page.Response.Redirect(RequestContext.URL.ToString(), true); } else { gridElem.ReloadData(); } } } }