public async Task <ActionResult <Department> > Add( [FromServices] IRepository <Models.Department, int> departmentRepository, [FromServices] IEntityScraper <Models.Department> departmentScraper, [FromBody] Uri uri) { var absoluteUrl = uri.AbsoluteUri; var storedDepartment = departmentRepository.Find(department => department.Url == absoluteUrl).FirstOrDefault(); if (storedDepartment == null) { var dateTime = DateTime.Now; var department = new Models.Department { Name = "Unknown Department", IsEnabled = true, Url = UriHelper.EnsureDepartmentUrl(absoluteUrl), Added = dateTime, Updated = dateTime, Read = dateTime }; var transaction = PolicyHelper.WaitAndRetry().Execute( () => departmentRepository.BeginTransaction(IsolationLevel.Serializable)); departmentRepository.Add(department); await departmentRepository.SaveChangesAsync(); await transaction.CommitAsync(); return(department.ToDataTransferObject(true)); } return(storedDepartment?.ToDataTransferObject()); }
public StoreService( IRepository <Store, int> storesRepository, IEntityScraper <Store> entityScraper, ICookiesAwareHttpClientFactory cookiesAwareHttpClientFactory) { this.storesRepository = storesRepository; _entityScraper = entityScraper; this.cookiesAwareHttpClientFactory = cookiesAwareHttpClientFactory; }
public InspectDepartmentProductsScraper( IBrowsingContext browsingContext, IEntityScraper <Product> productScraper, HttpClient httpClient) { this.browsingContext = browsingContext; this._productScraper = productScraper; this.httpClient = httpClient; }
public InspectStoreDepartmentsScraper( IBrowsingContext browsingContext, IEntityScraper <Department> entityScraper, HttpClient httpClient) { this.browsingContext = browsingContext; this._entityScraper = entityScraper; this.httpClient = httpClient; }
public DepartmentScraper( IBrowsingContext browsingContext, IEntityScraper <Store> storeScraper, ICacheStorage <string, Department> cacheStorage, ICookiesAwareHttpClientFactory cookiesAwareHttpClientFactory) { this.browsingContext = browsingContext; this.storeScraper = storeScraper; this.cacheStorage = cacheStorage; this.cookiesAwareHttpClientFactory = cookiesAwareHttpClientFactory; }