Skip to content

Commit

Permalink
Requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke-W-Hart committed Jan 28, 2025
1 parent 6c7fac3 commit 9fd0a24
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions Gordon360/Services/LostAndFoundService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,28 +311,23 @@ public IEnumerable<MissingItemReportViewModel> GetMissingItemsAll(string usernam
throw new UnauthorizedAccessException();
}

// If status is null do not perform where
if (status == null)
IQueryable<MissingItemData> missingItems = context.MissingItemData;
if (status is not null)
{
return context.MissingItemData
.GroupJoin(context.ActionsTakenData,
missingItem => missingItem.ID,
action => action.missingID,
(missingItem, action) => MissingItemReportViewModel.From(missingItem, action));
}
else
{
// Perform a group join to create a MissingItemReportViewModel with actions taken data for each report
// Only performs a single SQL query to the db, so much more performant than alternative solutions
return context.MissingItemData.Where(x => x.status == status)
.GroupJoin(context.ActionsTakenData,
missingItem => missingItem.ID,
action => action.missingID,
(missingItem, action) => MissingItemReportViewModel.From(missingItem, action));
missingItems = missingItems.Where(x => x.status == status);
}


// Perform a group join to create a MissingItemReportViewModel with actions taken data for each report
// Only performs a single SQL query to the db, so much more performant than alternative solutions
return missingItems
.GroupJoin(context.ActionsTakenData.OrderBy(action => action.actionDate),
missingItem => missingItem.ID,
action => action.missingID,
(missingItem, action) => MissingItemReportViewModel.From(missingItem, action));
}

}

Check failure on line 329 in Gordon360/Services/LostAndFoundService.cs

View workflow job for this annotation

GitHub Actions / build

Invalid token '}' in class, record, struct, or interface member declaration

Check failure on line 329 in Gordon360/Services/LostAndFoundService.cs

View workflow job for this annotation

GitHub Actions / build

Invalid token '}' in class, record, struct, or interface member declaration

/// <summary>
/// Gets a Missing by id, only allowed if it belongs to the username, or the user is an admin
/// </summary>
Expand Down

0 comments on commit 9fd0a24

Please sign in to comment.