public static VehicleData FromActorInterfacesInfo(VehicleActorInterfaces.VehicleInfo vehicleInfo) { if (vehicleInfo == null) { throw new ArgumentNullException(nameof(vehicleInfo)); } return(new VehicleData() { Brand = vehicleInfo.Brand, DailyCost = vehicleInfo.DailyCost, Model = vehicleInfo.Model, }); }
public async Task <VehicleActorError> UpdateVehicleInfoAsync(VehicleActorInterface.VehicleInfo info, CancellationToken cancellationToken) { if (info == null) { throw new ArgumentNullException(nameof(InfoKeyName)); } var vehicleData = VehicleData.FromActorInterfacesInfo(info); await SetVehicleDataIntoStateAsync(vehicleData, cancellationToken); await SetVehicleStateIntoStateAsync(info.State, cancellationToken); return(VehicleActorError.Ok); }
public async Task <VehicleActorInterface.VehicleInfo> GetInfoAsync(CancellationToken cancellationToken) { var info = await GetVehicleDataFromStateAsync(cancellationToken); if (info == null) { return(null); } var state = await GetVehicleStateFromStateAsync(cancellationToken); var rentInfo = await GetCurrentRentInfoFromStateAsync(cancellationToken); VehicleActorInterface.VehicleInfo response = info.ToInterfacesInfo(); response.Plate = this.Id.ToString(); response.State = state; response.CurrentRent = rentInfo; return(response); }