public bool CreateSubscriberRecord(SubscriberRecord record)
        {
            if (record.IsNull())
                return false;

            record.Contacted();

            _automessagingContext.Records.Add(record);

            return _automessagingContext.SaveChanges() > 0;
        }
        public SubscriberRecord GetExistingSubscriberRecord(SubscriberRecord record)
        {
            if (record.IsNull())
                return null;

            return
                _automessagingContext.Records.Active()
                    .FirstOrDefault(
                        s =>
                            (s.SubscriberEmail == record.SubscriberEmail) &&
                            (s.SubscriberTelephoneNumber == record.SubscriberTelephoneNumber) &&
                            (s.EventType == record.EventType));
        }
        public static SubscriberRecord BuildLandlordSubscriberRecord(LandlordSummary summary, Campaign campaign)
        {
            var subscriberRecord = new SubscriberRecord
            {
                ApplicationReference = summary.LandlordReference,
                CustomerReference = null,
                SubscriberEmail = summary.Email,
                SubscriberTelephoneNumber = summary.Mobile,
                SegmentType = campaign.SegmentType,
                EventType = campaign.Type
            };

            return subscriberRecord;
        }
        public bool Execute(Dictionary<string, string> traitsDictionary, SubscriberRecord subscriberRecord)
        {
            var properties = new Properties {{"newProperty", "true"}};

            try
            {
                Analytics.Client.Track(subscriberRecord.SubscriberEmail, EventType.NewPropertyAdded.ToString(), properties);
            }
            catch (Exception ex)
            {
                _logger.Error($"NewPropertyAddedTrackLogic - Exception thrown calling Analytics.Client.Track().  {ex}");
                return false;
            }
            return true;
        }
        public bool HasStateChanged(SubscriberRecord subscriberRecord)
        {
            //If the app has a GT of any kind or the tenant is
            //approved, they should not be in this segment
            var customers = _applicationService.GetCustomers(subscriberRecord.ApplicationReference);

            if (customers == null || customers.Count == 0)
                return false;

            var tenant = customers.FirstOrDefault(c => EnumHelper<RoleType>.Parse(c.RoleType) == RoleType.MasterTenant);

            if (tenant?.Status == Status.Approved.ToString())
                return true;

            return customers.Count(c => c.RoleType == RoleType.Guarantor.ToString()) > 0;
        }
        public bool DeleteExistingRecord(SubscriberRecord record)
        {
            if (record == null)
                return false;

            var existingRecord =
                _automessagingContext.Records.Active()
                    .FirstOrDefault(s => s.ApplicationReference == record.ApplicationReference);

            if (existingRecord.IsNull())
                return true;

            existingRecord?.SoftDelete();

            return _automessagingContext.SaveChanges() > 0;
        }
        public bool Execute(Dictionary<string, string> traitsDictionary, SubscriberRecord subscriberRecord)
        {
            var properties = new Properties
            {
                {"newSubmission", true},
                {"landlordReference", subscriberRecord.ApplicationReference}
            };

            try
            {
                Analytics.Client.Track(subscriberRecord.SubscriberEmail, EventType.NewPropertySubmission.ToString(), properties);
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
        public static SubscriberRecord BuildTenantSubscriber(ApplicationSummary summary, Campaign campaign)
        {
            var tenant = summary.Customers.FirstOrDefault(c => EnumHelper<RoleType>.Parse(c.RoleType) == RoleType.MasterTenant);
            if (tenant == null)
                return null;

            var subscriberRecord = new SubscriberRecord
            {
                ApplicationReference = summary.ApplicationReference,
                CustomerReference = tenant.CustomerReference,
                SubscriberEmail = tenant.Email,
                SubscriberTelephoneNumber = tenant.TelephoneNumber,
                SegmentType = campaign.SegmentType,
                EventType = campaign.Type
            };

            return subscriberRecord;
        }
예제 #9
0
 public bool AddSubscriber(SubscriberRecord subscriber)
 {
     switch(subscriber.EventType)
     {
         case CampaignType.ApplicationNoGuarantorAdd:
         case CampaignType.NewPropertyAdded:
         case CampaignType.BookAViewing:
         case CampaignType.DeclinedGuarantor:
             return _identityLogicFactory.GetIdentityLogicByType<ApplicationSummary>(subscriber.EventType)
                 .Execute(subscriber, _applicationService.GetSummaryByReference(subscriber.ApplicationReference),
                     true);
         case CampaignType.LandlordNewPropertySubmission:
             return _identityLogicFactory.GetIdentityLogicByType<LandlordSummary>(subscriber.EventType)
                                     .Execute(subscriber, _landlordService.GetSummaryByReference(subscriber.ApplicationReference),
                                         true);
         default:
             return false;
     }
 }
        public bool HasStateChanged(SubscriberRecord subscriberRecord)
        {
            var customers = _applicationService.GetCustomers(subscriberRecord.ApplicationReference);

            if (customers == null || customers.Count == 0)
                return false;

            var tenant = customers.FirstOrDefault(c => EnumHelper<RoleType>.Parse(c.RoleType) == RoleType.MasterTenant);

            if (tenant?.Status == Status.Cancelled.ToString())
                return true;

            var approvedGuarantor = customers.Where(
                c =>
                    c.RoleType == RoleType.Guarantor.ToString())
                        .Any(x => x.Status == Status.Approved.ToString());

            return approvedGuarantor;
        }
        public bool HasStateChanged(SubscriberRecord subscriberRecord)
        {
            //If the app contains a property with a status of Viewing, they should
            //not be in this segment
            var properties =
                _applicationService.GetApplicationPropertiesByApplicationReference(subscriberRecord.ApplicationReference);

            if (properties.IsNullOrEmpty())
                return true;

            return
                properties.Any(
                    p =>
                        p.Status == Status.AwaitingViewing.GetDescription() ||
                        p.Status == Status.Viewing.GetDescription() || 
                        p.Status == Status.Taken.GetDescription() || 
                        p.Status == Status.NotInterested.GetDescription() || 
                        p.Status == Status.Live.GetDescription());
        }
        public bool DeleteExistingRecords(SubscriberRecord record)
        {
            if (record == null)
                return false;

            var existingRecords =
                _automessagingContext.Records.Active()
                    .Where(s => s.ApplicationReference == record.ApplicationReference);

            if (existingRecords.IsNull())
                return true;

            foreach (var existingRecord in existingRecords)
            {
                existingRecord.SoftDelete();
            }

            return _automessagingContext.SaveChanges() > 0;
        }
 public void SetSubscriberRecordContacted(SubscriberRecord subscriberRecord)
 {
     _subscriberRecordRepository.SetSubscriberRecordDateLastContacted(subscriberRecord);
 }
 public SubscriberRecord GetExistingRecord(SubscriberRecord subscriberRecord)
 {
     var existingRecord = _subscriberRecordRepository.GetExistingSubscriberRecord(subscriberRecord);
     return existingRecord;
 }
 public void UpdateSubscriberRecord(SubscriberRecord subscriberRecord)
 {
     _subscriberRecordRepository.DeleteExistingRecords(subscriberRecord);
 }
        public void SetSubscriberRecordDateLastContacted(SubscriberRecord subscriberRecord)
        {
            var existingRecord =
                _automessagingContext.Records.Active()
                    .FirstOrDefault(
                        s =>
                            s.ApplicationReference == subscriberRecord.ApplicationReference &&
                            s.EventType == subscriberRecord.EventType);

            if (existingRecord.IsNotNull())
            {
                existingRecord.Contacted();
                _automessagingContext.SaveChanges();
            }
        }
 public void SetSubscriberRecordChecked(SubscriberRecord subscriberRecord)
 {
     _subscriberRecordRepository.SetSubscriberRecordChecked(subscriberRecord);
 }