Implemented ternary expression to make this if-else more concise.
This commit is contained in:
@@ -46,24 +46,16 @@ namespace lottery_co_uk_scraper
|
||||
var ballsDrawn = doc.DocumentNode.Descendants("span")
|
||||
.FirstOrDefault(x => x.Attributes["id"] != null && x.Attributes["id"].Value == "ballsDrawn");
|
||||
|
||||
List<int>? lottoBalls = null;
|
||||
List<int>? lottoBonusBalls = null;
|
||||
List<int>? lottoBalls = (ballsDrawn != null)
|
||||
? ExtractBalls(ballsDrawn, "lotto-ball")
|
||||
: null;
|
||||
|
||||
if (ballsDrawn != null)
|
||||
{
|
||||
lottoBalls = ExtractBalls(ballsDrawn, "lotto-ball");
|
||||
lottoBonusBalls = ExtractBalls(ballsDrawn, "lotto-bonus-ball");
|
||||
}
|
||||
List<int>? lottoBonusBalls = (ballsDrawn != null)
|
||||
? ExtractBalls(ballsDrawn, "lotto-bonus-ball")
|
||||
: null;
|
||||
|
||||
if (lottoBalls != null)
|
||||
{
|
||||
Console.WriteLine("Numbers inside lotto ball result: " + string.Join(", ", lottoBalls));
|
||||
}
|
||||
|
||||
if (lottoBonusBalls != null)
|
||||
{
|
||||
Console.WriteLine("Numbers inside lotto bonus ball result: " + string.Join(", ", lottoBonusBalls));
|
||||
}
|
||||
PrintResults("Numbers inside lotto ball result", lottoBalls);
|
||||
PrintResults("Numbers inside lotto bonus ball result", lottoBonusBalls);
|
||||
|
||||
var ballSetUsed = doc.DocumentNode.Descendants("td")
|
||||
.Where(x => x.InnerHtml.Contains("<strong>Ball Set Used:</strong>"))
|
||||
@@ -91,6 +83,7 @@ namespace lottery_co_uk_scraper
|
||||
}
|
||||
|
||||
Console.WriteLine($"Failed to parse {className} value: {x.InnerText}");
|
||||
|
||||
return 0;
|
||||
})
|
||||
.ToList();
|
||||
@@ -236,5 +229,13 @@ namespace lottery_co_uk_scraper
|
||||
Console.WriteLine("Rolldown: " + rolldown);
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintResults(string label, List<int>? values)
|
||||
{
|
||||
if (values != null)
|
||||
{
|
||||
Console.WriteLine($"{label}: " + string.Join(", ", values));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user