Exemplo n.º 1
0
        public IResult ValidateNoDuplicatedEmployeeDate(IList <Employee> employees)
        {
            var duplicateEmployee = employees.GroupBy(e => e.Date).Where(group => group.Count() > 1).ToList();

            if (duplicateEmployee.Any())
            {
                var error = new DuplicateEmployeeDateError(duplicateEmployee.First().Key);
                _errorResolver.Resolve(error);
                return(error);
            }

            return(new SuccessfulResult());
        }
 public async Task <TResponse> Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate <TResponse> next)
 {
     try {
         return(await next());
     } catch (Exception ex) {
         return(AppResponse.Failure(_errorResolver.Resolve(ex)) as TResponse);
     }
 }
Exemplo n.º 3
0
        private ParsedResult ReadFile(string filename)
        {
            var listInputRecords = new List <InputWorkingRecords>();

            try
            {
                using (var reader = new StreamReader(filename))
                {
                    Console.SetIn(reader);
                    string line;
                    while ((line = Console.ReadLine()) != null)
                    {
                        listInputRecords.Add(new InputWorkingRecords {
                            Line = line
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                _errorResolver.Resolve(new UnknownError(ex.Message));
            }

            return(ParseContent(listInputRecords));
        }
Exemplo n.º 4
0
        public IEnumerable <IError> Resolve(T resolvable)
        {
            var errors = _resolver.Resolve(resolvable).ToList();

            _chain.MatchSome(nestedResolver => {
                errors.AddRange(nestedResolver.Resolve(resolvable));
            });

            return(errors);
        }
Exemplo n.º 5
0
 public IEnumerable <IError> ResolveErrors(HttpResponseMessage response)
 {
     return(_errorResolver.Resolve(response));
 }