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 AssignCustomerToContact(ContactInfo contact, string customerFirstName) { var scalarResult = new ObjectQuery("ecommerce.customer").WhereEquals("CustomerFirstName", customerFirstName) .Column("CustomerID").GetScalarResult <int>(); if (scalarResult == 0) { return; } ContactMembershipInfoProvider.SetMembershipInfo(new ContactMembershipInfo { ContactID = contact.ContactID, MemberType = MemberTypeEnum.EcommerceCustomer, RelatedID = scalarResult }); }
protected void gridElem_OnAction(string actionName, object actionArgument) { switch (actionName) { case "delete": int membershipId = ValidationHelper.GetInteger(actionArgument, 0); if (membershipId > 0) { // Check permissions if (AuthorizationHelper.AuthorizedModifyContact(true)) { ContactMembershipInfoProvider.DeleteMembershipInfo(membershipId); } } break; } }
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(); } } } }
protected void Page_Load(object sender, EventArgs e) { chkEmail.Enabled = !String.IsNullOrEmpty(ContactHelper.GetEmailDomain(CurrentContact.ContactEmail)); chkAddress.Enabled = !String.IsNullOrEmpty(CurrentContact.ContactAddress1) || !String.IsNullOrEmpty(CurrentContact.ContactAddress2) || !String.IsNullOrEmpty(CurrentContact.ContactCity) || !String.IsNullOrEmpty(CurrentContact.ContactZIP); chkBirthDay.Enabled = (CurrentContact.ContactBirthday != DateTimeHelper.ZERO_TIME); chkPhone.Enabled = !String.IsNullOrEmpty(CurrentContact.ContactBusinessPhone) || !String.IsNullOrEmpty(CurrentContact.ContactHomePhone) || !String.IsNullOrEmpty(CurrentContact.ContactMobilePhone); chkMembership.Visible = chkIPaddress.Visible = ci.ContactSiteID != 0; if (chkMembership.Visible) { var relationships = ContactMembershipInfoProvider.GetRelationships() .WhereEquals("ActiveContactID", CurrentContact.ContactID); chkMembership.Enabled = relationships.Any(); var ips = IPInfoProvider.GetIps() .WhereEquals("IPActiveContactID", CurrentContact.ContactID); chkIPaddress.Enabled = ips.Any(); } // Current contact is global object if (ci.ContactSiteID == 0) { plcSite.Visible = true; // Display site selector in site manager if (ContactHelper.IsSiteManager) { siteOrGlobalSelector.Visible = false; } // Display 'site or global' selector in CMS desk for global objects else if (ContactHelper.AuthorizedReadContact(SiteContext.CurrentSiteID, false) && ContactHelper.AuthorizedModifyContact(SiteContext.CurrentSiteID, false)) { siteSelector.Visible = false; } else { plcSite.Visible = false; } } }