static void Main(string[] args) { Console.WriteLine("ORder Processing starts!"); //Create OrderProcessing //Do the Payment //Do the actions OrderProcesser orderProcesser = new OrderProcesser(); Product prod = new Product(); prod.ProductType = ProductPaymentType.Physical; prod.ProductName = "PhysicalItem"; //PhyscialProduct physcialProductExpected = new PhyscialProduct(); PhyscialMaster physcialMaster = orderProcesser.InitializePhyscial(prod); bool doActionsResult = orderProcesser.DoActionsPhyscial(prod, physcialMaster); prod.ProductType = ProductPaymentType.Book; prod.ProductName = "BookItem"; //PhyscialProduct physcialProductExpected = new PhyscialProduct(); PhyscialMaster bookProduct = orderProcesser.InitializePhyscial(prod); doActionsResult = orderProcesser.DoActionsPhyscial(prod, bookProduct); prod.ProductType = ProductPaymentType.BasicMemberShip; prod.ProductName = "BasicMembershipItem"; //PhyscialProduct physcialProductExpected = new PhyscialProduct(); MembershipMaster membershipMaster = orderProcesser.InitiliazeMembership(prod); doActionsResult = orderProcesser.DoActionsMembership(prod, membershipMaster); prod.ProductType = ProductPaymentType.PremierMemberShip; prod.ProductName = "PremierMembershipItem"; //PhyscialProduct physcialProductExpected = new PhyscialProduct(); membershipMaster = orderProcesser.InitiliazeMembership(prod); doActionsResult = orderProcesser.DoActionsMembership(prod, membershipMaster); Console.ReadLine(); Console.WriteLine("Order Processing ends! Press any key to end."); }
// public ProductPaymentType PaymentType { get; set; } //Initialize //D public PhyscialMaster InitializePhyscial(Product prod) { PhyscialMaster physcialMaster = null; if (prod.ProductType == ProductPaymentType.Physical) { PhyscialProduct physcialProduct = new PhyscialProduct(); physcialMaster = physcialProduct; } else if (prod.ProductType == ProductPaymentType.Book) { BookProduct bookProduct = new BookProduct(); physcialMaster = bookProduct; } return(physcialMaster); }
//public bool DoPayments(Product prod) //{ // bool isSuccess = false; // //Do Payment // isSuccess = true; // return isSuccess; //} public bool DoActionsPhyscial(Product prod, PhyscialMaster physcialMaster) { bool isSuccess = false; //DoActions if (prod.ProductType == ProductPaymentType.Physical) { PhyscialProduct physcialProduct = new PhyscialProduct(); PackageSlipDetails packageSlipDetails = physcialMaster.GeneratePackageSlip(prod); CommissionPayment commissionPayment = physcialMaster.GenerateCommisionPayment(prod); } else if (prod.ProductType == ProductPaymentType.Book) { BookProduct bookProduct = new BookProduct(); PackageSlipDetails packageSlipDetails = bookProduct.GeneratePackageSlip(prod); CommissionPayment commissionPayment = bookProduct.GenerateCommisionPayment(prod); } isSuccess = true; return(isSuccess); }