public CountryQuery(ICountryHttpClient countryHttpClient) { Name = this.GetType().Name; FieldAsync <ListGraphType <CountryType> >( name: "countries", resolve: async(context) => { var query = await countryHttpClient.GetAll(); return(query); } ); }
public AssetValidator(ICountryHttpClient countryHttpClient) { RuleFor(x => x.AssetName).MinimumLength(5); RuleFor(x => x.Department) .Custom((deparment, context) => { if (!Enum.TryParse(deparment, out Department department)) { context.AddFailure("Is not a valid department type."); } }); RuleFor(x => x.CountryOfDepartment).NotNull().Custom((country, context) => { if (!countryHttpClient.CountryExist(country).Result) { context.AddFailure("The specified country doesn't exist."); } }); RuleFor(x => x.PurchaseDate).Must(BeAValidDate); //-> must not be older then one year. RuleFor(x => x.EmailAdressOfDepartment).EmailAddress(); }
public CountryController(ICountryHttpClient countryHttpClient) { this._countryHttpClient = countryHttpClient; }