public static PhysicalExaminationViewModel GetViewModel(PhysicalExamination physicalExamination, Func<DateTime, DateTime> toLocal) { if (physicalExamination == null) return new PhysicalExaminationViewModel(); return new PhysicalExaminationViewModel { Id = physicalExamination.Id, PatientId = physicalExamination.PatientId, Notes = physicalExamination.Notes, MedicalRecordDate = toLocal(physicalExamination.MedicalRecordDate), }; }
public ActionResult Edit(PhysicalExaminationViewModel[] physicalExaminations) { var formModel = physicalExaminations.Single(); PhysicalExamination physicalExamination; if (formModel.Id == null) { Debug.Assert(formModel.PatientId != null, "formModel.PatientId != null"); physicalExamination = new PhysicalExamination { CreatedOn = this.GetUtcNow(), PatientId = formModel.PatientId.Value, PracticeId = this.DbUser.PracticeId, }; this.db.PhysicalExaminations.AddObject(physicalExamination); } else physicalExamination = this.db.PhysicalExaminations.FirstOrDefault(pe => pe.Id == formModel.Id); if (this.ModelState.IsValid) { Debug.Assert(physicalExamination != null, "physicalExamination != null"); physicalExamination.Patient.IsBackedUp = false; physicalExamination.Notes = formModel.Notes; physicalExamination.MedicalRecordDate = this.ConvertToUtcDateTime(formModel.MedicalRecordDate.Value); this.db.SaveChanges(); return this.View("Details", GetViewModel(physicalExamination, this.GetToLocalDateTimeConverter())); } return this.View("Edit", GetViewModel(physicalExamination, this.GetToLocalDateTimeConverter())); }
/// <summary> /// Create a new PhysicalExamination object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="patientId">Initial value of the PatientId property.</param> /// <param name="createdOn">Initial value of the CreatedOn property.</param> /// <param name="notes">Initial value of the Notes property.</param> /// <param name="practiceId">Initial value of the PracticeId property.</param> /// <param name="medicalRecordDate">Initial value of the MedicalRecordDate property.</param> public static PhysicalExamination CreatePhysicalExamination(global::System.Int32 id, global::System.Int32 patientId, global::System.DateTime createdOn, global::System.String notes, global::System.Int32 practiceId, global::System.DateTime medicalRecordDate) { PhysicalExamination physicalExamination = new PhysicalExamination(); physicalExamination.Id = id; physicalExamination.PatientId = patientId; physicalExamination.CreatedOn = createdOn; physicalExamination.Notes = notes; physicalExamination.PracticeId = practiceId; physicalExamination.MedicalRecordDate = medicalRecordDate; return physicalExamination; }
/// <summary> /// Deprecated Method for adding a new object to the PhysicalExaminations EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPhysicalExaminations(PhysicalExamination physicalExamination) { base.AddObject("PhysicalExaminations", physicalExamination); }