Exemplo n.º 1
0
        public static coreModel.Store ToCoreModel(this webModel.Store store, ShippingMethod[] shippingMethods, PaymentMethod[] paymentMethods, TaxProvider[] taxProviders)
        {
            var retVal = new coreModel.Store();
            retVal.InjectFrom(store);
            retVal.SeoInfos = store.SeoInfos;
            retVal.StoreState = store.StoreState;
            retVal.DynamicProperties = store.DynamicProperties;

            if (store.ShippingMethods != null)
            {
                retVal.ShippingMethods = new List<ShippingMethod>();
                foreach (var shippingMethod in shippingMethods)
                {
                    var webShippingMethod = store.ShippingMethods.FirstOrDefault(x => x.Code == shippingMethod.Code);
                    if (webShippingMethod != null)
                    {
                        retVal.ShippingMethods.Add(webShippingMethod.ToCoreModel(shippingMethod));
                    }
                }
            }

            if (store.PaymentMethods != null)
            {
                retVal.PaymentMethods = new List<PaymentMethod>();
                foreach (var paymentMethod in paymentMethods)
                {
                    var webPaymentMethod = store.PaymentMethods.FirstOrDefault(x => x.Code == paymentMethod.Code);
                    if (webPaymentMethod != null)
                    {
                        retVal.PaymentMethods.Add(webPaymentMethod.ToCoreModel(paymentMethod));
                    }
                }
            }

            if (store.TaxProviders != null)
            {
                retVal.TaxProviders = new List<TaxProvider>();
                foreach (var taxProvider in taxProviders)
                {
                    var webTaxProvider = store.TaxProviders.FirstOrDefault(x => x.Code == taxProvider.Code);
                    if (webTaxProvider != null)
                    {
                        retVal.TaxProviders.Add(webTaxProvider.ToCoreModel(taxProvider));
                    }
                }
            }

            if (store.Languages != null)
                retVal.Languages = store.Languages;
            if (store.Currencies != null)
                retVal.Currencies = store.Currencies;
            if (store.ReturnsFulfillmentCenter != null)
                retVal.ReturnsFulfillmentCenter = store.ReturnsFulfillmentCenter.ToCoreModel();
            if (store.FulfillmentCenter != null)
                retVal.FulfillmentCenter = store.FulfillmentCenter.ToCoreModel();

            return retVal;
        }
Exemplo n.º 2
0
 public Order(Customer customer, string shippingAddress, string billingAddress,
     ShippingMethod shippingMethod)
     : this()
 {
     this.customer.Value = customer;
     this.shippingAddress = shippingAddress;
     this.shippingMethod = shippingMethod;
     this.billingAddress = billingAddress;
 }
        protected void BtnCreate_Click( object sender, EventArgs e )
        {
            if ( Page.IsValid ) {
            ShippingMethod shippingMethod = new ShippingMethod( StoreId, TxtName.Text );
            shippingMethod.Save();

            Redirect( WebUtils.GetPageUrl( Constants.Pages.EditShippingMethod ) + "?id=" + shippingMethod.Id + "&storeId=" + shippingMethod.StoreId );
              }
        }
        public ShippingRateCalculationContext(ShippingMethod shippingMethod, object shippingRateProviderConfig, PriceCalculationContext pricingContext)
        {
            Require.NotNull(shippingMethod, "shippingMethod");
            Require.NotNull(pricingContext, "pricingContext");

            ShippingMethod = shippingMethod;
            ShippingRateProviderConfig = shippingRateProviderConfig;
            PricingContext = pricingContext;
        }
Exemplo n.º 5
0
        public void Delete(ShippingMethod method)
        {
            if (method.IsEnabled)
            {
                Disable(method);
            }

            _repository.Delete(method);
        }
        public static ShippingMethod ToWebModel(this VirtoCommerceQuoteModuleWebModelShipmentMethod serviceModel, Currency currency)
        {
            var webModel = new ShippingMethod();

            webModel.InjectFrom<NullableAndEnumValueInjecter>(serviceModel);

            webModel.Price = new Money(serviceModel.Price ?? 0, currency);

            return webModel;
        }
        public static ShippingMethod ToViewModel(this DataContracts.Cart.ShipmentMethod shipmentMethod)
        {
            var shippingMethodViewModel = new ShippingMethod();

            shippingMethodViewModel.ImageUrl = shipmentMethod.LogoUrl;
            shippingMethodViewModel.Keyword = shipmentMethod.ShipmentMethodCode;
            shippingMethodViewModel.Price = shipmentMethod.Price;
            shippingMethodViewModel.Title = shipmentMethod.Name;

            return shippingMethodViewModel;
        }
