Beispiel #1
0
        public ResultHandler <IEnumerable <Expression <Func <EventModel, bool> > > > BuildExpressions(IEnumerable <FilterStatement <EventModel> > filterStatements)
        {
            try
            {
                List <Expression <Func <EventModel, bool> > > result = new List <Expression <Func <EventModel, bool> > >();
                foreach (var filterStatement in filterStatements)
                {
                    IFilter <EventModel> filter = this._eventFilterResolver(filterStatement.FilterType);
                    ResultHandler <Expression <Func <EventModel, bool> > > expressionResult = filter.BuildExpression(filterStatement);
                    if (!expressionResult.Success)
                    {
                        this._logger.LogError(expressionResult.ErrorMessage);
                        return(ResultHandler.Fail <IEnumerable <Expression <Func <EventModel, bool> > > >(expressionResult.ErrorCode));
                    }

                    result.Add(expressionResult.Value);
                }
                return(ResultHandler.Ok <IEnumerable <Expression <Func <EventModel, bool> > > >(result));
            }
            catch (Exception ex)
            {
                return(ResultHandler.Fail <IEnumerable <Expression <Func <EventModel, bool> > > >(ex));
            }
        }