-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGradeManager.cs
78 lines (67 loc) · 2.39 KB
/
GradeManager.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
using Individuellt_databasprojekt.Data;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Individuellt_databasprojekt
{
public class GradeManager
{
public static void DisplayGradesFromLastMonth()
{
using (var context = new SchoolContext())
{
DateTime lastMonth = DateTime.Now.AddDays(-30);
var grades = context.Grades
.Include(g => g.Student)
.Include(g => g.Course)
.Include(g => g.Staff)
.Where(g => g.Date.ToDateTime(TimeOnly.MinValue) > lastMonth)
.ToList();
if (!grades.Any())
{
Console.WriteLine("No grades set in the last month.");
}
else
{
foreach (var grade in grades)
{
Console.WriteLine($"{grade.Student.FirstName} {grade.Student.LastName} - " +
$"{grade.Course.CourseName}: {grade.Value}. " +
$"Graded on {grade.Date:yyyy-MM-dd}");
}
}
}
Console.WriteLine("\nPress any key to continue...");
Console.ReadLine();
Console.Clear();
}
//Show all active courses
public static void DisplayActiveCourses()
{
using (var context = new SchoolContext())
{
var activeCourses = context.Courses
.Where(c => c.IsActive)
.ToList();
if (activeCourses.Any())
{
Console.WriteLine("List of active courses:");
foreach (var course in activeCourses)
{
Console.WriteLine($"Course ID: {course.CourseId}, Name: {course.CourseName}");
}
}
else
{
Console.WriteLine("No active courses found.");
}
}
Console.WriteLine("\nPress any key to continue...");
Console.ReadLine();
Console.Clear();
}
}
}