示例#1
0
        private List <KeyValuePair <string, string> > ValidateRequest(EventGetQuery request)
        {
            var issues = _validator.Validate(request).Errors;

            foreach (var issue in issues)
            {
                _errors.Add(new KeyValuePair <string, string>(issue.PropertyName, issue.ErrorMessage));
            }

            return(_errors);
        }
示例#2
0
        public async Task <QueryResponse <List <Event> > > Handle(EventGetQuery request, CancellationToken cancellationToken)
        {
            var response = new QueryResponse <List <Event> >()
            {
                Errors = ValidateRequest(request)
            };

            if (!response.Errors.Any())
            {
                try
                {
                    response.Result = _dbContext.Event.Where(request.QueryPredicate).ToList();
                }
                catch (Exception e)
                {
                    _logger.LogCritical(e.ToString());
                    response.ErrorInfo.UserErrorMessage = "An unknown error has occurred.";
                    response.ErrorInfo.HasException     = true;
                }
            }

            return(response);
        }