Ejemplo n.º 1
0
        public void Run()
        {
            listener.Start();

            var obj      = Activator.CreateInstance(StartupClass);
            var app      = ApplicationBuilder.GetInstance();
            var services = ServiceCollection.GetInstance();

            var configureServicesMethod = StartupClass.GetMethod("ConfigureServices");

            if (configureServicesMethod == null)
            {
                throw new ApplicationException(nameof(configureServicesMethod));
            }
            configureServicesMethod.Invoke(obj, new object[] { services });

            var configureMethod = StartupClass.GetMethod("Configure");

            if (configureMethod == null)
            {
                throw new ApplicationException(nameof(configureMethod));
            }
            configureMethod.Invoke(obj, new object[] { app });

            Logger.Log($"Server is running: localhost:{_port}");

            Console.WriteLine();
            while (true)
            {
                Console.WriteLine("Wait for connection...");

                var client = listener.AcceptTcpClient();

                Console.WriteLine("Client conected");

                Task.Factory.StartNew(() => HandleClient(client));
            }
        }
Ejemplo n.º 2
0
        public (List <ItemClass>, List <ItemClass>) ModifiedItems(List <ItemClass> items, List <ItemClass> allitems)
        {
            newList = items.ToList();
            AllList = allitems.ToList();

            StartupClass   Sc = new StartupClass();
            WelcomeHandler Wh = new WelcomeHandler();

label:
            Console.WriteLine("                                         Your List                                           ");
            foreach (ItemClass item in newList)
            {
                Console.WriteLine("-----------------------------------------------------------------------------------------");
                int a = 10 - item.Name.Length;
                Console.Write("Name     : " + item.Name); for (int j = 0; j < a; j++)
                {
                    Console.Write(" ");
                }
                int b = 10 - item.Price.ToString().Length;
                Console.Write("Price    : " + item.Price); for (int j = 0; j < b; j++)
                {
                    Console.Write(" ");
                }
                int c = 10 - item.Quantity.ToString().Length;
                Console.Write("Quantity : " + item.Quantity); for (int j = 0; j < c; j++)
                {
                    Console.Write(" ");
                }
                int d = 10 - item.ItemNumber.ToString().Length;
                Console.WriteLine("Item No: : " + item.ItemNumber);
            }
            Console.WriteLine("-----------------------------------------------------------------------------------------");


            Console.WriteLine(" 1.Add Quantity Of Item:");
            Console.WriteLine(" 2.Remove Item:");
            Console.WriteLine(" 3.Reduce Quantity Of Item:");
            Console.WriteLine(" 4.<=Go Back:");
            Console.Write(" ENTER YOUR CHOICE::=>  ");
            int choice = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
            case 1:

                Console.Write(" ENTER ITEM NUMBER::=>  ");
                int itemed = Convert.ToInt32(Console.ReadLine());
                Console.Write("--How Much Quantity to be Add--");
                int qty = Convert.ToInt32(Console.ReadLine());
                AddQuantity(itemed, qty);
                Console.Clear();
                goto label;

            case 2:

                Console.Write(" ENTER ITEM NUMBER::=>  ");
                int itemeds = Convert.ToInt32(Console.ReadLine());
                RemoveItem(itemeds);
                goto label;

            case 3:

                Console.Write(" ENTER ITEM NUMBER::=>  ");
                int iteme = Convert.ToInt32(Console.ReadLine());
                Console.Write("--How Much Quantity to Reduce--");
                int qt = Convert.ToInt32(Console.ReadLine());
                ReduceQuantity(iteme, qt);
                goto label;

            case 4:
                Console.Clear();
                Sc.Welcome();
                Wh.Handler();
                break;
            }
            return(newList, AllList);
        }
Ejemplo n.º 3
0
        public void Handler()
        {
            Program      pg = new Program();
            string       choice;
            ItemManager  Im     = new ItemManager();
            StartupClass Sc     = new StartupClass();
            int          Option = Sc.ChooseOption();

            switch (Option)
            {
            case 1:
                Im.ViewItem();
                Console.Write("Press any key to Shop...................................................................");
                Console.ReadLine();
                Console.Clear();
                Sc.Welcome();
                Handler();
                break;

            case 2:
label:
                Console.Write("Enter Item Number::=>  ");
                int Item = Convert.ToInt32(Console.ReadLine());
                Console.Write("Enter Quantity::=>  ");
                int Qty = Convert.ToInt32(Console.ReadLine());
                Im.AddItem(Item, Qty);
                Console.Write("Want to shop more??     [Y/N]    ");
                choice = Console.ReadLine();
                if (choice == "Y" || choice == "y" || choice == "yes" || choice == "YES")
                {
                    goto label;
                }
                Console.Clear();
                Sc.Welcome();
                Handler();
                break;

            case 3:
                Im.ModifyItem();
                break;

            case 4:
                Console.Write("Input Item No::=>  ");
                int item = Convert.ToInt32(Console.ReadLine());
                Im.RemoveItem(item);
                Console.Clear();
                Sc.Welcome();
                Handler();
                break;

            case 5:
                Im.ViewBucket();

                Console.Write("Press any key to Continue...............................................................");
                Console.ReadLine();
                Console.Clear();
                Sc.Welcome();
                Handler();
                break;

            case 6:
                Im.ClearBucket();
                Console.Write(".....................................................Clearing...........................");
                Thread.Sleep(2000);
                Console.Write("[[[[[Bucket Cleaned]]]]]");
                Thread.Sleep(200);
                Console.Clear();
                Sc.Welcome();
                Handler();
                break;

            case 7:
                Environment.Exit(1);
                break;
            }
        }