diff --git a/PoliNetwork.Graduatorie.Parser/Objects/RankingNS/RankingsSet.cs b/PoliNetwork.Graduatorie.Parser/Objects/RankingNS/RankingsSet.cs index 092ee92c..908d396a 100644 --- a/PoliNetwork.Graduatorie.Parser/Objects/RankingNS/RankingsSet.cs +++ b/PoliNetwork.Graduatorie.Parser/Objects/RankingNS/RankingsSet.cs @@ -20,24 +20,19 @@ public RankingsSet() LastUpdate = DateTime.UtcNow; } - - public void AddRanking(Ranking ranking) - { - var alreadyPresent = Contains(ranking); - if (!alreadyPresent) - Rankings.Add(ranking); - - if (LastUpdate == null || ranking.LastUpdate.Date > LastUpdate?.Date) LastUpdate = ranking.LastUpdate; - } - - public bool Contains(Ranking ranking) - { - return Rankings.Any(v => v.IsSimilarTo(ranking)); - } - - public void Merge(RankingsSet set) + public void Merge(RankingsSet newSet) { - foreach (var ranking in set.Rankings) AddRanking(ranking); + foreach (var ranking in newSet.Rankings) + { + var alreadyPresent = Rankings.Any(v => v.IsSimilarTo(ranking)); + if (!alreadyPresent) + { + Rankings.Add(ranking); + + if (LastUpdate == null || ranking.LastUpdate.Date > LastUpdate?.Date) + LastUpdate = ranking.LastUpdate; + } + } } public void WriteAllRankings(string outFolder, bool forceReparse = false)