Exemplo n.º 1
0
 public PayController(IPurchaseAppService purchaseAppService, IOrderPolicy orderPolicy,
                      IRechargeAppService rechargeAppService)
 {
     _purchaseAppService = purchaseAppService;
     _orderPolicy        = orderPolicy;
     _rechargeAppService = rechargeAppService;
 }
Exemplo n.º 2
0
 public PurchaseService(IWechatAuthentManager wechatAuthentManager,
                        IPurchaseServiceRepository purchaseServiceRepository, IRepository <UserPayOrderInfo, string> userPayOrdeRepository, IOrderPolicy orderPolicy)
 {
     _wechatAuthentManager      = wechatAuthentManager;
     _purchaseServiceRepository = purchaseServiceRepository;
     _userPayOrdeRepository     = userPayOrdeRepository;
     _orderPolicy = orderPolicy;
 }
Exemplo n.º 3
0
 public RechargeService(IRepository <UserPayOrderInfo, string> userPayOrdeRepository,
                        IPurchaseServiceRepository purchaseServiceRepository, IRepository <UserRecharge, string> userRechargeRepository, IRepository <UserInfo> userRepository, IOrderPolicy orderPolicy)
 {
     _userPayOrdeRepository     = userPayOrdeRepository;
     _purchaseServiceRepository = purchaseServiceRepository;
     _userRechargeRepository    = userRechargeRepository;
     _userRepository            = userRepository;
     _orderPolicy = orderPolicy;
 }
Exemplo n.º 4
0
 public OrderExecutor(IPurchaseService purchaseService, IOrderPolicy orderPolicy,
                      IRechargeService rechargeService,
                      IRepository <UserPayOrderInfo, string> userpayOrderRepository, IAlipayPurchaseService alipayPurchaseService)
 {
     _purchaseService        = purchaseService;
     _orderPolicy            = orderPolicy;
     _rechargeService        = rechargeService;
     _userpayOrderRepository = userpayOrderRepository;
     _alipayPurchaseService  = alipayPurchaseService;
 }
        public void Should_throw_when_order_shipped_without_paid_state()
        {
            var order = FakeOrder;
            var moq   = new Mock <IOrderPolicy>();

            moq.Setup(p => p.Apply(It.IsAny <OrderShouldBePaidBeforeShip>()))
            .Throws <OrderNotPaidYetException>();

            IOrderPolicy policy = moq.Object;

            CommandScenarioFor <OrderState> .With
            (
                order
            )
            .When(s => Order.ShipOrder(order, policy))
            .Throws(typeof(OrderNotPaidYetException))
            .Assert();
        }
        public OrderActor(IAggregateStore aggregateStore,
                          IOrderPolicy orderPolicy,
                          Now now)
            : base(aggregateStore)
        {
            When <CreateOrderCommand>(cmd =>
            {
                var order = Order.Create(new OrderId(ActorId),
                                         new CustomerId(cmd.BuyerId),
                                         cmd.City,
                                         cmd.Street,
                                         now);

                State = order.State;

                return(ActorId, order);
            });

            When <PayOrderCommand>(cmd => cmd.OrderNumber, cmd => Order.PayOrder(State));

            When <ShipOrderCommand>(cmd => cmd.OrderNumber, cmd => Order.ShipOrder(State, orderPolicy));

            When <CancelOrderCommand>(cmd => cmd.OrderNumber, cmd => Order.CancelOrder(State));
        }
 public ShipOrderCommandHandler(IAggregateStore aggregateStore,
                                IOrderPolicy orderPolicy) : base(aggregateStore) =>
Exemplo n.º 8
0
 public static OrderState.Result ShipOrder(OrderState state, IOrderPolicy policy) =>
 state.With(s => policy.Apply(new OrderShouldBePaidBeforeShip(s)))
 .AndThen(s => s.ApplyEvent(new OrderShippedEvent(s.Id)));