Exemple #1
0
        private SubscriberBatchDTO AddSubscribersToBatch(MpBulkEmailPublication publication, List <MpBulkEmailSubscriber> subscribers)
        {
            var batch = new SubscriberBatchDTO();

            batch.Operations = new List <SubscriberOperationDTO>();

            foreach (var subscriber in subscribers)
            {
                if (subscriber.EmailAddress != subscriber.ThirdPartyContactId)
                {
                    if (!string.IsNullOrEmpty(subscriber.ThirdPartyContactId))
                    {
                        var unsubscribeOperation = UnsubscribeOldEmailAddress(publication, subscriber);
                        batch.Operations.Add(unsubscribeOperation);
                    }

                    //Assuming success here, update the ID to match the emailaddress
                    //TODO: US2782 - need to also recongnize this is an email change and handle this acordingly
                    subscriber.ThirdPartyContactId = subscriber.EmailAddress;
                    _bulkEmailRepository.UpdateSubscriber(_token, subscriber);
                }

                var operation = GetOperation(publication, subscriber);
                batch.Operations.Add(operation);
            }

            return(batch);
        }