public ActionResult ShippingEstimate(ShippingEstimateViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } // Add the estimate partial address to the checkout context so that we can use that later to display rates if there is no customer address var customer = HttpContext.GetCustomer(); var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer); var shippingEstimateDetails = new ShippingEstimateDetails( country: model.Country, city: model.City, state: model.State, postalCode: model.PostalCode); var updatedCheckoutContext = new PersistedCheckoutContext( creditCard: checkoutContext.CreditCard, payPalExpress: checkoutContext.PayPalExpress, purchaseOrder: checkoutContext.PurchaseOrder, braintree: checkoutContext.Braintree, termsAndConditionsAccepted: checkoutContext.TermsAndConditionsAccepted, over13Checked: checkoutContext.Over13Checked, amazonPayments: checkoutContext.AmazonPayments, shippingEstimateDetails: shippingEstimateDetails, offsiteRequiresBillingAddressId: checkoutContext.OffsiteRequiresBillingAddressId, offsiteRequiresShippingAddressId: checkoutContext.OffsiteRequiresShippingAddressId, email: checkoutContext.Email, selectedShippingMethodId: checkoutContext.SelectedShippingMethodId); PersistedCheckoutContextProvider.SaveCheckoutContext(customer, updatedCheckoutContext); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); }
public ActionResult ShippingEstimate(ShippingEstimateViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } // Add the estimate partial address to the checkout context so that we can use that later to display rates if there is no customer address var customer = HttpContext.GetCustomer(); var shippingEstimateDetails = new ShippingEstimateDetails( country: model.Country, city: model.City, state: model.State, postalCode: model.PostalCode); var updatedPersistedCheckoutContext = new PersistedCheckoutContextBuilder() .From(PersistedCheckoutContextProvider.LoadCheckoutContext(customer)) .WithShippingEstimate(shippingEstimateDetails) .Build(); PersistedCheckoutContextProvider.SaveCheckoutContext(customer, updatedPersistedCheckoutContext); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); }