public List <string> ProcessScrapedWhiskies(IEnumerable <Whisky> scrapedWhiskies) { var discountsForEmail = new List <string>(); foreach (var whisky in scrapedWhiskies) { // Get whisky, preferably with it's type var whiskyEntity = string.IsNullOrWhiteSpace(whisky.Type) ? _whiskyService.GetWhisky(whisky.Name, whisky.Store) : _whiskyService.GetWhisky(whisky.Name, whisky.Store, whisky.Type); if (whiskyEntity == null) { // Add to database _whiskyService.AddWhisky(CustomMapper.MapWhisky(whisky)); continue; } // Whisky found, make this one inactive _whiskyService.EditWhisky(whiskyEntity); // Add new record with original id, which will now be active _whiskyService.AddWhisky(CustomMapper.MapWhisky(whisky), whiskyEntity.OriginalId); // Check if price has decreased since last scan if (whisky.Price >= whiskyEntity.Price) { continue; } var priceDifference = whiskyEntity.Price - whisky.Price; var body = $"<p>{whisky.Name} | Price: {whisky.Price} vs {whiskyEntity.Price} (-{priceDifference})</p>"; discountsForEmail.Add(body); } _whiskyService.SaveChanges(); return(discountsForEmail); }