/// <summary> /// 更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Edit(SymptomRecord model) { if (model == null) { return(false); } using (SymptomRecordDAL dal = new SymptomRecordDAL()) { CTMS_SYMPTOMRECORDS entitys = ModelToEntity(model); return(dal.Edit(entitys)); } }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public string Add(SymptomRecord model) { if (model == null) { return(string.Empty); } using (SymptomRecordDAL dal = new SymptomRecordDAL()) { CTMS_SYMPTOMRECORDS entity = ModelToEntity(model); entity.ID = string.IsNullOrEmpty(model.ID) ? Guid.NewGuid().ToString() : model.ID; return(dal.Add(entity)); } }
/// <summary> /// Entity转Model /// </summary> /// <param name="entity"></param> /// <returns></returns> private SymptomRecord EntityToModel(CTMS_SYMPTOMRECORDS entity) { if (entity != null) { var model = new SymptomRecord() { ID = entity.ID, SymptomId = entity.SYMPTOMID, UserId = entity.USERID, SymptomLevel = entity.SYMPTOMLEVEL, DictSymLevelId = entity.DICTSYMLEVELID, SymptomDate = entity.SYSMPTOMDATE, CreateDate = entity.CREATEDATE, EditDate = entity.EDITDATE }; return(model); } return(null); }
/// <summary> /// Model转Entity /// </summary> /// <param name="model"></param> /// <returns></returns> private CTMS_SYMPTOMRECORDS ModelToEntity(SymptomRecord model) { if (model != null) { var entity = new CTMS_SYMPTOMRECORDS() { ID = model.ID, SYMPTOMID = model.SymptomId, USERID = model.UserId, SYMPTOMLEVEL = model.SymptomLevel, DICTSYMLEVELID = model.DictSymLevelId, SYSMPTOMDATE = model.SymptomDate, CREATEDATE = model.CreateDate, EDITDATE = model.EditDate }; return(entity); } return(null); }
public IHttpActionResult Post([FromBody] Request <IList <SymptomExt> > request) { try { //获取参数 IList <SymptomExt> list = request.Data; DateTime dt = DateTime.Parse(request.ID); //获取登录信息 UserInfo currentUser = new UserInfoService().GetCurrentUser(); string userId = currentUser == null ? "" : currentUser.UserId; foreach (SymptomExt item in list) { Symptom symtom = new Symptom(); symtom = bll.GetOne(p => p.USERID == userId && p.SYMPTOMNAME.Equals(item.SymptomName)); string _symtomId = symtom == null?"":symtom.ID; if (string.IsNullOrEmpty(_symtomId)) { symtom = new Symptom(); symtom.SymptomName = item.SymptomName; symtom.DictsymptomId = item.DictsymptomId; symtom.UserId = userId; symtom.CreateDate = DateTime.Now; string symtomId = bll.Add(symtom); if (!string.IsNullOrEmpty(symtomId)) { SymptomRecord symRecord = new SymptomRecord(); symRecord.SymptomId = symtomId; symRecord.SymptomLevel = item.SymptomLevel; symRecord.UserId = userId; symRecord.SymptomDate = dt; SymptomRecordBLL strBLL = new SymptomRecordBLL(); strBLL.Add(symRecord); } } else { SymptomRecordBLL strBLL = new SymptomRecordBLL(); SymptomRecord symRecord = strBLL.GetOne(p => p.SYSMPTOMDATE == dt && p.USERID == userId && p.SYMPTOMID == _symtomId); if (symRecord == null) { symRecord = new SymptomRecord(); symRecord.SymptomId = _symtomId; symRecord.SymptomLevel = item.SymptomLevel; symRecord.UserId = userId; symRecord.SymptomDate = dt; symRecord.CreateDate = DateTime.Now; strBLL.Add(symRecord); } else { symRecord.SymptomLevel = item.SymptomLevel; symRecord.EditDate = DateTime.Now; strBLL.Edit(symRecord); } } } return(Ok("ok")); } catch (Exception ex) { return(BadRequest(ex.ToString())); } }