public DeliveryHandler(IOrder order, IDeliveryMethods deliveryMethods, IOrderSummary orderSummary, IStockBalanceHandler stockBalanceHandler)
 {
     _order               = order;
     _deliveryMethods     = deliveryMethods;
     _orderSummary        = orderSummary;
     _stockBalanceHandler = stockBalanceHandler;
 }
Exemple #2
0
        static void Main(string[] args)
        {
            var inventory = CreateProductSamples();


            ICustomer customer = Factory.CreateCustomer();

            customer.FirstName     = "Kenny";
            customer.LastName      = "Bennysson";
            customer.Email         = "*****@*****.**";
            customer.PhoneNumber   = "0738123443";
            customer.StreetAddress = "Vägstigen 44";


            IOrder order = Factory.CreateOrder(customer);


            order.AddProductToCart(inventory[0]);
            order.AddProductToCart(inventory[1]);
            order.RemoveProductFromCart(inventory[1]);
            order.AddProductToCart(inventory[2]);
            order.AddProductToCart(inventory[1]);

            order.CheckOut();

            IDeliveryMethods deliveryMethods = Factory.ChooseDeliveryMethods(
                Factory.ChoosePhysicalDeliveryMethod().Dhl(),
                Factory.ChooseDigitalDeliveryMethod().DownloadlinkToEmail()
                );

            Factory.ChoosePaymentMethod()
            .Klarna(order, deliveryMethods)
            .PayTheOrder();


            IDeliveryHandler delivery = Factory.CreateDeliveryHandler(order, deliveryMethods);

            delivery.DeliverToCustomer();


            Console.ReadLine();
        }
 public IPayment Swish(IOrder order, IDeliveryMethods deliveryMethods)
 {
     return(new SwishPayment(order, deliveryMethods));
 }
 public IPayment Klarna(IOrder order, IDeliveryMethods deliveryMethods)
 {
     return(new KlarnaPayment(order, deliveryMethods));
 }
 public IPayment Invoice(IOrder order, IDeliveryMethods deliveryMethods)
 {
     return(new InvoicePayment(order, deliveryMethods));
 }
 public IPayment Creditcard(IOrder order, long cardNumber, IDeliveryMethods deliveryMethods)
 {
     return(new CardPayment(order, cardNumber, deliveryMethods));
 }
Exemple #7
0
 public CardPayment(IOrder order, long cardNumber, IDeliveryMethods delivery)
 {
     CardNumber       = cardNumber;
     _order           = order;
     _deliveryMethods = delivery;
 }
Exemple #8
0
 public InvoicePayment(IOrder order, IDeliveryMethods delivery)
 {
     _order           = order;
     _deliveryMethods = delivery;
 }
Exemple #9
0
 public SwishPayment(IOrder order, IDeliveryMethods delivery)
 {
     _order           = order;
     _deliveryMethods = delivery;
 }
Exemple #10
0
 public KlarnaPayment(IOrder order, IDeliveryMethods delivery)
 {
     _order           = order;
     _deliveryMethods = delivery;
 }
 public static IDeliveryHandler CreateDeliveryHandler(IOrder order, IDeliveryMethods deliveryMethods)
 {
     return(new DeliveryHandler(order, deliveryMethods, Factory.CreateOrderSummary(), Factory.CreateStockBalanceHandler()));
 }