public static MeasurementModel ConvertfromEntity(Measurement inmeasurement) { MeasurementModel measurement = null; try { measurement = new MeasurementModel(); measurement.measid = inmeasurement.measid; measurement.timestamp = DateTime.Parse(inmeasurement.timestamp.ToString()); measurement.typeid = inmeasurement.typeid; measurement.installationid = inmeasurement.installationid; measurement.measurevalue = inmeasurement.measurevalue; log.Info("Measurement wurde konvertiert."); } catch (Exception exp) { log.Error("Measurement konnte nicht konvertiert werden."); throw new DalException("Measurement konnte nicht konvertiert werden.", exp); } return measurement; }
public static Measurement ConverttoEntity(MeasurementModel inmeasurement) { Measurement measurement; try { MeasurementTypeRepository mtrepo = new MeasurementTypeRepository(); //InstallationRepository irepo = new InstallationRepository(); measurement = new Measurement(); measurement.measid = inmeasurement.measid; measurement.timestamp = inmeasurement.timestamp; measurement.typeid = inmeasurement.typeid; measurement.installationid = inmeasurement.installationid; measurement.measurevalue = inmeasurement.measurevalue; //measurement.Measurement_Type = ConvertMeasurementType.ConverttoEntity(mtrepo.GetById(measurement.typeid)); //measurement.Installation = ConvertInstallation.ConverttoEntity(irepo.GetById(measurement.installationid)); log.Info("MeasurementModel wurde konvertiert."); } catch (Exception exp) { log.Info("MeasurementModel konnte nicht konvertiert werden."); throw new DalException("MeasurementModel konnte nicht konvertiert werden.", exp); } return measurement; }