From f2778426b32b5068d4453c232730adc40de869e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=82=9C=E7=BF=94?= <2307953404@qq.com> Date: Sat, 5 Oct 2024 12:05:36 +0800 Subject: [PATCH] 1 --- asg_form/Controllers/Budget/BgCountController.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/asg_form/Controllers/Budget/BgCountController.cs b/asg_form/Controllers/Budget/BgCountController.cs index d0c3ca1..a4959d2 100644 --- a/asg_form/Controllers/Budget/BgCountController.cs +++ b/asg_form/Controllers/Budget/BgCountController.cs @@ -84,7 +84,7 @@ namespace asg_form.Controllers.Budget used_event_id = msg.usedEventId, use_status = "0", update_person = msg.updatePerson, - update_time = dateString, + update_time = null, }; sub.budgetDetails.Add(budget); await sub.SaveChangesAsync(); @@ -185,7 +185,7 @@ namespace asg_form.Controllers.Budget } catch (Exception ex) { - return StatusCode(500, new { code = 500, message = "服务器错误", details = ex.Message }); + return Ok(new { code = 500, message = "服务器错误", details = ex.Message }); } } @@ -211,8 +211,9 @@ namespace asg_form.Controllers.Budget using (var db = new TestDbContext()) { var budgetTotals = await (from e in db.events - join b in db.budgetDetails on e.Id equals b.source_event_id - group b by new + join b in db.budgetDetails on e.Id equals b.source_event_id into budgetGroup + from bg in budgetGroup.DefaultIfEmpty() + group bg by new { e.Id, e.name @@ -221,7 +222,7 @@ namespace asg_form.Controllers.Budget { sourceEventId = g.Key.Id, sourceEventName = g.Key.name, - budgetTotalMoney = g.Sum(b => b.budget_money) + budgetTotalMoney = g.Sum(b => b == null ? 0 : b.budget_money) }).ToListAsync(); return Ok(new