public Plate CreatePlate(Plate plate) { if (plate.AccelerometerIds != null) { var accelerometers = _accelerometerService.GetAccelerometersByIds (plate.AccelerometerIds); if (accelerometers.Any(a => a.Plate != null)) { throw new Exception(); } plate.Accelerometer = accelerometers; } if (plate.GyroscopeIds != null) { var gyroscopes = _gyroscopeService.GetGyroscopeByIds(plate.GyroscopeIds); if (gyroscopes.Any(a => a.Plate != null)) { throw new Exception(); } plate.Gyroscope = gyroscopes; } return(_plateRepository.CreatePlate(plate)); }