public bool HandleContactSubscription(Guid messageRecipientListId, ContactIdentifier messageContactIdentifier, Guid messageManagerRootId, Language messageContextLanguage, bool messageSendSubscriptionConfirmation)
        {
            if (messageContactIdentifier == null)
            {
                throw new ArgumentNullException(nameof(messageContactIdentifier));
            }

            using (new LanguageSwitcher(messageContextLanguage))
            {
                var managerRoot = _managerRootService.GetManagerRoot(messageManagerRootId);
                var contact     = _xConnectContactService.GetXConnectContact(messageContactIdentifier, PersonalInformation.DefaultFacetKey, ExmKeyBehaviorCache.DefaultFacetKey, EmailAddressList.DefaultFacetKey, ListSubscriptions.DefaultFacetKey);

                return(HandleContactSubscriptionInternal(messageRecipientListId, contact, managerRoot, messageSendSubscriptionConfirmation));
            }
        }
Exemplo n.º 2
0
        private void RenderListItems(Item item, string selectedManagerRootId)
        {
            var database = Context.ContentDatabase ?? Context.Database;
            // ReSharper disable once UnusedVariable
            var isValid = Guid.TryParse(selectedManagerRootId, out var guidOutput);

            if (!isValid)
            {
                _logger.LogError($"No Valid Manager Root: {selectedManagerRootId}!");
                return;
            }

            var managerRoot = _managerRootService.GetManagerRoot(new Guid(selectedManagerRootId));

            if (managerRoot == null)
            {
                _logger.LogError($"You have to select a valid Manager Root: {selectedManagerRootId}!");
                return;
            }

            var marketingPreferences    = GetMarketingPreferences(managerRoot);
            var marketingCategoryGroups = managerRoot.Settings.MarketingCategoryGroups.Select(database.GetItem).ToList();

            if (!marketingCategoryGroups.Any())
            {
                _logger.LogWarn("no marketing groups are associated to the manager root!");
                return;
            }

            foreach (var marketingCategoryGroup in marketingCategoryGroups)
            {
                var marketingCategories = marketingCategoryGroup.Children;
                foreach (Item marketingCategory in marketingCategories)
                {
                    var categoryListItem = new ListFieldItem();
                    categoryListItem.ItemId   = categoryListItem.Value = marketingCategory.ID.ToString();
                    categoryListItem.Text     = marketingCategory.DisplayName;
                    categoryListItem.Selected = IsSelected(marketingPreferences, marketingCategory);
                    Items.Add(categoryListItem);
                }
            }

            using (new SecurityDisabler())
            {
                base.UpdateDataSourceSettings(item);
            }
        }
 public ManagerRoot GetManagerRoot(MarketingPreferencesViewModel model)
 {
     return(model == null || string.IsNullOrEmpty(model.ManagerRootId) ? null : _managerRootService.GetManagerRoot(new Guid(model.ManagerRootId)));
 }