public SystemGeneratedCallQueueCriteria UpdateUpsellQueueCriteria(UpsellQueueCriteriaEditModel model, long organizationRoleId) { SystemGeneratedCallQueueCriteria criteria; if (model.CriteriaId > 0) { criteria = _systemGeneratedCallQueueCriteriaRepository.GetById(model.CriteriaId); criteria.Amount = model.Amount; criteria.NoOfDays = model.NoOfDays; criteria.DataRecorderMetaData.DataRecorderModifier = new OrganizationRoleUser(organizationRoleId); criteria.DataRecorderMetaData.DateModified = DateTime.Now; criteria.IsQueueGenerated = false; } else { criteria = new SystemGeneratedCallQueueCriteria { DataRecorderMetaData = new DataRecorderMetaData(new OrganizationRoleUser(organizationRoleId), DateTime.Now, null), CallQueueId = model.CallQueueId, Amount = model.Amount, NoOfDays = model.NoOfDays, AssignedToOrgRoleUserId = organizationRoleId }; } return(_systemGeneratedCallQueueCriteriaRepository.Save(criteria)); }
public SystemGeneratedCallQueueCriteria Save(SystemGeneratedCallQueueCriteria systemGeneratedCallQueueCriteria) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entity = Mapper.Map <SystemGeneratedCallQueueCriteria, SystemGeneratedCallQueueCriteriaEntity>(systemGeneratedCallQueueCriteria); if (!adapter.SaveEntity(entity, true)) { throw new PersistenceFailureException(); } return(Mapper.Map <SystemGeneratedCallQueueCriteriaEntity, SystemGeneratedCallQueueCriteria>(entity)); } }
public IEnumerable <CallQueueCustomer> GetCallQueueCustomers(long callQueueId, SystemGeneratedCallQueueCriteria criteria) { var days = criteria.NoOfDays; var percentage = criteria.Percentage; var endDate = DateTime.Today.AddDays(days); var eventList = _eventRepository.GetEventsForFillEventsCallQueue(endDate); if (eventList == null || !eventList.Any()) { return(null); } eventList = _fillEventsCallQueueHelper.GetAllTheEventFilledUnderPecentage(eventList, percentage); if (eventList == null || !eventList.Any()) { return(null); } var eventIds = eventList.Select(x => x.Id); var eventZipPairList = new List <OrderedPair <long, string> >(); var hostList = _hostRepository.GetEventHosts(eventIds); foreach (var theEvent in eventList) { var host = hostList.FirstOrDefault(h => h.Id == theEvent.HostId); if (host != null) { eventZipPairList.Add(new OrderedPair <long, string>(theEvent.Id, host.Address.ZipCode.Zip)); } } var zipList = eventZipPairList.Select(x => x.SecondValue).Distinct().ToList(); var zipZipStringPairList = new List <OrderedPair <string, string> >(); foreach (var zip in zipList) { var zipCodesInRange = _zipCodeRepository.GetZipCodesInRadius(zip, 10) ?? new List <ZipCode>(); if (!zipCodesInRange.Any()) { zipZipStringPairList.Add(new OrderedPair <string, string>(zip, "," + zip + ",")); } else { var zipCodestring = "," + string.Join(",", zipCodesInRange) + ","; zipZipStringPairList.Add(new OrderedPair <string, string>(zip, zipCodestring)); } } var customers = _customerRepository.GetCustomerForFillEventCallQueue(eventZipPairList, zipZipStringPairList); var pcustomers = _prospectCustomerRepository.GetProspectCustomerForFillEventCallQueue(eventZipPairList, zipZipStringPairList); if ((customers == null || !customers.Any()) && (pcustomers == null || !pcustomers.Any())) { return(null); } var callQueueCustomerList = new List <CallQueueCustomer>(); if (customers != null && customers.Any()) { foreach (var customer in customers) { callQueueCustomerList.Add(new CallQueueCustomer { CallQueueId = callQueueId, EventId = customer.FirstValue, CustomerId = customer.SecondValue }); } } if (pcustomers != null && pcustomers.Any()) { foreach (var pcustomer in pcustomers) { if (callQueueCustomerList.Any(cqcl => cqcl.CustomerId == pcustomer.CustomerId && cqcl.EventId == pcustomer.EventId)) { continue; } callQueueCustomerList.Add(new CallQueueCustomer { CallQueueId = callQueueId, ProspectCustomerId = pcustomer.ProspectCustomerId, CustomerId = pcustomer.CustomerId, EventId = pcustomer.EventId }); } } return(callQueueCustomerList); }
public SystemGeneratedCallQueueCriteria Save(SystemGeneratedCallQueueCriteria systemGeneratedCallQueueCriteria) { var criteria = _systemGeneratedCallQueueCriteriaRepository.Save(systemGeneratedCallQueueCriteria); return(criteria); }