/// <summary>
        /// Retrives a vehicle by id
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public async Task <VehicleDataDto> GetVehicleById(params object[] args)
        {
            _exceptionService.Throw(() => Validator.CheckArgsLength(args, 1));

            var id   = (long)args[0];
            var poco = await _vehicleDataRepository.GetVehicleById(id);

            var dto = Mapper.Map <VehicleDataDto>(poco);

            return(dto);
        }
Esempio n. 2
0
        /// <summary>
        /// Delete
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public async Task <bool> Delete(params object[] args)
        {
            _exceptionService.Throw(() => Validator.CheckArgsLength(args, 1));

            var id          = (long)args[0];
            var vehiclePoco = await _vehicleDataRepository.GetVehicleById(id);

            var res = await _vehicleDataRepository.DeleteEntry(vehiclePoco);

            if (res > -1)
            {
                // Notify other APIs about the deleted vehicle.
                _serviceBus.Publish(new VehicleDeletedEvent {
                    VehicleId = id
                });
            }

            return(res > -1);
        }