/// <summary> /// 修改随访方案 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Edit(QATestSolution model) { if (string.IsNullOrEmpty(model.SolutionID)) { LogService.WriteInfoLog(logTitle, "试图修改为空的QATestSolution实体!"); throw new KeyNotFoundException(); } using (DbContext db = new CRDatabase()) { db.Entry(ModelToEntity(model)).State = EntityState.Modified; return(db.SaveChanges() > 0); } }
/// <summary> /// 新增随访方案 /// </summary> /// <param name="model"></param> /// <returns></returns> public string Add(QATestSolution model) { if (model == null) { return(string.Empty); } using (DbContext db = new CRDatabase()) { db.Set <CTMS_QA_TESTSOLUTION>().Add(ModelToEntity(model)); db.SaveChanges(); return(model.SolutionID); } }
public QATestSolution EntityToModel(CTMS_QA_TESTSOLUTION entity) { if (entity == null) { return(null); } QATestSolution model = new QATestSolution() { SolutionID = entity.SOLUTIONID, SolutionCode = entity.SOLUTIONCODE, SolutionName = entity.SOLUTIONNAME, SolutionSource = entity.SOLUTIONSOURCE, SolutionDescription = entity.SOLUTIONDESCRIPTION, DiseaseCode = entity.DISEASECODE, DiseaseName = entity.DISEASENAME, }; base.EntityToModel <CTMS_QA_TESTSOLUTION, QATestSolution>(entity, model); return(model); }
public CTMS_QA_TESTSOLUTION ModelToEntity(QATestSolution model) { if (model == null) { return(null); } CTMS_QA_TESTSOLUTION entity = new CTMS_QA_TESTSOLUTION() { SOLUTIONID = string.IsNullOrEmpty(model.SolutionID) ? Guid.NewGuid().ToString() : model.SolutionID, SOLUTIONCODE = model.SolutionCode, SOLUTIONNAME = model.SolutionName, SOLUTIONSOURCE = model.SolutionSource, SOLUTIONDESCRIPTION = model.SolutionDescription, DISEASECODE = model.DiseaseCode, DISEASENAME = model.DiseaseName, }; base.ModelToEntity <QATestSolution, CTMS_QA_TESTSOLUTION>(model, entity); return(entity); }