Add Logic for EuroMillions Draw Machine.
This commit is contained in:
41
lottery-co-uk-scraper/EuroMillions/DrawMachine.cs
Normal file
41
lottery-co-uk-scraper/EuroMillions/DrawMachine.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using HtmlAgilityPack;
|
||||
using lottery_co_uk_scraper.core.Models;
|
||||
using lottery_co_uk_scraper.Utilities;
|
||||
|
||||
namespace lottery_co_uk_scraper.EuroMillions
|
||||
{
|
||||
internal class DrawMachine
|
||||
{
|
||||
public static string ProcessMachineUsed(HtmlDocument doc, EurosResult eurosResult)
|
||||
{
|
||||
try
|
||||
{
|
||||
var machineName = doc.DocumentNode.Descendants("td")
|
||||
.Where(x => x.InnerHtml.Contains("<strong>Ball Machine Used:</strong>"))
|
||||
.Select(x => x.InnerText.Split(':')[1].Trim())
|
||||
.FirstOrDefault();
|
||||
|
||||
if (machineName != null)
|
||||
{
|
||||
AssignDrawMachineToModelProperty(nameof(eurosResult.MachineUsed), machineName, eurosResult);
|
||||
|
||||
return machineName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// ToDo: Logger
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AssignDrawMachineToModelProperty(string propertyName, string machineName, EurosResult eurosResult)
|
||||
{
|
||||
PropertyManager.SetProperty(propertyName, eurosResult, machineName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user