Пример #1
0
        public CallCentreAgentQueueListModel GetCallAgentSpecificQueuesData([FromUri] CallCentreAgentQueueFilter filter, int pageNumber)
        {
            int totalRecords        = 0;
            var agentOrgRoleUserId  = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId;
            var agentOrganizationId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationId;

            filter.AgentOrganizationRoleUserId = agentOrgRoleUserId;
            filter.AgentOrganizationId         = agentOrganizationId;

            var collection = _customerCallQueueCallAttemptService.CallCenterAgentDashboardData(filter, pageNumber, PageSize, out totalRecords);

            var model = new CallCentreAgentQueueListModel
            {
                HealthPlanList = _healthPlanCallQueueService.GetHealthPlanDropdownList(agentOrganizationId),
                CallQueuesList = _healthPlanCallQueueService.GetHealthPlanCallQueueDropDownList(),
                Collection     = collection,
                Filter         = filter,
                PagingModel    = new PagingModel(pageNumber, PageSize, totalRecords, null)
            };

            return(model);
        }
Пример #2
0
        public IEnumerable <CallCentreAgentQueueListViewModel> CallCenterAgentDashboardData(CallCentreAgentQueueFilter filter, int pageNumber, int pageSize, out int totalRecords)
        {
            var criteriaCollection = _callQueueCriteriaRepository.GetAgentAssignedCallQueueCriteria(filter);

            if (criteriaCollection.IsNullOrEmpty())
            {
                totalRecords = 0;
                return(null);
            }

            //to find distinct list of healthplanIds just group them and select first of each such group
            var healthPlanIds = criteriaCollection.Select(x => x.HealthPlanId).Distinct();

            var healthPlanNameIdPairList = _corporateAccountRepository.HealthPlanNamesCorrepondingToHealthPlanIds(healthPlanIds);

            var callQueues = _callQueueRepository.GetByIds(criteriaCollection.Select(x => x.CallQueueId).Distinct(), false, true);

            var campaignIds = criteriaCollection.Where(x => x.CampaignId.HasValue).Select(x => x.CampaignId.Value).ToList();
            var campaigns   = _campaignRepository.GetByIds(campaignIds);

            var criteriaIds = criteriaCollection.Select(x => x.Id).ToArray();

            //Eliminating those criterias for which Number of Customers are ZERO
            var criteriasToExclude = new List <long>();

            foreach (var criteria in criteriaCollection)
            {
                var count = CustomerCountForHealthPlanCriteria(criteria, callQueues, true);
                if (!(count > 0))
                {
                    criteriasToExclude.Add(criteria.Id);
                }
            }
            criteriaCollection = criteriaCollection.Where(x => !criteriasToExclude.Contains(x.Id)).Select(x => x);    //uncomment this to make this work(except fillevent)

            //Take criterias according to our paging
            pageNumber         = pageNumber <= 0 ? 1 : pageNumber;
            totalRecords       = criteriaCollection.Count();
            criteriaCollection = criteriaCollection.Skip(pageSize * (pageNumber - 1)).Take(pageSize);

            var assignments     = _healthPlanCriteriaAssignmentRepository.GetByCriteriaIds(criteriaIds);
            var teamAssignments = _healthPlanCriteriaTeamAssignmentRepository.GetByCriteriaIds(criteriaIds);

            var criteriaDirectMailDates = _healthPlanCriteriaDirectMailService.GetDirectMailDatesByCriteriaIds(criteriaCollection.Select(x => x.Id));

            //putting data into our View model to be returned
            var listModel = new List <CallCentreAgentQueueListViewModel>();

            foreach (var item in criteriaCollection)
            {
                var model = new CallCentreAgentQueueListViewModel();

                var healthPlan     = healthPlanNameIdPairList.First(x => x.FirstValue == item.HealthPlanId);
                var callQueue      = callQueues.First(x => x.Id == item.CallQueueId);
                var campaign       = item.CampaignId.HasValue ? campaigns.First(x => x.Id == item.CampaignId.Value) : null;
                var assignmentDate = assignments != null?assignments.FirstOrDefault(x => x.HealthPlanCriteriaId == item.Id && x.AssignedToOrgRoleUserId == filter.AgentOrganizationRoleUserId) : null;

                var teamAssignmentDate = teamAssignments != null?teamAssignments.FirstOrDefault(x => x.HealthPlanCriteriaId == item.Id) : null;

                var directMailDates = criteriaDirectMailDates.Where(x => x.FirstValue == item.Id).Select(x => x.SecondValue);

                model.CriteriaName = callQueue.Category == HealthPlanCallQueueCategory.FillEventsHealthPlan || callQueue.Category == HealthPlanCallQueueCategory.AppointmentConfirmation ? item.CriteriaName
                    : (callQueue.Category == HealthPlanCallQueueCategory.MailRound ? campaign.Name : healthPlan.SecondValue + " " + callQueue.Name);
                model.CriteriaId     = item.Id;
                model.HealthPlanName = healthPlan.SecondValue;
                model.HealthPlanId   = healthPlan.FirstValue;
                model.CallQueueName  = callQueue.Name;
                model.CallQueueId    = callQueue.Id;
                model.CapmaignId     = item.CampaignId;
                model.CampaignName   = campaign != null ? campaign.Name : string.Empty;
                if (assignmentDate != null)
                {
                    model.StartDate = assignmentDate.StartDate;
                    model.EndDate   = assignmentDate.EndDate;
                }
                else if (teamAssignmentDate != null)
                {
                    model.StartDate = teamAssignmentDate.StartDate;
                    model.EndDate   = teamAssignmentDate.EndDate;
                }

                model.DirectMailDates = directMailDates;

                listModel.Add(model);
            }

            return(listModel);
        }
