Exemplo n.º 1
0
        public CallOutComeEditModel GetCallOutCome(long callId, long callQueueCustomerId, long customerId)
        {
            var callOutComeModel = new CallOutComeEditModel();
            var objCall          = _callCenterCallRepository.GetById(callId);

            if (objCall == null)
            {
                return(callOutComeModel);
            }

            callOutComeModel.CallStatusId         = objCall.Status;
            callOutComeModel.NotIntrestedReasonId = objCall.NotInterestedReasonId;

            var objNote = _callCenterNotesRepository.GetByCallId(callId);

            if (objNote != null)
            {
                callOutComeModel.Note = objNote.Notes.Replace(ProspectCustomerTag.MemberStatesIneligibleMastectomy.GetDescription(), "").Replace(":", "").Trim();
            }

            callOutComeModel.DispositionAlias = objCall.Disposition;

            var customer = _customerRepository.GetCustomer(customerId);

            if (customer.DoNotContactTypeId.HasValue && (customer.DoNotContactTypeId.Value == (long)DoNotContactType.DoNotContact || customer.DoNotContactTypeId.Value == (long)DoNotContactType.DoNotCall))
            {
                callOutComeModel.DoNotCall = true;
            }

            callOutComeModel.PhoneHome        = customer.HomePhoneNumber.FormatPhoneNumber;
            callOutComeModel.PhoneHomeConsent = customer.PhoneHomeConsentId;

            callOutComeModel.PhoneOffice        = customer.OfficePhoneNumber.FormatPhoneNumber;
            callOutComeModel.PhoneOfficeConsent = customer.PhoneOfficeConsentId;

            callOutComeModel.PhoneCell        = customer.MobilePhoneNumber.FormatPhoneNumber;
            callOutComeModel.PhoneCellConsent = customer.PhoneCellConsentId;

            if (customerId > 0 && objCall.Disposition == (ProspectCustomerTag.CallBackLater).ToString())
            {
                var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(customerId);
                if (prospectCustomer != null && prospectCustomer.IsQueuedForCallBack && prospectCustomer.CallBackRequestedOn.HasValue) //&& prospectCustomer.CallBackRequestedOn.Value.Date == DateTime.Today
                {
                    callOutComeModel.CallBackDateTime = prospectCustomer.CallBackRequestedDate;
                }
            }

            if (callQueueCustomerId > 0)
            {
                var callQueueCustomer = _callQueueCustomerRepository.GetById(callQueueCustomerId);

                if (callQueueCustomer.Status == CallQueueStatus.Removed)
                {
                    callOutComeModel.RemoveFromQueue = true;
                }
                callOutComeModel.CallQueueId = callQueueCustomer.CallQueueId;
            }

            return(callOutComeModel);
        }
Exemplo n.º 2
0
        private ProspectCustomer GetProspectCustomer(long eventCustomerId)
        {
            var eventCustomer = _eventCustomerRepository.GetById(eventCustomerId);

            if (eventCustomer == null)
            {
                return(null);
            }
            var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(eventCustomer.CustomerId);

            if (prospectCustomer == null)
            {
                var customer = _customerRepository.GetCustomer(eventCustomer.CustomerId);
                prospectCustomer = new ProspectCustomer
                {
                    FirstName           = customer.Name.FirstName,
                    LastName            = customer.Name.LastName,
                    Gender              = customer.Gender,
                    Address             = customer.Address,
                    CallBackPhoneNumber = customer.HomePhoneNumber,
                    Email           = customer.Email,
                    BirthDate       = customer.DateOfBirth,
                    MarketingSource = customer.MarketingSource,
                    CustomerId      = customer.CustomerId,
                    Source          = ProspectCustomerSource.CallCenter
                };
            }
            return(prospectCustomer);
        }
Exemplo n.º 3
0
        public bool EndActiveCall([FromUri] long callQueueCustomerId, [FromUri] long callId, [FromUri] bool isCallQueueRequsted, [FromUri] bool removeFromCallQueue)
        {
            var callQueueCustomer = _callQueueCustomerRepository.GetById(callQueueCustomerId);
            var orgRoleUserId     = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId;

            _callQueueCustomerContactService.EndActiveCall(callQueueCustomer, callId, isCallQueueRequsted, orgRoleUserId, removeFromCallQueue);

            var customerId         = callQueueCustomer.CustomerId ?? 0;
            var prospectCustomerId = callQueueCustomer.ProspectCustomerId ?? 0;

            if (prospectCustomerId == 0)
            {
                var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(customerId);
                if (prospectCustomer != null)
                {
                    prospectCustomerId = prospectCustomer.Id;
                }
            }

            _callQueueCustomerRepository.UpdateOtherCustomerAttempt(callQueueCustomerId, customerId, prospectCustomerId, orgRoleUserId, callQueueCustomer.CallDate, removeFromCallQueue, callQueueCustomer.CallQueueId);

            return(true);
        }
