Example #1
0
        public CallQueueCampaignListModel GetCampaignListModel(CampaignCallQueueFilter filter, int pageSize, out int totalRecords)
        {
            var campaigns = _campaignRepository.GetCampaignIdsForCallQueue(filter, pageSize, out totalRecords);

            var healthPlan = ((IUniqueItemRepository <CorporateAccount>)_corporateAccountRepository).GetById(filter.HealthPlanId);

            var campaignBasic = new List <CampaignBasicInfo>();


            var campaignIdCriteriaIdPair = _campaignRepository.GetCriteriaIdsForCampaigns(campaigns.Select(x => x.Id));

            if (!campaigns.IsNullOrEmpty() && !campaignIdCriteriaIdPair.IsNullOrEmpty())
            {
                campaignBasic.AddRange(campaigns.Select(campaign => new CampaignBasicInfo
                {
                    Id            = campaign.Id,
                    Name          = campaign.Name,
                    StartDate     = campaign.StartDate,
                    EndDate       = campaign.EndDate,
                    HealthPlanTag = healthPlan.Tag,
                    CriteriaId    = campaignIdCriteriaIdPair.First(x => x.FirstValue == campaign.Id).SecondValue
                }));
            }

            return(new CallQueueCampaignListModel
            {
                Campaign = campaignBasic,
                Filter = filter,
                PagingModel = new PagingModel(filter.PageNumber, pageSize, totalRecords, null)
            });
        }
Example #2
0
        public CallQueueCampaignListModel GetCampaignHealthPlan([FromUri] CampaignCallQueueFilter filter)
        {
            int totalRecords;

            filter.AssignedToOrgRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId;
            var model = _campaignService.GetCampaignListModel(filter, PageSize, out totalRecords);

            return(model);
        }
Example #3
0
        public ActionResult CampaignCallQueue([FromUri] CampaignCallQueueFilter filter, int pageNumber = 1)
        {
            int totalRecords;
            var model = _campaignService.GetCampaignListModel(filter, _pageSize, out totalRecords);

            var currentAction          = ControllerContext.RouteData.Values["action"].ToString();
            Func <int, string> urlFunc =
                pn =>
                Url.Action(currentAction,
                           new
            {
                pageNumber = pn,
                filter.CallQueueId,
                filter.CampaignId,
                filter.HealthPlanId,
            });

            model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc);

            return(View(model));
        }
Example #4
0
        public IEnumerable <Campaign> GetCampaignIdsForCallQueue(CampaignCallQueueFilter filter, int pageSize, out int totalRecords)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var callQueueCampaignIds = (from cqc in linqMetaData.CallQueueCustomer where cqc.CampaignId.HasValue && cqc.CallQueueId == filter.CallQueueId select cqc.CampaignId.Value);

                var query = (from hpca in linqMetaData.HealthPlanCriteriaAssignment
                             join hpcqc in linqMetaData.HealthPlanCallQueueCriteria on hpca.HealthPlanCriteriaId equals hpcqc.Id
                             join c in linqMetaData.Campaign on hpcqc.CampaignId equals c.Id
                             where c.IsPublished && c.TypeId == (long)CampaignType.Corporate && c.EndDate >= DateTime.Today && hpca.AssignedToOrgRoleUserId == filter.AssignedToOrgRoleUserId && hpcqc.HealthPlanId == filter.HealthPlanId && hpcqc.CampaignId.HasValue &&
                             callQueueCampaignIds.Contains(hpcqc.CampaignId.Value)
                             select c);

                if (filter.StartDate.HasValue)
                {
                    query = (from q in query where q.StartDate >= filter.StartDate.Value select q);
                }

                if (filter.EndDate.HasValue)
                {
                    query = (from q in query where q.EndDate <= filter.EndDate.Value select q);
                }

                var campaignWithCriteria = (from c in query
                                            join hpcqc in linqMetaData.HealthPlanCallQueueCriteria on c.Id equals hpcqc.CampaignId.Value
                                            where hpcqc.CampaignId.HasValue && hpcqc.CampaignId.Value > 0
                                            select new { c, hpcqc }
                                            );

                totalRecords = campaignWithCriteria.Count();
                var campaignQuery = campaignWithCriteria.OrderByDescending(q => q.hpcqc.DateModified).ThenByDescending(o => o.hpcqc.DateCreated).Select(q => q.c);

                var entities = campaignQuery.TakePage(filter.PageNumber, pageSize);

                return(AutoMapper.Mapper.Map <IEnumerable <CampaignEntity>, IEnumerable <Campaign> >(entities));
            }
        }