-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisplay.cs
109 lines (103 loc) · 3.66 KB
/
Display.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Individuellt_databasprojekt
{
public class Display
{
public static void Run()
{
while (true)
{
ShowMenu();
string input = Console.ReadLine();
if (Enum.TryParse(input, out MenuOption option))
{
if (!HandleMenuOption(option))
{
break;
}
}
else
{
Console.WriteLine("Invalid choice. Please select a valid option.");
}
}
}
public enum MenuOption
{
DisplayAllStaff = 1,
DisplayStudent,
DisplayStudentsFromClass,
DisplayGradesFromLastMonth,
DisplayGradesFromCourse,
AddStudent,
AddStaff,
DisplayStaffCountByRole,
DisplayAllStudents,
DisplayActiveCourses,
Exit
}
private static void ShowMenu()
{
Console.WriteLine("Menu options:");
Console.WriteLine("1 - Display all staff");
Console.WriteLine("2 - Display all students");
Console.WriteLine("3 - Display all students from a class");
Console.WriteLine("4 - Display all grades from set last month");
Console.WriteLine("5 - Display all grades from one course");
Console.WriteLine("6 - Add a new student value");
Console.WriteLine("7 - Add a new staff value");
Console.WriteLine("8 - How many staff in each role");
Console.WriteLine("9 - Show all student in the database");
Console.WriteLine("10 - Show active courses");
Console.WriteLine("11 - Exit");
}
private static bool HandleMenuOption(MenuOption option)
{
switch (option)
{
case MenuOption.DisplayAllStaff:
StaffManager.DisplayStaff();
break;
case MenuOption.DisplayStudent:
StudentManager.DisplayStudents();
break;
case MenuOption.DisplayStudentsFromClass:
StudentManager.DisplayStudentsInCourse();
break;
case MenuOption.DisplayGradesFromLastMonth:
GradeManager.DisplayGradesFromLastMonth();
break;
case MenuOption.DisplayGradesFromCourse:
StudentManager.DisplayGradesFromCourse();
break;
case MenuOption.AddStudent:
StudentManager.AddStudent();
break;
case MenuOption.AddStaff:
StaffManager.AddStaff();
break;
case MenuOption.DisplayStaffCountByRole:
StaffManager.DisplayStaffCountByRole();
break;
case MenuOption.DisplayAllStudents:
StudentManager.DisplayAllStudents();
break;
case MenuOption.DisplayActiveCourses:
GradeManager.DisplayActiveCourses();
break;
case MenuOption.Exit:
return false;
default:
Console.WriteLine("Invalid choice");
break;
}
return true;
Console.WriteLine();
}
}
}