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

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

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

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