Пример #1
0
        public Plate UpdatePlate(UpdatePlate updatePlate)
        {
            var plate = _context.Plates.Where(a => a.Id.Equals(updatePlate.Id)).SingleOrDefault();

            if (plate is null)
            {
                throw new Exception("");
            }

            if (updatePlate.AccelerometerIds != null)
            {
                plate.AccelerometerIds = updatePlate.AccelerometerIds;
            }

            if (updatePlate.Accelerometer != null)
            {
                plate.Accelerometer = updatePlate.Accelerometer;
            }

            if (updatePlate.Gyroscope != null)
            {
                plate.Gyroscope = updatePlate.Gyroscope;
            }

            _context.SaveChanges();

            return(plate);
        }
Пример #2
0
        public Plate UpdatePlate(UpdatePlate updatePlate)
        {
            if (updatePlate.AccelerometerIds != null)
            {
                var accelerometers = _accelerometerService.GetAccelerometersByIds
                                         (updatePlate.AccelerometerIds);
                if (accelerometers.Any(a => a.Plate != null))
                {
                    throw new Exception();
                }
                updatePlate.Accelerometer = accelerometers;
            }

            if (updatePlate.GyroscopeIds != null)
            {
                var gyroscopes = _gyroscopeService.GetGyroscopeByIds(updatePlate.GyroscopeIds);
                if (gyroscopes.Any(a => a.Plate != null))
                {
                    throw new Exception();
                }
                updatePlate.Gyroscope = gyroscopes;
            }

            return(_plateRepository.UpdatePlate(updatePlate));
        }
Пример #3
0
 public Plate UpdatePlate(UpdatePlate plate)
 {
     return(_plateService.UpdatePlate(plate));
 }