public void Run(OrderShipmentRequest request)
        {
            Order order = orderRepository.GetById(request.GetOrderId());

            if (order.GetStatus().Equals(OrderStatus.Created) || order.GetStatus().Equals(OrderStatus.Rejected))
            {
                throw new OrderCannotBeShippedException();
            }

            if (order.GetStatus().Equals(OrderStatus.Shipped))
            {
                throw new OrderCannotBeShippedTwiceException();
            }

            shipmentService.Ship(order);

            order.SetStatus(OrderStatus.Shipped);
            orderRepository.Save(order);
        }
Exemple #2
0
        public void Run(OrderShipmentRequest request)
        {
            Order order = this.orderRepository.GetById(request.OrderId);

            if (order.Status == OrderStatus.Created || order.Status == OrderStatus.Rejected)
            {
                throw new OrderCannotBeShippedException();
            }

            if (order.Status == OrderStatus.Shipped)
            {
                throw new OrderCannotBeShippedTwiceException();
            }

            shipmentService.Ship(order);

            order.Status = OrderStatus.Shipped;
            orderRepository.Save(order);
        }
Exemple #3
0
 public void Run(OrderShipmentRequest request)
 {
     Order order = orderRepository.GetById(request.OrderId);
     order.ShipWith(shipmentService);
     orderRepository.Save(order);
 }