Exemplo n.º 4
0
        public bool UpdateCustomerDetails(MedicareCustomerViewModel customerViewModel)
        {
            var customer = _customerRepository.GetCustomer(customerViewModel.Id);

            if (customer == null)
            {
                return(false);
            }
            _medicareFactory.UpdateCustomer(customerViewModel, customer);
            PrepareAddress(customer, customerViewModel);
            //_addressService.SaveAfterSanitizing(customer.Address);
            //_userRepository.SaveUser(customer);

            ProspectCustomer prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(customerViewModel.Id);

            if (prospectCustomer == null)
            {
                return(_customerService.SaveCustomerOnly(customer, customerViewModel.UpdatedBy));
            }
            prospectCustomer.FirstName = customerViewModel.FirstName;
            prospectCustomer.LastName  = customerViewModel.LastName;

            if (customer.Gender > 0)
            {
                prospectCustomer.Gender = customer.Gender;
            }
            prospectCustomer.BirthDate           = customer.DateOfBirth;
            prospectCustomer.Email               = customer.Email;
            prospectCustomer.CallBackPhoneNumber = customer.HomePhoneNumber;

            if (customer.Address != null)
            {
                prospectCustomer.Address.StreetAddressLine1 = customer.Address.StreetAddressLine1;
                prospectCustomer.Address.StreetAddressLine2 = customer.Address.StreetAddressLine2;
                if (customer.Address.StateId > 0)
                {
                    var state = _stateRepository.GetState(customer.Address.StateId);
                    prospectCustomer.Address.State = state.Name;
                }

                if (!string.IsNullOrEmpty(customer.Address.City))
                {
                    prospectCustomer.Address.City = customer.Address.City;
                }
                prospectCustomer.Address.ZipCode = customer.Address.ZipCode;
            }
            ((IUniqueItemRepository <ProspectCustomer>)_prospectCustomerRepository).Save(prospectCustomer);

            return(_customerService.SaveCustomer(customer, customerViewModel.UpdatedBy));
        }
Exemplo n.º 5
0
        public void StartOutboundCall(long customerId, long prospectCustomerId, long callQueueCustomerId)
        {
            var organizationRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId;
            var callId           = _outboundCallQueueService.SetCallDetail(organizationRoleUserId, customerId);
            var guid             = Guid.NewGuid().ToString();
            var registrationFlow = new RegistrationFlowModel
            {
                GuId   = guid,
                CallId = callId,
                CallQueueCustomerId = callQueueCustomerId
            };

            var callQueueCustomer = _callQueueCustomerRepository.GetById(callQueueCustomerId);

            callQueueCustomer.Status                  = CallQueueStatus.InProcess;
            callQueueCustomer.DateModified            = DateTime.Now;
            callQueueCustomer.ModifiedByOrgRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId;

            _callQueueCustomerRepository.Save(callQueueCustomer);

            var callQueueCustomerCall = new CallQueueCustomerCall {
                CallQueueCustomerId = callQueueCustomerId, CallId = callId
            };

            _callQueueCustomerCallRepository.Save(callQueueCustomerCall);

            Session[guid] = registrationFlow;
            if (customerId == 0 && prospectCustomerId > 0)
            {
                UpdateContactedInfo(prospectCustomerId);
                registrationFlow.ProspectCustomerId = prospectCustomerId;
                Response.RedirectUser("/App/CallCenter/CallCenterRep/BasicCallInfo.aspx?guid=" + guid);
            }
            else if (customerId > 0)
            {
                var customer         = _customerRepository.GetCustomer(customerId);
                var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(customerId);
                if (prospectCustomer != null)
                {
                    UpdateContactedInfo(prospectCustomer.Id);
                    registrationFlow.ProspectCustomerId = prospectCustomer.Id;
                }
                Response.RedirectUser("/App/CallCenter/CallCenterRep/CustomerVerification.aspx?CustomerID=" + customerId + "&Zip=" + customer.Address.ZipCode.Zip + "&guid=" + guid);
            }
        }
        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);
            }
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 public ProspectCustomer GetByCustomerId(long customerId)
 {
     return(_prospectCustomerRepository.GetProspectCustomerByCustomerId(customerId));
 }
        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);
            }
        }
