public async Task <List <EventInfo> > ListEventsAsync(
            EventInfoFilter filter            = null,
            EventRetrievalOrder order         = EventRetrievalOrder.StartDate,
            EventInfoRetrievalOptions options = null)
        {
            var query = _context.EventInfos.AsNoTracking()
                        .UseOptions(options ?? new EventInfoRetrievalOptions())
                        .UseFilter(filter ?? new EventInfoFilter())
                        .UseOrder(order);

            query = await AddOrgFilterIfNeededAsync(query);

            return(await query.ToListAsync());
        }
        public async Task <List <EventInfo> > ListEventsAsync(
            EventInfoFilter filter,
            EventRetrievalOrder order,
            EventInfoRetrievalOptions options,
            CancellationToken cancellationToken)
        {
            filter ??= new EventInfoFilter();

            var query = _context.EventInfos
                        .AsNoTracking()
                        .UseOptions(options ?? new EventInfoRetrievalOptions())
                        .UseFilter(filter)
                        .UseOrder(order);

            if (filter.AccessibleOnly)
            {
                query = await AddOrgFilterIfNeededAsync(query, cancellationToken);
            }

            return(await query.ToListAsync(cancellationToken));
        }
        public static IQueryable <EventInfo> UseOrder(this IQueryable <EventInfo> query, EventRetrievalOrder order)
        {
            switch (order)
            {
            case EventRetrievalOrder.Title:
                query = query.OrderBy(e => e.Title);
                break;

            default:
                query = query.OrderBy(e => e.DateStart);
                break;
            }

            return(query);
        }