public async Task <IActionResult> GetEvents([FromQuery] EventResourceParameters eventResourceParameters)
        {
            Func <Event, bool> filter = GetFilter(eventResourceParameters);

            IEnumerable <Event> events = await _batchReader.Read(filter);

            return(Ok(events));
        }
        private static Func <Event, bool> GetFilter(EventResourceParameters eventResourceParameters)
        {
            Expression <Func <Event, bool> > filterExpression = e => true;

            if (eventResourceParameters.FromDate != null)
            {
                Expression <Func <Event, bool> > fromFilterExpression = e => e.OpenDate >= eventResourceParameters.FromDate;
                filterExpression = filterExpression.And(fromFilterExpression);
            }
            if (eventResourceParameters.ToDate != null)
            {
                Expression <Func <Event, bool> > toFilterExpression = e => e.OpenDate <= eventResourceParameters.ToDate;
                filterExpression = filterExpression.And(toFilterExpression);
            }
            return(filterExpression.Compile());
        }
        public async Task <IActionResult> GetEventsByCompetitionId(string competitionId, [FromQuery] EventResourceParameters eventResourceParameters)
        {
            Competition competition = await _competitionReader.Read(competitionId);

            if (competition == null)
            {
                return(NotFound($"Could not find Competition with id of {competitionId}"));
            }

            Func <Event, bool>  filter = GetFilter(eventResourceParameters);
            IEnumerable <Event> events = await _batchReader.Read(e => filter(e) && e.CompetitionId == competitionId);

            return(Ok(events));
        }