feat(giving): include Sunday attendance total in offering session list
This commit is contained in:
@@ -11,4 +11,5 @@ public class OfferingSessionListItemDto
|
||||
public decimal Difference { get; set; }
|
||||
public int LineCount { get; set; }
|
||||
public bool HasProof { get; set; }
|
||||
public int? SundayAttendanceCount { get; set; } // null = no attendance recorded for the date
|
||||
}
|
||||
|
||||
@@ -45,6 +45,11 @@ public class OfferingSessionService : IOfferingSessionService
|
||||
.Select(grp => new { Id = grp.Key, Count = grp.Count() })
|
||||
.ToDictionaryAsync(x => x.Id, x => x.Count);
|
||||
|
||||
var dates = rows.Select(r => r.SessionDate).ToList();
|
||||
var attendance = await _db.MealAttendances.AsNoTracking()
|
||||
.Where(a => dates.Contains(a.AttendanceDate))
|
||||
.ToDictionaryAsync(a => a.AttendanceDate, a => a.AdultCount + a.YouthCount + a.KidCount);
|
||||
|
||||
var items = rows.Select(s => new OfferingSessionListItemDto
|
||||
{
|
||||
Id = s.Id, SessionDate = s.SessionDate.ToString("yyyy-MM-dd"), Status = s.Status,
|
||||
@@ -52,6 +57,7 @@ public class OfferingSessionService : IOfferingSessionService
|
||||
SystemTotal = s.SystemTotal, Difference = s.Difference,
|
||||
LineCount = counts.TryGetValue(s.Id, out var c) ? c : 0,
|
||||
HasProof = s.ProofPdfPath != null,
|
||||
SundayAttendanceCount = attendance.TryGetValue(s.SessionDate, out var att) ? att : (int?)null,
|
||||
}).ToList();
|
||||
|
||||
return new PagedResult<OfferingSessionListItemDto>
|
||||
|
||||
Reference in New Issue
Block a user