Utils: Add ActiveAreaCommitments()

This commit is contained in:
2024-03-25 16:22:58 +01:00
parent c6e83ffff4
commit 3f9c4cb1f6
5 changed files with 15 additions and 6 deletions

View File

@ -488,5 +488,15 @@ namespace Elwig.Helpers {
return obj.GetHashCode();
}
}
public static IQueryable<AreaCom> ActiveAreaCommitments(IQueryable<AreaCom> query) => ActiveAreaCommitments(query, CurrentYear);
public static IQueryable<AreaCom> ActiveAreaCommitments(IQueryable<AreaCom> query, int yearTo) {
return query.Where(c => (c.YearFrom <= CurrentYear) && (c.YearTo == null || c.YearTo >= yearTo));
}
public static IEnumerable<AreaCom> ActiveAreaCommitments(IEnumerable<AreaCom> query) => ActiveAreaCommitments(query, CurrentYear);
public static IEnumerable<AreaCom> ActiveAreaCommitments(IEnumerable<AreaCom> query, int yearTo) {
return query.Where(c => (c.YearFrom <= CurrentYear) && (c.YearTo == null || c.YearTo >= yearTo));
}
}
}