This commit is contained in:
王炜翔 2024-10-05 11:54:43 +08:00
parent 84eca38131
commit 3e1995bf3d

View File

@ -12,7 +12,7 @@ namespace asg_form.Controllers.Budget
{ {
public int id { get; set; } public int id { get; set; }
public string budget_year { 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_type { get; set; }
public string budget_name { get; set; } public string budget_name { get; set; }
public string budget_used { get; set; } public string budget_used { get; set; }
@ -210,19 +210,20 @@ namespace asg_form.Controllers.Budget
{ {
using (var db = new TestDbContext()) using (var db = new TestDbContext())
{ {
var budgetTotals = await db.budgetDetails var budgetTotals = await (from e in db.events
.GroupBy(b => new join b in db.budgetDetails on e.Id equals b.source_event_id
{ group b by new
b.source_event_id, {
b.source_event_name e.Id,
}) e.name
.Select(g => new } into g
{ select new
sourceEventId = g.Key.source_event_id, {
sourceEventName = g.Key.source_event_name, sourceEventId = g.Key.Id,
budgetTotalMoney = g.Sum(b => b.budget_money) sourceEventName = g.Key.name,
}) budgetTotalMoney = g.Sum(b => b.budget_money)
.ToListAsync(); }).ToListAsync();
return Ok(new return Ok(new
{ {
code = 200, code = 200,