public void GetZipCodesInRadiusReturnsZipCodes() { List <ZipCode> zipCodes = _zipCodeRepository.GetZipCodesInRadius(ZIP_WITH_OTHERS_IN_RANGE, 1); Assert.IsNotNull(zipCodes); Assert.IsNotEmpty(zipCodes, "No zip codes returned from persistence."); }
public IEnumerable <PhysicianMaster> Search(string firstName, string lastName, string zipcode, int pageNumber, int pageSize, out int totalRecords) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var linqMetaData = new LinqMetaData(adapter); var query = (from pm in linqMetaData.PhysicianMaster where pm.IsActive select pm); if (!string.IsNullOrEmpty(zipcode)) { //query = (from q in query where q.PracticeZip == zipcode select q); var zipInRange = _zipcodeRepository.GetZipCodesInRadius(zipcode, 10); var zipCodesInRange = zipInRange != null?zipInRange.Select(zcir => zcir.Zip).ToList() : null; if (!(zipCodesInRange == null || zipCodesInRange.IsEmpty())) { var mapping = new FunctionMapping(this.GetType(), "IndexOf", 2, " charindex({0}, {1})"); if (linqMetaData.CustomFunctionMappings == null) { linqMetaData.CustomFunctionMappings = new FunctionMappingStore(); } linqMetaData.CustomFunctionMappings.Add(mapping); mapping = new FunctionMapping(typeof(Convert), "ToString", 1, "',' + Convert(varchar, {0}) + ','"); linqMetaData.CustomFunctionMappings.Add(mapping); string zipIdstring = "," + string.Join(",", zipCodesInRange) + ","; query = from pm in linqMetaData.PhysicianMaster where pm.IsActive && IndexOf(Convert.ToString(pm.PracticeZip), zipIdstring) > 0 select pm; } } if (!string.IsNullOrEmpty(firstName)) { query = (from q in query where q.FirstName.Contains(firstName) select q); } if (!string.IsNullOrEmpty(lastName)) { query = (from q in query where q.LastName.Contains(lastName) select q); } query = (from q in query orderby q.FirstName, q.LastName, q.PhysicianMasterId select q); totalRecords = query.Count(); var entities = query.TakePage(pageNumber, pageSize).ToList(); return(Mapper.Map <IEnumerable <PhysicianMasterEntity>, IEnumerable <PhysicianMaster> >(entities)); } }
public static List <ZipCode> GetZipCodesInRange(string originatingZipCode, int rangeInMiles) { return(_zipCodeRepository.GetZipCodesInRadius(originatingZipCode, rangeInMiles).OrderBy(z => z.Zip).ToList()); }
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); }