public Poll <EventViewModel> GetEventPoll(EventsFilter filter = null, int?offset = 0, int?count = 100) { var wholeSequence = context.Events .Include(e => e.EventCategories).ThenInclude(ec => ec.Category) .Include(e => e.EventTags).ThenInclude(et => et.Tag) .Include(e => e.Place).Include(e => e.Dates).AsNoTracking(); if (filter != null) { wholeSequence = filter.FilterEvents(wholeSequence).AsQueryable(); } var limitedSequence = wholeSequence .Skip(offset ?? 0).Take(count ?? 100); return(limitedSequence.AsEnumerable() .AsViewModels <Event, EventViewModel>() .ToPoll()); }
public async Task <Poll <EventViewModel> > Get() { var events = await GetEventsFromTarget(); var query = Request.Query; if (query.ContainsKey(Constants.CategoriesKey)) { var filter = new EventsFilter { RequiredCategories = new List <string>() }; var categories = query[Constants.CategoriesKey].ToString().Split(','); foreach (var category in categories) { filter.RequiredCategories.Add(category); } events = filter.FilterEvents(events.Results).ToPoll(); } return(events); }