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); }