コード例 #1
0
 public IEnumerable <CountryModel> GetCountries()
 {
     return(AllowableShipCounties
            .OrderBy(x => x.Name).Select(x => new CountryModel()
     {
         CountryCode = x.CountryCode, Name = x.Name
     }));
 }
コード例 #2
0
        public ShippingRateQuotes GetShippingMethodQuotes(CheckoutAddress address)
        {
            var customer = Services.CustomerService.GetAnyByKey(address.CustomerKey);

            if (customer == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            var basket = Basket.GetBasket(customer);

            // for this version there is only ever a single shipment
            var destination = address.ToAddress();

            // validate we can estimate shipping
            if (string.IsNullOrEmpty(destination.CountryCode) || AllowableShipCounties.FirstOrDefault(x => x.CountryCode == destination.CountryCode) == null)
            {
                throw new InvalidOperationException("The shipping destination's country code is either null or contains a country code that is not associated with any shipping provider.");
            }

            var shipment = basket.PackageBasket(address.ToAddress()).FirstOrDefault();

            if (shipment == null)
            {
                return new ShippingRateQuotes()
                       {
                           Status = ShipQuoteStatus.NoShippableItems.ToString()
                       }
            }
            ;

            var providerQuotes = shipment.ShipmentRateQuotes();

            return(new ShippingRateQuotes(providerQuotes.ToShipMethodQuotes())
            {
                Status = ShipQuoteStatus.Ok.ToString()
            });
        }
コード例 #3
0
 public IEnumerable <CountryDisplay> GetCountries()
 {
     return(AllowableShipCounties
            .OrderBy(x => x.Name).Select(GetCountryDisplay));
 }
コード例 #4
0
 public IEnumerable <ProvinceDisplay> GetProvinces()
 {
     return(BuildProvinceCollection(AllowableShipCounties.Where(x => x.Provinces.Any())));
 }