Пример #1
0
        public IFieldValueBinderResult GetBindingValue()
        {
            var currentContact = xDbService.GetCurrentContact();

            if (currentContact == null)
            {
                return(new NoFieldValueBindingFoundResult());
            }
            var xConnectFacet = currentContact.GetFacet <IXConnectFacets>("XConnectFacets");

            if (xConnectFacet == null)
            {
                return(new NoFieldValueBindingFoundResult());
            }
            if (xConnectFacet.Facets == null)
            {
                return(new NoFieldValueBindingFoundResult());
            }
            if (!xConnectFacet.Facets.ContainsKey(GetFacetKey()))
            {
                return(new NoFieldValueBindingFoundResult());
            }
            if (!(xConnectFacet.Facets[GetFacetKey()] is T facet))
            {
                return(new NoFieldValueBindingFoundResult());
            }
            return(GetFieldBindingValueFromFacet(facet));
        }
        private ContactIdentifier UpdateEmailContact(string toAddress)
        {
            var currentContact = xDbService.GetCurrentContact();

            if (currentContact == null)
            {
                return(null);
            }
            new PreferredEmailFieldValueBinder().StoreValue(toAddress);
            return(new ContactIdentifier(Sitecore.Analytics.XConnect.DataAccess.Constants.IdentifierSource, currentContact.ContactId.ToString("N"), ContactIdentifierType.Anonymous));
        }
        private ContactIdentifier GetContactIdentifier()
        {
            var contact = xDbService.GetCurrentContact();

            if (contact == null)
            {
                logger.LogWarn("Current contact is null");
                return(null);
            }
            var contactIdentifier = contact.Identifiers.FirstOrDefault(c => c.Type == ContactIdentificationLevel.Known);

            return(contactIdentifier == null ? null : new ContactIdentifier(contactIdentifier.Source, contactIdentifier.Identifier, ContactIdentifierType.Known));
        }