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);
        }
        /// <summary>
        /// This method is called whenever an actor is activated.
        /// An actor is activated the first time any of its methods are invoked.
        /// </summary>
        protected override async Task OnActivateAsync()
        {
            ActorEventSource.Current.ActorMessage(this, "Actor activated.");

            var stateInfo = await GetVehicleDataFromStateAsync();

            if (stateInfo == null)
            {
                var info = await this.vehiclesServiceProxy.GetVehicleByPlateAsync(this.Id.GetStringId(),
                                                                                  default(CancellationToken));

                VehicleData vehicleInfo = null;
                VehicleActorInterface.VehicleState vehicleState = VehicleActorInterface.VehicleState.NotAvailable;
                if (info != null)
                {
                    vehicleInfo  = VehicleData.FromServiceInterfacesInfo(info);
                    vehicleState = info.State.ToActorInterfaceState();
                }
                await SetVehicleDataIntoStateAsync(vehicleInfo);
                await SetVehicleStateIntoStateAsync(vehicleState);
            }
        }
 private Task SetVehicleDataIntoStateAsync(VehicleData data, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(this.StateManager.SetStateAsync <VehicleData>(InfoKeyName, data, cancellationToken));
 }