public static Installation ConverttoEntity(InstallationModel ininstallation) { Installation installation = null; try { CustomerRepository crepo = new CustomerRepository(); MeasurementRepository mrepo = new MeasurementRepository(); installation = new Installation(); installation.customerid = ininstallation.customerid; installation.installationid = ininstallation.installationid; installation.latitude = ininstallation.latitude; installation.longitude = ininstallation.longitude; installation.description = ininstallation.description; installation.serialno = ininstallation.serialno; //installation.Customer = ConvertCustomer.ConverttoEntity(crepo.GetById(installation.customerid)); foreach (var item in ininstallation.Measurement) { installation.Measurement.Add(ConvertMeasurement.ConverttoEntity(mrepo.GetById(item))); } log.Info("InstallationModel wurde konvertiert."); } catch (Exception exp) { log.Error("InstallationModel konnte nicht konvertiert werden."); throw new DalException("InstallationModel konnte nicht konvertiert werden.", exp); } return installation; }
public static InstallationModel ConvertfromEntity(Installation ininstallation) { InstallationModel installation = null; try { installation = new InstallationModel(); installation.customerid = ininstallation.customerid; installation.installationid = ininstallation.installationid; installation.latitude = ininstallation.latitude; installation.longitude = ininstallation.longitude; installation.description = ininstallation.description; installation.serialno = ininstallation.serialno; foreach (var item in ininstallation.Measurement) { installation.Measurement.Add(item.measid); } log.Info("Installation wurde konvertiert."); } catch (Exception exp) { log.Error("Installation konnte nicht konvertiert werden."); throw new DalException("Installation konnte nicht konvertiert werden.", exp); } return installation; }