Skip to content

Commit

Permalink
Version 1.60 (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
NomisNostab authored Aug 21, 2024
2 parents 3cce19d + 243b4ac commit 072d80b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
10 changes: 6 additions & 4 deletions Services/ReportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,7 @@ public IWorkbook GenerateAttendanceReportWorkbook(AttendanceReportModel attendan
sheet.Range[rowNumber, columnNumber + 8, rowNumber, columnNumber + 10].CellStyle.ColorIndex = GetChallengeAreaColour("Growth");
sheet.Range[rowNumber, columnNumber + 2, rowNumber, columnNumber + 10].CellStyle.Font.Bold = true;
rowNumber++;
// Group attendance by member for youth
var groupedAttendances = attendanceReportData.attendanceReportItems.Where(m => m.IsAdultMember == 0).GroupBy(wa => wa.MemberName).ToList();

var allEvents = attendanceReportData.attendanceReportItems.DistinctBy(i => i.EventNameDisplay).OrderBy(i => i.EventStartDate).ToList();

// Add Event Details
Expand Down Expand Up @@ -906,6 +905,8 @@ public IWorkbook GenerateAttendanceReportWorkbook(AttendanceReportModel attendan


// Add youth member rows
// Group attendance by member for youth
var groupedAttendances = attendanceReportData.attendanceReportItems.Where(m => m.IsAdultMember == 0).GroupBy(wa => wa.MemberName).ToList();
var sumStartRow = rowNumber + 1;
foreach (var groupedAttendance in groupedAttendances.OrderBy(a => a.Key))
{
Expand Down Expand Up @@ -972,7 +973,7 @@ public IWorkbook GenerateAttendanceReportWorkbook(AttendanceReportModel attendan

// Add adult member rows
sumStartRow = rowNumber + 1;
foreach (var groupedAttendance in groupedAttendances)
foreach (var groupedAttendance in groupedAttendances.OrderBy(a => a.Key))
{
rowNumber++;
columnNumber = 1;
Expand All @@ -989,8 +990,9 @@ public IWorkbook GenerateAttendanceReportWorkbook(AttendanceReportModel attendan
sheet.Range[rowNumber, columnNumber].Text = groupedAttendance.FirstOrDefault().MemberLastName;
sheet.Range[rowNumber, columnNumber].BorderAround();
}
foreach (var eventAttendance in groupedAttendance)
foreach (var events in allEvents)
{
var eventAttendance = groupedAttendance.Where(a => a.EventNameDisplay == events.EventNameDisplay).FirstOrDefault();
columnNumber++;
sheet.Range[rowNumber, columnNumber].Text = eventAttendance.Attended > 0 ? "Y" : "";
sheet.Range[rowNumber, columnNumber].BorderAround();
Expand Down
39 changes: 20 additions & 19 deletions Topo/Services/ProgramService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public async Task<EventListModel> GetAttendanceForEvent(string eventId)
eventListModel.EventDisplay = $"{eventListModel.EventName} {eventListModel.EventDate}";
eventListModel.attendees = eventAttendance;

if (getEventResultModel != null && getEventResultModel.attendance != null && getEventResultModel.attendance.attendee_members != null && getEventResultModel.attendance.attendee_members.Any())
if (getEventResultModel != null && getEventResultModel.attendance != null && (getEventResultModel.attendance.attendee_members != null || getEventResultModel.attendance.participant_members != null))
{
foreach (var attended in getEventResultModel.attendance.attendee_members)
{
Expand All @@ -173,11 +173,27 @@ public async Task<EventListModel> GetAttendanceForEvent(string eventId)
});
}
}
foreach (var participated in getEventResultModel.attendance.participant_members)
foreach (var attended in getEventResultModel.attendance.participant_members)
{
if (eventAttendance.Any(a => a.member_number == participated.member_number))
if (eventAttendance.Any(a => a.member_number == attended.member_number))
{
eventAttendance.Where(a => a.member_number == attended.member_number).Single().pal = "P";
}
else
{
eventAttendance.Where(a => a.member_number == participated.member_number).Single().pal = "P";
// for older events participant_members seems to be used, not attendee_members
// Load out of unit members
eventAttendance.Add(new EventAttendance
{
id = attended.id,
first_name = attended.first_name,
last_name = attended.last_name,
member_number = attended.member_number,
patrol_name = "",
isAdultMember = false,
attended = true,
pal = "P"
});
}
}
foreach (var assisted in getEventResultModel.attendance.assistant_members)
Expand All @@ -198,21 +214,6 @@ public async Task<EventListModel> GetAttendanceForEvent(string eventId)
return eventListModel;
}

// for older events participant_members seems to be used, not attendee_members
if (getEventResultModel != null && getEventResultModel.attendance != null && getEventResultModel.attendance.participant_members != null && getEventResultModel.attendance.participant_members.Any())
{
foreach (var attended in getEventResultModel.attendance.participant_members)
{
if (eventAttendance.Any(a => a.member_number == attended.member_number))
{
eventAttendance.Where(a => a.member_number == attended.member_number).Single().attended = true;
eventAttendance.Where(a => a.member_number == attended.member_number).Single().pal = "P";
}
}
eventListModel.attendees = eventAttendance;
return eventListModel;
}

return eventListModel;
}

Expand Down
2 changes: 1 addition & 1 deletion Topo/Services/StorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ public bool IsYouthMember
}
}

public string Version = "1.59";
public string Version = "1.60";
}
}
Loading

0 comments on commit 072d80b

Please sign in to comment.