private OnlineSchedulingEventListModel GetEvents(string zipCode, int maxNumberofRecordstoFetch, out int totalRecords) { var filter = new OnlineSchedulingEventListModelFilter { DateFrom = DateTime.Now.Date.AddDays(1), DateTo = DateTime.Now.Date.AddDays(30), ZipCode = zipCode, Radius = 50 }; return(_eventService.GetOnlineSchedulingEventCollection(filter, SortOrderBy.Distance, SortOrderType.Ascending, maxNumberofRecordstoFetch, 1, maxNumberofRecordstoFetch, out totalRecords)); }
public OnlineEventListModel GetEvents([FromUri] OnlineSchedulingEventListModelFilter filter) { filter.CutOffHourstoMarkEventforOnlineSelection = _cutOffhoursbeforeEventSelection; var onlineRequestValidationModel = _tempcartService.ValidateOnlineRequest(filter.Guid); var model = new OnlineEventListModel { RequestValidationModel = onlineRequestValidationModel }; if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid) { return(model); } int totalRecords = 0; if (!string.IsNullOrEmpty(filter.Guid)) { filter = CompleteFilter(model.RequestValidationModel.TempCart, filter); } model.Events = _onlineEventService.GetEvents(filter, _maxNumberOfEventstoFetch, _pageSize, out totalRecords); model.TotalEvents = totalRecords; model.PagingModel = new PagingModel(filter.PageNumber, _pageSize, totalRecords, null); if (string.IsNullOrWhiteSpace(filter.InvitationCode)) { return(model); } ; var theEvent = _eventRepository.GetEventByInvitationCode(filter.InvitationCode); if (theEvent != null) { var account = _corporateAccountRepository.GetbyEventId(theEvent.Id); if (account != null && account.CheckoutPhoneNumber != null && !string.IsNullOrWhiteSpace(account.CheckoutPhoneNumber.DomesticPhoneNumber)) { model.CheckoutPhoneNumber = account.CheckoutPhoneNumber.FormatPhoneNumber; } } return(model); }
private static OnlineSchedulingEventListModelFilter CompleteFilter(TempCart tempCart, OnlineSchedulingEventListModelFilter filter) { if (tempCart == null) { return(filter); } if (filter == null) { filter = new OnlineSchedulingEventListModelFilter(); } filter.ZipCode = !string.IsNullOrEmpty(filter.ZipCode) ? filter.ZipCode : tempCart.ZipCode; filter.Radius = (int?)tempCart.Radius; filter.EventId = tempCart.EventId.HasValue ? tempCart.EventId.Value : 0; filter.InvitationCode = !string.IsNullOrEmpty(filter.InvitationCode) ? filter.InvitationCode : tempCart.InvitationCode; return(filter); }
public IEnumerable <OnlineEventViewModel> GetEvents(OnlineSchedulingEventListModelFilter filter, int maxNumberofRecordstoFetch, int pageSize, out int totalRecords) { var events = _eventRepository.GetEventsbyFilters(filter, out totalRecords); if (events == null || !events.Any()) { return(null); } var todayEventIds = events.Where(e => e.EventDate < DateTime.Now.Date.AddDays(1)).Select(e => e.Id); var todaySlots = _eventSchedulingSlotRepository.GetbyEventIds(todayEventIds); var eventIds = events.Select(e => e.Id).Distinct().ToArray(); var hosts = _hostRepository.GetEventHosts(eventIds); var eventAppointmentStatsModels = _eventAppointmentStatsService.Get(eventIds); ZipCode zipCode = null; try { if (!string.IsNullOrEmpty(filter.ZipCode)) { zipCode = _zipCodeRepository.GetZipCode(filter.ZipCode).FirstOrDefault(); } } catch (ObjectNotFoundInPersistenceException <ZipCode> ) { zipCode = null; } var eventCollection = _onlineEventListModelFactory.Create(events, hosts, eventAppointmentStatsModels, zipCode, todaySlots, filter.EventId, filter.CutOffHourstoMarkEventforOnlineSelection, filter.OrderBy, filter.OrderType, maxNumberofRecordstoFetch, filter.PageNumber, pageSize, out totalRecords); eventIds = eventCollection.Select(e => e.EventId).Distinct().ToArray(); foreach (var theEvent in eventCollection) { var eventTest = _eventTestRepository.GetByEventAndTestIds(theEvent.EventId, TestGroup.BreastCancer); theEvent.HasBreastCancer = eventTest != null && eventTest.Any(); } var eventHpPairs = _hospitalPartnerRepository.GetEventAndHospitalPartnerOrderedPair(eventIds); var eventCorporateAccountPairs = _corporateAccountRepository.GetEventIdCorporateAccountPairForSponsoredBy(eventIds); var organizations = eventCorporateAccountPairs == null || eventCorporateAccountPairs.Count() < 1 ? null : _organizationRepository.GetOrganizations(eventCorporateAccountPairs.Select(m => m.SecondValue).Distinct().ToArray()); var fileIds = organizations != null?organizations.Where(o => o.LogoImageId > 0).Select(o => o.LogoImageId).ToArray() : null; var files = fileIds == null ? null : _fileRepository.GetByIds(fileIds); if (files != null) { var location = _mediaRepository.GetOrganizationLogoImageFolderLocation(); files = files.Select(f => { f.Path = location.Url + f.Path; return(f); }).ToArray(); eventCollection = _onlineEventListModelFactory.ManageSponsoredByLogo(eventCollection, eventCorporateAccountPairs, organizations, files); } organizations = eventHpPairs == null || eventHpPairs.Count() < 1 ? null : _organizationRepository.GetOrganizations(eventHpPairs.Select(m => m.SecondValue).Distinct().ToArray()); fileIds = organizations != null?organizations.Where(o => o.LogoImageId > 0).Select(o => o.LogoImageId).ToArray() : null; files = fileIds == null ? null : _fileRepository.GetByIds(fileIds); if (files != null) { var location = _mediaRepository.GetOrganizationLogoImageFolderLocation(); files = files.Select(f => { f.Path = location.Url + f.Path; return(f); }).ToArray(); eventCollection = _onlineEventListModelFactory.ManageSponsoredByLogo(eventCollection, eventHpPairs, organizations, files); } return(eventCollection); }