Exemplo n.º 8
0
        public bool Enable(ShippingMethod method)
        {
            if (method.IsEnabled)
            {
                return false;
            }

            method.IsEnabled = true;
            _repository.Database.SaveChanges();

            Event.Raise(new ShippingMethodEnabled(method), _instance);

            return true;
        }
        public static ShippingMethod ToWebModel(this VirtoCommerceCartModuleWebModelShippingMethod shippingMethod, IEnumerable<Currency> availCurrencies, Language language)
        {
            var shippingMethodModel = new ShippingMethod();

            shippingMethodModel.InjectFrom(shippingMethod);

            var currency = availCurrencies.FirstOrDefault(x=> x.Equals(shippingMethod.Currency)) ?? new Currency(language, shippingMethod.Currency); 
            if (shippingMethod.Discounts != null)
            {
                shippingMethodModel.Discounts = shippingMethod.Discounts.Select(d => d.ToWebModel(availCurrencies, language)).ToList();
            }

            shippingMethodModel.Price = new Money(shippingMethod.Price ?? 0, currency);

            return shippingMethodModel;
        }
        ShippingMethod GetOrderShippingMethod(Commerce.Data.SqlRepository.ShippingMethod method, SqlRepository.Order order) {

            ShippingMethod result = null;
            Decimal orderWeight = order.OrderItems.Sum(x => x.Product.WeightInPounds);
            if (method != null) {
                result = new ShippingMethod();
                result.ID = method.ShippingMethodID;
                result.Carrier = method.Carrier;
                result.EstimatedDelivery = method.EstimatedDelivery;
                result.RatePerPound = method.RatePerPound;
                result.ServiceName = method.ServiceName;
                result.Cost = method.BaseRate + (method.RatePerPound * orderWeight);
            }

            return result;
        }
Exemplo n.º 11
0
		public static coreModel.Store ToCoreModel(this webModel.Store store, ShippingMethod[] shippingMethods, PaymentMethod[] paymentMethods)
		{
			var retVal = new coreModel.Store();
			retVal.InjectFrom(store);
			retVal.SeoInfos = store.SeoInfos;
			retVal.StoreState = store.StoreState;
			if (store.Settings != null)
				retVal.Settings = store.Settings.Select(x => x.ToCoreModel()).ToList();

			if (store.ShippingMethods != null)
			{
				retVal.ShippingMethods = new List<ShippingMethod>();
				foreach (var shippingMethod in shippingMethods)
				{
					var webShippingMethod = store.ShippingMethods.FirstOrDefault(x => x.Code == shippingMethod.Code);
					if (webShippingMethod != null)
					{
						retVal.ShippingMethods.Add(webShippingMethod.ToCoreModel(shippingMethod));
					}
				}
			}

			if (store.PaymentMethods != null)
			{
				retVal.PaymentMethods = new List<PaymentMethod>();
				foreach (var paymentMethod in paymentMethods)
				{
					var webPaymentMethod = store.PaymentMethods.FirstOrDefault(x => x.Code == paymentMethod.Code);
					if (webPaymentMethod != null)
					{
						retVal.PaymentMethods.Add(webPaymentMethod.ToCoreModel(paymentMethod));
					}
				}
			}

			if (store.Languages != null)
				retVal.Languages = store.Languages;
			if (store.Currencies != null)
				retVal.Currencies = store.Currencies;
			if (store.ReturnsFulfillmentCenter != null)
				retVal.ReturnsFulfillmentCenter = store.ReturnsFulfillmentCenter.ToCoreModel();
			if (store.FulfillmentCenter != null)
				retVal.FulfillmentCenter = store.FulfillmentCenter.ToCoreModel();
			

			return retVal;
		}
        public static ShippingMethod ToWebModel(this VirtoCommerceCartModuleWebModelShippingMethod shippingMethod)
        {
            var shippingMethodModel = new ShippingMethod();

            shippingMethodModel.InjectFrom(shippingMethod);

            var currency = new Currency(EnumUtility.SafeParse(shippingMethod.Currency, CurrencyCodes.USD));

            if (shippingMethod.Discounts != null)
            {
                shippingMethodModel.Discounts = shippingMethod.Discounts.Select(d => d.ToWebModel()).ToList();
            }

            shippingMethodModel.Price = new Money(shippingMethod.Price ?? 0, currency.Code);

            return shippingMethodModel;
        }
