Beispiel #1
0
        public void Update(int position, string oldId, List <Assignment> assignments, List <Teacher> teachers)
        {
            Console.CursorVisible = true;
            Console.WriteLine("giảng viên cũ: " + assignments[position].TeacherID);
            //string tcherId = DrawInputForm(assignments, position, teachers, 1); // ==> nhấn enter và lấy được teacherID sau khi nhập
            //assignments[position].TeacherID = tcherId;
            //Assignment newInfo = assignments[position];
            //handler.Update(oldId, newInfo);
            //PrintSelectorTable(assignments, position);
            int pos = 0;

            PrintTeacherSelector(teachers, pos);
            bool exit = false;

            while (!exit)
            {
                ConsoleKeyInfo consoleKey = Console.ReadKey();
                Console.Clear();
                switch (consoleKey.Key)
                {
                case ConsoleKey.DownArrow:
                    if (pos < teachers.Count)
                    {
                        pos++;
                        PrintTeacherSelector(teachers, pos);
                    }
                    else
                    {
                        Console.CursorLeft = 0;
                    }
                    break;

                case ConsoleKey.UpArrow:
                    if (pos > 0)
                    {
                        pos--;
                        PrintTeacherSelector(teachers, pos);
                    }
                    else
                    {
                        Console.CursorLeft = 0;
                    }
                    break;

                case ConsoleKey.Enter:
                    assignments[position].TeacherID = teachers[pos].ID;
                    PrintSemesterSelector(assignments[position]);
                    handler.Update(oldId, assignments[position]);
                    exit = true;
                    break;
                }
            }
        }