public static void ListAllClasses() { EducationClassStore classStore = new EducationClassStore(); List <EducationClass> classList = classStore.All().ToList(); ShowClass(classList); }
public void Initialize() { _testClass = new EducationClass { ClassId = "su15", Description = "Systemutvecklare, agil applikationsprogrammering", StudentString = "kalle", CourseString = "Mattematik1" }; _testSuperVisor = new User { UserLevel = UserLevel.EducationSupervisor, UserName = "******" }; _testClass.EducationSupervisorId = _testSuperVisor.UserName; List <EducationClass> classList = new List <EducationClass> { _testClass }; List <User> userList = new List <User> { _testSuperVisor }; _testUserStore = new UserStore(userList); _classStore = new EducationClassStore(classList); }
public void Initialize() { _testSupervisor = new User { UserName = "******" }; _testStudent = new User() { UserName = "******" }; _testEducationClass = new EducationClass { ClassId = "klass1", Description = "Testklass", EducationSupervisorId = "supervisor" }; _testEducationClass.AddStudent(_testStudent); var otherClass = new EducationClass { ClassId = "klass2", Description = "Should not be found", EducationSupervisorId = "someone" }; var classList = new List <EducationClass> { _testEducationClass, otherClass }; _testEducationClassStore = new EducationClassStore(classList); }
public static void ListAllClasses(User supervisor) { EducationClassStore classStore = new EducationClassStore(); List <EducationClass> classList = classStore.All().ForSupervisor(supervisor).ToList(); ShowClass(classList); }
public static void ShowCoursesForClass() { EducationClassStore classStore = new EducationClassStore(); bool loop = true; do { Console.Clear(); Console.WriteLine("Tryck enter för att avbryta"); string input = UserInput.GetInput <string>("Ange klass-id:"); if (input == string.Empty) { break; } EducationClass klass = classStore.FindById(input); if (klass == null) { Console.WriteLine("Finns ingen klass med det id:t"); UserInput.WaitForContinue(); } else { CoursePresenter.ShowClassCourseList(klass); loop = false; } } while (loop); }
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 EducationClass GetClass() { if (UserLevel != UserLevel.Student) { return(null); } else { var classStore = new EducationClassStore(); return(classStore.FindByStudentId(UserName)); } }
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); }
private static bool AdminMainMenu() { bool logout = false; do { Console.Clear(); Console.WriteLine("Tiger Board!"); Console.WriteLine("Admin-meny"); Console.WriteLine(); Console.WriteLine("0. Logga ut"); Console.WriteLine("1. Skapa användare"); Console.WriteLine("2. Redigera användarinfo"); Console.WriteLine("3. Byt lösenord för användare"); Console.WriteLine(); Console.Write("Ditt val: "); string menuChoice = UserInput.GetInput <string>(); switch (menuChoice) { case "0": logout = LogoutConfirmation(); break; case "1": UserStore userStore = new UserStore(); UserCreator creator = new UserCreator(); creator.Create(userStore); break; case "2": UserManagerPresenter.ChangeUser(UserLevel.Admin); break; case "3": AdminPresenter.ChangeUserPassword(); break; case "4": var ds = new EducationClassStore(); EducationClassCreator edCreator = new EducationClassCreator(); edCreator.Create(ds); break; case "5": ClassListPresenter.MainMenu(); break; } } while (!logout); return(false); }
internal static void ManageClassMenu(User user) { Console.Clear(); Console.WriteLine("Hantera klasser"); Console.WriteLine(); Console.WriteLine("1. Skapa ny klass"); Console.WriteLine("2. Visa klasser jag ansvarar för"); Console.WriteLine("3. Visa kurslista för en klass"); Console.WriteLine("4. Visa klasslista för en klass"); Console.WriteLine("5. Lägg till student i klass"); Console.WriteLine("6. Ta bort student från klass"); Console.WriteLine(); Console.Write("Ditt val: "); string menuChoice = UserInput.GetInput <string>(); switch (menuChoice) { case "1": var creator = new EducationClassCreator(); var classStore = new EducationClassStore(); creator.Create(classStore); break; case "2": ClassListPresenter.ListAllClasses(user); break; case "3": ClassListPresenter.ShowCoursesForClass(); break; case "4": ClassListPresenter.ShowClassStudentList(); break; case "5": ClassListPresenter.AddStudentToClass(); break; case "6": ClassListPresenter.RemoveStudentFromClass(); break; default: return; } }
public static void ShowStudentCourseList(User student) { EducationClassStore classStore = new EducationClassStore(); foreach (EducationClass klass in classStore.All()) { if (klass.HasStudent(student.UserName)) { EducationClass studentClass = klass; List <string> courseList = studentClass.GetCourseList(); ListCourses(courseList); break; } } }
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); }
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(); }
public static void GradeStudentInCourse(User grader) { var userStore = new UserStore(); var educationClassStore = new EducationClassStore(); var courseStore = new CourseStore(); var gradeStore = new GradeStore(); List <string> courseList; Course course; User student; Console.Clear(); Console.WriteLine("Betygsätt student"); Console.WriteLine(); List <Course> courses = GetCourses(grader, courseStore).ToList(); do { Console.WriteLine("Tryck enter för att avbryta"); string studentName = UserInput.GetInput <string>("Ange student-id:"); if (studentName == string.Empty) { return; } student = userStore.FindById(studentName); if (student == null) { Console.WriteLine("Finns ingen student med det id:t"); } else { EducationClass studentClass = educationClassStore.FindByStudentId(student.UserName); courseList = studentClass.GetCourseList(); break; } } while (true); do { Console.WriteLine("Tryck enter för att avbryta"); string courseName = UserInput.GetInput <string>("Ange kurs-id:"); if (courseName == string.Empty) { return; } if (courses.Exists(c => c.CourseId == courseName)) { if (courseList.Contains(courseName)) { course = courseStore.FindById(courseName); break; } Console.WriteLine("Studentens klass läser inte kursen"); UserInput.WaitForContinue(); } else { Console.WriteLine("Kursen finns inte eller du är inte lärare för den"); UserInput.WaitForContinue(); } } while (true); GradeLevel gradeLevel = AskForGrade(); Console.WriteLine($"Student: {student.FullName()} ({student.UserName})"); Console.WriteLine($"Kurs: {course.CourseName} ({course.CourseId})"); Console.WriteLine($"Betyg: {gradeLevel}"); bool confirm = UserInput.AskConfirmation("Betygsätt student?"); if (confirm) { var grade = new Grade { CourseId = course.CourseId, StudentId = student.UserName, Result = gradeLevel }; gradeStore.GradeStudent(student, grade); gradeStore.Save(); } }
public static void AddStudentToClass() { var classStore = new EducationClassStore(); var studentStore = new UserStore(); Console.Clear(); Console.WriteLine("Lägg till student i klass"); Console.WriteLine(); Console.WriteLine("Ange klass-id: "); string classID = UserInput.GetInput <string>(); var educationClass = classStore.FindById(classID); if (educationClass == null) { Console.WriteLine("Klassen kunde inte hittas"); return; } Console.WriteLine("Ange student-id: "); string studentID = UserInput.GetInput <string>(); var studentUser = studentStore.FindById(studentID); if (studentUser == null) { Console.WriteLine("Finns ingen student med det namnet"); } else if (!studentUser.HasLevel(UserLevel.Student)) { Console.WriteLine("Användaren är inte en student"); } else if (educationClass.HasStudent(studentUser.UserName)) { Console.WriteLine("Studenten finns redan i klassen"); } else if (studentUser.HasLevel(UserLevel.Student)) { Console.Clear(); UserManagerPresenter.PrintUserInfo(studentUser); bool accept = UserInput.AskConfirmation("Vill du lägga till studenten till klassen?"); if (accept) { List <string> studentList = educationClass.GetStudentList(); studentList.Add(studentUser.UserName); educationClass.SetStudentList(studentList); var educationList = classStore.All().ToList(); foreach (var item in educationList) { if (item.ClassId == educationClass.ClassId) { item.SetStudentList(educationClass.GetStudentList()); classStore.Save(); } } } } }