From 74cb8ff01eba452044f846bd7513789114169a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=82=9C=E7=BF=94?= <2307953404@qq.com> Date: Fri, 4 Oct 2024 16:23:24 +0800 Subject: [PATCH] 22 --- asg_form/Controllers/AssignmentController.cs | 8 ++++---- asg_form/Controllers/Champion.cs | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/asg_form/Controllers/AssignmentController.cs b/asg_form/Controllers/AssignmentController.cs index 316cc77..195c6e8 100644 --- a/asg_form/Controllers/AssignmentController.cs +++ b/asg_form/Controllers/AssignmentController.cs @@ -224,10 +224,10 @@ namespace asg_form.Controllers var TotalRecords = await query.CountAsync(); var Tasks = await query - .OrderByDescending(t => t.status == "1" ? 0 : - t.status == "0" ? 1 : - t.status == "3" ? 2 : - t.status == "2" ? 3 : + .OrderByDescending(t => t.status == "1" ? 3 : + t.status == "0" ? 2 : + t.status == "3" ? 1 : + t.status == "2" ? 0 : int.MaxValue) .Skip((page - 1) * limit) .Take(limit) diff --git a/asg_form/Controllers/Champion.cs b/asg_form/Controllers/Champion.cs index cb8e8b8..c01afe4 100644 --- a/asg_form/Controllers/Champion.cs +++ b/asg_form/Controllers/Champion.cs @@ -55,23 +55,25 @@ namespace asg_form.Controllers { if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin")) { - TestDbContext testDb = new TestDbContext(); + int err = 0; try { + TestDbContext testDb = new TestDbContext(); var form = testDb.Forms.First(x => x.Id == req.formId); err = 1; var events = testDb.events.First(x => x.name == req.eventname); err = 2; testDb.Champions.Add(new T_Champion { events = events, form = form ,msg=req.msg}); err = 3; + await testDb.SaveChangesAsync(); + return Ok(); } catch (Exception ex) { return Ok(new { code = 500, message = "服务器错误",detailcode=err, details = ex.Message }); } - await testDb.SaveChangesAsync(); - return Ok(); + } return BadRequest(new error_mb { code = 400, message = "你没有管理员呢~" }); }