public bool AddExam(Exam exam) { return service.AddExam(exam); }
public static void ExamSave(ExamModel exam) { using (var db = new PosEntities()) { Exam dbExam; if (exam.ExamID > 0) { dbExam = (from e in db.Exams where e.ExamID == exam.ExamID select e).First(); } else { dbExam = new Exam(); db.Exams.Add(dbExam); } dbExam.ExamText = exam.ExamText; dbExam.ExamDate = exam.ExamDate; dbExam.PatientID = exam.PatientID; dbExam.UserName = exam.UserName; dbExam.SavedInd = exam.SaveInd; dbExam.LastUpdatedDate = DateTime.Now; dbExam.ExamCorrectDate = exam.ExamCorrectDate; dbExam.CorrectExamID = exam.CorrectExamID; var patient = (from pat in db.Patients where pat.PatientID == exam.PatientID select pat).First(); if (!patient.LastExamDate.HasValue || patient.LastExamDate < exam.ExamDate) { patient.LastExamDate = exam.ExamDate; } db.SaveChanges(); exam.ExamID = dbExam.ExamID; } }