Exemplo n.º 1
0
        public async Task <ActionResult <HistoryResponse> > GetHistory()
        {
            //取得存在cookie的当前账户id
            var student_id = 3;//Int32.Parse(User.Identity.Name);
            //查找当前id是否存在history
            var temp = await HistoryAccessor.Find(student_id);

            if (temp != null)
            {
                return(Ok(_mapper.Map <HistoryResponse>(temp)));
            }
            return(Ok(-1));
        }
Exemplo n.º 2
0
        public async Task <int> CreateHistory([FromBody] HistoryRequest request)
        {
            //判断request里是否满足前置条件
            if (!ModelState.IsValid)
            {
                return(-5);
            }
            //取得存在cookie的当前账户id
            var student_id = 3;//Int32.Parse(User.Identity.Name);
            //生成comment实例
            var history = _mapper.Map <HistoryEntity>(request);

            history.student_id = student_id;
            //新建comment
            var num = await HistoryAccessor.Create(history);

            return(student_id);
        }