public void Save(CustomerTargeted customerTargeted) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entity = Mapper.Map <CustomerTargeted, CustomerTargetedEntity>(customerTargeted); adapter.SaveEntity(entity); } }
public void Save(long customerId, int forYear, bool?isTargeted, long createdBy) { var customerTargeted = _customerTargetedRepository.GetByCustomerIdAndYear(customerId, forYear); bool?oldIsTargated = null; if (customerTargeted == null) { var domain = new CustomerTargeted { CustomerId = customerId, ForYear = forYear, IsTargated = isTargeted, CreatedBy = createdBy, DateCreated = DateTime.Now }; _customerTargetedRepository.Save(domain); } else { oldIsTargated = customerTargeted.IsTargated; if (oldIsTargated != isTargeted) { var customerEligibility = _customerEligibilityRepository.GetByCustomerIdAndYear(customerId, DateTime.Today.Year); var customerProfileHistoryId = _customerProfileHistoryRepository.CreateCustomerHistory(customerId, createdBy, customerEligibility); _eventCustomerRepository.UpdateCustomerProfileIdByCustomerId(customerId, customerProfileHistoryId); } customerTargeted.IsTargated = isTargeted; customerTargeted.DateModified = DateTime.Now; customerTargeted.ModifiedBy = createdBy; _customerTargetedRepository.Save(customerTargeted); } if (DateTime.Today.Year == forYear && (customerTargeted == null || oldIsTargated != isTargeted)) { _callQueueCustomerRepository.UpdateCallQueueCustomerTargeted(customerId, forYear, isTargeted); } }
private List <string> GetReasons(Customer customer, IEnumerable <ProspectCustomer> prospectCustomers, IEnumerable <EventCustomer> eventCustomers, IEnumerable <Event> events, IEnumerable <OrganizationRoleUser> orgRoleUsers, IEnumerable <User> users, CallQueueCustomerCriteraAssignmentForStats callQueueCustomer, IEnumerable <long> healthPlanZipIdPairs, CorporateAccount account, IEnumerable <AccountCallQueueSetting> callQueueSettings, CustomerEligibility customerEligibility, CustomerTargeted customerTargeted) { var resons = new List <string>(); var orgRoleUser = orgRoleUsers.Where(x => x.Id == customer.CustomerId).FirstOrDefault(); var firstDayOfYear = new DateTime(DateTime.Today.Year, 1, 1); if (orgRoleUser != null) { var user = users.Where(x => x.Id == orgRoleUser.UserId).FirstOrDefault(); if (user != null && (string.IsNullOrEmpty(user.HomePhoneNumber.Number) && string.IsNullOrEmpty(user.HomePhoneNumber.Number) && string.IsNullOrEmpty(user.MobilePhoneNumber.Number))) { resons.Add("Phone Number is not available"); } } var prospectCustomer = prospectCustomers.Where(x => x.CustomerId == customer.CustomerId).FirstOrDefault(); if (prospectCustomer != null) { var homeVisitRequested = ProspectCustomerTag.HomeVisitRequested.ToString(); var doNotContact = ProspectCustomerTag.DoNotCall.ToString(); var deceased = ProspectCustomerTag.Deceased.ToString(); var mobilityIssue = ProspectCustomerTag.MobilityIssue.ToString(); var inLongTermCareNursingHome = ProspectCustomerTag.InLongTermCareNursingHome.ToString(); var mobilityIssue_LeftMessageWithOther = ProspectCustomerTag.MobilityIssues_LeftMessageWithOther.ToString(); var debilitatingDisease = ProspectCustomerTag.DebilitatingDisease.ToString(); var noLongeronInsurancePlan = ProspectCustomerTag.NoLongeronInsurancePlan.ToString(); var refusedCustomerTag = prospectCustomer.Tag.ToString(); if (refusedCustomerTag == deceased || ((!prospectCustomer.ContactedDate.HasValue || prospectCustomer.ContactedDate.Value.Year == firstDayOfYear.Year) && (refusedCustomerTag == homeVisitRequested || refusedCustomerTag == doNotContact || refusedCustomerTag == mobilityIssue || refusedCustomerTag == inLongTermCareNursingHome || refusedCustomerTag == mobilityIssue_LeftMessageWithOther || refusedCustomerTag == debilitatingDisease || refusedCustomerTag == noLongeronInsurancePlan))) { resons.Add(((ProspectCustomerTag)Enum.Parse(typeof(ProspectCustomerTag), refusedCustomerTag, true)).GetDescription()); } if (prospectCustomer.CallBackRequestedDate.HasValue && refusedCustomerTag == ProspectCustomerTag.CallBackLater.ToString() && prospectCustomer.CallBackRequestedDate > DateTime.Today.AddDays(1)) { resons.Add("Requested for Callback on " + prospectCustomer.CallBackRequestedDate.Value.ToShortDateString() + " at " + prospectCustomer.CallBackRequestedDate.Value.ToShortTimeString()); } } if (customerEligibility == null || customerEligibility.IsEligible == null) { resons.Add("Eligibility is not available"); } if (customerEligibility != null && customerEligibility.IsEligible == false) { resons.Add("Not Eligible"); } if (customerTargeted == null || !customerTargeted.IsTargated.HasValue || customerTargeted.IsTargated == false) { resons.Add("Non-Targeted"); } if (!customer.ActivityId.HasValue) { resons.Add("Activity is not available"); } if (customer.ActivityId.HasValue && (customer.ActivityId == ((long)UploadActivityType.MailOnly) || customer.ActivityId == (long)UploadActivityType.DoNotCallDoNotMail)) { var activty = ((UploadActivityType)customer.ActivityId.Value).GetDescription(); resons.Add("Activity is " + activty); } if (!callQueueSettings.IsNullOrEmpty() && customer.IsIncorrectPhoneNumber && customer.IncorrectPhoneNumberMarkedDate >= firstDayOfYear) { resons.Add("Incorrect Phone Number"); } else if (customer.IsIncorrectPhoneNumber) { resons.Add("Incorrect Phone Number"); } //if ((customer.DoNotContactUpdateDate > firstDayOfYear && (customer.DoNotContactTypeId == (long)DoNotContactType.DoNotContact || customer.DoNotContactTypeId == (long)DoNotContactType.DoNotCall)) // || (customer.DoNotContactUpdateSource == (long)DoNotContactSource.Manual && customer.DoNotContactTypeId != (long)DoNotContactType.DoNotMail)) if (customer.DoNotContactTypeId == (long)DoNotContactType.DoNotContact || customer.DoNotContactTypeId == (long)DoNotContactType.DoNotCall) { resons.Add(((DoNotContactType)customer.DoNotContactTypeId).GetDescription()); } var eventCustomer = eventCustomers.Where(x => x.CustomerId == customer.CustomerId).ToArray(); if (eventCustomer.Any()) { var eventIds = eventCustomer.Select(x => x.EventId).ToArray(); var customerEvents = events.Where(x => eventIds.Contains(x.Id)).ToArray(); if (customerEvents.Any()) { var customerContactedThisYear = new DateTime(DateTime.Today.Year, 1, 1); if (customerEvents.Any(x => x.EventDate.Year == customerContactedThisYear.Year) || customerEvents.Any(x => x.EventDate > customerContactedThisYear)) { resons.Add("Booked Appointment"); } } } if (callQueueCustomer != null && account != null) { SetReasonsForCampaign(resons, customer, callQueueCustomer, healthPlanZipIdPairs, account, callQueueSettings); } return(resons.Distinct().ToList()); }
private CallQueueCustomer CreateCustomerCallQueueCustomerModel(CallQueueCustomer existingCallQueueCustomer, CallQueueCustomer callQueueCustomer, Customer customer, IEnumerable <Call> customerCalls, int callAttempts, Appointment futureAppointment, ProspectCustomer prospectCustomer, EventAppointmentCancellationLog eacl, bool isConfirmationCallQueue, CustomerEligibility customerEligibility, IEnumerable <EventCustomer> eventCustomers, CustomerTargeted customerTargeted) { var lastCall = (from cc in customerCalls where cc.Status != (long)CallStatus.CallSkipped && (isConfirmationCallQueue == false || cc.CallQueueId == callQueueCustomer.CallQueueId) orderby cc.DateCreated descending select cc).FirstOrDefault(); if (existingCallQueueCustomer == null) { existingCallQueueCustomer = callQueueCustomer; existingCallQueueCustomer.DateCreated = DateTime.Now; existingCallQueueCustomer.CallDate = DateTime.Now; } else { existingCallQueueCustomer.CallDate = DateTime.Now; } existingCallQueueCustomer.IsActive = true; existingCallQueueCustomer.Status = CallQueueStatus.Initial; existingCallQueueCustomer.FirstName = customer.Name.FirstName; existingCallQueueCustomer.LastName = customer.Name.LastName; existingCallQueueCustomer.MiddleName = customer.Name.MiddleName; existingCallQueueCustomer.PhoneHome = customer.HomePhoneNumber; existingCallQueueCustomer.PhoneCell = customer.MobilePhoneNumber; existingCallQueueCustomer.PhoneOffice = customer.OfficePhoneNumber; existingCallQueueCustomer.ZipId = customer.Address.ZipCode.Id; existingCallQueueCustomer.ZipCode = customer.Address.ZipCode.Zip; existingCallQueueCustomer.Tag = customer.Tag; existingCallQueueCustomer.IsEligble = customerEligibility != null ? customerEligibility.IsEligible : null; existingCallQueueCustomer.IsIncorrectPhoneNumber = customer.IsIncorrectPhoneNumber; existingCallQueueCustomer.IsLanguageBarrier = customer.IsLanguageBarrier; existingCallQueueCustomer.ActivityId = customer.ActivityId; existingCallQueueCustomer.DoNotContactTypeId = customer.DoNotContactTypeId; existingCallQueueCustomer.DoNotContactUpdateDate = customer.DoNotContactUpdateDate; existingCallQueueCustomer.AppointmentDate = futureAppointment != null ? futureAppointment.StartTime : (DateTime?)null; existingCallQueueCustomer.NoShowDate = futureAppointment == null ? (eventCustomers.Any() ? eventCustomers.OrderByDescending(x => x.NoShowDate).First().NoShowDate : null) : null; if (!isConfirmationCallQueue) { existingCallQueueCustomer.CallCount = customerCalls.Count(x => x.IsContacted.HasValue && x.IsContacted.Value); existingCallQueueCustomer.Attempts = callAttempts; existingCallQueueCustomer.CallStatus = lastCall != null ? lastCall.Status : (long?)null; existingCallQueueCustomer.Disposition = lastCall != null ? lastCall.Disposition : string.Empty; } //confirm call queue - called then registered for another event, and queue regenerated existingCallQueueCustomer.ContactedDate = lastCall != null ? lastCall.DateCreated : (DateTime?)null; existingCallQueueCustomer.CallBackRequestedDate = null; if (prospectCustomer != null && lastCall != null && lastCall.Status == (long)CallStatus.Attended && lastCall.Disposition == ProspectCustomerTag.CallBackLater.ToString()) { existingCallQueueCustomer.CallBackRequestedDate = prospectCustomer.CallBackRequestedDate; } existingCallQueueCustomer.AppointmentCancellationDate = (DateTime?)null; if (eacl != null && (lastCall == null || lastCall.DateCreated < eacl.DateCreated)) { existingCallQueueCustomer.AppointmentCancellationDate = eacl.DateCreated; } existingCallQueueCustomer.DoNotContactUpdateSource = customer.DoNotContactUpdateSource; existingCallQueueCustomer.LanguageBarrierMarkedDate = customer.LanguageBarrierMarkedDate; existingCallQueueCustomer.IncorrectPhoneNumberMarkedDate = customer.IncorrectPhoneNumberMarkedDate; existingCallQueueCustomer.LanguageId = customer.LanguageId; if (customerTargeted != null) { existingCallQueueCustomer.TargetedYear = customerTargeted.ForYear; existingCallQueueCustomer.IsTargeted = customerTargeted.IsTargated; } existingCallQueueCustomer.ProductTypeId = customer.ProductTypeId; return(existingCallQueueCustomer); }