public void Search() { bool exit = false; List <Major> majors = majorHandler.GetMajors(); List <Subject> subjects = subjectHandler.GetSubjects(); while (!exit) { Console.Clear(); Console.CursorVisible = true; List <Major> result = new List <Major>(); Console.Write("Từ khóa: "); string input = Console.ReadLine(); input = input.ToLower(); foreach (var major in majors) { if (major.ID.Contains(input) || major.Name.ToLower().Contains(input) || major.SubjectID.Contains(input)) { result.Add(major); } } Console.Clear(); PrintTable(result); Console.Write("Bạn có muốn nhập tiếp không(nhấn esc để thoát)?"); ConsoleKeyInfo exitStr = Console.ReadKey(); if (exitStr.Key == ConsoleKey.Escape) { Console.CursorVisible = false; exit = true; } } }
public string GetSubId() { Console.Clear(); List <Subject> subjects = subjectHandler.GetSubjects(); string[] selectItem = new string[subjects.Count]; for (int i = 0; i < subjects.Count; i++) { selectItem[i] = subjects[i].Name; } MenuSelector selector = new MenuSelector(selectItem, "Bộ môn: "); return(subjects[selector.Selector()].ID); }
public void TestGetSubjectsReturnTwoSubjects() { SubjectHandler _sut = SubjectHandler.Instance; int expected = 2; int actual = _sut.GetSubjects().Count; Assert.AreEqual(expected, actual); }
public void PrintTable(List <Teacher> teachers) { Console.Clear(); List <Subject> subjects = handler.GetSubjects(); table.PrintLine(); table.PrintRow("ID", "Tên", "Chức vụ", "Bộ môn"); table.PrintLine(); foreach (var item in teachers) { table.PrintRow( item.ID, item.Name, teacherHandler.GetPosition(item.Position), subjects[subjectHandler.GetSubIndex(item.SubjectID)].Name); } table.PrintLine(); }
public void TestGetSubjectsReturnAListOfSubjects() { SubjectHandler _sut = SubjectHandler.Instance; var subjects = _sut.GetSubjects(); Type expected = typeof(SubjectM); Type actual = subjects[0].GetType(); Assert.AreEqual(expected, actual); }
} //checked public void PrintTable(List <Class> classes) { Console.Clear(); List <Teacher> teachers = teacherHandler.GetList(); List <Major> majors = majorHandler.GetMajors(); List <Subject> subjects = subjectHandler.GetSubjects(); Table table = new Table(90); table.PrintLine(); table.PrintRow("Lớp", "Sĩ số", "Bộ môn", "Chuyên ngành", "Giảng viên CN", "Niên khóa"); table.PrintLine(); foreach (var c in classes) { string tcName = teacherHandler.GetInfo(c.TeacherId, teachers).Name; string majorName = majorHandler.GetMajor(c.MajorID, majors).Name; string subjectName = subjectHandler.GetSubject(c.SubjectID, subjects).Name; table.PrintRow(c.ID, c.Population.ToString(), subjectName, majorName, tcName, c.StartYear + "-" + c.EndYear); } table.PrintLine(); } // checked
public void Add() { List <Subject> subjects = handler.GetSubjects(); bool exit = false; while (!exit) { Console.Clear(); Console.CursorVisible = true; PrintTable(subjects); Subject subject = new Subject(GetId(), GetName()); handler.AddSubject(subject); subjects.Add(subject); Console.Clear(); PrintTable(subjects); Console.Write("Bạn có muốn nhập tiếp không?(esc để thoát)"); ConsoleKeyInfo exitStr = Console.ReadKey(); if (exitStr.Key == ConsoleKey.Escape) { Console.CursorVisible = false; exit = true; } } }