public void Save(CustomerAccountGlocomNumber model, bool refatch = true) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entity = Mapper.Map <CustomerAccountGlocomNumber, CustomerAccountGlocomNumberEntity>(model); adapter.SaveEntity(entity, refatch); } }
public void SaveAccountCheckoutPhoneNumber(CustomerAccountGlocomNumber model) { model.GlocomNumber = model.GlocomNumber.Replace("-", ""); //var oldCustomerGlocomNumber = _customerAccountGlocomNumberRepository.GetByCustomerIdAndGlocomNumber(model.CustomerId, model.GlocomNumber); //if (oldCustomerGlocomNumber != null) //{ // oldCustomerGlocomNumber.IsActive = false; // _customerAccountGlocomNumberRepository.Update(oldCustomerGlocomNumber); //} _customerAccountGlocomNumberRepository.Save(model, false); }
public PhoneNumber GetGlocomNumber(long accountId, long stateId, long customerId, long?callId = null) { var accountCheckoutPhoneNumbers = _accountCheckoutPhoneNumberRepository.GetAccountCheckoutPhoneNumberByStateID(accountId, stateId); if (accountCheckoutPhoneNumbers.IsNullOrEmpty()) { return(null); } var phoneNumber = string.Empty; var customerAccountGlocomNumbers = _customerAccountGlocomNumberRepository.GetByCustomerId(customerId) .Where(x => accountCheckoutPhoneNumbers.Select(acpn => acpn.CheckoutPhoneNumber).Contains(x.GlocomNumber)); CustomerAccountGlocomNumber checkoutPhoneNumberForCall = null; if (!customerAccountGlocomNumbers.IsNullOrEmpty()) { if (callId != null && callId > 0) { checkoutPhoneNumberForCall = customerAccountGlocomNumbers.OrderByDescending(x => x.CreatedDate).FirstOrDefault(x => x.CallId == callId); if (checkoutPhoneNumberForCall != null) { phoneNumber = checkoutPhoneNumberForCall.GlocomNumber; return(_phoneNumberFactory.CreatePhoneNumber(phoneNumber, PhoneNumberType.Unknown)); } } var checkoutPhoneNumbers = (from acpn in accountCheckoutPhoneNumbers where !customerAccountGlocomNumbers.Select(x => x.GlocomNumber).Contains(acpn.CheckoutPhoneNumber) select acpn); if (!checkoutPhoneNumbers.IsNullOrEmpty()) { var glocomNumber = checkoutPhoneNumbers.First(); phoneNumber = glocomNumber.CheckoutPhoneNumber; } else { var glocomNumber = customerAccountGlocomNumbers.First(); phoneNumber = glocomNumber.GlocomNumber; } } else { var glocomNumber = accountCheckoutPhoneNumbers.First(); phoneNumber = glocomNumber.CheckoutPhoneNumber; } if (string.IsNullOrEmpty(phoneNumber)) { return(null); } else { return(_phoneNumberFactory.CreatePhoneNumber(phoneNumber, PhoneNumberType.Unknown)); } }
public void Update(CustomerAccountGlocomNumber model) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entity = Mapper.Map <CustomerAccountGlocomNumber, CustomerAccountGlocomNumberEntity>(model); if (entity.Id > 0) { var bucket = new RelationPredicateBucket(CustomerAccountGlocomNumberFields.Id == entity.Id); if (adapter.UpdateEntitiesDirectly(entity, bucket) == 0) { throw new PersistenceFailureException("Updation failed"); } } } }
public long StartCallAndUpdateCallAttemptTable(long callQueueCustomerId, long callAttemptId, string calledGlocomNumber, string patientPhoneNumber, string callQueueCategory) { var callQueueCustomer = _callQueueCustomerRepository.GetById(callQueueCustomerId); var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(callQueueCustomer.CustomerId.Value); var oldCustomerGlocomNumber = _customerAccountGlocomNumberRepository.GetByCustomerIdAndGlocomNumber(callQueueCustomer.CustomerId.Value, calledGlocomNumber.Replace("-", "")); var incomingPhoneLine = calledGlocomNumber.Replace("-", ""); var callersPhoneNumber = patientPhoneNumber.Replace("-", ""); var customer = _customerRepository.GetCustomer((long)callQueueCustomer.CustomerId); using (var scope = new TransactionScope()) { var organizationRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId; var callStatus = CallType.Existing_Customer.ToString().Replace("_", " "); var eventId = callQueueCustomer.EventId.HasValue && callQueueCustomer.EventCustomerId.HasValue ? callQueueCustomer.EventId.Value : 0; var callId = _outboundCallQueueService.SetCallDetail(organizationRoleUserId, callQueueCustomer.CustomerId.Value, incomingPhoneLine, callersPhoneNumber, callStatus, callQueueCustomer.CampaignId, callQueueCustomer.HealthPlanId, null, callQueueCustomer.CallQueueId, eventId: eventId, callQueueCategory: callQueueCategory, ProductTypeId: customer.ProductTypeId); UpdateContactedInfo(prospectCustomer.Id, callId); _customerCallQueueCallAttemptService.SetCallIdCallAttempt(callAttemptId, callId); var callQueueCustomerCallModel = new CallQueueCustomerCall(); callQueueCustomerCallModel.CallId = callId; callQueueCustomerCallModel.CallQueueCustomerId = callQueueCustomerId; _callQueueCustomerCallRepository.Save(callQueueCustomerCallModel); var customerAccountGlocomNumber = new CustomerAccountGlocomNumber { CallId = callId, CustomerId = callQueueCustomer.CustomerId.Value, GlocomNumber = calledGlocomNumber, CreatedDate = DateTime.Now, IsActive = true }; var editmodel = new CallQueueCustomerCallDetailsEditModel { CallQueueCustomerId = callQueueCustomerId, Disposition = string.Empty, CallStatusId = (long)CallStatus.Initiated, IsCallSkipped = false, ModifiedByOrgRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId, Attempt = 0, CallQueueStatus = (long)CallQueueStatus.Initial, CallDate = DateTime.Today.AddDays(30), CallQueueId = callQueueCustomer.CallQueueId }; _callQueueCustomerRepository.UpdateCallqueueCustomerByCustomerId(editmodel, callQueueCustomer.CustomerId.Value); if (oldCustomerGlocomNumber != null) { oldCustomerGlocomNumber.IsActive = false; _customerAccountGlocomNumberRepository.Update(oldCustomerGlocomNumber); } _accountCheckoutPhoneNumberService.SaveAccountCheckoutPhoneNumber(customerAccountGlocomNumber); scope.Complete(); return(callId); } }
public long SaveViciDialerCall(ViciDialerCallModel model, long orgRoleUserId) { long status = 0; var disposition = string.Empty; if (model.Disposition.ToUpper() == "ANS.MACH")//Left Voice mail { status = (long)CallStatus.VoiceMessage; } else if (model.Disposition.ToUpper() == "NO.ANS" || model.Disposition.ToUpper() == "BUSY") //No Answer/Busy/Mail Full { status = (long)CallStatus.NoAnswer; } else if (model.Disposition.ToUpper() == "DEAD") //Incorrect Phone number { status = (long)CallStatus.TalkedtoOtherPerson; disposition = ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers.ToString(); } CallQueue callQueue = null; if (model.CallQueueId > 0) { callQueue = _callQueueRepository.GetById(model.CallQueueId); } var customer = _customerRepository.GetCustomer(model.CustomerId); var account = _corporateAccountRepository.GetByTag(customer.Tag); bool?isContacted = false; if (callQueue == null || callQueue.Category == HealthPlanCallQueueCategory.AppointmentConfirmation) { isContacted = null; } else { isContacted = (status == (long)CallStatus.Attended || status == (long)CallStatus.VoiceMessage || status == (long)CallStatus.LeftMessageWithOther); } var call = new Call() { CallDateTime = model.CallStartDateTime, StartTime = model.CallStartDateTime, EndTime = model.CallEndDateTime, CallStatus = CallType.Existing_Customer.GetDescription(), IsIncoming = false, CalledCustomerId = model.CustomerId, Status = status, CreatedByOrgRoleUserId = orgRoleUserId, IsNewCustomer = false, DateCreated = model.CallStartDateTime, DateModified = model.CallStartDateTime, ReadAndUnderstood = true, HealthPlanId = account != null ? account.Id : (long?)null, CallQueueId = callQueue != null ? callQueue.Id : (long?)null, DialerType = (long)DialerType.Vici, CalledInNumber = model.CallerId, CallerNumber = model.CallerPhoneNumber, CallBackNumber = model.CallerPhoneNumber, IsContacted = isContacted, Disposition = disposition, ProductTypeId = customer.ProductTypeId }; call = _callCenterCallRepository.Save(call); if (status == (long)CallStatus.TalkedtoOtherPerson && disposition == ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers.ToString()) { _customerService.UpdateIsIncorrectPhoneNumber(model.CustomerId, true, orgRoleUserId); } if (!string.IsNullOrEmpty(model.CallerId)) { var customerAccountGlocomNumber = new CustomerAccountGlocomNumber { CallId = call.Id, CustomerId = model.CustomerId, GlocomNumber = PhoneNumber.ToNumber(model.CallerId), CreatedDate = model.CallStartDateTime, IsActive = true }; _customerAccountGlocomNumberService.SaveAccountCheckoutPhoneNumber(customerAccountGlocomNumber); } if (callQueue != null) { var callQueueCustomer = _callQueueCustomerRepository.GetCallQueueCustomerByCustomerIdAndHealthPlanId(model.CustomerId, account.Id, callQueue.Category); var callQueueCustomerCall = new CallQueueCustomerCall { CallQueueCustomerId = callQueueCustomer.Id, CallId = call.Id }; _callQueueCustomerCallRepository.Save(callQueueCustomerCall); bool removeFromCallQueue = status == (long)CallStatus.TalkedtoOtherPerson; var callQueueStatus = CallQueueStatus.Initial; if (removeFromCallQueue) { callQueueStatus = CallQueueStatus.Removed; } _callQueueCustomerContactService.SetCallQueueCustomerStatus(callQueueCustomer, callQueueStatus, orgRoleUserId, false, status, model.CallStartDateTime); var prospectCustomerId = callQueueCustomer.ProspectCustomerId ?? 0; if (prospectCustomerId == 0) { var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(model.CustomerId); if (prospectCustomer != null) { prospectCustomerId = prospectCustomer.Id; } } _callQueueCustomerRepository.UpdateOtherCustomerAttempt(callQueueCustomer.Id, model.CustomerId, prospectCustomerId, orgRoleUserId, callQueueCustomer.CallDate, removeFromCallQueue, callQueueCustomer.CallQueueId, status, model.CallStartDateTime, isForParsing: true, disposition: disposition); } return(call.Id); }
public long SaveGmsDialerCall(GmsDialerCallModel model, long orgRoleUserId, ILogger logger) { var callDateTime = Convert.ToDateTime(model.CallDate + " " + model.CallTime); long status = 0; var disposition = string.Empty; if (model.CallDisposition.ToUpper() == "ANS.MACH")//Left Voice mail { status = (long)CallStatus.VoiceMessage; } else if (model.CallDisposition.ToUpper() == "NO.ANS") //No Answer/Busy/Mail Full { status = (long)CallStatus.NoAnswer; } else if (model.CallDisposition.ToUpper() == "BUSY") //No Answer/Busy/Mail Full { status = (long)CallStatus.NoAnswer; } else if (model.CallDisposition.ToUpper() == "DEAD") { //Incorrect Phone number status = (long)CallStatus.TalkedtoOtherPerson; disposition = ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers.ToString(); } var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.MailRound); long customerId = Convert.ToInt64(model.CustomerId); var customer = _customerRepository.GetCustomer(customerId); var healthPlanId = _corporateAccountRepository.GetHealthPlanIdByAccountName(model.HealthPlan); if (healthPlanId == 0) { logger.Info(string.Format("Unable to parse for Customer Id : {0}. Healthplan not found by Name : {1}", model.CustomerId, model.HealthPlan)); return(0); } var calledNumber = !string.IsNullOrEmpty(model.PhoneHome) ? model.PhoneHome : !string.IsNullOrEmpty(model.PhoneOffice) ? model.PhoneOffice : model.PhoneCell; var callQueueCustomer = _callQueueCustomerRepository.GetCallQueueCustomerByCustomerIdAndHealthPlanId(customerId, healthPlanId, HealthPlanCallQueueCategory.MailRound); if (callQueueCustomer == null) { logger.Info(string.Format("Unable to parse for Customer Id : {0}. Call Queue Customer not found.", model.CustomerId)); return(0); } bool?isContacted = false; if (callQueue.Category == HealthPlanCallQueueCategory.AppointmentConfirmation) { isContacted = null; } else { isContacted = (status == (long)CallStatus.Attended || status == (long)CallStatus.VoiceMessage || status == (long)CallStatus.LeftMessageWithOther); } var call = new Call() { CallDateTime = callDateTime, StartTime = callDateTime, EndTime = callDateTime, CallStatus = CallType.Existing_Customer.GetDescription(), IsIncoming = false, CalledCustomerId = customerId, Status = status, CreatedByOrgRoleUserId = orgRoleUserId, IsNewCustomer = false, DateCreated = callDateTime, DateModified = callDateTime, ReadAndUnderstood = true, HealthPlanId = healthPlanId, CallQueueId = callQueue.Id, DialerType = (long)DialerType.Gms, CalledInNumber = model.CallerId, CallerNumber = calledNumber, CallBackNumber = calledNumber, IsContacted = isContacted, Disposition = disposition, ProductTypeId = customer.ProductTypeId }; call = _callCenterCallRepository.Save(call); if (status == (long)CallStatus.TalkedtoOtherPerson && disposition == ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers.ToString()) { _customerService.UpdateIsIncorrectPhoneNumber(customerId, true, orgRoleUserId); } var callQueueCustomerCall = new CallQueueCustomerCall { CallQueueCustomerId = callQueueCustomer.Id, CallId = call.Id }; _callQueueCustomerCallRepository.Save(callQueueCustomerCall); var customerAccountGlocomNumber = new CustomerAccountGlocomNumber { CallId = call.Id, CustomerId = customerId, GlocomNumber = PhoneNumber.ToNumber(model.CallerId), CreatedDate = callDateTime, IsActive = true }; _customerAccountGlocomNumberService.SaveAccountCheckoutPhoneNumber(customerAccountGlocomNumber); bool removeFromCallQueue = status == (long)CallStatus.TalkedtoOtherPerson; var callQueueStatus = CallQueueStatus.Initial; if (removeFromCallQueue) { callQueueStatus = CallQueueStatus.Removed; } callQueueCustomer.Disposition = disposition; _callQueueCustomerContactService.SetCallQueueCustomerStatus(callQueueCustomer, callQueueStatus, orgRoleUserId, false, status, callDateTime); var prospectCustomerId = callQueueCustomer.ProspectCustomerId ?? 0; if (prospectCustomerId == 0) { var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(customerId); if (prospectCustomer != null) { prospectCustomerId = prospectCustomer.Id; } } _callQueueCustomerRepository.UpdateOtherCustomerAttempt(callQueueCustomer.Id, customerId, prospectCustomerId, orgRoleUserId, callQueueCustomer.CallDate, removeFromCallQueue, callQueueCustomer.CallQueueId, status, callDateTime, isForParsing: true, disposition: disposition); return(call.Id); }
private long SaveCallQueueCustomerDetailAndGetCallId(Customer customer, CallQueue callQueue, long orgRoleUserId, long callId, long dialerType, long eventId = 0) { var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(customer.CustomerId); var _event = _eventRepository.GetById(eventId); var HealthPlanId = _eventRepository.GetById(eventId) != null?_eventRepository.GetById(eventId).AccountId : null; long?prospectCustomerId_ = null; if (prospectCustomer != null) { prospectCustomerId_ = prospectCustomer.Id; } using (var scope = new TransactionScope()) { //lock customer in call queue so that other agent not be able to call them; var domain = new PreAssessmentCallQueueCustomerLock { CustomerId = customer.CustomerId, ProspectCustomerId = prospectCustomerId_, CreatedBy = orgRoleUserId, CreatedOn = DateTime.Now }; _preAssessmentCallQueueCustomerLockRepository.SavePreAssessmentCallQueueCustomerLock(domain); var customerId = customer != null ? customer.CustomerId : 0; var prospectCustomerId = prospectCustomerId_ != null ? (long)prospectCustomerId_ : 0; var organizationRoleUserId = orgRoleUserId; var callStatus = customerId > 0 ? CallType.Existing_Customer.ToString().Replace("_", " ") : CallType.Register_New_Customer.ToString().Replace("_", " "); PhoneNumber glocomNumber = null; if (customer != null && customer.Address != null && HealthPlanId > 0) { glocomNumber = _customerAccountGlocomNumberService.GetGlocomNumber((long)HealthPlanId, customer.Address.StateId, customerId); if (glocomNumber == null) { var corporateAccount = _corporateAccountRepository.GetByTag(customer.Tag); glocomNumber = corporateAccount != null ? corporateAccount.CheckoutPhoneNumber : null; } } var incomingPhoneLine = glocomNumber != null ? glocomNumber.AreaCode + glocomNumber.Number : ""; callId = _outboundCallQueueService.SetCallDetail(organizationRoleUserId, customerId, incomingPhoneLine, "", callStatus, null, HealthPlanId, "", callQueue.Id, callId, true, dialerType: dialerType, callQueueCategory: callQueue.Category, eventId: eventId, ProductTypeId: customer.ProductTypeId); if (customerId == 0 && prospectCustomerId > 0) { UpdateContactedInfo(prospectCustomerId, callId, orgRoleUserId); } else if (customerId > 0) { if (!(callQueue.Category == CallQueueCategory.Upsell || callQueue.Category == CallQueueCategory.PreAssessmentCallQueue)) { if (prospectCustomer == null && customer != null) { prospectCustomer = _prospectCustomerFactory.CreateProspectCustomerFromCustomer(customer, false); prospectCustomer = ((IUniqueItemRepository <ProspectCustomer>)_prospectCustomerRepository).Save(prospectCustomer); } if (prospectCustomer != null) { UpdateContactedInfo(prospectCustomer.Id, callId, orgRoleUserId); } } } var customerCallQueueCallAttempt = new PreAssessmentCustomerCallQueueCallAttempt { DateCreated = DateTime.Now, IsCallSkipped = false, IsNotesReadAndUnderstood = true, CreatedBy = orgRoleUserId, CustomerId = customerId, CallId = callId, NotInterestedReasonId = null }; _preAssessmentCustomerCallQueueCallAttemptRepository.Save(customerCallQueueCallAttempt, false); if (glocomNumber != null) { var customerAccountGlocomNumber = new CustomerAccountGlocomNumber { CallId = callId, CustomerId = customerId, GlocomNumber = glocomNumber.AreaCode + glocomNumber.Number, CreatedDate = DateTime.Now, IsActive = true }; _customerAccountGlocomNumberService.SaveAccountCheckoutPhoneNumber(customerAccountGlocomNumber); } scope.Complete(); return(callId); } }