Exemple #1
0
        public Task <VehicleStatusMessage> Update(string id, VehicleStatusMessage vehicle)
        {
            _logger.LogTrace($"Cache update for vehicle {id}: {vehicle.Status}");
            var entry = _cache.Set(id, vehicle, DateTimeOffset.UtcNow.AddMinutes(2));

            return(Task.FromResult(vehicle));
        }
        public void ToVehicle_Test(VehicleData vehicleData, VehicleStatusMessage info, Customer customer, Vehicle expected)
        {
            var result = vehicleData.ToVehicle(info, customer);

            result.ShouldNotBeNull();
            result.ShouldBe(expected);
        }
 public static Vehicle ToVehicle(this VehicleData vdata, VehicleStatusMessage info, Customer customer)
 => new Vehicle
 {
     Id           = vdata.Id,
     RegNr        = vdata.RegNr,
     CustomerId   = vdata.CustomerId,
     CustomerName = customer?.Name,
     Status       = info?.Status ?? VehicleStatus.Unknown,
     TimeUtc      = info?.TimeUtc ?? DateTime.UtcNow,
 };
 public static Task SendVehicleStatus(this IServiceBus serviceBus, VehicleStatusMessage req)
 => serviceBus.Publish(QueueNames.StatusQueueName, req, InteractionType.PublishSubscribe);
 public Task Send(VehicleStatusMessage vehicleInfo)
 {
     _logger.LogTrace($"Sending to clients: {vehicleInfo.Id} was {vehicleInfo.Status} at {vehicleInfo.TimeUtc}");
     return(_hub.Clients.All.SendAsync("Send", vehicleInfo));
 }