public override void FixtureSetup() { base.FixtureSetup(); // assert we have our defaults setup var dtos = PreTestDataWorker.Database.Query<WarehouseDto>("SELECT * FROM merchWarehouse"); var catalogs = PreTestDataWorker.Database.Query<WarehouseCatalogDto>("SELECT * FROM merchWarehouseCatalog"); if (!dtos.Any() || !catalogs.Any()) { Assert.Ignore("Warehouse defaults are not installed."); } // TODO : This is only going to be the case for the initial Merchello release Catalog = PreTestDataWorker.WarehouseService.GetDefaultWarehouse().WarehouseCatalogs.FirstOrDefault(); if (Catalog == null) { Assert.Ignore("Warehouse Catalog is null"); } GatewayProviderService = PreTestDataWorker.GatewayProviderService; StoreSettingService = PreTestDataWorker.StoreSettingService; ShipCountryService = PreTestDataWorker.ShipCountryService; PreTestDataWorker.DeleteAllShipCountries(); const string countryCode = "US"; var us = StoreSettingService.GetCountryByCode(countryCode); var shipCountry = new ShipCountry(Catalog.Key, us); ShipCountryService.Save(shipCountry); var dk = StoreSettingService.GetCountryByCode("DK"); ShipCountryService.Save(new ShipCountry(Catalog.Key, dk)); }
/// <summary> /// Attempts to create a <see cref="ITaxMethod"/> for a given provider and country. If the provider already /// defines a tax rate for the country, the creation fails. /// </summary> /// <param name="providerKey">The unique 'key' (GUID) of the TaxationGatewayProvider</param> /// <param name="countryCode">The two character ISO country code</param> /// <param name="percentageTaxRate">The tax rate in percentage for the country</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> /// <returns><see cref="Attempt"/> indicating whether or not the creation of the <see cref="ITaxMethod"/> with respective success or fail</returns> internal Attempt <ITaxMethod> CreateTaxMethodWithKey(Guid providerKey, string countryCode, decimal percentageTaxRate, bool raiseEvents = true) { var country = _storeSettingService.GetCountryByCode(countryCode); return(country == null ? Attempt <ITaxMethod> .Fail(new ArgumentException("Could not create a country for country code '" + countryCode + "'")) : CreateTaxMethodWithKey(providerKey, country, percentageTaxRate, raiseEvents)); }
public void Init() { _gatewayProviderService = PreTestDataWorker.GatewayProviderService; _storeSettingService = PreTestDataWorker.StoreSettingService; _shipCountryService = PreTestDataWorker.ShipCountryService; _merchelloContext = new MerchelloContext(new ServiceContext(new PetaPocoUnitOfWorkProvider()), new CacheHelper(new NullCacheProvider(), new NullCacheProvider(), new NullCacheProvider())); _catalog = PreTestDataWorker.WarehouseService.GetDefaultWarehouse().WarehouseCatalogs.FirstOrDefault(); PreTestDataWorker.DeleteAllShipCountries(); var country = _storeSettingService.GetCountryByCode("US"); var shipCountry = new ShipCountry(_catalog.Key, country); _shipCountryService.Save(shipCountry); var shippingProvider = (FixedRateShippingGatewayProvider) _merchelloContext.Gateways.Shipping.CreateInstance(Core.Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey); Assert.NotNull(shippingProvider); var resource = shippingProvider.ListResourcesOffered().FirstOrDefault(); var gatewayShipMethod = shippingProvider.CreateShippingGatewayMethod(resource, shipCountry, "Ground"); shippingProvider.SaveShippingGatewayMethod(gatewayShipMethod); }
public void Init() { _gatewayProviderService = PreTestDataWorker.GatewayProviderService; _storeSettingService = PreTestDataWorker.StoreSettingService; _shipCountryService = PreTestDataWorker.ShipCountryService; _catalog = PreTestDataWorker.WarehouseService.GetDefaultWarehouse().WarehouseCatalogs.FirstOrDefault(); PreTestDataWorker.DeleteAllShipCountries(); var country = _storeSettingService.GetCountryByCode("US"); var shipCountry = new ShipCountry(_catalog.Key, country); _shipCountryService.Save(shipCountry); var shippingProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Gateways.Shipping.CreateInstance(Core.Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey); Assert.NotNull(shippingProvider); var resource = shippingProvider.ListResourcesOffered().FirstOrDefault(); var gatewayShipMethod = shippingProvider.CreateShippingGatewayMethod(resource, shipCountry, "Ground"); shippingProvider.SaveShippingGatewayMethod(gatewayShipMethod); }
/// <summary> /// The create ship country with key. /// </summary> /// <param name="warehouseCatalogKey"> /// The warehouse catalog key. /// </param> /// <param name="countryCode"> /// The country code. /// </param> /// <param name="raiseEvents"> /// The raise events. /// </param> /// <returns> /// The <see cref="Attempt"/>. /// </returns> internal Attempt <IShipCountry> CreateShipCountryWithKey(Guid warehouseCatalogKey, string countryCode, bool raiseEvents = true) { var country = _storeSettingService.GetCountryByCode(countryCode); return(country == null ? Attempt <IShipCountry> .Fail(new ArgumentException("Could not create a country for country code '" + countryCode + "'")) : CreateShipCountryWithKey(warehouseCatalogKey, country, raiseEvents)); }
public void Can_Create_And_Save_A_ShipCountry() { //// Arrange const string countryCode = "US"; var country = _storeSettingService.GetCountryByCode(countryCode); //// Act var shipCountry = new ShipCountry(_catalog.Key, country); Assert.IsFalse(shipCountry.HasIdentity); _shipCountryService.Save(shipCountry); //// Assert Assert.IsTrue(shipCountry.HasIdentity); }
public void Can_Retrieve_Denmark_Region_By_DK_Code() { //// Arrange const string countryCode = "DK"; //// Act var denmark = _storeSettingService.GetCountryByCode(countryCode); //// Assert Assert.NotNull(denmark); Assert.AreEqual(countryCode, denmark.CountryCode); }
public override void FixtureSetup() { base.FixtureSetup(); // assert we have our defaults setup var dtos = PreTestDataWorker.Database.Query <WarehouseDto>("SELECT * FROM merchWarehouse"); var catalogs = PreTestDataWorker.Database.Query <WarehouseCatalogDto>("SELECT * FROM merchWarehouseCatalog"); if (!dtos.Any() || !catalogs.Any()) { Assert.Ignore("Warehouse defaults are not installed."); } // TODO : This is only going to be the case for the initial Merchello release Catalog = PreTestDataWorker.WarehouseService.GetDefaultWarehouse().WarehouseCatalogs.FirstOrDefault(); if (Catalog == null) { Assert.Ignore("Warehouse Catalog is null"); } GatewayProviderService = PreTestDataWorker.GatewayProviderService; StoreSettingService = PreTestDataWorker.StoreSettingService; ShipCountryService = PreTestDataWorker.ShipCountryService; PreTestDataWorker.DeleteAllShipCountries(); const string countryCode = "US"; var us = StoreSettingService.GetCountryByCode(countryCode); var shipCountry = new ShipCountry(Catalog.Key, us); ShipCountryService.Save(shipCountry); var dk = StoreSettingService.GetCountryByCode("DK"); ShipCountryService.Save(new ShipCountry(Catalog.Key, dk)); }
public IShipCountry BuildEntity(ShipCountryDto dto) { var country = dto.CountryCode.Equals(Constants.CountryCodes.EverywhereElse) ? new Country(Constants.CountryCodes.EverywhereElse, new List <IProvince>()) : _storeSettingService.GetCountryByCode(dto.CountryCode); var shipCountry = new ShipCountry(dto.CatalogKey, country) { Key = dto.Key, UpdateDate = dto.UpdateDate, CreateDate = dto.CreateDate }; shipCountry.ResetDirtyProperties(); return(shipCountry); }
public IEnumerable <IProvince> GetProvincesForCountry(string countryCode) { return(_storeSettingService.GetCountryByCode(countryCode).Provinces); }
/// <summary> /// Returns a list of all countries that can be assigned to a shipment /// </summary> /// <returns>A collection of <see cref="ICountry"/></returns> public IEnumerable <ICountry> GetAllowedShipmentDestinationCountries() { var shipCountries = GatewayProviderService.GetAllShipCountries().ToArray(); var elseCountries = shipCountries.Where(x => x.CountryCode == "ELSE").ToArray(); if (elseCountries.Any()) { // get a list of all providers associated with the else countries var providers = new List <IShippingGatewayProvider>(); foreach (var ec in elseCountries) { providers.AddRange(GetGatewayProvidersByShipCountry(ec)); } if (providers.Any(x => x.ShipMethods.Any())) { return(_storeSettingService.GetAllCountries()); } } var countries = GatewayProviderService.GetAllShipCountries().Where(x => x.CountryCode != "ELSE").Select(x => _storeSettingService.GetCountryByCode(x.CountryCode)).Where(x => x != null); return(countries.Distinct()); }