OpenDataVisualizer/Schaad.OpenData.Watercraft/Storage/WatercraftSnapshot.cs
Claudio Schaad 39a62255af Add Thurgau watercraft map (#2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
2026-11-06 21:10:01 +00:00

27 lines
827 B
C#

using Schaad.OpenData.Watercraft.Models;
namespace Schaad.OpenData.Watercraft.Storage;
public sealed class WatercraftSnapshot
{
public static readonly WatercraftSnapshot Empty = new([], null);
public WatercraftSnapshot(IEnumerable<VesselYear> years, DateTimeOffset? lastRefresh)
{
Years = years
.GroupBy(y => y.Year)
.Select(g => g.Last())
.OrderBy(y => y.Year)
.ToList();
LastRefresh = lastRefresh;
}
public IReadOnlyList<VesselYear> Years { get; }
public DateTimeOffset? LastRefresh { get; }
public VesselYear? FindYear(int year) => Years.FirstOrDefault(y => y.Year == year);
public WatercraftSnapshot With(IEnumerable<VesselYear> changed, DateTimeOffset lastRefresh) =>
new(Years.Concat(changed), lastRefresh);
}