Exemple #1
0
        public void purchase()                            //Function to display shops for selection
        {
            localhost.WebService1 obj      = new localhost.WebService1();
            LaptopRead            lap      = new LaptopRead();
            MouseRead             mouse    = new MouseRead();
            PendriveRead          pendrive = new PendriveRead();

            int choice;

            Console.Clear();
            Console.WriteLine("***************************** Welcome ******************************");
            Console.WriteLine();
            Console.WriteLine("------------Select the Shop 1/2/3 to display the Items--------------");
            Console.WriteLine();
            Console.WriteLine("-------> Shop-1: Laptop  Shop-2: Mouse  Shop-3: Pendrives <-------");

            Console.WriteLine();
            Console.Write("Choice: ");
            choice = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine();

            switch (choice)
            {
            case 1:
                dynamic x = obj.Getlaptop();
                lap.lapDisplay(x);
                Console.ReadKey();
                break;

            case 2:
                dynamic z = obj.Getmouse();
                mouse.mouseDisplay(z);
                Console.ReadKey();
                break;

            case 3:
                dynamic y = obj.Getpendrive();
                pendrive.pendriveDisplay(y);
                Console.ReadKey();
                break;

            default:
                Console.WriteLine("Invalid choice - Please enter 1/2/3");
                Console.ReadLine();
                Console.Clear();
                break;
            }
        }
        public static void LapSelection()                                            //fn to display laptop variant selected by the user
        {
            int price = 0;
            //int qty = 0;
            //int localprice = 0;
            var user_id = Console.ReadLine();

            //Console.Clear();
            localhost.WebService1 obj1 = new localhost.WebService1();
            var x = obj1.GetLaptopJSON();;

            dynamic variant1 = JsonConvert.DeserializeObject(x);

            foreach (var i in variant1)
            {
                if (user_id == i.Id.ToString())
                {
                    String id           = i.Id;
                    String brandname    = i.Brand;
                    String price_detail = i.Price;
                    String model_detail = i.Model;

                    price = Convert.ToInt32(price_detail);

                    Program.brandcart.Add(brandname);
                    Program.pricecart.Add(price_detail);
                    Program.modelcart.Add(model_detail);

                    Console.WriteLine("Id: {0}", id);
                    Console.WriteLine("Brand: {0}", brandname);
                    Console.WriteLine("Model: {0}", model_detail);
                    Console.WriteLine("Price: Rs. {0}", price_detail);
                }
            }
            Console.ReadKey();
            Console.WriteLine();
            Console.WriteLine("---------------------------Your Selection-----------------------------");
            Console.WriteLine();
        }