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