public Patient ViewModelToPatient(PatientDetailViewModel vm) { Patient patient = new Patient() { Id = vm.Id, }; Comment comment = new Comment() { }; foreach (TreatmentDetailViewModel t in vm.TreatmentDetailViewModels) { Treatment treatment = new Treatment() { Id = t.Id, Name = t.Name, Patient = patient, BeginDate = t.BeginDate, EndDate = t.EndDate, //TreatmentType = t.TypeId, Comments = new List <Comment>(t.Comments), }; patient.AddTreatment(treatment); } return(patient); }
public void AddTreatment() { Patient patient = new Patient(1, "username", "email", "password", "name", DateTime.Today, "phonenumber", true, Gender.Female, 23); Doctor doctor = new Doctor(1, "username", "email", "password", "name", DateTime.Today, "phonenumber", true, Gender.Female); TreatmentType treatmentType = new TreatmentType("name", "description"); Treatment treatment = new Treatment(1, "name", DateTime.MinValue, DateTime.Today, patient, doctor, treatmentType); Treatment treatment2 = new Treatment(1, "name", DateTime.MinValue, DateTime.Today); patient.AddTreatment(treatment); patient.AddTreatment(treatment2); Assert.True(patient.Treatments.Exists(t => t == treatment)); Assert.Equal(2, patient.Treatments.Count); patient = new Patient(1, "username", "email", "name"); patient.AddTreatment(treatment); patient.AddTreatment(treatment2); Assert.True(patient.Treatments.Exists(t => t == treatment)); Assert.Equal(2, patient.Treatments.Count); }