public PersonMedicineObject(PersonMedicineDbRecord dbRecord) : base(dbRecord) { DbRecord.Person = DbRecord.Person ?? new PersonDbRecord(); DbRecord.Medicine = DbRecord.Medicine ?? new MedicineDbRecord(); Person = new PersonObject(DbRecord.Person); Medicine = new MedicineObject(DbRecord.Medicine); }
public static PersonMedicineObject Create(PersonObject person, MedicineObject medicine, Suitability suitableForPerson, DateTime?validFrom = null, DateTime?validTo = null) { var o = new PersonMedicineDbRecord { Person = person?.DbRecord ?? new PersonDbRecord(), Medicine = medicine?.DbRecord ?? new MedicineDbRecord(), Suitability = suitableForPerson, ValidFrom = validFrom ?? DateTime.MinValue, ValidTo = validTo ?? DateTime.MaxValue }; o.PersonID = o.Person.ID; o.MedicineID = o.Medicine.ID; return(new PersonMedicineObject(o)); }