Example #1
0
        public void Process(ReturnOrder order)
        {
            var process = ReturnProcessFactory.CreateFrom(order);

            process.Process(order);
            Console.WriteLine(order.AmountToRefund);
        }
Example #2
0
        static void Main(string[] args)
        {
            ReturnOrder o1 = new ReturnOrder {
                PricePaid = 10, PostageCost = 10, Action = ReturnAction.FaultyReturn
            };
            ReturnOrder o2 = new ReturnOrder {
                PricePaid = 10, PostageCost = 10, Action = ReturnAction.NoQuibblesReturn
            };
            ReturnService rs = new ReturnService();

            rs.Process(o1);
            rs.Process(o2);
            Console.ReadLine();
        }
Example #3
0
        public static ReturnProcessTemplate CreateFrom(ReturnOrder order)
        {
            ReturnProcessTemplate template;

            switch (order.Action)
            {
            case ReturnAction.FaultyReturn:
                template = new FaultyReturnProcess();
                break;

            case ReturnAction.NoQuibblesReturn:
                template = new NoQuibblesReturnProcess();
                break;

            default:
                throw new NotImplementedException("no action found for this return order");
            }

            return(template);
        }
Example #4
0
 protected override void GenerateReturnTransactionFor(ReturnOrder order)
 {
     Console.WriteLine("transaction generated for no quibbles return....");
 }
Example #5
0
 protected override void CalculateRefundFor(ReturnOrder order)
 {
     order.AmountToRefund = order.PricePaid;
 }
Example #6
0
 public void Process(ReturnOrder order)
 {
     this.CalculateRefundFor(order);
     this.GenerateReturnTransactionFor(order);
 }
Example #7
0
 protected abstract void GenerateReturnTransactionFor(ReturnOrder order);
Example #8
0
 protected abstract void CalculateRefundFor(ReturnOrder order);