Example #1
0
 public StateMachineContext(Customer customer, int storeId, ShoppingCart shoppingCart, CheckoutConfiguration configuration, CheckoutSelectionContext selections)
 {
     Customer      = customer;
     StoreId       = storeId;
     ShoppingCart  = shoppingCart;
     Configuration = configuration;
     Selections    = selections;
 }
Example #2
0
 public CheckoutEvaluationResult(
     CheckoutState state,
     CheckoutStageContext checkoutStageContext,
     CheckoutSelectionContext selections)
 {
     State = state;
     CheckoutStageContext = checkoutStageContext;
     Selections           = selections;
 }
Example #3
0
        public CheckoutEvaluationResult EvaluateCheckout(CheckoutConfiguration configuration, PersistedCheckoutContext persistedCheckoutContext, CheckoutSelectionContext checkoutSelectionContext, Customer customer, int storeId, CartContext cartContext)
        {
            // Build the evaluation context
            var stateMachineContext = new StateMachineContext(
                customer: customer,
                storeId: storeId,
                shoppingCart: cartContext.Cart,
                configuration: configuration,
                selections: checkoutSelectionContext);

            // Run the state machine
            var stateEvaluationResult = EvaluateStateMachine(stateMachineContext);

            // Put together a result
            var checkoutEvaluationResult = new CheckoutEvaluationResult(
                state: stateEvaluationResult.State,
                checkoutStageContext: stateEvaluationResult.CheckoutStageContext,
                selections: stateEvaluationResult.Selections);

            return(checkoutEvaluationResult);
        }