diff --git a/asg_form/Controllers/Budget/BgCountController.cs b/asg_form/Controllers/Budget/BgCountController.cs index 2443eea..d0c3ca1 100644 --- a/asg_form/Controllers/Budget/BgCountController.cs +++ b/asg_form/Controllers/Budget/BgCountController.cs @@ -12,7 +12,7 @@ namespace asg_form.Controllers.Budget { public int id { get; set; } public string budget_year { get; set; } - public int budget_money { get; set; } + public int budget_money { get; set; } = 0; public string budget_type { get; set; } public string budget_name { get; set; } public string budget_used { get; set; } @@ -210,19 +210,20 @@ namespace asg_form.Controllers.Budget { using (var db = new TestDbContext()) { - var budgetTotals = await db.budgetDetails - .GroupBy(b => new - { - b.source_event_id, - b.source_event_name - }) - .Select(g => new - { - sourceEventId = g.Key.source_event_id, - sourceEventName = g.Key.source_event_name, - budgetTotalMoney = g.Sum(b => b.budget_money) - }) - .ToListAsync(); + 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 + { + e.Id, + e.name + } into g + select new + { + sourceEventId = g.Key.Id, + sourceEventName = g.Key.name, + budgetTotalMoney = g.Sum(b => b.budget_money) + }).ToListAsync(); + return Ok(new { code = 200,