/// <summary> /// Returns ShipCountry by id (key) /// /// GET /umbraco/Merchello/ShippingMethodsApi/GetShipCountry/{guid} /// </summary> /// <param name="id">Key of the ShipCountry to retrieve</param> public ShipCountryDisplay GetShipCountry(Guid id) { var shipCountry = _shipCountryService.GetByKey(id); if (shipCountry == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(shipCountry.ToShipCountryDisplay()); }
public void Can_Retrieve_A_ShipCountry() { //// Arrange const string countryCode = "US"; var country = _storeSettingService.GetCountryByCode(countryCode); var shipCountry = new ShipCountry(_catalog.Key, country); _shipCountryService.Save(shipCountry); Assert.IsTrue(shipCountry.HasIdentity); var key = shipCountry.Key; //// Act var retrieved = _shipCountryService.GetByKey(key); //// Assert Assert.NotNull(retrieved); Assert.AreEqual(shipCountry.CountryCode, retrieved.CountryCode); }
/// <summary> /// /// /// GET /umbraco/Merchello/ShippingMethodsApi/GetAllShipCountryFixedRateProviders/{id} /// </summary> /// <remarks> /// /// </remarks> /// <param name="id">ShipCountry Key</param> public IEnumerable <ShippingGatewayProviderDisplay> GetAllShipCountryFixedRateProviders(Guid id) { var shipCountry = _shipCountryService.GetByKey(id); if (shipCountry != null) { var providers = _shippingContext.GetGatewayProvidersByShipCountry(shipCountry); var fixedProviders = providers.Where(x => x.Key == Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey); foreach (var provider in fixedProviders) { yield return(provider.ToShipGatewayProviderDisplay()); } } else { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } }
/// <summary> /// Gets a <see cref="IShipCountry"/> by it's unique key (Guid) /// </summary> /// <param name="shipCountryKey">The unique key of the <see cref="IShipCountry"/></param> /// <returns>The <see cref="IShipCountry"/></returns> public IShipCountry GetShipCountryByKey(Guid shipCountryKey) { return(_shipCountryService.GetByKey(shipCountryKey)); }