/// <summary> /// Agrega un nuevo vehículo, valida la Idempotencia /// </summary> /// <param name="vehiculo">entidad vehículo</param> /// <returns></returns> public async Task <Vehiculo> Add(Vehiculo vehiculo) { // product has been added. var targetVehicle = await _vehiculoRepository.GetByIdWithIdempotencyCheck(vehiculo.IdVehiculo); if (targetVehicle == null) { await _vehiculoRepository.Add(vehiculo); AlmacenaHistorial(vehiculo); } else { // Assign Id from original insert vehiculo.IdVehiculo = targetVehicle.IdVehiculo; } return(vehiculo); }