Exemplo n.º 1
0
        public IHttpActionResult InsertSport([FromBody] SportInsertModel model)
        {
            var result = new BaseResult();

            result.ResultCode    = "1";
            result.ResultMessage = "Error";
            if (model.UserId == Guid.Empty)
            {
                result.ResultMessage = "用户ID不能为空";
                return(Ok(result));
            }
            SportRecord record = new SportRecord();

            record.Id            = Guid.NewGuid();
            record.SportLastTime = model.LastTime;
            record.CreateTime    = DateTime.Now;
            record.UpdateTime    = DateTime.Now;
            record.UserId        = model.UserId;
            record.Version       = 1;
            record.Status        = 1;
            record.OperationUser = model.UserId.ToString();
            var re = new SportRecordDAL().Insert(record);

            if (re)
            {
                result.ResultCode    = "0";
                result.ResultMessage = "上传成功";
            }
            return(Ok(result));
        }
Exemplo n.º 2
0
        public IHttpActionResult Sport([FromUri] Guid Id)
        {
            var result = new BaseResult();

            result.ResultCode    = "1";
            result.ResultMessage = "Error";
            var        sport = new SportRecordDAL().GetListByUserId(Id);
            SportModel model = new SportModel();

            model.Count          = sport.Count;
            model.LastTime       = sport.Sum(a => a.SportLastTime.Value);
            result.ResultCode    = "0";
            result.ResultMessage = "Success";
            result.ResultData    = model;
            return(Ok(result));
        }