示例#1
0
        public void GetStudentList__Returns_Student_List()
        {
            List <string> expected = new List <string>()
            {
                "adam", "bertil", "caesar", "david", "erik", "johndoe"
            };
            List <string> actual = _testClass.GetStudentList();

            CollectionAssert.AreEqual(expected, actual);
        }
示例#2
0
        public static void RemoveStudentFromClass()
        {
            var classStore   = new EducationClassStore();
            var studentStore = new UserStore();

            do
            {
                Console.Clear();
                Console.WriteLine("Ta bort student från klass");
                Console.WriteLine();
                Console.WriteLine("Tryck enter för att avbryta");
                string input = UserInput.GetInput <string>("Ange klass-id:");

                if (input == string.Empty)
                {
                    return;
                }

                EducationClass edClass = classStore.FindById(input);

                if (edClass == null)
                {
                    Console.WriteLine("Finns ingen klass med det id:t");
                }
                else
                {
                    input = UserInput.GetInput <string>("Ange student-id:");
                    User student = studentStore.FindById(input);

                    if (student == null)
                    {
                        Console.WriteLine("Studenten finns inte");
                    }
                    else
                    {
                        if (edClass.HasStudent(student.UserName))
                        {
                            bool confirmation =
                                UserInput.AskConfirmation(
                                    $"Vill du ta bort {student.FullName()} från klassen {edClass.ClassId}?");
                            if (confirmation)
                            {
                                List <string> studentList = edClass.GetStudentList();
                                studentList.Remove(student.UserName);
                                Console.WriteLine($"Plockade bort {student.UserName} från klassen");

                                edClass.SetStudentList(studentList);
                                classStore.Save();
                            }
                        }
                    }
                }
            } while (true);
        }
示例#3
0
        public static void ShowClassStudentList()
        {
            EducationClassStore classStore   = new EducationClassStore();
            UserStore           studentStore = new UserStore();
            bool keepLooping = true;

            do
            {
                Console.Clear();
                Console.WriteLine("Visa klass");
                Console.WriteLine();
                Console.WriteLine("Tryck enter för att avbryta");
                string classId = UserInput.GetInput <string>("Ange klass-id:");

                if (classId == string.Empty)
                {
                    return;
                }

                EducationClass edClass = classStore.FindById(classId);

                if (edClass == null)
                {
                    Console.WriteLine($"Finns ingen klass med id {classId}");
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine(
                        "Student-id".PadRight(12) +
                        "Namn".PadRight(40) +
                        "Telefon".PadRight(15) +
                        "Person-nr"
                        );
                    Console.WriteLine(new string('-', Console.WindowWidth));

                    List <string> studentList = edClass.GetStudentList();
                    foreach (string studentId in studentList)
                    {
                        User student = studentStore.FindById(studentId);

                        Console.WriteLine(
                            student.UserName.PadRight(12) +
                            student.FullName().Truncate(39).PadRight(40) +
                            student.PhoneNumber.PadRight(15) +
                            student.SSN
                            );
                    }
                }
                UserInput.WaitForContinue();
            } while (keepLooping);
        }
示例#4
0
        public static void ShowStudentsForCourse(User user)
        {
            bool isTeacher = user.HasLevel(UserLevel.Teacher);

            do
            {
                CourseStore         courseStore = new CourseStore();
                EducationClassStore classStore  = new EducationClassStore();

                Console.Clear();
                Console.WriteLine("Visa klasslista för kurs");
                Console.WriteLine();

                Console.WriteLine("Tryck enter för att avbryta.");
                string courseName = UserInput.GetInput <string>("Ange kurs-id:");

                if (courseName == string.Empty)
                {
                    break;
                }

                Course course = courseStore.FindById(courseName);

                if (course == null)
                {
                    Console.WriteLine("Finns ingen kurs med det namnet");
                    Console.WriteLine();
                }
                else if (isTeacher && course.CourseTeacher != user.UserName)
                {
                    Console.WriteLine("Du är ej lärare för den kursen.");
                    Console.WriteLine();
                }
                else
                {
                    EducationClass klass        = classStore.FindByCourseId(course.CourseId);
                    List <string>  studentNames = klass.GetStudentList();
                    UserManagerPresenter.PrintStudentList(studentNames);
                }
            } while (true);
        }
示例#5
0
        public static void ShowClassForStudent(User student)
        {
            EducationClassStore classStore   = new EducationClassStore();
            UserStore           studentStore = new UserStore();

            Console.Clear();
            Console.WriteLine("Visa klass");
            Console.WriteLine();
            Console.WriteLine("Tryck enter för att gå tillbaka till föregående skärm.");



            EducationClass edClass = classStore.FindByStudentId(student.UserName);

            Console.Clear();
            Console.WriteLine(
                "Student-id".PadRight(12) +
                "Namn".PadRight(40) +
                "Telefon".PadRight(15)
                );
            Console.WriteLine(new string('-', Console.WindowWidth));

            List <string> studentList = edClass.GetStudentList();

            foreach (string studentId in studentList)
            {
                User s = studentStore.FindById(studentId);

                Console.WriteLine(
                    s.UserName.PadRight(12) +
                    s.FullName().PadRight(40) +
                    s.PhoneNumber.PadRight(15)
                    );
            }
            UserInput.WaitForContinue();
        }