Пример #1
0
 public static AccountDTO? FromAccount(Account account)
 {
     return (account == null) ? default(Nullable<AccountDTO>) : new AccountDTO
     {
         AccountId = account.AccountId,
         ProviderId = account.ProviderId,
         ServerId = account.ServerId,
         IsActive = account.IsActive,
         DateAccountCreated = account.DateAccountCreated,
         LastEngagedDate = account.LastEngagedDate
     };
 }
Пример #2
0
        public static SeedDiscrepancy FromEngager(Account account, Subscriber subscriber)
        {
            var accountData = AccountDTO.FromAccount(account);
            var subscriberData = SubscriberDTO.FromSubscriber(subscriber);

            return new SeedDiscrepancy
            {
                Account = accountData,
                Subscriber = subscriberData,

                EmailAddress = account.EmailAddress,
                FirstName = account.FirstName,
                LastName = account.LastName,
                DOB = account.DateOfBirth,
                Gender = account.Gender,
                Country = account.Country,
                State = account.State,
                City = account.City,
                ZipCode = account.Zip,
                Description = !subscriberData.HasValue ? string.Format(MissingSeedMessage, "WD") : !subscriberData.Value.IsMailable ? NotMailableSeedMessage : UnknownDiscrepancyMessage
            };
        }
Пример #3
0
        private static void VerifyDiscrepancyResolution(IDiscrepanciesService service)
        {
            // Assort
            var account = new Account
            {
                EmailAddress = "*****@*****.**",
                FirstName = "Amaury",
                LastName = "Rodriguez",
                ProviderId = (int)Domain.Engagement.Providers.ProviderType.Yahoo
            };
            var subscriber = default(Subscriber);

            var notExistingSeedDiscrepancy = SeedDiscrepancy.FromEngager(account, subscriber); 

            // Act
            var result = service.Resolve(notExistingSeedDiscrepancy).Result;

            // Assert
            Assert.IsTrue(result.Succeeded);
            Assert.AreEqual(SeedDiscrepancy.ResolvedMessage, result.Messages);
            Assert.AreEqual(notExistingSeedDiscrepancy, result.Source);

            using (var ctx = new SubscribersContext())
            {
                var provider = WD40.Domain.Engagement.Providers.Registry.Instance[notExistingSeedDiscrepancy.Account.Value.ProviderId];
                var metadata = service.GetMetadataForProviderAsync(provider.SubscriberId).Result;
                subscriber = ctx.FromStore(metadata.DatabaseName, metadata.TableName).GetSubscribers(s => s.email.Trim() == notExistingSeedDiscrepancy.EmailAddress).Result.SingleOrDefault();
                Assert.IsNotNull(subscriber);
                Assert.AreEqual(subscriber.send, 1);
            }

            // TODO: Update subscriber set Mailable = false
            subscriber.SetMailable(false);

            var notMailableSeedDiscrepancy = SeedDiscrepancy.FromEngager(account, subscriber);

            // Act
            result = service.Resolve(notMailableSeedDiscrepancy).Result;

            // Assert
            Assert.IsTrue(result.Succeeded);
            Assert.AreEqual(SeedDiscrepancy.ResolvedMessage, result.Messages);
            Assert.AreEqual(notMailableSeedDiscrepancy, result.Source);

            using (var ctx = new SubscribersContext())
            {
                var provider = WD40.Domain.Engagement.Providers.Registry.Instance[notExistingSeedDiscrepancy.Account.Value.ProviderId];
                var metadata = service.GetMetadataForProviderAsync(provider.SubscriberId).Result;
                subscriber = ctx.FromStore(metadata.DatabaseName, metadata.TableName).GetSubscribers(s => s.email.Trim() == notExistingSeedDiscrepancy.EmailAddress).Result.SingleOrDefault();
                Assert.IsNotNull(subscriber);
                Assert.AreEqual(subscriber.send, 1);

                // Clean Up
                var wasDeleted = ctx.Delete(subscriber).Result;
                Assert.IsTrue(wasDeleted);
                subscriber = ctx.GetSubscribers(s => s.email.Trim() == notExistingSeedDiscrepancy.EmailAddress).Result.SingleOrDefault();
                Assert.IsNull(subscriber);
            }
        }
Пример #4
0
        public static SeedDiscrepancy FromWhiteDelivery(Account account, Subscriber subscriber)
        {
            var accountData = AccountDTO.FromAccount(account);
            var subscriberData = SubscriberDTO.FromSubscriber(subscriber);

            return new SeedDiscrepancy
            {
                Account = accountData,
                Subscriber = subscriberData,

                EmailAddress = subscriber.email,
                FirstName = subscriber.firstName,
                LastName = subscriber.lastName,
                DOB = subscriber.dob,
                Gender = subscriber.gender,
                Country = subscriber.country,
                State = subscriber.state,
                City = subscriber.city,
                ZipCode = subscriber.zip,
                Description = !accountData.HasValue ? string.Format(MissingSeedMessage, "Engager") : !accountData.Value.IsActive ? NotActiveSeedMessage : UnknownDiscrepancyMessage
            };
        }