Progress Overhaul + Profile Page and a LOT more! (#4262)

Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
Joe Milazzo
2025-12-09 10:00:11 -07:00
committed by GitHub
parent 4ac13f1f25
commit 9f29fa593d
645 changed files with 25585 additions and 4805 deletions
+34 -1
View File
@@ -6,7 +6,6 @@ using API.Data.Misc;
using API.Entities;
using API.Entities.Enums;
using API.Entities.Metadata;
using Microsoft.AspNetCore.Identity;
namespace API.Extensions;
#nullable enable
@@ -70,6 +69,40 @@ public static class EnumerableExtensions
return q;
}
/// <summary>
/// Safety net around Max, returning the default value if source contains no elements
/// </summary>
/// <param name="source"></param>
/// <param name="selector"></param>
/// <param name="defaultValue"></param>
/// <typeparam name="TSource"></typeparam>
/// <typeparam name="TResult"></typeparam>
/// <returns></returns>
public static TResult? MaxOrDefault<TSource, TResult>(
this IList<TSource> source,
Func<TSource, TResult> selector,
TResult? defaultValue)
{
return source.Count == 0 ? defaultValue : source.Max(selector);
}
/// <summary>
/// Safety wrapper around Min, returning the default value if source has no elements
/// </summary>
/// <param name="source"></param>
/// <param name="selector"></param>
/// <param name="defaultValue"></param>
/// <typeparam name="TSource"></typeparam>
/// <typeparam name="TResult"></typeparam>
/// <returns></returns>
public static TResult? MinOrDefault<TSource, TResult>(
this IList<TSource> source,
Func<TSource, TResult> selector,
TResult? defaultValue)
{
return source.Count == 0 ? defaultValue : source.Min(selector);
}
public static IEnumerable<TSource> WhereNotNull<TSource>(this IEnumerable<TSource?> source)
where TSource : class
{