예제 #1
0
 public void AddCard(IPaymentCard card)
 {
     if (!Cards.Contains(card))
     {
         Cards.Add(card);
     }
 }
예제 #2
0
 public static void PrintCardDetails(IPaymentCard card)
 {
     if (card != null)
     {
         Console.WriteLine("Card Type is : " + card.GetCardType());
         Console.WriteLine("Card Expiry is : " + card.Validity());
         Console.WriteLine("Card Annual Renewal Charges are  : " + card.AnnualCharges());
         Console.WriteLine("Card Limit is  : " + card.CardLimit());
     }
     else
     {
         Console.WriteLine("Invalid Card Type...");
     }
     Console.Read();
 }
예제 #3
0
 public void RemoveCard(IAccount account, IPaymentCard card)
 {
 }
예제 #4
0
 public void AddCard(IAccount account, IPaymentCard card)
 {
 }
예제 #5
0
        public async Task <PaymentGatewayResult <IPaymentCard> > UpdateCardAsync(string paymentCustomerId, IPaymentCard card)
        {
            if (string.IsNullOrEmpty(card.Id))
            {
                return(PaymentGatewayResult <IPaymentCard> .Failed(HttpStatusCode.NotFound, "Card ID not Found"));
            }

            try
            {
                var result = await _cardService.UpdateAsync(paymentCustomerId, card.Id, _mapper.Map <CardUpdateOptions>(card));

                return(PaymentGatewayResult <IPaymentCard> .Success(_mapper.Map <IPaymentCard>(result)));
            }
            catch (StripeException e)
            {
                return(PaymentGatewayResult <IPaymentCard> .Failed(e));
            }
        }
예제 #6
0
 public void RemoveCard(IPaymentCard card)
 {
     Cards.Remove(card);
 }
예제 #7
0
        static void Main(string[] args)
        {
            #region Creational Patterns Calling
            #region Singleton
            //SingletonDemo SingletonObject = SingletonDemo.GetObject();
            //SingletonObject.Print("Hello World");

            //SingletonDemo SingletonObject1 = SingletonDemo.GetObject();
            //SingletonObject1.Print("HELLO DUNYA");

            //SingletonDemo SingletonObject2 = SingletonDemo.GetObject();
            //SingletonObject2.Print("HELLO");

            //Console.ReadLine();
            #endregion
            #region Factory
            IPaymentCard card = null;
            Console.WriteLine("Please Select your card type");
            string choice = Console.ReadLine();
            switch (choice.ToLower())
            {
            case "debit":
                card = new DebitCard();
                PrintCardDetails(card);
                break;

            case "gold":
                card = new GoldCard();
                PrintCardDetails(card);
                break;

            case "platinum":
                card = new PlatinumCard();
                PrintCardDetails(card);
                break;

            default:
                card = null;
                PrintCardDetails(card);
                break;
            }

            #endregion
            #endregion
            #region Structural Patterns Calling
            #region Decorator
            ////Step 1: Define some dishes, and how many of each we can make
            //FreshSalad caesarSalad = new FreshSalad("Crisp romaine lettuce", "Freshly-grated Parmesan cheese", "House-made Caesar dressing");
            //caesarSalad.Display();

            //Pasta fettuccineAlfredo = new Pasta("Fresh-made daily pasta", "Creamly garlic alfredo sauce");
            //fettuccineAlfredo.Display();

            //Console.WriteLine("\nMaking these dishes available.");

            ////Step 2: Decorate the dishes; now if we attempt to order them once we're out of ingredients, we can notify the customer
            //Available caesarAvailable = new Available(caesarSalad, 3);
            //Available alfredoAvailable = new Available(fettuccineAlfredo, 4);

            ////Step 3: Order a bunch of dishes
            //caesarAvailable.OrderItem("John");
            //caesarAvailable.OrderItem("Sally");
            //caesarAvailable.OrderItem("Manush");

            //alfredoAvailable.OrderItem("Sally");
            //alfredoAvailable.OrderItem("Francis");
            //alfredoAvailable.OrderItem("Venkat");
            //alfredoAvailable.OrderItem("Diana");
            //alfredoAvailable.OrderItem("Dennis"); //There won't be enough for this order.

            //caesarAvailable.Display();
            //alfredoAvailable.Display();

            //Console.ReadKey();
            #endregion
            #region Adapter
            //Program p = new Program();
            //p.getJson();
            //Console.Read();
            #endregion
            #endregion
            #region Behavioral Patterns Calling
            #region Chain Of Responsibility
            // Setup Chain of Responsibility

            //Approver Waqas = new Director();
            //Approver Azeem = new VicePresident();
            //Approver Raheel = new President();

            //Waqas.SetSuccessor(Azeem);
            //Azeem.SetSuccessor(Raheel);

            //// Generate and process purchase requests

            //Purchase pr = new Purchase(2034, 350.00, "Assets");
            //Waqas.ProcessRequest(pr);

            //pr = new Purchase(2035, 32590.10, "Servers");
            //Waqas.ProcessRequest(pr);

            //pr = new Purchase(2036, 122100.00, "Property");
            //Waqas.ProcessRequest(pr);

            //// Wait for user

            //Console.ReadKey();
            #endregion
            #endregion
        }
