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); } }
public bool EndHealthPlanActiveCall(EndHealthPlanCallEditModel model) { var isCallQueueRequsted = false; var removeFromCallQueue = false; long customerId = 0; var call = _callCenterCallRepository.GetById(model.CallId); var eventCustomer = _eventCustomerRepository.Get(call.EventId, call.CalledCustomerId); customerId = call.CalledCustomerId; //update call status in CustomerCallQueueCallAttempt Table if (model.IsSkipped && model.AttemptId > 0) { var attempt = _preAssessmentCustomerCallQueueCallAttemptRepository.GetByCallId(model.CallId); attempt.IsCallSkipped = true; if (!string.IsNullOrEmpty(model.SkipCallNote)) { attempt.SkipCallNote = model.SkipCallNote; } _preAssessmentCustomerCallQueueCallAttemptRepository.Save(attempt); } else if (model.CallId != 0) { if (model.CallId > 0) { if (call != null && call.Status == (long)CallStatus.TalkedtoOtherPerson) { removeFromCallQueue = true; } } if (!string.IsNullOrEmpty(model.SelectedDisposition)) { var tag = (ProspectCustomerTag)System.Enum.Parse(typeof(ProspectCustomerTag), model.SelectedDisposition); if (tag == ProspectCustomerTag.CallBackLater) { isCallQueueRequsted = true; } else if (tag == ProspectCustomerTag.BookedAppointment || tag == ProspectCustomerTag.HomeVisitRequested || tag == ProspectCustomerTag.MobilityIssue || tag == ProspectCustomerTag.DoNotCall || tag == ProspectCustomerTag.Deceased || tag == ProspectCustomerTag.NoLongeronInsurancePlan || tag == ProspectCustomerTag.MobilityIssues_LeftMessageWithOther || tag == ProspectCustomerTag.DebilitatingDisease || tag == ProspectCustomerTag.InLongTermCareNursingHome || tag == ProspectCustomerTag.PatientConfirmed || tag == ProspectCustomerTag.CancelAppointment || tag == ProspectCustomerTag.ConfirmLanguageBarrier) { removeFromCallQueue = true; } if (tag == ProspectCustomerTag.LanguageBarrier && customerId > 0) { _customerService.UpdateIsLanguageBarrier(customerId, true, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId); } if (tag == ProspectCustomerTag.IncorrectPhoneNumber && customerId > 0) { _customerService.UpdateIsIncorrectPhoneNumber(customerId, true, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId); } if (tag == ProspectCustomerTag.PatientConfirmed && call != null && eventCustomer.Id > 0) { eventCustomer.IsAppointmentConfirmed = true; eventCustomer.ConfirmedBy = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId; _eventCustomerRepository.Save(eventCustomer); } } var orgRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId; _preAssessmentCallQueueService.EndActiveCall(customerId, model.CallId, isCallQueueRequsted, orgRoleUserId, removeFromCallQueue, model.CallOutcomeId, model.SkipCallNote); } return(true); }