Exemplo n.º 13
0
        public double CalculateShippingCost(ShippingMethod method)
        {
            double cost = 0;
            switch(method)
            {
                case ShippingMethod.USPS:
                    cost = 1.0 * 1;
                    break;
                case ShippingMethod.FedEx:
                    cost = 1.0 * 2;
                    break;
                case ShippingMethod.DHL:
                    cost = 1.0 * 3;
                    break;
                case ShippingMethod.UPS:
                    cost = 1.0 * 4;
                    break;
            }

            return cost;
        }
        public IShippingCostCalculator GetCalculator(ShippingMethod shippingMethod)
        {
            //switch (shippingMethod)
            //{
            //    case ShippingMethod.Express:
            //        return new ExpressShippingCalculator();
            //    case ShippingMethod.PriceSaver:
            //        return new PriceSaverShippingCalculator();
            //    case ShippingMethod.Standard:
            //    default:
            //        return new StandardShippingCalculator();
            //}

            return (from c in _calculators
                    let handles = c as IHandleShippingMethod
                    where handles != null
                    && handles.CanHandle(shippingMethod)
                    select c).First();

            //return (from c in this.candidates
            //        let t = c.GetType()
            //        where t.Name.StartsWith(shippingMethod.ToString())
            //        select c).First();
        }
 public ShippingRateProviderEditor GetEditor(ShippingMethod shippingMethod)
 {
     return new ShippingRateProviderEditor("~/Areas/" + Strings.AreaName + "/Views/Config.cshtml");
 }
 public bool CanHandle(ShippingMethod shippingMethod)
 {
     return shippingMethod == ShippingMethod.Express;
 }
Exemplo n.º 17
0
 public void DeleteShippingMethod(ShippingMethod data)
 {
     try {
     SetService();  SerClient.DeleteShippingMethod(data); }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
         SerClient.Abort(); 
     }
 }
Exemplo n.º 18
0
 public void Save(ShippingMethod shippingMethod)
 {
     _shippingMethods.Value.Save(shippingMethod);
 }
Exemplo n.º 19
0
 public void Enable(ShippingMethod method)
 {
     method.Enable();
 }
Exemplo n.º 20
0
        public void ShipProduct(Product product, ShippingMethod method)
        {
            var shipping = CalculateShippingCost(method);
            var total = shipping + product.Price;

            // Charge Customer the {total} amount
            // Not Implemented

            product.Ship(total);
        }
Exemplo n.º 21
0
 public void Disable(ShippingMethod method)
 {
     method.Disable();
 }
Exemplo n.º 22
0
        public async Task<CartBuilder> AddShipmentAsync(ShippingMethod shippingMethod)
        {
            var shipment = shippingMethod.ToShipmentModel(_currency);

            _cart.Shipments.Clear();
            _cart.Shipments.Add(shipment);

            await EvaluatePromotionsAsync();

            return this;
        }
Exemplo n.º 23
0
 public void ChangeShippingMethod(ShoppingCart cart, ShippingMethod shippingMethod)
 {
     if (cart.ShippingMethod == null || cart.ShippingMethod.Id != shippingMethod.Id)
     {
         cart.ShippingMethod = shippingMethod;
         _repository.Database.SaveChanges();
     }
 }
Exemplo n.º 24
0
 public void Create(ShippingMethod method)
 {
     _repository.Insert(method);
 }
 public string GetEditorVirtualPath(ShippingMethod shippingMethod)
 {
     return "~/Areas/" + Strings.AreaName + "/Views/Config.cshtml";
 }
 public decimal GetShippingRate(ShippingMethod method, ShippingRateCalculationContext context)
 {
     return 0m;
 }
 public bool CanHandle(ShippingMethod shippingMethod)
 {
     return shippingMethod == ShippingMethod.PriceSaver;
 }
Exemplo n.º 28
0
 public ShippingMethodEnabled(ShippingMethod method)
 {
     ShippingMethodId = method.Id;
 }
Exemplo n.º 29
0
 public ShippingMethod SaveShippingMethod(ShippingMethod data)
 {
     try {
     SetService();  return SerClient.SaveShippingMethod(data); }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
         SerClient.Abort(); 
     }
 }
 public bool CanHandle(ShippingMethod shippingMethod)
 {
     return shippingMethod == ShippingMethod.Standard;
 }