public static DiagnosticHypothesisViewModel GetViewModel(DiagnosticHypothesis diagnosticHypothesis, Func<DateTime, DateTime> toLocal)
 {
     return new DiagnosticHypothesisViewModel
     {
         Id = diagnosticHypothesis.Id,
         Cid10Code = diagnosticHypothesis.Cid10Code,
         Cid10Name = diagnosticHypothesis.Cid10Name,
         Text = diagnosticHypothesis.Observations,
         PatientId = diagnosticHypothesis.PatientId,
         MedicalRecordDate = toLocal(diagnosticHypothesis.MedicalRecordDate),
     };
 }
 /// <summary>
 /// Create a new DiagnosticHypothesis object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="cid10Name">Initial value of the Cid10Name property.</param>
 /// <param name="practiceId">Initial value of the PracticeId property.</param>
 /// <param name="createdOn">Initial value of the CreatedOn property.</param>
 /// <param name="patientId">Initial value of the PatientId property.</param>
 /// <param name="medicalRecordDate">Initial value of the MedicalRecordDate property.</param>
 public static DiagnosticHypothesis CreateDiagnosticHypothesis(global::System.Int32 id, global::System.String cid10Name, global::System.Int32 practiceId, global::System.DateTime createdOn, global::System.Int32 patientId, global::System.DateTime medicalRecordDate)
 {
     DiagnosticHypothesis diagnosticHypothesis = new DiagnosticHypothesis();
     diagnosticHypothesis.Id = id;
     diagnosticHypothesis.Cid10Name = cid10Name;
     diagnosticHypothesis.PracticeId = practiceId;
     diagnosticHypothesis.CreatedOn = createdOn;
     diagnosticHypothesis.PatientId = patientId;
     diagnosticHypothesis.MedicalRecordDate = medicalRecordDate;
     return diagnosticHypothesis;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the DiagnosticHypotheses EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDiagnosticHypotheses(DiagnosticHypothesis diagnosticHypothesis)
 {
     base.AddObject("DiagnosticHypotheses", diagnosticHypothesis);
 }
        public ActionResult Edit(DiagnosticHypothesisViewModel[] diagnosticHypotheses)
        {
            var formModel = diagnosticHypotheses.Single();

            Debug.Assert(formModel.PatientId != null, "formModel.PatientId != null");
            if (this.ModelState.IsValid)
            {
                DiagnosticHypothesis diagnosticHypothesis;
                if (formModel.Id == null)
                {
                    diagnosticHypothesis = new DiagnosticHypothesis
                    {
                        CreatedOn = this.GetUtcNow(),
                        PatientId = formModel.PatientId.Value,
                        PracticeId = this.DbUser.PracticeId
                    };
                    this.db.DiagnosticHypotheses.AddObject(diagnosticHypothesis);
                }
                else
                    diagnosticHypothesis = this.db.DiagnosticHypotheses.First(a => a.Id == formModel.Id);

                diagnosticHypothesis.Patient.IsBackedUp = false;
                diagnosticHypothesis.Observations = formModel.Text;
                diagnosticHypothesis.Cid10Code = formModel.Cid10Code;
                diagnosticHypothesis.Cid10Name = formModel.Cid10Name;
                diagnosticHypothesis.MedicalRecordDate = this.ConvertToUtcDateTime(formModel.MedicalRecordDate.Value);

                this.db.SaveChanges();

                // todo: this shoud be a redirect... so that if user press F5 in browser, the object will no be saved again.
                return this.View("Details", GetViewModel(diagnosticHypothesis, this.GetToLocalDateTimeConverter()));
            }

            return this.View("Edit", formModel);
        }