public static ExamFindings ToDomainModel(this ExamFindingsViewModel examFindingsViewModel) { ExamFindings examFindings = new ExamFindings(); examFindings.Id = examFindingsViewModel.Id; examFindings.Abnormal = examFindingsViewModel.Abnormal; examFindings.Positive = examFindingsViewModel.Positive; examFindings.RelevantNegative = examFindingsViewModel.RelevantNegative; examFindings.MedicalRecordEntry = examFindingsViewModel.MedicalRecordEntryViewModel.ToDomainModel(); return(examFindings); }
public void Delete(ExamFindings examFindings) { ExamFindings result = context.ExamFindings.FirstOrDefault(e => e.Id == examFindings.Id); if (result != null) { context.MedicalRecordEntries.Attach(examFindings.MedicalRecordEntry); context.MedicalRecordEntries.Attach(result.MedicalRecordEntry); context.Entry(result.MedicalRecordEntry.Patient).State = System.Data.Entity.EntityState.Detached; context.ExamFindings.Remove(result); context.SaveChanges(); } }
public void Update(ExamFindings examFindings) { ExamFindings result = context.ExamFindings.FirstOrDefault(e => e.Id == examFindings.Id); if (result != null) { context.MedicalRecordEntries.Attach(examFindings.MedicalRecordEntry); context.MedicalRecordEntries.Attach(result.MedicalRecordEntry); context.Entry(result.MedicalRecordEntry.Patient).State = System.Data.Entity.EntityState.Detached; result.Positive = examFindings.Positive; result.RelevantNegative = examFindings.RelevantNegative; result.Abnormal = examFindings.Abnormal; result.MedicalRecordEntry = examFindings.MedicalRecordEntry; result.MedicalRecordEntry.Patient = examFindings.MedicalRecordEntry.Patient; context.SaveChanges(); } }
public void Add(ExamFindings examFindings) { context.MedicalRecordEntries.Attach(examFindings.MedicalRecordEntry); context.ExamFindings.Add(examFindings); context.SaveChanges(); }