コード例 #1
0
        public async Task <dynamic> OnFinishExamAsync([FromForm] int examID, [FromForm] string token)
        {
            try
            {
                var t = await tokenService.GetTokenAsync(token);

                if (t == null)
                {
                    throw new Exception("请先登录");
                }
                if (await examService.GetExamRoleAsync(examID, t.UserID) != UserRole.Student)
                {
                    throw new Exception("无效操作");
                }
                await examService.StuFinishExamAsync(t.UserID, examID);

                return(new { Res = true });
            }
            catch (Exception e)
            {
                return(new { Res = false, Error = e.Message });
            }
        }