예제 #8
0
 public void AddCard(IAccount account, IPaymentCard card)
 {
     throw new NotImplementedException();
 }
예제 #9
0
        static void Main(string[] args)
        {
            #region singleton

            /* Task task1 = Task.Factory.StartNew(() => {
             * Counter counter1 = Counter.GetInstance();
             * counter1.AddOne();
             * Console.WriteLine("counter 1 :"+ counter1.count.ToString());
             * });
             *
             * Task task2 = Task.Factory.StartNew(() => {
             * Counter counter2 = Counter.GetInstance();
             * counter2.AddOne();
             * Console.WriteLine("counter 2 :"+ counter2.count.ToString());
             * Console.WriteLine();
             * });  */
            //counter1.AddOne();
            //Console.WriteLine("counter 1 :"+ counter1.count.ToString());
            //Console.WriteLine("counter 2 :"+ counter2.count.ToString());
            #endregion

            #region prototype

            /*EmployeePrototype tempEmp1 = new TempEmployee();
             * tempEmp1.Name = "temp employee 1";
             * tempEmp1.Id = 1;
             * tempEmp1.EmpAddress = new Address{City="city 1", Building="B1", StreetName="street name"};
             *
             * EmployeePrototype tempEmp2 =tempEmp1.ShallowCopy();
             *
             * Console.WriteLine("========= Temp Emp 1 Original Values=============");
             * Console.WriteLine(tempEmp1.ToString());
             * Console.WriteLine("========= Temp Emp 2 Copy========================");
             * Console.WriteLine(tempEmp2.ToString());
             *
             * tempEmp2.EmpAddress.City="new city";
             * tempEmp2.Name="sadasdasd";
             * tempEmp2.Id=1000;
             * Console.ForegroundColor = ConsoleColor.Cyan;
             * Console.WriteLine("========= Temp Emp 1 After Change =============");
             * Console.WriteLine(tempEmp1.ToString());
             * Console.WriteLine("========= Temp Emp 2 ==========================");
             * Console.WriteLine(tempEmp2.ToString());*/

            #endregion

            #region Builder

            /*System.Text.StringBuilder sb =new System.Text.StringBuilder();
             * sb.Append("Word 1,");
             * sb.Append("Word 2");
             *
             * WriteColoredLine(sb.ToString(),ConsoleColor.Cyan);*/
            /*WriteColoredLine("***Builder Pattern***",ConsoleColor.Yellow);
             * Director director = new Director();
             * IBuilder carBuilder = new Car("Jeep");
             * IBuilder motorCycleBuilder = new MotorCycle("Honda");*/

            // Making Car

            /*director.Construct(carBuilder);
             * Product car = carBuilder.GetVehicle();
             * WriteColoredLine($"Car {car.Show()}");
             *
             * //Making MotorCycle
             * director.Construct(motorCycleBuilder);
             * Product motorCycle = motorCycleBuilder.GetVehicle();
             * WriteColoredLine($"MotorCycle {motorCycle.Show()}");*/
            #endregion

            #region Factory Method
            string      cardNumber, bankCode;
            BankFactory bankFactory = new BankFactory();

            WriteColoredLine("Enter your card number", ConsoleColor.Cyan);
            cardNumber = Console.ReadLine();
            bankCode   = cardNumber.Substring(0, 6);
            IBank        bank        = bankFactory.GetBank(bankCode);
            IPaymentCard paymentCard = bankFactory.GetPaymentCard("12");

            WriteColoredLine(bank.Withdraw());
            WriteColoredLine(paymentCard.GetName());
            #endregion

            Console.ReadKey();
        }
예제 #10
0
 public void RemoveCard(IPaymentCard card)
 {
 }
예제 #11
0
 public void AddCard(IPaymentCard card)
 {
 }