/// <summary> /// 構造函數。 /// </summary> /// <param name="surveys"></param> /// <param name="conclusion"></param> /// <param name="db"></param> public SaveConclusioModel(Surveys surveys, SurveysConclusion conclusion, DbContext db) { Conclusion = conclusion; var template = db.Set <SurveysTemplate>().Find(surveys.TemplateId); UserId = surveys.UserId; SurveysTemplateId = surveys.TemplateId; var question = template.Questions.FirstOrDefault(c => c.QuestionTitle == "姓名"); if (null != question) { Name = surveys.SurveysAnswers.FirstOrDefault(c => c.TemplateId == question.Id)?.Guts; } question = template.Questions.FirstOrDefault(c => c.QuestionTitle == "手机号"); if (null != question) { Mobile = surveys.SurveysAnswers.FirstOrDefault(c => c.TemplateId == question.Id)?.Guts; } question = template.Questions.FirstOrDefault(c => c.QuestionTitle == "性别"); if (null != question) { Sex = surveys.SurveysAnswers.FirstOrDefault(c => c.TemplateId == question.Id)?.Guts; } //写入方剂Id var idTp = surveys.ThingPropertyItems.FirstOrDefault(c => c.Name == "PrescriptionId"); PrescriptionId = idTp?.Value; //写入方剂数据 idTp = conclusion.ThingPropertyItems.FirstOrDefault(c => c.Name == CnMedicineAlgorithmBase.CnPrescriptionesName); if (null != idTp) { Prescriptiones = EntityUtility.FromJson <List <CnPrescription> >(idTp.Value); } }