예제 #1
0
        public MeasurementDomain Save(MeasurementDomain measurement)
        {
            var successFlag = _connection.Get.Insert(MeasurementEntity.FromDomain(measurement));

            if (successFlag <= 0)
            {
                return(null);
            }

            var measurementId = _connection.LastIndex;

            measurement = measurement.WithId(measurementId)
                          .WithCurrent(_itemRepository.Save(measurement.Current, measurementId))
                          .WithHistory(_itemRepository.SaveAll(measurement.History, measurementId))
                          .WithForecast(_itemRepository.SaveAll(measurement.Forecast, measurementId))
                          .WithInstallation(_installationRepository.Save(measurement.Installation));

            return(measurement);
        }
 public static MeasurementEntity FromDomain(MeasurementDomain measurement)
 => new MeasurementEntity(measurement.Id, measurement.CurrentDisplayValue, measurement.Installation.Id);