From 1b318286a860ce542cd2b4a2635daa542379f9ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Kr=C3=A1l?=
<90798024+Jitralar@users.noreply.github.com>
Date: Fri, 12 Dec 2025 00:07:47 +0100
Subject: [PATCH] =?UTF-8?q?Rename=20seeded=20lecturer=20to=20Jan=20Nov?=
=?UTF-8?q?=C3=ADk?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BlazorApp1/Components/Layout/NavMenu.razor | 11 +-
.../Components/Layout/NavMenu.razor.css | 8 +
BlazorApp1/Components/Pages/Home.razor | 15 +-
BlazorApp1/Components/Pages/Management.razor | 321 ++++++++++++++++++
BlazorApp1/Components/Pages/Schedule.razor | 62 ++++
.../Components/Pages/SubjectDetails.razor | 90 +++++
BlazorApp1/Components/_Imports.razor | 2 +
BlazorApp1/Models/Classroom.cs | 16 +
BlazorApp1/Models/Department.cs | 10 +
BlazorApp1/Models/Lesson.cs | 22 ++
BlazorApp1/Models/LessonType.cs | 8 +
BlazorApp1/Models/Person.cs | 20 ++
BlazorApp1/Models/Role.cs | 8 +
BlazorApp1/Models/Subject.cs | 14 +
BlazorApp1/Program.cs | 3 +
BlazorApp1/Services/ScheduleService.cs | 186 ++++++++++
16 files changed, 787 insertions(+), 9 deletions(-)
create mode 100644 BlazorApp1/Components/Pages/Management.razor
create mode 100644 BlazorApp1/Components/Pages/Schedule.razor
create mode 100644 BlazorApp1/Components/Pages/SubjectDetails.razor
create mode 100644 BlazorApp1/Models/Classroom.cs
create mode 100644 BlazorApp1/Models/Department.cs
create mode 100644 BlazorApp1/Models/Lesson.cs
create mode 100644 BlazorApp1/Models/LessonType.cs
create mode 100644 BlazorApp1/Models/Person.cs
create mode 100644 BlazorApp1/Models/Role.cs
create mode 100644 BlazorApp1/Models/Subject.cs
create mode 100644 BlazorApp1/Services/ScheduleService.cs
diff --git a/BlazorApp1/Components/Layout/NavMenu.razor b/BlazorApp1/Components/Layout/NavMenu.razor
index ffda8b2..d1b23c8 100644
--- a/BlazorApp1/Components/Layout/NavMenu.razor
+++ b/BlazorApp1/Components/Layout/NavMenu.razor
@@ -1,6 +1,6 @@
@@ -15,14 +15,13 @@
-
- Counter
+
+ Rozvrh týdne
-
-
- Weather
+
+ Správa dat
diff --git a/BlazorApp1/Components/Layout/NavMenu.razor.css b/BlazorApp1/Components/Layout/NavMenu.razor.css
index 4e15395..17bc108 100644
--- a/BlazorApp1/Components/Layout/NavMenu.razor.css
+++ b/BlazorApp1/Components/Layout/NavMenu.razor.css
@@ -46,6 +46,14 @@
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
}
+.bi-calendar-event-fill-nav-menu {
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-calendar-event-fill' viewBox='0 0 16 16'%3E%3Cpath d='M4 .5a.5.5 0 0 1 .5-.5h.5a.5.5 0 0 1 .5.5V1h4V.5a.5.5 0 0 1 .5-.5h.5a.5.5 0 0 1 .5.5V1h.5A2.5 2.5 0 0 1 15 3.5V4H1v-.5A2.5 2.5 0 0 1 3.5 1H4z'/%3E%3Cpath d='M1 5h14v7.5A2.5 2.5 0 0 1 12.5 15h-9A2.5 2.5 0 0 1 1 12.5zM4 7.5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 1 0v-1A.5.5 0 0 0 4 7.5z'/%3E%3C/svg%3E");
+}
+
+.bi-clipboard-plus-nav-menu {
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-clipboard-plus' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M10 1.5A1.5 1.5 0 0 1 11.5 3v1H14a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h2.5V3A1.5 1.5 0 0 1 6 1.5h4zM8 3a1 1 0 0 0 1-1H7a1 1 0 0 0 1 1z'/%3E%3Cpath d='M8.5 6.5a.5.5 0 0 0-1 0V8H6a.5.5 0 0 0 0 1h1.5v1.5a.5.5 0 0 0 1 0V9H10a.5.5 0 0 0 0-1H8.5z'/%3E%3C/svg%3E");
+}
+
.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
diff --git a/BlazorApp1/Components/Pages/Home.razor b/BlazorApp1/Components/Pages/Home.razor
index 9001e0b..1f801d3 100644
--- a/BlazorApp1/Components/Pages/Home.razor
+++ b/BlazorApp1/Components/Pages/Home.razor
@@ -1,7 +1,16 @@
@page "/"
-Home
+Rozvrh
-Hello, world!
+Jednoduchý rezervační systém
-Welcome to your new app.
+
+ Prohlížejte si rozvrh, otevírejte detail předmětu a přidávejte nové záznamy pro učebny, katedry, osoby
+ i lekce. Aplikace je připravena na další rozšiřování podle zadání semestrální práce.
+
+
+
+ Rozvrh týdne: přehled všech plánovaných lekcí s návazností na předměty a vyučující.
+ Detail předmětu: harmonogram, základní informace a seznam zapsaných studentů.
+ Správa dat: formuláře pro přidání entit (učebna, katedra, předmět, role, osoba, druh lekce, lekce).
+
diff --git a/BlazorApp1/Components/Pages/Management.razor b/BlazorApp1/Components/Pages/Management.razor
new file mode 100644
index 0000000..9a09c46
--- /dev/null
+++ b/BlazorApp1/Components/Pages/Management.razor
@@ -0,0 +1,321 @@
+@page "/sprava"
+@inject ScheduleService ScheduleService
+
+Správa evidence
+Přidávejte nové entity pro rozvrh. Pro jednoduchost se data ukládají pouze v paměti.
+
+
+
+
Učebna
+
+
+
+ Název učebny
+
+
+
+ Zkratka
+
+
+
+ Patro
+
+
+
+ Kapacita
+
+
+
+ Určení
+
+
+ Přidat učebnu
+
+
+
+
Katedra
+
+
+
+ Třímístná zkratka
+
+
+
+ Název katedry
+
+
+ Přidat katedru
+
+
+
+
+
+
+
+
Předmět
+
+
+
+ Název předmětu
+
+
+
+ Katedra
+
+ @foreach (var dep in ScheduleService.Departments)
+ {
+ @dep.Code - @dep.Name
+ }
+
+
+
+ Zkratka předmětu (3-5 znaků)
+
+
+
+ Počet kreditů
+
+
+ Přidat předmět
+
+
+
+
Role & Osoby
+
+
+ Typ role
+
+ Přidat roli
+
+
+
+
+
+
+
+ Jméno
+
+
+
+ Příjmení
+
+
+
+
+ Titul (volitelné)
+
+
+
+ Zařazení
+
+ Akademický pracovník
+ Student
+
+
+
+ Typ role (pouze akademici)
+
+ Bez role
+ @foreach (var role in ScheduleService.Roles)
+ {
+ @role.RoleType
+ }
+
+
+ Přidat osobu
+
+
+
+
+
+
+
+
Druh lekce
+
+
+
+ Popis druhu lekce
+
+
+ Přidat druh
+
+
+
+
Lekce
+
+
+
+ Předmět
+
+ @foreach (var subject in ScheduleService.Subjects)
+ {
+ @subject.SubjectCode - @subject.Name
+ }
+
+
+
+ Den
+
+ @foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)))
+ {
+ @day
+ }
+
+
+
+
+ Začátek (HH:mm)
+
+
+
+ Konec (HH:mm)
+
+
+
+
+ Učebna
+
+ @foreach (var room in ScheduleService.Classrooms)
+ {
+ @room.Code - @room.Name
+ }
+
+
+
+ Druh lekce
+
+ @foreach (var lt in ScheduleService.LessonTypes)
+ {
+ @lt.Name
+ }
+
+
+
+ Vyučující
+
+ @foreach (var person in ScheduleService.People.Where(p => p.Affiliation == "Akademický pracovník"))
+ {
+ @person.FullName
+ }
+
+
+
+
Zapsaní studenti
+ @foreach (var student in ScheduleService.People.Where(p => p.Affiliation == "Student"))
+ {
+
+ ToggleStudent(student.Id, args.Value)">
+ @student.FullName
+
+ }
+
+ Přidat lekci
+
+
+
+
+@if (!string.IsNullOrWhiteSpace(_message))
+{
+ @_message
+}
+
+@code {
+ private Classroom _newClassroom = new();
+ private Department _newDepartment = new();
+ private Subject _newSubject = new();
+ private Role _newRole = new();
+ private Person _newPerson = new();
+ private LessonType _newLessonType = new();
+ private Lesson _newLesson = new() { Day = DayOfWeek.Monday };
+ private string _start = "08:00";
+ private string _end = "09:30";
+ private string _message = string.Empty;
+
+ protected override void OnInitialized()
+ {
+ _newSubject.DepartmentCode = ScheduleService.Departments.FirstOrDefault()?.Code ?? string.Empty;
+ _newLesson.SubjectCode = ScheduleService.Subjects.FirstOrDefault()?.SubjectCode ?? string.Empty;
+ _newLesson.ClassroomCode = ScheduleService.Classrooms.FirstOrDefault()?.Code ?? string.Empty;
+ _newLesson.LessonTypeId = ScheduleService.LessonTypes.FirstOrDefault()?.Id ?? Guid.Empty;
+ _newLesson.LecturerId = ScheduleService.People.FirstOrDefault(p => p.Affiliation == "Akademický pracovník")?.Id ?? Guid.Empty;
+ }
+
+ private void HandleAddClassroom()
+ {
+ ScheduleService.AddClassroom(_newClassroom);
+ _newClassroom = new Classroom();
+ _message = "Učebna byla přidána.";
+ }
+
+ private void HandleAddDepartment()
+ {
+ ScheduleService.AddDepartment(_newDepartment);
+ _newDepartment = new Department();
+ _message = "Katedra byla přidána.";
+ }
+
+ private void HandleAddSubject()
+ {
+ ScheduleService.AddSubject(_newSubject);
+ _newSubject = new Subject();
+ _message = "Předmět byl přidán.";
+ }
+
+ private void HandleAddRole()
+ {
+ ScheduleService.AddRole(_newRole);
+ _newRole = new Role();
+ _message = "Role byla přidána.";
+ }
+
+ private void HandleAddPerson()
+ {
+ ScheduleService.AddPerson(_newPerson);
+ _newPerson = new Person();
+ _message = "Osoba byla přidána.";
+ }
+
+ private void HandleAddLessonType()
+ {
+ ScheduleService.AddLessonType(_newLessonType);
+ _newLessonType = new LessonType();
+ _message = "Druh lekce byl přidán.";
+ }
+
+ private void HandleAddLesson()
+ {
+ if (TimeSpan.TryParse(_start, out var start) && TimeSpan.TryParse(_end, out var end))
+ {
+ _newLesson.StartTime = start;
+ _newLesson.EndTime = end;
+ ScheduleService.AddLesson(_newLesson);
+ _newLesson = new Lesson { Day = DayOfWeek.Monday };
+ _start = "08:00";
+ _end = "09:30";
+ _message = "Lekce byla přidána.";
+ }
+ else
+ {
+ _message = "Čas nebyl ve správném formátu (HH:mm).";
+ }
+ }
+
+ private void ToggleStudent(Guid studentId, object? value)
+ {
+ var isChecked = value switch
+ {
+ bool boolean => boolean,
+ string text when text.Equals("on", StringComparison.OrdinalIgnoreCase) => true,
+ string text when bool.TryParse(text, out var parsed) => parsed,
+ _ => false
+ };
+ if (isChecked && !_newLesson.StudentIds.Contains(studentId))
+ {
+ _newLesson.StudentIds.Add(studentId);
+ }
+ else if (!isChecked)
+ {
+ _newLesson.StudentIds.Remove(studentId);
+ }
+ }
+}
diff --git a/BlazorApp1/Components/Pages/Schedule.razor b/BlazorApp1/Components/Pages/Schedule.razor
new file mode 100644
index 0000000..e8bc647
--- /dev/null
+++ b/BlazorApp1/Components/Pages/Schedule.razor
@@ -0,0 +1,62 @@
+@page "/schedule"
+@inject ScheduleService ScheduleService
+
+Rozvrh týdne
+Kliknutím na název předmětu zobrazíte detail, včetně navazujících lekcí a kontaktních osob.
+
+@foreach (var dayGroup in _groupedLessons)
+{
+
+ @dayGroup.Key
+ @if (dayGroup.Any())
+ {
+
+ @foreach (var lesson in dayGroup)
+ {
+ var subject = ScheduleService.GetSubjectByCode(lesson.SubjectCode);
+ var classroom = ScheduleService.GetClassroomByCode(lesson.ClassroomCode);
+ var lecturer = ScheduleService.GetPerson(lesson.LecturerId);
+ var lessonType = ScheduleService.GetLessonType(lesson.LessonTypeId);
+
+
+
+
@FormatTime(lesson.StartTime) - @FormatTime(lesson.EndTime)
+
+
+ }
+
+ }
+ else
+ {
+ V tento den nejsou v rozvrhu žádné lekce.
+ }
+
+}
+
+@code {
+ private IEnumerable> _groupedLessons = Enumerable.Empty>();
+
+ protected override void OnInitialized()
+ {
+ _groupedLessons = ScheduleService.GetWeeklyLessons()
+ .GroupBy(l => TranslateDay(l.Day));
+ }
+
+ private static string FormatTime(TimeSpan time) => time.ToString(@"hh\:mm");
+
+ private static string TranslateDay(DayOfWeek day) => day switch
+ {
+ DayOfWeek.Monday => "Pondělí",
+ DayOfWeek.Tuesday => "Úterý",
+ DayOfWeek.Wednesday => "Středa",
+ DayOfWeek.Thursday => "Čtvrtek",
+ DayOfWeek.Friday => "Pátek",
+ DayOfWeek.Saturday => "Sobota",
+ DayOfWeek.Sunday => "Neděle",
+ _ => day.ToString()
+ };
+}
diff --git a/BlazorApp1/Components/Pages/SubjectDetails.razor b/BlazorApp1/Components/Pages/SubjectDetails.razor
new file mode 100644
index 0000000..5aa622e
--- /dev/null
+++ b/BlazorApp1/Components/Pages/SubjectDetails.razor
@@ -0,0 +1,90 @@
+@page "/subjects/{SubjectCode}"
+@inject ScheduleService ScheduleService
+
+Detail předmětu
+
+@if (_subject is null)
+{
+ Předmět s kódem @SubjectCode nebyl nalezen.
+}
+else
+{
+ @_subject.Name (@_subject.SubjectCode)
+ @_subject.DepartmentCode · @_subject.Credits kreditů
+
+ Lekce v týdnu
+ @if (!_lessons.Any())
+ {
+ Pro tento předmět zatím nejsou naplánované žádné lekce.
+ }
+ else
+ {
+
+ @foreach (var lesson in _lessons)
+ {
+ var classroom = ScheduleService.GetClassroomByCode(lesson.ClassroomCode);
+ var lecturer = ScheduleService.GetPerson(lesson.LecturerId);
+ var lessonType = ScheduleService.GetLessonType(lesson.LessonTypeId);
+
+
+
@TranslateDay(lesson.Day) · @lessonType?.Name
+
@classroom?.Name (@classroom?.Code)
+
Vyučující: @lecturer?.FullName
+
+ @FormatTime(lesson.StartTime) – @FormatTime(lesson.EndTime)
+
+ }
+
+ }
+
+ Zapsaní studenti
+ @if (_students.Any())
+ {
+
+ @foreach (var student in _students)
+ {
+ @student.FullName
+ }
+
+ }
+ else
+ {
+ Pro tento předmět nejsou zapsáni žádní studenti.
+ }
+}
+
+@code {
+ [Parameter]
+ public string SubjectCode { get; set; } = string.Empty;
+
+ private Subject? _subject;
+ private List _lessons = new();
+ private List _students = new();
+
+ protected override void OnParametersSet()
+ {
+ _subject = ScheduleService.GetSubjectByCode(SubjectCode);
+ _lessons = ScheduleService.Lessons.Where(l => l.SubjectCode.Equals(SubjectCode, StringComparison.OrdinalIgnoreCase)).ToList();
+ _students = _lessons
+ .SelectMany(l => l.StudentIds)
+ .Distinct()
+ .Select(id => ScheduleService.GetPerson(id))
+ .Where(p => p is not null)
+ .Cast()
+ .ToList();
+ }
+
+ private static string FormatTime(TimeSpan time) => time.ToString(@"hh\:mm");
+
+ private static string TranslateDay(DayOfWeek day) => day switch
+ {
+ DayOfWeek.Monday => "Pondělí",
+ DayOfWeek.Tuesday => "Úterý",
+ DayOfWeek.Wednesday => "Středa",
+ DayOfWeek.Thursday => "Čtvrtek",
+ DayOfWeek.Friday => "Pátek",
+ DayOfWeek.Saturday => "Sobota",
+ DayOfWeek.Sunday => "Neděle",
+ _ => day.ToString()
+ };
+}
diff --git a/BlazorApp1/Components/_Imports.razor b/BlazorApp1/Components/_Imports.razor
index 7a1de04..b7de097 100644
--- a/BlazorApp1/Components/_Imports.razor
+++ b/BlazorApp1/Components/_Imports.razor
@@ -8,3 +8,5 @@
@using Microsoft.JSInterop
@using BlazorApp1
@using BlazorApp1.Components
+@using BlazorApp1.Models
+@using BlazorApp1.Services
diff --git a/BlazorApp1/Models/Classroom.cs b/BlazorApp1/Models/Classroom.cs
new file mode 100644
index 0000000..03765f9
--- /dev/null
+++ b/BlazorApp1/Models/Classroom.cs
@@ -0,0 +1,16 @@
+namespace BlazorApp1.Models;
+
+public class Classroom
+{
+ public Guid Id { get; set; } = Guid.NewGuid();
+
+ public string Name { get; set; } = string.Empty;
+
+ public string Code { get; set; } = string.Empty;
+
+ public int Floor { get; set; }
+
+ public int Capacity { get; set; }
+
+ public string Purpose { get; set; } = string.Empty;
+}
diff --git a/BlazorApp1/Models/Department.cs b/BlazorApp1/Models/Department.cs
new file mode 100644
index 0000000..9340b30
--- /dev/null
+++ b/BlazorApp1/Models/Department.cs
@@ -0,0 +1,10 @@
+namespace BlazorApp1.Models;
+
+public class Department
+{
+ public Guid Id { get; set; } = Guid.NewGuid();
+
+ public string Code { get; set; } = string.Empty;
+
+ public string Name { get; set; } = string.Empty;
+}
diff --git a/BlazorApp1/Models/Lesson.cs b/BlazorApp1/Models/Lesson.cs
new file mode 100644
index 0000000..3684eb7
--- /dev/null
+++ b/BlazorApp1/Models/Lesson.cs
@@ -0,0 +1,22 @@
+namespace BlazorApp1.Models;
+
+public class Lesson
+{
+ public Guid Id { get; set; } = Guid.NewGuid();
+
+ public DayOfWeek Day { get; set; }
+
+ public TimeSpan StartTime { get; set; }
+
+ public TimeSpan EndTime { get; set; }
+
+ public string ClassroomCode { get; set; } = string.Empty;
+
+ public string SubjectCode { get; set; } = string.Empty;
+
+ public Guid LessonTypeId { get; set; }
+
+ public Guid LecturerId { get; set; }
+
+ public List StudentIds { get; set; } = new();
+}
diff --git a/BlazorApp1/Models/LessonType.cs b/BlazorApp1/Models/LessonType.cs
new file mode 100644
index 0000000..2a31224
--- /dev/null
+++ b/BlazorApp1/Models/LessonType.cs
@@ -0,0 +1,8 @@
+namespace BlazorApp1.Models;
+
+public class LessonType
+{
+ public Guid Id { get; set; } = Guid.NewGuid();
+
+ public string Name { get; set; } = string.Empty;
+}
diff --git a/BlazorApp1/Models/Person.cs b/BlazorApp1/Models/Person.cs
new file mode 100644
index 0000000..094345c
--- /dev/null
+++ b/BlazorApp1/Models/Person.cs
@@ -0,0 +1,20 @@
+namespace BlazorApp1.Models;
+
+public class Person
+{
+ public Guid Id { get; set; } = Guid.NewGuid();
+
+ public string FirstName { get; set; } = string.Empty;
+
+ public string LastName { get; set; } = string.Empty;
+
+ public string? Title { get; set; }
+
+ public string Affiliation { get; set; } = string.Empty;
+
+ public Guid? RoleId { get; set; }
+
+ public string FullName => string.IsNullOrWhiteSpace(Title)
+ ? $"{FirstName} {LastName}"
+ : $"{Title} {FirstName} {LastName}";
+}
diff --git a/BlazorApp1/Models/Role.cs b/BlazorApp1/Models/Role.cs
new file mode 100644
index 0000000..552b63d
--- /dev/null
+++ b/BlazorApp1/Models/Role.cs
@@ -0,0 +1,8 @@
+namespace BlazorApp1.Models;
+
+public class Role
+{
+ public Guid Id { get; set; } = Guid.NewGuid();
+
+ public string RoleType { get; set; } = string.Empty;
+}
diff --git a/BlazorApp1/Models/Subject.cs b/BlazorApp1/Models/Subject.cs
new file mode 100644
index 0000000..1967529
--- /dev/null
+++ b/BlazorApp1/Models/Subject.cs
@@ -0,0 +1,14 @@
+namespace BlazorApp1.Models;
+
+public class Subject
+{
+ public Guid Id { get; set; } = Guid.NewGuid();
+
+ public string Name { get; set; } = string.Empty;
+
+ public string DepartmentCode { get; set; } = string.Empty;
+
+ public string SubjectCode { get; set; } = string.Empty;
+
+ public int Credits { get; set; }
+}
diff --git a/BlazorApp1/Program.cs b/BlazorApp1/Program.cs
index 1953994..24282b6 100644
--- a/BlazorApp1/Program.cs
+++ b/BlazorApp1/Program.cs
@@ -1,4 +1,5 @@
using BlazorApp1.Components;
+using BlazorApp1.Services;
var builder = WebApplication.CreateBuilder(args);
@@ -6,6 +7,8 @@
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
+builder.Services.AddSingleton();
+
var app = builder.Build();
// Configure the HTTP request pipeline.
diff --git a/BlazorApp1/Services/ScheduleService.cs b/BlazorApp1/Services/ScheduleService.cs
new file mode 100644
index 0000000..ff17004
--- /dev/null
+++ b/BlazorApp1/Services/ScheduleService.cs
@@ -0,0 +1,186 @@
+using BlazorApp1.Models;
+
+namespace BlazorApp1.Services;
+
+public class ScheduleService
+{
+ private readonly List _classrooms = new();
+ private readonly List _departments = new();
+ private readonly List _subjects = new();
+ private readonly List _roles = new();
+ private readonly List _people = new();
+ private readonly List _lessonTypes = new();
+ private readonly List _lessons = new();
+
+ public ScheduleService()
+ {
+ SeedDepartments();
+ SeedRoles();
+ SeedPeople();
+ SeedClassrooms();
+ SeedLessonTypes();
+ SeedSubjects();
+ SeedLessons();
+ }
+
+ public IReadOnlyCollection Classrooms => _classrooms;
+ public IReadOnlyCollection Departments => _departments;
+ public IReadOnlyCollection Subjects => _subjects;
+ public IReadOnlyCollection Roles => _roles;
+ public IReadOnlyCollection People => _people;
+ public IReadOnlyCollection LessonTypes => _lessonTypes;
+ public IReadOnlyCollection Lessons => _lessons;
+
+ public void AddClassroom(Classroom classroom) => _classrooms.Add(classroom);
+
+ public void AddDepartment(Department department) => _departments.Add(department);
+
+ public void AddSubject(Subject subject) => _subjects.Add(subject);
+
+ public void AddRole(Role role) => _roles.Add(role);
+
+ public void AddPerson(Person person) => _people.Add(person);
+
+ public void AddLessonType(LessonType lessonType) => _lessonTypes.Add(lessonType);
+
+ public void AddLesson(Lesson lesson) => _lessons.Add(lesson);
+
+ public Subject? GetSubjectByCode(string code) =>
+ _subjects.FirstOrDefault(s => s.SubjectCode.Equals(code, StringComparison.OrdinalIgnoreCase));
+
+ public Classroom? GetClassroomByCode(string code) =>
+ _classrooms.FirstOrDefault(c => c.Code.Equals(code, StringComparison.OrdinalIgnoreCase));
+
+ public LessonType? GetLessonType(Guid id) => _lessonTypes.FirstOrDefault(l => l.Id == id);
+
+ public Person? GetPerson(Guid id) => _people.FirstOrDefault(p => p.Id == id);
+
+ public IEnumerable GetWeeklyLessons() => _lessons
+ .OrderBy(l => l.Day)
+ .ThenBy(l => l.StartTime);
+
+ private void SeedDepartments()
+ {
+ _departments.AddRange([
+ new Department { Code = "KMA", Name = "Katedra matematiky" },
+ new Department { Code = "KIT", Name = "Katedra informačních technologií" }
+ ]);
+ }
+
+ private void SeedRoles()
+ {
+ _roles.AddRange([
+ new Role { RoleType = "Vyučující" },
+ new Role { RoleType = "Přednášející" },
+ new Role { RoleType = "Garant" }
+ ]);
+ }
+
+ private void SeedPeople()
+ {
+ var lecturerRole = _roles.First();
+ _people.AddRange([
+ new Person
+ {
+ FirstName = "Jan",
+ LastName = "Novík",
+ Title = "Ing.",
+ Affiliation = "Akademický pracovník",
+ RoleId = lecturerRole.Id
+ },
+ new Person
+ {
+ FirstName = "Petra",
+ LastName = "Nováková",
+ Affiliation = "Student"
+ },
+ new Person
+ {
+ FirstName = "Jan",
+ LastName = "Dvořák",
+ Affiliation = "Student"
+ }
+ ]);
+ }
+
+ private void SeedClassrooms()
+ {
+ _classrooms.AddRange([
+ new Classroom { Name = "Velká posluchárna", Code = "VP101", Floor = 1, Capacity = 120, Purpose = "Přednášková" },
+ new Classroom { Name = "Počítačová laboratoř", Code = "PC204", Floor = 2, Capacity = 32, Purpose = "Počítačová" }
+ ]);
+ }
+
+ private void SeedLessonTypes()
+ {
+ _lessonTypes.AddRange([
+ new LessonType { Name = "Přednáška" },
+ new LessonType { Name = "Cvičení" },
+ new LessonType { Name = "Seminář" }
+ ]);
+ }
+
+ private void SeedSubjects()
+ {
+ _subjects.AddRange([
+ new Subject
+ {
+ Name = "Programování v C#",
+ DepartmentCode = "KIT",
+ SubjectCode = "KIT-CSP",
+ Credits = 5
+ },
+ new Subject
+ {
+ Name = "Lineární algebra",
+ DepartmentCode = "KMA",
+ SubjectCode = "KMA-LA",
+ Credits = 4
+ }
+ ]);
+ }
+
+ private void SeedLessons()
+ {
+ var lecture = _lessonTypes.First();
+ var lab = _lessonTypes.First(lt => lt.Name == "Cvičení");
+ var lecturer = _people.First();
+ var studentIds = _people.Where(p => p.Affiliation == "Student").Select(p => p.Id).ToList();
+
+ _lessons.AddRange([
+ new Lesson
+ {
+ SubjectCode = "KIT-CSP",
+ Day = DayOfWeek.Monday,
+ StartTime = new TimeSpan(9, 0, 0),
+ EndTime = new TimeSpan(10, 30, 0),
+ ClassroomCode = "VP101",
+ LessonTypeId = lecture.Id,
+ LecturerId = lecturer.Id,
+ StudentIds = studentIds
+ },
+ new Lesson
+ {
+ SubjectCode = "KIT-CSP",
+ Day = DayOfWeek.Wednesday,
+ StartTime = new TimeSpan(14, 0, 0),
+ EndTime = new TimeSpan(15, 30, 0),
+ ClassroomCode = "PC204",
+ LessonTypeId = lab.Id,
+ LecturerId = lecturer.Id,
+ StudentIds = studentIds
+ },
+ new Lesson
+ {
+ SubjectCode = "KMA-LA",
+ Day = DayOfWeek.Thursday,
+ StartTime = new TimeSpan(8, 0, 0),
+ EndTime = new TimeSpan(9, 30, 0),
+ ClassroomCode = "VP101",
+ LessonTypeId = lecture.Id,
+ LecturerId = lecturer.Id,
+ StudentIds = studentIds
+ }
+ ]);
+ }
+}