Настраиваю связи

This commit is contained in:
gg12 darfren 2024-04-08 14:40:49 +04:00
parent febd9ee5f2
commit 35f58ba3bc
61 changed files with 2584 additions and 2 deletions

View File

@ -3,7 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34701.34
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchoolSchedule", "SchoolSchedule\SchoolSchedule.csproj", "{DEDD5B0C-5F76-4EB4-809C-E2343CF92FCE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SchoolSchedule", "SchoolSchedule\SchoolSchedule.csproj", "{DEDD5B0C-5F76-4EB4-809C-E2343CF92FCE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SchoolScheduleDataModels", "SchoolScheduleDataModels\SchoolScheduleDataModels.csproj", "{7FB0B40C-7E5B-4675-A52E-3A9CB8ECBD26}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SchoolScheduleContracts", "SchoolScheduleContracts\SchoolScheduleContracts.csproj", "{AAC735A1-0806-4556-8371-7F001E0ADFAD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SchoolScheduleBusinessLogic", "SchoolScheduleBusinessLogic\SchoolScheduleBusinessLogic.csproj", "{1F155433-B778-4252-8637-5B3561C5AD1E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SchoolScheduleDataBaseImplement", "SchoolScheduleDataBaseImplement\SchoolScheduleDataBaseImplement.csproj", "{3B115972-7390-4FD9-87E0-FAFE78C4A178}"
ProjectSection(ProjectDependencies) = postProject
{AAC735A1-0806-4556-8371-7F001E0ADFAD} = {AAC735A1-0806-4556-8371-7F001E0ADFAD}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +26,22 @@ Global
{DEDD5B0C-5F76-4EB4-809C-E2343CF92FCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEDD5B0C-5F76-4EB4-809C-E2343CF92FCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEDD5B0C-5F76-4EB4-809C-E2343CF92FCE}.Release|Any CPU.Build.0 = Release|Any CPU
{7FB0B40C-7E5B-4675-A52E-3A9CB8ECBD26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FB0B40C-7E5B-4675-A52E-3A9CB8ECBD26}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FB0B40C-7E5B-4675-A52E-3A9CB8ECBD26}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FB0B40C-7E5B-4675-A52E-3A9CB8ECBD26}.Release|Any CPU.Build.0 = Release|Any CPU
{AAC735A1-0806-4556-8371-7F001E0ADFAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AAC735A1-0806-4556-8371-7F001E0ADFAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAC735A1-0806-4556-8371-7F001E0ADFAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAC735A1-0806-4556-8371-7F001E0ADFAD}.Release|Any CPU.Build.0 = Release|Any CPU
{1F155433-B778-4252-8637-5B3561C5AD1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F155433-B778-4252-8637-5B3561C5AD1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F155433-B778-4252-8637-5B3561C5AD1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F155433-B778-4252-8637-5B3561C5AD1E}.Release|Any CPU.Build.0 = Release|Any CPU
{3B115972-7390-4FD9-87E0-FAFE78C4A178}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B115972-7390-4FD9-87E0-FAFE78C4A178}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B115972-7390-4FD9-87E0-FAFE78C4A178}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B115972-7390-4FD9-87E0-FAFE78C4A178}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -2,10 +2,21 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SchoolScheduleDataBaseImplement\SchoolScheduleDataBaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,112 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleBusinessLogic
{
public class GradeLogic : IGradeLogic
{
private readonly IGradeStorage _gradeStorage;
private readonly IStudentStorage _studentStorage;
public GradeLogic(IGradeStorage gradeStorage, IStudentStorage studentStorage)
{
_gradeStorage = gradeStorage;
_studentStorage = studentStorage;
}
public List<GradeViewModel> ReadList(GradeSearchModel? model)
{
var list = model == null ? _gradeStorage.GetFullList() :
_gradeStorage.GetFilteredList(model);
return list;
}
public GradeViewModel? ReadElement(GradeSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _gradeStorage.GetElement(model);
return element;
}
public List<StudentViewModel> GetStudents(GradeSearchModel model)
{
var list = _studentStorage.GetFilteredList(new StudentSearchModel { GradeId = model.Id });
return list;
}
public bool Create(GradeBindingModel model)
{
CheckModel(model);
if (_gradeStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(GradeBindingModel model)
{
CheckModel(model);
if (_gradeStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(GradeBindingModel model)
{
CheckModel(model, false);
if (_gradeStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(GradeBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (!(model.Letter >= 'A' && model.Letter <= 'Z'))
{
throw new ArgumentNullException("Буква класса не является заглавной буквой",
nameof(model.Letter));
}
if (!(model.Year >= 1 && model.Year <= 11))
{
throw new ArgumentNullException("Год класса не является числом от 1 до 11",
nameof(model.Letter));
}
var element = _gradeStorage.GetElement(new GradeSearchModel
{
Letter = model.Letter,
Year = model.Year
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Такой класс уже есть");
}
}
}
}

View File

@ -0,0 +1,120 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleBusinessLogic
{
public class LessonLogic : ILessonLogic
{
private readonly ILessonStorage _lessonStorage;
private readonly ISubjectStorage _subjectStorage;
private readonly ITeacherStorage _teacherStorage;
private readonly IGradeStorage _gradeStorage;
private readonly IStudentStorage _studentStorage;
public LessonLogic(ILessonStorage lessonStorage, ISubjectStorage subjectStorage, ITeacherStorage teacherStorage, IGradeStorage gradeStorage, IStudentStorage studentStorage)
{
_lessonStorage = lessonStorage;
_subjectStorage = subjectStorage;
_teacherStorage = teacherStorage;
_gradeStorage = gradeStorage;
_studentStorage = studentStorage;
}
public List<LessonViewModel> ReadList(LessonSearchModel? model)
{
var list = model == null ? _lessonStorage.GetFullList() :
_lessonStorage.GetFilteredList(model);
return list;
}
public LessonViewModel? ReadElement(LessonSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _lessonStorage.GetElement(model);
return element;
}
public List<StudentViewModel> GetStudents(LessonSearchModel model)
{
var list = _studentStorage.GetFilteredList(new StudentSearchModel { GradeId = model.GradeId });
return list;
}
public bool Create(LessonBindingModel model)
{
CheckModel(model);
if (_lessonStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(LessonBindingModel model)
{
CheckModel(model);
if (_lessonStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(LessonBindingModel model)
{
CheckModel(model, false);
if (_lessonStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(LessonBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
var element1 = _lessonStorage.GetElement(new LessonSearchModel
{
Date = model.Date,
SchedulePlaceId = model.SchedulePlaceId,
TeacherId = model.TeacherId
});
var element2 = _lessonStorage.GetElement(new LessonSearchModel
{
Date = model.Date,
SchedulePlaceId = model.SchedulePlaceId,
GradeId = model.GradeId
});
if (element1 != null)
{
throw new InvalidOperationException("У учителя уже есть урок в это время");
}
if (element2 != null)
{
throw new InvalidOperationException("У класса уже есть урок в это время");
}
}
}
}

View File

@ -0,0 +1,64 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleBusinessLogic
{
public class SchedulePlaceLogic : ISchedulePlaceLogic
{
private readonly ISchedulePlaceStorage _schedulePlaceStorage;
public SchedulePlaceLogic(ISchedulePlaceStorage schedulePlaceStorage)
{
_schedulePlaceStorage = schedulePlaceStorage;
}
public List<SchedulePlaceViewModel> ReadList(SchedulePlaceSearchModel? model)
{
var list = model == null ? _schedulePlaceStorage.GetFullList() :
_schedulePlaceStorage.GetFilteredList(model);
return list;
}
public SchedulePlaceViewModel? ReadElement(SchedulePlaceSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _schedulePlaceStorage.GetElement(model);
return element;
}
public bool Create(SchedulePlaceBindingModel model)
{
if (_schedulePlaceStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(SchedulePlaceBindingModel model)
{
if (_schedulePlaceStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(SchedulePlaceBindingModel model)
{
if (_schedulePlaceStorage.Delete(model) == null)
{
return false;
}
return true;
}
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SchoolScheduleContracts\SchoolScheduleContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,63 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleBusinessLogic
{
public class StudentLogic : IStudentLogic
{
private readonly IStudentStorage _studentStorage;
public StudentLogic(IStudentStorage studentStorage)
{
_studentStorage = studentStorage;
}
public List<StudentViewModel> ReadList(StudentSearchModel? model)
{
var list = model == null ? _studentStorage.GetFullList() :
_studentStorage.GetFilteredList(model);
return list;
}
public StudentViewModel? ReadElement(StudentSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _studentStorage.GetElement(model);
return element;
}
public bool Create(StudentBindingModel model)
{
if (_studentStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(StudentBindingModel model)
{
if (_studentStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(StudentBindingModel model)
{
if (_studentStorage.Delete(model) == null)
{
return false;
}
return true;
}
}
}

View File

@ -0,0 +1,96 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleBusinessLogic
{
public class SubjectLogic : ISubjectLogic
{
private readonly ISubjectStorage _subjectStorage;
public SubjectLogic(ISubjectStorage subjectStorage)
{
_subjectStorage = subjectStorage;
}
public List<SubjectViewModel> ReadList(SubjectSearchModel? model)
{
var list = model == null ? _subjectStorage.GetFullList() :
_subjectStorage.GetFilteredList(model);
return list;
}
public SubjectViewModel? ReadElement(SubjectSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _subjectStorage.GetElement(model);
return element;
}
public bool Create(SubjectBindingModel model)
{
CheckModel(model);
if (_subjectStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(SubjectBindingModel model)
{
CheckModel(model);
if (_subjectStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(SubjectBindingModel model)
{
CheckModel(model, false);
if (_subjectStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(SubjectBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.SubjectName))
{
throw new ArgumentNullException("Нет названия предмета",
nameof(model.SubjectName));
}
var element = _subjectStorage.GetElement(new SubjectSearchModel
{
SubjectName = model.SubjectName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Предмет с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,63 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleBusinessLogic
{
public class TeacherLogic : ITeacherLogic
{
private readonly ITeacherStorage _teacherStorage;
public TeacherLogic(ITeacherStorage teacherStorage)
{
_teacherStorage = teacherStorage;
}
public List<TeacherViewModel> ReadList(TeacherSearchModel? model)
{
var list = model == null ? _teacherStorage.GetFullList() :
_teacherStorage.GetFilteredList(model);
return list;
}
public TeacherViewModel? ReadElement(TeacherSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _teacherStorage.GetElement(model);
return element;
}
public bool Create(TeacherBindingModel model)
{
if (_teacherStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(TeacherBindingModel model)
{
if (_teacherStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(TeacherBindingModel model)
{
if (_teacherStorage.Delete(model) == null)
{
return false;
}
return true;
}
}
}

View File

@ -0,0 +1,17 @@
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BindingModels
{
public class GradeBindingModel : IGradeModel
{
public int Id { get; set; }
public char Letter { get; set; }
public int Year { get; set; }
public int TeacherId { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BindingModels
{
public class LessonBindingModel : ILessonModel
{
public int Id { get; set; }
public DateOnly Date { get; set; }
public string? Homework { get; set; }
public int SchedulePlaceId { get; set; }
public int TeacherId { get; set; }
public int SubjectId { get; set; }
public int GradeId { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BindingModels
{
public class SchedulePlaceBindingModel : ISchedulePlaceModel
{
public int Id { get; set; }
public TimeOnly Time { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using SchoolScheduleDataModels.Enums;
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BindingModels
{
public class StudentBindingModel : IStudentModel
{
public int Id { get; set; }
public string FullName { get; set; } = string.Empty;
public int GradeId { get; set; }
public Dictionary<int, (ILessonModel, StudentStatus, int?)> Attendance { get; set; } = new();
}
}

View File

@ -0,0 +1,15 @@
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BindingModels
{
public class SubjectBindingModel : ISubjectModel
{
public int Id { get; set; }
public string SubjectName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,16 @@
using SchoolScheduleDataModels.Enums;
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BindingModels
{
public class TeacherBindingModel : ITeacherModel
{
public int Id { get; set; }
public string FullName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,21 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BusinessLogicsContracts
{
public interface IGradeLogic
{
List<GradeViewModel> ReadList(GradeSearchModel? model);
GradeViewModel? ReadElement(GradeSearchModel? model);
List<StudentViewModel> GetStudents(GradeSearchModel model);
bool Create(GradeBindingModel model);
bool Update(GradeBindingModel model);
bool Delete(GradeBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BusinessLogicsContracts
{
public interface ILessonLogic
{
List<LessonViewModel>? ReadList(LessonSearchModel? model);
LessonViewModel? ReadElement(LessonSearchModel model);
bool Create(LessonBindingModel model);
bool Update(LessonBindingModel model);
bool Delete(LessonBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BusinessLogicsContracts
{
public interface ISchedulePlaceLogic
{
List<SchedulePlaceViewModel>? ReadList(SchedulePlaceSearchModel? model);
SchedulePlaceViewModel? ReadElement(SchedulePlaceSearchModel model);
bool Create(SchedulePlaceBindingModel model);
bool Update(SchedulePlaceBindingModel model);
bool Delete(SchedulePlaceBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BusinessLogicsContracts
{
public interface IStudentLogic
{
List<StudentViewModel>? ReadList(StudentSearchModel? model);
StudentViewModel? ReadElement(StudentSearchModel model);
bool Create(StudentBindingModel model);
bool Update(StudentBindingModel model);
bool Delete(StudentBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BusinessLogicsContracts
{
public interface ISubjectLogic
{
List<SubjectViewModel>? ReadList(SubjectSearchModel? model);
SubjectViewModel? ReadElement(SubjectSearchModel model);
bool Create(SubjectBindingModel model);
bool Update(SubjectBindingModel model);
bool Delete(SubjectBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.BusinessLogicsContracts
{
public interface ITeacherLogic
{
List<TeacherViewModel>? ReadList(TeacherSearchModel? model);
TeacherViewModel? ReadElement(TeacherSearchModel model);
bool Create(TeacherBindingModel model);
bool Update(TeacherBindingModel model);
bool Delete(TeacherBindingModel model);
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SchoolScheduleDataModels\SchoolScheduleDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.SearchModels
{
public class GradeSearchModel
{
public int? Id { get; set; }
public char? Letter { get; set; }
public int? Year { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.SearchModels
{
public class LessonSearchModel
{
public int? Id { get; set; }
public int? GradeId { get; set; }
public int? TeacherId { get; set; }
public int? SubjectId { get; set; }
public DateOnly? Date { get; set; }
public int? SchedulePlaceId { get; set; }
public DateOnly? DateFrom { get; set; }
public DateOnly? DateTo { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.SearchModels
{
public class SchedulePlaceSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.SearchModels
{
public class StudentSearchModel
{
public int? Id { get; set; }
public int? GradeId { get; set; }
public string? FullName { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.SearchModels
{
public class SubjectSearchModel
{
public int? Id { get; set; }
public string? SubjectName { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.SearchModels
{
public class TeacherSearchModel
{
public int? Id { get; set; }
public string? FullName { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.StoragesContracts
{
public interface IGradeStorage
{
List<GradeViewModel> GetFullList();
List<GradeViewModel> GetFilteredList(GradeSearchModel model);
GradeViewModel? GetElement(GradeSearchModel model);
GradeViewModel? Insert(GradeBindingModel model);
GradeViewModel? Update(GradeBindingModel model);
GradeViewModel? Delete(GradeBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.StoragesContracts
{
public interface ILessonStorage
{
List<LessonViewModel> GetFullList();
List<LessonViewModel> GetFilteredList(LessonSearchModel model);
LessonViewModel? GetElement(LessonSearchModel model);
LessonViewModel? Insert(LessonBindingModel model);
LessonViewModel? Update(LessonBindingModel model);
LessonViewModel? Delete(LessonBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.StoragesContracts
{
public interface ISchedulePlaceStorage
{
List<SchedulePlaceViewModel> GetFullList();
List<SchedulePlaceViewModel> GetFilteredList(SchedulePlaceSearchModel model);
SchedulePlaceViewModel? GetElement(SchedulePlaceSearchModel model);
SchedulePlaceViewModel? Insert(SchedulePlaceBindingModel model);
SchedulePlaceViewModel? Update(SchedulePlaceBindingModel model);
SchedulePlaceViewModel? Delete(SchedulePlaceBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.StoragesContracts
{
public interface IStudentStorage
{
List<StudentViewModel> GetFullList();
List<StudentViewModel> GetFilteredList(StudentSearchModel model);
StudentViewModel? GetElement(StudentSearchModel model);
StudentViewModel? Insert(StudentBindingModel model);
StudentViewModel? Update(StudentBindingModel model);
StudentViewModel? Delete(StudentBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.StoragesContracts
{
public interface ISubjectStorage
{
List<SubjectViewModel> GetFullList();
List<SubjectViewModel> GetFilteredList(SubjectSearchModel model);
SubjectViewModel? GetElement(SubjectSearchModel model);
SubjectViewModel? Insert(SubjectBindingModel model);
SubjectViewModel? Update(SubjectBindingModel model);
SubjectViewModel? Delete(SubjectBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.StoragesContracts
{
public interface ITeacherStorage
{
List<TeacherViewModel> GetFullList();
List<TeacherViewModel> GetFilteredList(TeacherSearchModel model);
TeacherViewModel? GetElement(TeacherSearchModel model);
TeacherViewModel? Insert(TeacherBindingModel model);
TeacherViewModel? Update(TeacherBindingModel model);
TeacherViewModel? Delete(TeacherBindingModel model);
}
}

View File

@ -0,0 +1,22 @@
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.ViewModels
{
public class GradeViewModel : IGradeModel
{
public int Id { get; set; }
[DisplayName("Год")]
public int Year { get; set; }
[DisplayName("Буква")]
public char Letter { get; set; }
public int TeacherId { get; set; }
[DisplayName("Классный руководитель")]
public string TeacherFullName { get; set; }
}
}

View File

@ -0,0 +1,31 @@
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.ViewModels
{
public class LessonViewModel : ILessonModel
{
public int Id { get; set; }
[DisplayName("Дата")]
public DateOnly Date { get; set; }
[DisplayName("Домашняя работа")]
public string? Homework { get; set; }
public int SchedulePlaceId { get; set; }
[DisplayName("Время")]
public TimeOnly SchedulePlaceTime { get; set; } = TimeOnly.MinValue;
public int TeacherId { get; set; }
public int SubjectId { get; set; }
public int GradeId { get; set; }
[DisplayName("Учитель")]
public string TeacherFullName { get; set; } = string.Empty;
[DisplayName("Предмет")]
public string SubjectName { get; set; } = string.Empty;
[DisplayName("Класс")]
public string GradeName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,17 @@
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.ViewModels
{
public class SchedulePlaceViewModel : ISchedulePlaceModel
{
public int Id { get; set; }
[DisplayName("Время")]
public TimeOnly Time { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using SchoolScheduleDataModels.Enums;
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.ViewModels
{
public class StudentViewModel : IStudentModel
{
public int Id { get; set; }
[DisplayName("Полное имя")]
public string FullName { get; set; } = string.Empty;
public int GradeId { get; set; }
[DisplayName("Класс")]
public string GradeName { get; set; } = string.Empty;
public Dictionary<int, (ILessonModel, StudentStatus, int?)> Attendance { get; set; } = new();
}
}

View File

@ -0,0 +1,17 @@
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.ViewModels
{
public class SubjectViewModel : ISubjectModel
{
public int Id { get; set; }
[DisplayName("Название")]
public string SubjectName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,17 @@
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleContracts.ViewModels
{
public class TeacherViewModel : ITeacherModel
{
public int Id { get; set; }
[DisplayName("Полное имя")]
public string FullName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,312 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SchoolScheduleDataBaseImplement;
#nullable disable
namespace SchoolScheduleDataBaseImplement.Migrations
{
[DbContext(typeof(SchoolScheduleDataBase))]
[Migration("20240408103656_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Grade", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Letter")
.IsRequired()
.HasColumnType("nvarchar(1)");
b.Property<int>("TeacherId")
.HasColumnType("int");
b.Property<int>("Year")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Grades");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Lesson", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<int>("GradeId")
.HasColumnType("int");
b.Property<string>("Homework")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("SchedulePlaceId")
.HasColumnType("int");
b.Property<int>("SubjectId")
.HasColumnType("int");
b.Property<int>("TeacherId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("GradeId");
b.HasIndex("SchedulePlaceId");
b.HasIndex("SubjectId");
b.HasIndex("TeacherId");
b.ToTable("Lessons");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.LessonStudent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("LessonId")
.HasColumnType("int");
b.Property<int?>("Mark")
.IsRequired()
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<int>("StudentId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LessonId");
b.HasIndex("StudentId");
b.ToTable("LessonStudents");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.SchedulePlace", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<TimeOnly>("Time")
.HasColumnType("time");
b.HasKey("Id");
b.ToTable("SchedulePlaces");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Student", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("GradeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("GradeId");
b.ToTable("Students");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Subject", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("SubjectName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Subjects");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Teacher", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("TeacherId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TeacherId")
.IsUnique();
b.ToTable("Teachers");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Lesson", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Grade", "Grade")
.WithMany("Lessons")
.HasForeignKey("GradeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SchoolScheduleDataBaseImplement.Models.SchedulePlace", "SchedulePlace")
.WithMany("Lessons")
.HasForeignKey("SchedulePlaceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SchoolScheduleDataBaseImplement.Models.Subject", "Subject")
.WithMany("Lessons")
.HasForeignKey("SubjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SchoolScheduleDataBaseImplement.Models.Teacher", "Teacher")
.WithMany("Lessons")
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Grade");
b.Navigation("SchedulePlace");
b.Navigation("Subject");
b.Navigation("Teacher");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.LessonStudent", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Lesson", "Lesson")
.WithMany("Students")
.HasForeignKey("LessonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SchoolScheduleDataBaseImplement.Models.Student", "Student")
.WithMany("Lessons")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Lesson");
b.Navigation("Student");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Student", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Grade", "Grade")
.WithMany("Students")
.HasForeignKey("GradeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Grade");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Teacher", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Grade", "Grade")
.WithOne("Teacher")
.HasForeignKey("SchoolScheduleDataBaseImplement.Models.Teacher", "TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Grade");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Grade", b =>
{
b.Navigation("Lessons");
b.Navigation("Students");
b.Navigation("Teacher")
.IsRequired();
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Lesson", b =>
{
b.Navigation("Students");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.SchedulePlace", b =>
{
b.Navigation("Lessons");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Student", b =>
{
b.Navigation("Lessons");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Subject", b =>
{
b.Navigation("Lessons");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Teacher", b =>
{
b.Navigation("Lessons");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,232 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SchoolScheduleDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Grades",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Year = table.Column<int>(type: "int", nullable: false),
Letter = table.Column<string>(type: "nvarchar(1)", nullable: false),
TeacherId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Grades", x => x.Id);
});
migrationBuilder.CreateTable(
name: "SchedulePlaces",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Time = table.Column<TimeOnly>(type: "time", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SchedulePlaces", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Subjects",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SubjectName = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Subjects", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Students",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FullName = table.Column<string>(type: "nvarchar(max)", nullable: false),
GradeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Students", x => x.Id);
table.ForeignKey(
name: "FK_Students_Grades_GradeId",
column: x => x.GradeId,
principalTable: "Grades",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Teachers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FullName = table.Column<string>(type: "nvarchar(max)", nullable: false),
TeacherId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Teachers", x => x.Id);
table.ForeignKey(
name: "FK_Teachers_Grades_TeacherId",
column: x => x.TeacherId,
principalTable: "Grades",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Lessons",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Date = table.Column<DateOnly>(type: "date", nullable: false),
Homework = table.Column<string>(type: "nvarchar(max)", nullable: false),
SchedulePlaceId = table.Column<int>(type: "int", nullable: false),
TeacherId = table.Column<int>(type: "int", nullable: false),
SubjectId = table.Column<int>(type: "int", nullable: false),
GradeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Lessons", x => x.Id);
table.ForeignKey(
name: "FK_Lessons_Grades_GradeId",
column: x => x.GradeId,
principalTable: "Grades",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Lessons_SchedulePlaces_SchedulePlaceId",
column: x => x.SchedulePlaceId,
principalTable: "SchedulePlaces",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Lessons_Subjects_SubjectId",
column: x => x.SubjectId,
principalTable: "Subjects",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Lessons_Teachers_TeacherId",
column: x => x.TeacherId,
principalTable: "Teachers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "LessonStudents",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
StudentId = table.Column<int>(type: "int", nullable: false),
LessonId = table.Column<int>(type: "int", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
Mark = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LessonStudents", x => x.Id);
table.ForeignKey(
name: "FK_LessonStudents_Lessons_LessonId",
column: x => x.LessonId,
principalTable: "Lessons",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_LessonStudents_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Lessons_GradeId",
table: "Lessons",
column: "GradeId");
migrationBuilder.CreateIndex(
name: "IX_Lessons_SchedulePlaceId",
table: "Lessons",
column: "SchedulePlaceId");
migrationBuilder.CreateIndex(
name: "IX_Lessons_SubjectId",
table: "Lessons",
column: "SubjectId");
migrationBuilder.CreateIndex(
name: "IX_Lessons_TeacherId",
table: "Lessons",
column: "TeacherId");
migrationBuilder.CreateIndex(
name: "IX_LessonStudents_LessonId",
table: "LessonStudents",
column: "LessonId");
migrationBuilder.CreateIndex(
name: "IX_LessonStudents_StudentId",
table: "LessonStudents",
column: "StudentId");
migrationBuilder.CreateIndex(
name: "IX_Students_GradeId",
table: "Students",
column: "GradeId");
migrationBuilder.CreateIndex(
name: "IX_Teachers_TeacherId",
table: "Teachers",
column: "TeacherId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LessonStudents");
migrationBuilder.DropTable(
name: "Lessons");
migrationBuilder.DropTable(
name: "Students");
migrationBuilder.DropTable(
name: "SchedulePlaces");
migrationBuilder.DropTable(
name: "Subjects");
migrationBuilder.DropTable(
name: "Teachers");
migrationBuilder.DropTable(
name: "Grades");
}
}
}

View File

@ -0,0 +1,309 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SchoolScheduleDataBaseImplement;
#nullable disable
namespace SchoolScheduleDataBaseImplement.Migrations
{
[DbContext(typeof(SchoolScheduleDataBase))]
partial class SchoolScheduleDataBaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Grade", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Letter")
.IsRequired()
.HasColumnType("nvarchar(1)");
b.Property<int>("TeacherId")
.HasColumnType("int");
b.Property<int>("Year")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Grades");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Lesson", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<int>("GradeId")
.HasColumnType("int");
b.Property<string>("Homework")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("SchedulePlaceId")
.HasColumnType("int");
b.Property<int>("SubjectId")
.HasColumnType("int");
b.Property<int>("TeacherId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("GradeId");
b.HasIndex("SchedulePlaceId");
b.HasIndex("SubjectId");
b.HasIndex("TeacherId");
b.ToTable("Lessons");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.LessonStudent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("LessonId")
.HasColumnType("int");
b.Property<int?>("Mark")
.IsRequired()
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<int>("StudentId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LessonId");
b.HasIndex("StudentId");
b.ToTable("LessonStudents");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.SchedulePlace", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<TimeOnly>("Time")
.HasColumnType("time");
b.HasKey("Id");
b.ToTable("SchedulePlaces");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Student", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("GradeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("GradeId");
b.ToTable("Students");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Subject", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("SubjectName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Subjects");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Teacher", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("TeacherId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TeacherId")
.IsUnique();
b.ToTable("Teachers");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Lesson", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Grade", "Grade")
.WithMany("Lessons")
.HasForeignKey("GradeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SchoolScheduleDataBaseImplement.Models.SchedulePlace", "SchedulePlace")
.WithMany("Lessons")
.HasForeignKey("SchedulePlaceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SchoolScheduleDataBaseImplement.Models.Subject", "Subject")
.WithMany("Lessons")
.HasForeignKey("SubjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SchoolScheduleDataBaseImplement.Models.Teacher", "Teacher")
.WithMany("Lessons")
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Grade");
b.Navigation("SchedulePlace");
b.Navigation("Subject");
b.Navigation("Teacher");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.LessonStudent", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Lesson", "Lesson")
.WithMany("Students")
.HasForeignKey("LessonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SchoolScheduleDataBaseImplement.Models.Student", "Student")
.WithMany("Lessons")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Lesson");
b.Navigation("Student");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Student", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Grade", "Grade")
.WithMany("Students")
.HasForeignKey("GradeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Grade");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Teacher", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Grade", "Grade")
.WithOne("Teacher")
.HasForeignKey("SchoolScheduleDataBaseImplement.Models.Teacher", "TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Grade");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Grade", b =>
{
b.Navigation("Lessons");
b.Navigation("Students");
b.Navigation("Teacher")
.IsRequired();
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Lesson", b =>
{
b.Navigation("Students");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.SchedulePlace", b =>
{
b.Navigation("Lessons");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Student", b =>
{
b.Navigation("Lessons");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Subject", b =>
{
b.Navigation("Lessons");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Teacher", b =>
{
b.Navigation("Lessons");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,66 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Models
{
public class Grade : IGradeModel
{
public int Id { get; private set; }
[Required]
public int Year { get; private set; }
[Required]
public char Letter { get; private set; }
[Required]
public int TeacherId { get; private set; }
[ForeignKey("GradeId")]
public virtual List<Student> Students { get; set; } =
new();
[ForeignKey("GradeId")]
public virtual List<Lesson> Lessons { get; set; } =
new();
public virtual Teacher Teacher { get; set; } = new();
public static Grade? Create(SchoolScheduleDataBase context, GradeBindingModel model)
{
if (model == null)
{
return null;
}
return new Grade()
{
Id = model.Id,
Year = model.Year,
TeacherId = model.TeacherId,
Letter = model.Letter
};
}
public void Update(SchoolScheduleDataBase context, GradeBindingModel model)
{
if (model == null)
{
return;
}
Year = model.Year;
Letter = model.Letter;
TeacherId = model.TeacherId;
Teacher = context.Teachers.First(x => x.Id == TeacherId);
}
public GradeViewModel GetViewModel => new()
{
Id = Id,
Year = Year,
Letter = Letter,
TeacherId = TeacherId,
TeacherFullName = Teacher.FullName
};
}
}

View File

@ -0,0 +1,85 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Models
{
public class Lesson : ILessonModel
{
public int Id { get; private set; }
[Required]
public DateOnly Date { get; private set; }
[Required]
public string? Homework { get; private set; } = null;
[Required]
public int SchedulePlaceId { get; private set; }
[Required]
public int TeacherId { get; private set; }
[Required]
public int SubjectId { get; private set; }
[Required]
public int GradeId { get; private set; }
[ForeignKey("LessonId")]
public virtual List<LessonStudent> Students { get; set; } = new();
public virtual SchedulePlace SchedulePlace { get; set; } = new();
public virtual Teacher Teacher { get; set; } = new();
public virtual Subject Subject { get; set; } = new();
public virtual Grade Grade { get; set; } = new();
public static Lesson Create(SchoolScheduleDataBase context, LessonViewModel model)
{
return new Lesson
{
Id = model.Id,
Date = model.Date,
Homework = model.Homework,
SchedulePlaceId = model.SchedulePlaceId,
SchedulePlace = context.SchedulePlaces.First(y => y.Id == model.SchedulePlaceId),
TeacherId = model.TeacherId,
SubjectId = model.SubjectId,
GradeId = model.GradeId,
Teacher = context.Teachers.First(x => x.Id == model.TeacherId),
Subject = context.Subjects.First(x => x.Id == model.SubjectId),
Grade = context.Grades.First(x => x.Id == model.GradeId)
};
}
public void Update(SchoolScheduleDataBase context, LessonBindingModel model)
{
if (model == null)
{
return;
}
Date = model.Date;
Homework = model.Homework;
SchedulePlaceId = model.SchedulePlaceId;
SchedulePlace = context.SchedulePlaces.First(y => y.Id == model.SchedulePlaceId);
TeacherId = model.TeacherId;
SubjectId = model.SubjectId;
GradeId = model.GradeId;
Teacher = context.Teachers.First(x => x.Id == model.TeacherId);
Subject = context.Subjects.First(x => x.Id == model.SubjectId);
Grade = context.Grades.First(x => x.Id == model.GradeId);
}
public LessonViewModel GetViewModel => new()
{
Id = Id,
Date = Date,
Homework = Homework,
SchedulePlaceId = SchedulePlaceId,
SchedulePlaceTime = SchedulePlace.Time,
TeacherFullName = Teacher.FullName,
SubjectName = Subject.SubjectName,
GradeName = Grade.Year.ToString() + Grade.Letter.ToString()
};
}
}

View File

@ -0,0 +1,25 @@
using SchoolScheduleDataModels.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Models
{
public class LessonStudent
{
public int Id { get; private set; }
[Required]
public int StudentId { get; private set; }
[Required]
public int LessonId { get; private set; }
[Required]
public StudentStatus Status { get; set; }
[Required]
public int? Mark { get; set; } = null;
public virtual Student Student { get; set; } = new();
public virtual Lesson Lesson { get; set; } = new();
}
}

View File

@ -0,0 +1,40 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Models
{
public class SchedulePlace : ISchedulePlaceModel
{
public int Id { get; private set; }
[Required]
public TimeOnly Time { get; private set; }
[ForeignKey("SchedulePlaceId")]
public virtual List<Lesson> Lessons { get; set; } = new();
public static SchedulePlace Create(SchedulePlaceViewModel model)
{
return new SchedulePlace
{
Id = model.Id,
Time = model.Time,
};
}
public void Update(SchedulePlaceBindingModel model)
{
Time = model.Time;
}
public SchedulePlaceViewModel GetViewModel => new()
{
Id = Id,
Time = Time
};
}
}

View File

@ -0,0 +1,97 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataModels.Enums;
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Models
{
public class Student : IStudentModel
{
public int Id { get; private set; }
[Required]
public string FullName { get; private set; }
[Required]
public int GradeId { get; private set; }
public virtual Grade Grade { get; set; } = new();
private Dictionary<int, (ILessonModel, StudentStatus, int?)> _attendance = null;
[NotMapped]
public Dictionary<int, (ILessonModel, StudentStatus, int?)> Attendance
{
get
{
if (_attendance == null)
{
_attendance = Lessons.ToDictionary(recPC => recPC.LessonId, recPC =>
(recPC.Lesson as ILessonModel, recPC.Status, recPC.Mark));
}
return _attendance;
}
}
[ForeignKey("StudentId")]
public virtual List<LessonStudent> Lessons { get; set; } = new();
public static Student Create(SchoolScheduleDataBase context, StudentBindingModel model)
{
return new Student()
{
Id = model.Id,
FullName = model.FullName,
GradeId = model.GradeId,
Grade = context.Grades.First(y => y.Id == model.GradeId),
Lessons = model.Attendance.Select(x => new LessonStudent
{
Lesson = context.Lessons.First(y => y.Id == x.Key),
Status = x.Value.Item2,
Mark = x.Value.Item3,
}).ToList(),
};
}
public void Update(SchoolScheduleDataBase context, StudentBindingModel model)
{
FullName = model.FullName;
GradeId = model.GradeId;
Grade = context.Grades.First(y => y.Id == model.GradeId);
}
public StudentViewModel GetViewModel => new()
{
Id = Id,
FullName = FullName,
GradeId = GradeId,
GradeName = Grade.Year.ToString() + Grade.Letter.ToString(),
};
public void UpdateAttendance(SchoolScheduleDataBase context, StudentBindingModel model)
{
var attendance = context.LessonStudents.Where(rec => rec.StudentId == model.Id).ToList();
if (attendance != null && attendance.Count > 0)
{
context.LessonStudents.RemoveRange(attendance.Where(rec
=> !model.Attendance.ContainsKey(rec.Id)));
context.SaveChanges();
}
var student = context.Students.First(x => x.Id == Id);
foreach (var pc in model.Attendance)
{
context.LessonStudents.Add(new LessonStudent
{
Student = student,
Lesson = context.Lessons.First(x => x.Id == pc.Key),
Mark = pc.Value.Item3,
Status = pc.Value.Item2,
});
context.SaveChanges();
}
_attendance = null;
}
}
}

View File

@ -0,0 +1,45 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Models
{
public class Subject : ISubjectModel
{
public int Id { get; private set; }
[Required]
public string SubjectName { get; private set; } = string.Empty;
[ForeignKey("SubjectId")]
public virtual List<Lesson> Lessons { get; set; } = new();
public static Subject? Create(SchoolScheduleDataBase context, SubjectBindingModel model)
{
if (model == null)
{
return null;
}
return new Subject()
{
Id = model.Id,
SubjectName = model.SubjectName,
};
}
public void Update(SchoolScheduleDataBase context, SubjectBindingModel model)
{
SubjectName = SubjectName;
}
public SubjectViewModel GetViewModel => new()
{
Id = Id,
SubjectName = SubjectName
};
}
}

View File

@ -0,0 +1,45 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Models
{
public class Teacher : ITeacherModel
{
public int Id { get; private set; }
[Required]
public string FullName { get; private set; } = string.Empty;
[ForeignKey("TeacherId")]
public virtual List<Lesson> Lessons { get; set; } = new();
[ForeignKey("TeacherId")]
public virtual Grade Grade { get; set; }
public static Teacher Create(SchoolScheduleDataBase context, TeacherBindingModel model)
{
return new Teacher()
{
Id = model.Id,
FullName = model.FullName
};
}
public void Update(SchoolScheduleDataBase context, TeacherBindingModel model)
{
FullName = model.FullName;
}
public TeacherViewModel GetViewModel => new()
{
Id = Id,
FullName = FullName,
};
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using SchoolScheduleDataBaseImplement.Models;
namespace SchoolScheduleDataBaseImplement
{
public class SchoolScheduleDataBase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder
optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=SchoolScheduleDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Grade> Grades { set; get; }
public virtual DbSet<Lesson> Lessons { set; get; }
public virtual DbSet<LessonStudent> LessonStudents { set; get; }
public virtual DbSet<SchedulePlace> SchedulePlaces { set; get; }
public virtual DbSet<Student> Students { set; get; }
public virtual DbSet<Subject> Subjects { set; get; }
public virtual DbSet<Teacher> Teachers { set; get; }
}
}

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SchoolScheduleContracts\SchoolScheduleContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataModels.Enums
{
public enum StudentStatus
{
УП = 1,
ОТ = 2,
ПР = 3,
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataModels.Models
{
public interface IGradeModel : IId
{
int Year { get; }
char Letter { get; }
int TeacherId { get; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataModels.Models
{
public interface ILessonModel : IId
{
DateOnly Date { get; }
string? Homework { get; }
int SchedulePlaceId { get; }
int TeacherId { get; }
int SubjectId { get; }
int GradeId { get; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataModels.Models
{
public interface ISchedulePlaceModel : IId
{
TimeOnly Time { get; }
}
}

View File

@ -0,0 +1,16 @@
using SchoolScheduleDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataModels.Models
{
public interface IStudentModel : IId
{
string FullName { get; }
int GradeId { get; }
Dictionary<int, (ILessonModel, StudentStatus, int?)> Attendance { get; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataModels.Models
{
public interface ISubjectModel : IId
{
string SubjectName { get; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataModels.Models
{
public interface ITeacherModel : IId
{
string FullName { get; }
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>