Exemplo n.º 1
0
        //================================================= Constructors


        public Daneshjooyan(List <MyClass1> ListeAsatidEntekhabi)
        {
            List <MyClass1> DestructMAsters = new List <MyClass1>();

            _ListeAsatidEntekhabi = ListeAsatidEntekhabi;

            for (int i = 0; i < _ListeAsatidEntekhabi.Count; i++)
            {
                Console.WriteLine($"Ostade {_ListeAsatidEntekhabi[i]._NameOfMaster} Doroos e Zir Ra Eraee Mikonad : ");
                for (int j = 0; j < _ListeAsatidEntekhabi[i]._Doroose_eraeeShode.Count; j++)
                {
                    Console.WriteLine($"{j + 1}.Name e Dars :{_ListeAsatidEntekhabi[i]._Doroose_eraeeShode[j]._NameOfDars} And ID : {_ListeAsatidEntekhabi[i]._Doroose_eraeeShode[j]._IdDars}");
                }
                Console.Write("ID e Darse Mored e Nazar Ra Vared Namaeyd : ");
                int      IDDars           = Convert.ToInt32(Console.ReadLine());
                MyClass1 DestructerMaster = new MyClass1();
                Doroos   DrDistruct       = _ListeAsatidEntekhabi[i]._Doroose_eraeeShode.Find(x => x._IdDars == IDDars);
                if (DrDistruct != null)
                {
                    DestructerMaster = _ListeAsatidEntekhabi[i];
                    DestructMAsters.Add(DestructerMaster);
                }
            }
            _ListeAsatidEntekhabi = new List <MyClass1>();
            _ListeAsatidEntekhabi = DestructMAsters;
        }
        static void Main(string[] args)
        {
            Console.Write("Welcome To Master Registration ==> Enter Count Of The Masters : ");
            int             counts  = Convert.ToInt32(Console.ReadLine());
            List <MyClass1> Masters = new List <MyClass1>();

            for (int i = 0; i < counts; i++)
            {
                MyClass1 objMasters = new MyClass1();
                Console.Write("Enter Master Name : ");
                //objMasters._NameOfMaster = Console.ReadLine();
                string name = Console.ReadLine();
                Console.Write("Enter Count Of Master Valute Prices : ");
                int        valutPriceCount = Convert.ToInt32(Console.ReadLine());
                List <int> Price           = new List <int>();
                for (int j = 0; j < valutPriceCount; j++)
                {
                    Console.Write($"{j.ToString()} . Enter Price : ");
                    Price.Add(Convert.ToInt32(Console.ReadLine()));
                }
                int Result = objMasters.RegisterMaster(name, Price);
                if (Result == 1)
                {
                    Masters.Add(objMasters);
                    Console.WriteLine("Master Add Success!\n=========================================================\n");
                }
            }
            //=====================================================================
            Console.Write("Press Any Key To Continue");
            Console.ReadLine();
            //=======================================================================
            Console.WriteLine($"There Are {Masters.Count} In Our DataBase !");
            for (int i = 0; i < Masters.Count; i++)
            {
                Console.WriteLine($"Master No.{i + 1} : {Masters[i]._NameOfMaster}\nRegistered In : {Masters[i]._Master_Register_Date}\nWith Token :{Masters[i]._MasterToken}\nHas {Masters[i]._Prices.Count} Prices And His Prices :");
                for (int j = 0; j < Masters[i]._Prices.Count; j++)
                {
                    Console.WriteLine($"Price No.{j + 1} : {Masters[i]._Prices[j]}");
                }
            }
            Console.Write("=========================================================\nPress Any Key To Continue");
            Console.ReadLine();
            Console.WriteLine("listeDoroos ra vared namaeyd !");
            List <Doroos> Darsha  = new List <Doroos>();
            int           counter = 0;

            while (true)
            {
                counter++;
                Doroos objdoroos = new Doroos();
                Console.Write("lotfan ID e dars e mored e nazar ra vared namaeyd : ");
                objdoroos._IdDars = Convert.ToInt32(Console.ReadLine());
                Console.Write("name e dars ra vared namaeyd : ");
                objdoroos._NameOfDars = Console.ReadLine();
                Console.Write("Teedad e vahed e dars ra vared namaeyd : ");
                objdoroos._Vahed = Convert.ToInt32(Console.ReadLine());
                Console.Write("Baraye khateme dadan be vared kardan e doroos lotfan \"E\" ya \"e\" ra vared namaeyd : ");
                string Continue = Console.ReadLine();
                Darsha.Add(objdoroos);
                Console.WriteLine($"======================== Darse shomare.{counter.ToString()} Vared shod ! ===============================");
                if (Continue.ToUpper() == "E")
                {
                    break;
                }
                Console.WriteLine();
            }

            Console.WriteLine("Please Insert Master Lessons Below! :");
            for (int i = 0; i < Masters.Count; i++)
            {
                Console.WriteLine("lotfan az doroos e zir yeki ya chand dars ra be ostad motasel namaeyd !\nNahve ye etesale doroos be soorate  \"IDdars1,IDdars2,IDdars3,...\" Mibashad !");
                Console.WriteLine($"Name e ostad : {Masters[i]._NameOfMaster}");
                for (int j = 0; j < Darsha.Count; j++)
                {
                    Console.WriteLine($"{j + 1}.Name : {Darsha[j]._NameOfDars} -- ID : {Darsha[j]._IdDars}");
                }
                Console.WriteLine("=============== Id Doroos Ra Vared Namaeyd ");
                string Doroos = Console.ReadLine();
                if (Doroos.Contains(','))
                {
                    string[] DoroosArry = Doroos.Split(',');
                    for (int k = 0; k < DoroosArry.Length; k++)
                    {
                        Doroos objDoroos = new Doroos();
                        objDoroos = Darsha.Find(x => x._IdDars == Convert.ToInt32(DoroosArry[k]));
                        Masters[i]._Doroose_eraeeShode.Add(objDoroos);
                        Console.WriteLine($"Baraye ostad {Masters[i]._NameOfMaster} Darse {objDoroos._NameOfDars} ba ID : {objDoroos._IdDars} Va tedad Vahed e  : {objDoroos._Vahed} Add Shod !\n=========================================");
                    }
                }
                else
                {
                    Doroos objDoroos = new Doroos();
                    objDoroos = Darsha.Find(x => x._IdDars == Convert.ToInt32(Doroos));
                    Masters[i]._Doroose_eraeeShode.Add(objDoroos);
                    Console.WriteLine($"Baraye ostad {Masters[i]._NameOfMaster} Darse {objDoroos._NameOfDars} ba ID : {objDoroos._IdDars} Va tedad Vahed e  : {objDoroos._Vahed} Add Shod !\n=========================================");
                }
            }


            Console.Write("=========================================================\nPress Any Key To Continue");
            Console.ReadLine();
            List <Daneshjooyan> Daneshjooyan = new List <Daneshjooyan>();

            Console.Write("Tedade Daneshjuyane khod ra vared namaeyd : ");
            int CountDaneshju = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < CountDaneshju; i++)
            {
                Daneshjooyan MyDaneshju = new Daneshjooyan(Masters);
                Console.Write("Name e Daneshju ra vared namaeyd : ");
                MyDaneshju._NameDaneshjoo = Console.ReadLine();
                Console.Write("ID e Daneshju ra vared namaeyd : ");
                MyDaneshju._IDDaneshjooey = Convert.ToInt32(Console.ReadLine());
                Daneshjooyan.Add(MyDaneshju);
            }
            Console.WriteLine("=========================================================================================");
            for (int i = 0; i < Daneshjooyan.Count; i++)
            {
                Console.WriteLine($"No.{i + 1} : {Daneshjooyan[i]._NameDaneshjoo} -- {Daneshjooyan[i]._IDDaneshjooey} Tedad vahed e bardashte ==> {Daneshjooyan[i].TedadVahedeBardashteShode().ToString()}");
            }
            Console.Write("=========================================================\nPress Any Key To Continue");
            Console.ReadLine();
        }