Esempio n. 1
0
        private List <KeyValuePair <string, string> > ValidateRequest(LocationGetQuery request)
        {
            var issues = _validator.Validate(request).Errors;

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

            return(_errors);
        }
Esempio n. 2
0
        public async Task <QueryResponse <List <Location> > > Handle(LocationGetQuery request, CancellationToken cancellationToken)
        {
            var response = new QueryResponse <List <Location> >()
            {
                Errors = ValidateRequest(request)
            };

            if (!response.Errors.Any())
            {
                try
                {
                    response.Result = _dbContext.Location.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);
        }