Example #1
0
        public IHttpActionResult Get(string id)
        {
            try{
                IList <SymptomExt> response = new List <SymptomExt>();
                //获取登录信息
                UserInfo currentUser = new UserInfoService().GetCurrentUser();
                if (currentUser == null)
                {
                    return(Ok(response));
                }

                string userId = currentUser.UserId;
                IEnumerable <Symptom> list = bll.GetList(p => p.USERID == userId);

                SymptomRecordBLL            strBLL     = new SymptomRecordBLL();
                IEnumerable <SymptomRecord> symRecords = strBLL.GetList(p => p.USERID == userId);
                foreach (SymptomRecord item in symRecords)
                {
                    SymptomExt ext = new SymptomExt();
                    ext.SymptomID    = item.SymptomId;
                    ext.SymptomName  = GetSymptomName(list, item.SymptomId);
                    ext.SymptomDate  = item.SymptomDate;
                    ext.SymptomLevel = item.SymptomLevel == "" ? "0" : item.SymptomLevel;

                    response.Add(ext);
                }

                return(Ok(response.OrderBy(p => p.SymptomDate)));
            }catch (Exception ex) {
                return(BadRequest(ex.ToString()));
            }
        }
Example #2
0
        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()));
            }
        }