My console app will loop through each User to get their Websites, so that it can take new screenshots of them. However, to prevent taking screenshot of the same website twice I have to check whether there already has been taken screenshot of the website, while looping through another users websites.
My current solution is:
Database:
User
|--> ID: 1
|--> FirstName: Joe
|--> ID: 2
|--> FirstName: Stranger
Websites
|--> ID: 1
|--> UserID: 1
|--> URL: http://site.com
|--> ID: 2
|--> UserID: 2
|--> URL: http://site.com
Console app:
static void RenewWebsiteThumbNails()
{
Console.WriteLine("Starting renewal process...");
using (_repository)
{
var websitesUpdated = new List<string>();
foreach (var user in _repository.GetAll())
{
foreach (var website in user.Websites.Where(website => !websitesUpdated.Contains(website.URL)))
{
_repository.TakeScreenDumpAndSave(website.URL);
websitesUpdated.Add(website.URL);
Console.WriteLine(new string('-', 50));
Console.WriteLine("{0} has successfully been renewed", website.URL);
}
}
}
}
However, it seems wrong to declare a List for such a scenario, just to check whether a specific URL already has been added... any suggestions for an alternative way?