Check for single item with same itemId prior to inserting item from existing assort file into merged file
This commit is contained in:
parent
2fa1e95281
commit
6b86c6c29a
@ -9,7 +9,7 @@ namespace AssortUpdater
|
|||||||
{
|
{
|
||||||
var completeAssorts = new List<FlatAssort>();
|
var completeAssorts = new List<FlatAssort>();
|
||||||
|
|
||||||
// Add live assorts
|
// Add live assorts to merged list
|
||||||
foreach (var liveAssort in flattenedLiveAssorts)
|
foreach (var liveAssort in flattenedLiveAssorts)
|
||||||
{
|
{
|
||||||
completeAssorts.Add(liveAssort);
|
completeAssorts.Add(liveAssort);
|
||||||
@ -41,7 +41,14 @@ namespace AssortUpdater
|
|||||||
|
|
||||||
private static FlatAssort? GetMatchingAssortFromCompleteList(string traderName, FlatAssort assortToFind, List<FlatAssort> completeAssorts)
|
private static FlatAssort? GetMatchingAssortFromCompleteList(string traderName, FlatAssort assortToFind, List<FlatAssort> completeAssorts)
|
||||||
{
|
{
|
||||||
IEnumerable<FlatAssort>? existingAssort = GetAssortByItemIdAndLevel(assortToFind, completeAssorts);
|
IEnumerable<FlatAssort>? existingAssort = GetAssortByItemId(assortToFind, completeAssorts);
|
||||||
|
if (existingAssort.Any() && existingAssort.Count() == 1)
|
||||||
|
{
|
||||||
|
// one match found by id, dont add
|
||||||
|
return existingAssort.First();
|
||||||
|
}
|
||||||
|
|
||||||
|
existingAssort = GetAssortByItemIdAndLevel(assortToFind, completeAssorts);
|
||||||
|
|
||||||
if (SingleAssortFound(existingAssort))
|
if (SingleAssortFound(existingAssort))
|
||||||
{
|
{
|
||||||
@ -101,6 +108,11 @@ namespace AssortUpdater
|
|||||||
&& x.BarterDetails[0].count == assortToFind.BarterDetails[0].count);
|
&& x.BarterDetails[0].count == assortToFind.BarterDetails[0].count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<FlatAssort> GetAssortByItemId(FlatAssort assortToFind, List<FlatAssort> completeAssorts)
|
||||||
|
{
|
||||||
|
return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId);
|
||||||
|
}
|
||||||
|
|
||||||
private static IEnumerable<FlatAssort> GetAssortByItemIdAndLevel(FlatAssort assortToFind, List<FlatAssort> completeAssorts)
|
private static IEnumerable<FlatAssort> GetAssortByItemIdAndLevel(FlatAssort assortToFind, List<FlatAssort> completeAssorts)
|
||||||
{
|
{
|
||||||
return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId
|
return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId
|
||||||
|
Loading…
x
Reference in New Issue
Block a user