Exemplo n.º 1
0
 public VehicleValidator(LocationRead.LocationReadClient locationReadClient)
 {
     RuleFor(v => v.Vin).NotNull().NotEmpty().Length(17);
     RuleFor(v => v.LocationCode)
     .MustAsync(async(v, l, token) =>
                string.IsNullOrEmpty(l) || await locationReadClient.GetLocationAsync(new LocationRequest {
         LocationCode = v.LocationCode
     }) != null)
     .WithMessage(v => $"No location was found for location code: {v.LocationCode}.");
 }
        public LocationSubscription(LocationRead.LocationReadClient locationReadClient)
        {
            _locationReadClient = locationReadClient;

            AddField(new EventStreamFieldType
            {
                Name       = "locationChange",
                Type       = typeof(LocationType),
                Resolver   = new FuncFieldResolver <Contracts.Location>(ctx => ctx.Source as Contracts.Location),
                Subscriber = new EventStreamResolver <Contracts.Location>(GetLocationChangeSubscription)
            });
        }