/// <summary>
        /// 添加手环数据
        /// </summary>
        /// <param name="input">输入</param>
        /// <returns></returns>
        public async Task <OutputBase> Add(AddHandRingInput input)
        {
            if (await _patientRepository.GetPatientById(input.PatientId) == null)
            {
                return(OutputBase.Fail("患者不存在"));
            }

            foreach (var item in input.HandRingList)
            {
                if (!await _repository.IsExsit(input.PatientId, item.Date))
                {
                    var entity = new HandRing
                    {
                        Date      = item.Date,
                        Distance  = item.Distance,
                        Energy    = item.Energy,
                        SleepTime = item.SleepTime,
                        Steps     = item.Steps,
                        PatientId = input.PatientId
                    };

                    _repository.Add(entity);
                }
            }
            return(_unitWork.Commit() ? OutputBase.Success("保存成功") : OutputBase.Fail("保存失败"));
        }
Example #2
0
 public async Task <OutputBase> Add([FromBody] AddHandRingInput input)
 {
     return(await _service.Add(input));
 }