public void ProcessPriceUpdates(string productCode) { // get the necessary dependencies IWebPageEngine pageEngine = EngineLocator.CreateEngine <IWebPageEngine>(); IProductParserEngine priceEngine = EngineLocator.CreateEngine <IProductParserEngine>(); IProductAccessor productAccessor = AccessorLocator.CreateAccessor <IProductAccessor>(); IEmailAccessor emailAccessor = AccessorLocator.CreateAccessor <IEmailAccessor>(); // build the url string url = pageEngine.BuildUrl(productCode); // get the page contents string contents = pageEngine.GetWebPageContents(url); // get the stored product information var product = productAccessor.FindByCode(productCode); // get the current price decimal currentPrice = priceEngine.GetProductPrice(contents, productCode); // if the current price is different from the price threshold then send an email if (currentPrice > 0) { if (product.PriceThreshold != currentPrice) { emailAccessor.SendPriceNotice(product, currentPrice); } } }
public RegisterUserCommandHandler(IApplicationDbContext context, IJwtGenerator jwtGenerator, UserManager <AppUser> userManager, IEmailAccessor emailAccessor) { _context = context; _jwtGenerator = jwtGenerator; _userManager = userManager; _emailAccessor = emailAccessor; }
/// <summary> /// Constructor used for dependency injection /// </summary> public PriceManager(IWebPageEngine pageEngine, IProductParserEngine priceEngine, IProductAccessor productAccessor, IEmailAccessor emailAccessor) { Console.WriteLine("PriceManager constructor called"); _emailAccessor = emailAccessor; _pageEngine = pageEngine; _priceEngine = priceEngine; _productAccessor = productAccessor; }
public ExportProcessingEngine(IExportAccessor exportAccessor, IDirectoryAccessor directoryAccessor, IEmailAccessor emailAccessor, ICacheAccessor cache) { _exportAccessor = exportAccessor ?? throw new ArgumentNullException(nameof(exportAccessor)); _directoryAccessor = directoryAccessor ?? throw new ArgumentNullException(nameof(directoryAccessor)); _emailAccessor = emailAccessor ?? throw new ArgumentNullException(nameof(emailAccessor)); _cache = cache ?? throw new ArgumentNullException(nameof(cache)); }
public EmailEngine(IEmailAccessor emailAccessor) { _emailAccessor = emailAccessor; }