public IEnumerable <EventModel> GetNextEvents(IPublishedContent eventsPage, IPublishedContent currentMember, int maxItems = 0) { EventSearchCriteria criteria = new EventSearchCriteria { FutureOnly = true, MaxItems = maxItems }; IEnumerable <EventModel> nextEvents = SearchEvents(eventsPage, currentMember, criteria); return(nextEvents); }
public IEnumerable <EventModel> SearchEvents(IPublishedContent eventsPage, IPublishedContent member, EventSearchCriteria criteria) { IEnumerable <EventModel> events = eventsPage .Children .Select(GetEvent) .Where(x => member != null || x.Public) .OrderBy(x => x.Date); if (criteria.FutureOnly == true) { events = events.Where(x => x.Date >= DateTime.Today); } if (criteria.Month != null) { events = events.Where(x => x.Date.Month == criteria.Month.Value); } if (criteria.MaxItems > 0) { events = events.Take(criteria.MaxItems.Value); } return(events); }