Exemplo n.º 10
0
        public bool EndHealthPlanActiveCall(EndHealthPlanCallEditModel model)
        {
            var  isCallQueueRequsted = false;
            var  removeFromCallQueue = false;
            long customerId          = 0;

            var callQueueCustomer = _callQueueCustomerRepository.GetById(model.CallQueueCustomerId);

            if (callQueueCustomer != null)
            {
                customerId = callQueueCustomer.CustomerId ?? 0;
            }

            //update call status in CustomerCallQueueCallAttempt Table
            if (model.IsSkipped && model.AttemptId > 0)
            {
                var attempt = _customerCallQueueCallAttemptRepository.GetById(model.AttemptId);
                attempt.IsCallSkipped = true;

                if (!string.IsNullOrEmpty(model.SkipCallNote))
                {
                    attempt.SkipCallNote = model.SkipCallNote;
                }
                _customerCallQueueCallAttemptRepository.Save(attempt);
            }

            else if (model.CallId != 0)
            {
                Call callCenterCalll = null;
                if (model.CallId > 0)
                {
                    callCenterCalll = _callCenterCallRepository.GetById(model.CallId);
                    customerId      = callCenterCalll != null ? callCenterCalll.CalledCustomerId : 0;

                    if (callCenterCalll != null && callCenterCalll.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.RescheduleAppointment && callQueueCustomer != null && callQueueCustomer.EventCustomerId.HasValue)
                    {
                        var eventCustomer = _eventCustomerRepository.GetById(callQueueCustomer.EventCustomerId.Value);
                        if (eventCustomer.AppointmentId.HasValue)
                        {
                            var appointment = _appointmentRepository.GetById(eventCustomer.AppointmentId.Value);

                            var eventInfo = _eventService.GetById(eventCustomer.EventId);

                            callQueueCustomer.EventId         = eventCustomer.EventId;
                            callQueueCustomer.AppointmentDate = appointment.StartTime;
                            callQueueCustomer.AppointmentDateTimeWithTimeZone = _smsHelper.ConvertToServerTime(appointment.StartTime, eventInfo.EventTimeZone, !DaylightSavingNotApplicableStates.Contains(eventInfo.State));
                        }
                    }

                    if (tag == ProspectCustomerTag.PatientConfirmed && callQueueCustomer != null && callQueueCustomer.EventCustomerId.HasValue)
                    {
                        var eventCustomer = _eventCustomerRepository.GetById(callQueueCustomer.EventCustomerId.Value);
                        eventCustomer.IsAppointmentConfirmed = true;
                        eventCustomer.ConfirmedBy            = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId;
                        _eventCustomerRepository.Save(eventCustomer);
                    }
                }

                var orgRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId;
                _callQueueCustomerContactService.EndActiveCall(callQueueCustomer, model.CallId, isCallQueueRequsted, orgRoleUserId, removeFromCallQueue, model.CallOutcomeId, model.SkipCallNote);

                if (callQueueCustomer != null)
                {
                    var prospectCustomerId = callQueueCustomer.ProspectCustomerId ?? 0;

                    if (prospectCustomerId == 0)
                    {
                        var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(customerId);
                        if (prospectCustomer != null)
                        {
                            prospectCustomerId = prospectCustomer.Id;
                        }
                    }
                    _callQueueCustomerRepository.UpdateOtherCustomerAttempt(model.CallQueueCustomerId, customerId, prospectCustomerId, orgRoleUserId, callQueueCustomer.CallDate, removeFromCallQueue, callQueueCustomer.CallQueueId, model.CallOutcomeId);
                }
            }
            return(true);
        }
        private CustomerCallQueueCallAttempt SetCustomerCallQueueAttempt(CallQueueCustomer callQueueCustomer)
        {
            try
            {
                var lockedCustomer = _callQueueCustomerLockRepository.GetCallQueueCustomerLock(callQueueCustomer);

                if (lockedCustomer != null)
                {
                    return(null);
                }

                var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(callQueueCustomer.CustomerId.Value);

                Customer customer = null;
                if (prospectCustomer == null)
                {
                    customer = _customerRepository.GetCustomer(callQueueCustomer.CustomerId.Value);
                }

                using (var scope = new TransactionScope())
                {
                    //lock customer in call queue so that other agent not be able to call them;
                    var domain = new CallQueueCustomerLock
                    {
                        CallQueueCustomerId = callQueueCustomer.Id,
                        CustomerId          = callQueueCustomer.CustomerId,
                        ProspectCustomerId  = callQueueCustomer.ProspectCustomerId,
                        CreatedBy           = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId,
                        CreatedOn           = DateTime.Now
                    };

                    _callQueueCustomerLockRepository.SaveCallQueueCustomerLock(domain);                                     //Lock Customer

                    callQueueCustomer.Status                  = CallQueueStatus.InProcess;
                    callQueueCustomer.DateModified            = DateTime.Now;
                    callQueueCustomer.ModifiedByOrgRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId;

                    _callQueueCustomerRepository.Save(callQueueCustomer, false);                                                  //Update CallQueueCustomer Status



                    if (prospectCustomer == null && customer != null)
                    {
                        prospectCustomer = _prospectCustomerFactory.CreateProspectCustomerFromCustomer(customer, false);
                        ((IUniqueItemRepository <ProspectCustomer>)_prospectCustomerRepository).Save(prospectCustomer);
                    }

                    var customerCallQueueCallAttempt = new CustomerCallQueueCallAttempt
                    {
                        DateCreated              = DateTime.Now,
                        IsCallSkipped            = false,
                        IsNotesReadAndUnderstood = false,
                        CreatedBy             = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId,
                        CustomerId            = callQueueCustomer.CustomerId.Value,
                        CallId                = null,
                        CallQueueCustomerId   = callQueueCustomer.Id,
                        NotInterestedReasonId = null
                    };

                    var callAttempt = _customerCallQueueCallAttemptRepository.Save(customerCallQueueCallAttempt);           //CustomerCallQueueCallAttempt Entry
                    scope.Complete();
                    return(callAttempt);
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Some Error occured");
                _logger.Error("Message: " + ex.Message);
                _logger.Error("Stack Trace: " + ex.StackTrace);
            }
            return(null);
        }