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); }
public void SetStudentList__Can_Set_With_A_List() { List <string> input = new List <string>() { "dilbert", "dogbert", "catbert" }; List <string> expected = input.ToList(); // Set and get new list _testClass.SetStudentList(input); List <string> actual = _testClass.GetStudentList(); CollectionAssert.AreEqual(expected, actual); }
public void Initialize() { _testClass = new EducationClass() { ClassId = "testclass", Description = "The Joy of Painting with Bob Ross", EducationSupervisorId = "bobross" }; var studentList = new List <string> { "adam", "bertil", "caesar", "david", "erik", "johndoe" }; _testClass.SetStudentList(studentList); _testCourse = new Course { CourseId = "oop1", CourseName = "Objektorienterad Programmering 1", CourseTeacher = "pontus", StartDate = DateTime.Today, EndDate = DateTime.Today }; _testUser = new User { UserName = "******" }; _testAddUser = new User { UserName = "******" }; var courseList = new List <Course>(); courseList.Add(_testCourse); _courseStore = new CourseStore(courseList); }