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); } }
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)); }
public IEnumerable <IError> Resolve(T resolvable) { var errors = _resolver.Resolve(resolvable).ToList(); _chain.MatchSome(nestedResolver => { errors.AddRange(nestedResolver.Resolve(resolvable)); }); return(errors); }
public IEnumerable <IError> ResolveErrors(HttpResponseMessage response) { return(_errorResolver.Resolve(response)); }