Пример #3
0
        public IEnumerable <HealthPlanCallQueueCriteria> GetAgentAssignedCallQueueCriteria(CallCentreAgentQueueFilter filter)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                //var confirmationCallQueue = (from cq in linqMetaData.CallQueue where cq.Category == HealthPlanCallQueueCategory.AppointmentConfirmation select cq).SingleOrDefault();

                var agentOrganization = (from acco in linqMetaData.AccountCallCenterOrganization
                                         where acco.OrganizationId == filter.AgentOrganizationId && acco.IsDeleted == false
                                         select acco.AccountId);

                var accountIds = (from a in linqMetaData.Account
                                  where a.IsHealthPlan && (a.RestrictHealthPlanData == false || agentOrganization.Contains(a.AccountId))
                                  select a.AccountId);

                var collection = (from hpcqc in linqMetaData.HealthPlanCallQueueCriteria
                                  join hpca in linqMetaData.HealthPlanCriteriaAssignment on hpcqc.Id equals hpca.HealthPlanCriteriaId into assignment
                                  from a in assignment.DefaultIfEmpty()
                                  join hpct in linqMetaData.HealthPlanCriteriaTeamAssignment on hpcqc.Id equals hpct.HealthPlanCriteriaId into healthPlanCriteriaTeamAssignment
                                  from hpcta in healthPlanCriteriaTeamAssignment.DefaultIfEmpty()
                                  join cca in linqMetaData.CallCenterAgentTeam on hpcta.TeamId equals cca.TeamId into callCenterAgentTeam
                                  from ccat in callCenterAgentTeam.DefaultIfEmpty()
                                  where hpcqc.IsDeleted == false &&
                                  hpcqc.HealthPlanId.HasValue &&
                                  accountIds.Contains(hpcqc.HealthPlanId.Value) &&
                                  hpcqc.IsQueueGenerated &&
                                  (
                                      //(confirmationCallQueue != null && hpcqc.CallQueueId == confirmationCallQueue.CallQueueId)
                                      //||
                                      (a.AssignedToOrgRoleUserId != null && a.AssignedToOrgRoleUserId == filter.AgentOrganizationRoleUserId && a.StartDate < DateTime.Today.AddDays(1) && (a.EndDate == null || a.EndDate >= DateTime.Today))
                                      ||
                                      (ccat.AgentId != null && ccat.AgentId == filter.AgentOrganizationRoleUserId && hpcta.StartDate < DateTime.Today.AddDays(1) && (hpcta.EndDate == null || hpcta.EndDate >= DateTime.Today))
                                  )

                                  select hpcqc);

                if (filter.HealthPlanId > 0)
                {
                    collection = (from c in collection
                                  where c.HealthPlanId == filter.HealthPlanId
                                  select c);
                }
                if (filter.CallQueueId > 0)
                {
                    collection = (from c in collection
                                  where c.CallQueueId == filter.CallQueueId
                                  select c);
                }

                var entities = collection.Distinct().ToArray();
                return(Mapper.Map <IEnumerable <HealthPlanCallQueueCriteriaEntity>, IEnumerable <HealthPlanCallQueueCriteria> >(entities));
            }
        }