protected void ImportClick(object sender, EventArgs e) { string[] isbnNumbers = LoadIsbnNumbers().ToArray(); WipePriceDatabase(); var collection = PriceHarvestRepository.MongoCollection(); foreach (string isbnNumber in isbnNumbers) { var pricingService = new PricingService(new ConsoleLog()); var pricingDetails = new PricingDetails() { IsbnNumber = isbnNumber }; foreach (Currency currency in pricingService.Currencies) { var price = pricingService.FindPriceByIsbn(isbnNumber, currency); PricingMapper.Map(isbnNumber, price, pricingDetails); } collection.Insert(pricingDetails); } }
private static PricingCurrencyDetails GetApiPrices(string isbn, string currency) { Endpoints.PricingService service = new Endpoints.PricingService(new ConsoleLog()); var result = service.FindPriceByIsbn(isbn); return(SelectCurrency(PricingMapper.Map(isbn, result), currency)); }
/** * This console app will sync products created in the last X time */ public static void Main() { _cachedEaAuthToken = GetEaAuthToken(); _cachedMagentoAuthToken = GetMagentoAuthToken(); var controllerFactory = new ControllerFactory(_cachedMagentoAuthToken, _cachedEaAuthToken); var assetsController = controllerFactory.CreateController(ControllerType.Assets) as AssetsController; var availabilityController = controllerFactory.CreateController(ControllerType.Availability) as AvailabilityController; var catalogsController = controllerFactory.CreateController(ControllerType.Catalogs) as CatalogsController; var entitiesController = controllerFactory.CreateController(ControllerType.Entities) as EntitiesController; var fieldController = controllerFactory.CreateController(ControllerType.FieldDefinition) as FieldDefinitionController; var ordersController = controllerFactory.CreateController(ControllerType.Orders) as OrdersController; var pricingController = controllerFactory.CreateController(ControllerType.Pricing) as PricingController; var productLibraryController = controllerFactory.CreateController(ControllerType.ProductLibrary) as ProductLibraryController; var cartController = controllerFactory.CreateController(ControllerType.Cart) as CartController; var attributesController = controllerFactory.CreateController(ControllerType.CustomAttributes) as CustomAttributesController; var customerController = controllerFactory.CreateController(ControllerType.Customer) as CustomerController; var productController = controllerFactory.CreateController(ControllerType.Product) as ProductController; var regionController = controllerFactory.CreateController(ControllerType.Region) as RegionController; _productMapper = new ProductMapper(catalogsController, productLibraryController, productController); _assetMapper = new AssetMapper(assetsController, productLibraryController, catalogsController); _availabilityMapper = new AvailabilityMapper(availabilityController); _colorMapper = new ColorMapper(attributesController, productLibraryController); _fieldMapper = new FieldMapper(productLibraryController, productController, fieldController, catalogsController, attributesController); _pricingMapper = new PricingMapper(pricingController); _orderMapper = new OrderMapper(ordersController, catalogsController, cartController, productController); _entityMapper = new EntityMapper(entitiesController, regionController); _customerMapper = new CustomerMapper(customerController); bool doOrderSync; bool productsSynced = ProductSync(); if (productsSynced) { Console.WriteLine("Products successfully synced"); doOrderSync = true; } else { Console.WriteLine("An error occurred while syncing products to Endless Aisle. Check errorLog.txt for more details."); Console.WriteLine("Continue on to synchronizing Orders to Magento?"); doOrderSync = Console.ReadKey().ToString().Equals(UserAffirmativeString, StringComparison.OrdinalIgnoreCase); } //Order syncing if (doOrderSync) { bool ordersSynced = OrderSync(); Console.WriteLine(ordersSynced ? "Orders successfully synced" : "An error occurred while syncing orders to Magento. Check errorLog.txt for more details."); } Console.WriteLine("Press enter to exit..."); Console.ReadLine(); }