예제 #1
0
 public VehicleValidator(LocationReadService locationReadService)
 {
     RuleFor(v => v.Vin).NotNull().NotEmpty().Length(17);
     RuleFor(v => v.LocationCode)
     .MustAsync(async
                    (v, l, token) => string.IsNullOrEmpty(l) || await locationReadService.GetLocation(new LocationRequest {
         LocationCode = l
     }, new InMemoryGrpcServerCallContext()) != null)
     .WithMessage(v => $"No location was found for location code: {v.LocationCode}.");
 }
 public Task <Contracts.Location> Resolve(Contracts.Vehicle source) =>
 _locationReadService.GetLocation(new LocationRequest {
     LocationCode = source.LocationCode
 }, new InMemoryGrpcServerCallContext());