LANCommander/LANCommander.Server.Services/Mappers/MapperFunctions.cs
2026-07-02 18:09:14 -05:00

23 lines
1.1 KiB
C#

using Entities = LANCommander.Server.Data.Models;
namespace LANCommander.Server.Services.Mappers
{
/// <summary>
/// Pure helper functions shared by the Mapperly mappers for logic that cannot be
/// expressed with mapping attributes (version resolution from related archives/versions).
/// </summary>
public static class MapperFunctions
{
public static string? LatestArchiveVersion(ICollection<Entities.Archive>? archives)
=> archives != null && archives.Any()
? archives.OrderByDescending(a => a.CreatedOn).First().Version
: null;
public static string? ManifestVersion(ICollection<Entities.GameVersion>? versions, ICollection<Entities.Archive>? archives)
=> versions != null && versions.Any()
? versions.OrderByDescending(v => v.SortOrder).ThenByDescending(v => v.CreatedOn).First().Version
: (archives != null && archives.Any()
? archives.OrderByDescending(a => a.CreatedOn).First().Version
: null);
}
}