diff --git a/StudentEnrollment/StudentEnrollment.sln b/StudentEnrollment/StudentEnrollment.sln new file mode 100644 index 0000000..f7f0fc5 --- /dev/null +++ b/StudentEnrollment/StudentEnrollment.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33815.320 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentEnrollmentView", "StudentEnrollmentView\StudentEnrollmentView.csproj", "{9F2D2847-BC2D-43E8-95D3-65FF657A4BC9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentEnrollmentDatabaseImplement", "StudentEnrollmentDatabaseImplement\StudentEnrollmentDatabaseImplement.csproj", "{0E15CFEE-D946-455E-9E4E-90FA14674F7D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentEnrollmentDataModels", "StudentEnrollmentDataModels\StudentEnrollmentDataModels.csproj", "{1E2E27BF-4895-4191-9669-A5822D7FA989}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentEnrollmentBusinessLogic", "StudentEnrollmentBusinessLogic\StudentEnrollmentBusinessLogic.csproj", "{A53CE753-75B2-44CC-9BE8-AE478C1A5796}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentEnrollmentContracts", "StudentEnrollmentContracts\StudentEnrollmentContracts.csproj", "{2F21A9AA-6FA9-4113-88C0-9C7BCCFBB822}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9F2D2847-BC2D-43E8-95D3-65FF657A4BC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F2D2847-BC2D-43E8-95D3-65FF657A4BC9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F2D2847-BC2D-43E8-95D3-65FF657A4BC9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F2D2847-BC2D-43E8-95D3-65FF657A4BC9}.Release|Any CPU.Build.0 = Release|Any CPU + {0E15CFEE-D946-455E-9E4E-90FA14674F7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E15CFEE-D946-455E-9E4E-90FA14674F7D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E15CFEE-D946-455E-9E4E-90FA14674F7D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E15CFEE-D946-455E-9E4E-90FA14674F7D}.Release|Any CPU.Build.0 = Release|Any CPU + {1E2E27BF-4895-4191-9669-A5822D7FA989}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E2E27BF-4895-4191-9669-A5822D7FA989}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E2E27BF-4895-4191-9669-A5822D7FA989}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E2E27BF-4895-4191-9669-A5822D7FA989}.Release|Any CPU.Build.0 = Release|Any CPU + {A53CE753-75B2-44CC-9BE8-AE478C1A5796}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A53CE753-75B2-44CC-9BE8-AE478C1A5796}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A53CE753-75B2-44CC-9BE8-AE478C1A5796}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A53CE753-75B2-44CC-9BE8-AE478C1A5796}.Release|Any CPU.Build.0 = Release|Any CPU + {2F21A9AA-6FA9-4113-88C0-9C7BCCFBB822}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F21A9AA-6FA9-4113-88C0-9C7BCCFBB822}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F21A9AA-6FA9-4113-88C0-9C7BCCFBB822}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F21A9AA-6FA9-4113-88C0-9C7BCCFBB822}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6F203950-511C-4D26-A9CF-129D159AE690} + EndGlobalSection +EndGlobal diff --git a/StudentEnrollment/StudentEnrollmentBusinessLogic/CourseLogic.cs b/StudentEnrollment/StudentEnrollmentBusinessLogic/CourseLogic.cs new file mode 100644 index 0000000..959e992 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentBusinessLogic/CourseLogic.cs @@ -0,0 +1,106 @@ +using Microsoft.Extensions.Logging; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.BusinessLogicContracts; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.StorageContracts; +using StudentEnrollmentContracts.ViewModels; + +namespace StudentEnrollmentBusinessLogic +{ + public class CourseLogic : ICourseLogic + { + private readonly ILogger _logger; + private readonly ICourseStorage _courseStorage; + public CourseLogic(ILogger logger, ICourseStorage + courseStorage) + { + _logger = logger; + _courseStorage = courseStorage; + } + public List? ReadList(CourseSearchModel? model) + { + _logger.LogInformation("ReadList. CourseName:{CourseName}.Id:{ Id}", model?.CourseName, model?.Id); + var list = model == null ? _courseStorage.GetFullList() : + _courseStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public CourseViewModel? ReadElement(CourseSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. CourseName:{CourseName}.Id:{ Id}", model.CourseName, model.Id); + var element = _courseStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(CourseBindingModel model) + { + CheckModel(model); + if (_courseStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(CourseBindingModel model) + { + CheckModel(model); + if (_courseStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(CourseBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_courseStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(CourseBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.CourseName)) + { + throw new ArgumentNullException("Нет названия направления!", + nameof(model.CourseName)); + } + _logger.LogInformation("Course. CourseName:{CourseName}. Id: { Id}", model.CourseName, model.Id); + var element = _courseStorage.GetElement(new CourseSearchModel + { + CourseName = model.CourseName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Направление с таким названием уже есть"); + } + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentBusinessLogic/ExamPointsLogic.cs b/StudentEnrollment/StudentEnrollmentBusinessLogic/ExamPointsLogic.cs new file mode 100644 index 0000000..fb77049 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentBusinessLogic/ExamPointsLogic.cs @@ -0,0 +1,112 @@ +using Microsoft.Extensions.Logging; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.BusinessLogicContracts; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.StorageContracts; +using StudentEnrollmentContracts.ViewModels; + +namespace StudentEnrollmentBusinessLogic +{ + public class ExamPointsLogic : IExamPointsLogic + { + private readonly ILogger _logger; + private readonly IExamPointsStorage _examPointsStorage; + public ExamPointsLogic(ILogger logger, IExamPointsStorage + examPointsStorage) + { + _logger = logger; + _examPointsStorage = examPointsStorage; + } + public List? ReadList(ExamPointsSearchModel? model) + { + _logger.LogInformation("ReadList. Id:{ Id}", model?.Id); + var list = model == null ? _examPointsStorage.GetFullList() : + _examPointsStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ExamPointsViewModel? ReadElement(ExamPointsSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement .Id:{ Id}", model.Id); + var element = _examPointsStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(ExamPointsBindingModel model) + { + CheckModel(model); + if (_examPointsStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ExamPointsBindingModel model) + { + CheckModel(model); + if (_examPointsStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ExamPointsBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_examPointsStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ExamPointsBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.FirstExamPoints == 0) + { + throw new ArgumentNullException("Нет баллов за первый экзамен", + nameof(model.FirstExamPoints)); + } + if (model.SecondExamPoints == 0) + { + throw new ArgumentNullException("Нет баллов за второй экзамен", + nameof(model.SecondExamPoints)); + } + if (model.ThirdExamPoints == 0) + { + throw new ArgumentNullException("Нет баллов за третий экзамен", + nameof(model.ThirdExamPoints)); + } + _logger.LogInformation("ExamPoints. FirstExamPoints: {FirstExamPoints}. " + + "SecondExamPoints: {SecondExamPoints}. ThirdExamPoints: {ThirdExamPoints}. AddPoints: {AddPoints}. Summary: {Summary}" + + "Id: { Id}", + model.FirstExamPoints, model.SecondExamPoints, model.ThirdExamPoints, + model.AddPoints, model.Summary, model.Id); + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentBusinessLogic/FacultyLogic.cs b/StudentEnrollment/StudentEnrollmentBusinessLogic/FacultyLogic.cs new file mode 100644 index 0000000..32227ed --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentBusinessLogic/FacultyLogic.cs @@ -0,0 +1,108 @@ +using StudentEnrollmentContracts.BusinessLogicContracts; +using StudentEnrollmentContracts.StorageContracts; +using StudentEnrollmentContracts.ViewModels; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using Microsoft.Extensions.Logging; + +namespace StudentEnrollmentBusinessLogic +{ + public class FacultyLogic : IFacultyLogic + { + private readonly IFacultyStorage _facultyStorage; + private readonly ILogger _logger; + + public FacultyLogic(IFacultyStorage facultyStorage, ILogger logger) + { + _facultyStorage = facultyStorage; + _logger = logger; + } + public List? ReadList(FacultySearchModel? model) + { + _logger.LogInformation("ReadList. FacultyName:{FacultyName}.Id:{ Id}", model?.FacultyName, model?.Id); + var list = model == null ? _facultyStorage.GetFullList() : + _facultyStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public FacultyViewModel? ReadElement(FacultySearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. FacultyName:{FacultyName}.Id:{ Id}", model.FacultyName, model.Id); + var element = _facultyStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(FacultyBindingModel model) + { + CheckModel(model); + if (_facultyStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(FacultyBindingModel model) + { + CheckModel(model); + if (_facultyStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + public bool Delete(FacultyBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_facultyStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + private void CheckModel(FacultyBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.FacultyName)) + { + throw new ArgumentNullException("Нет названия факультета!", + nameof(model.FacultyName)); + } + _logger.LogInformation("Faculty. FacultyName:{FacultyName}. Id: { Id}", model.FacultyName, model.Id); + var element = _facultyStorage.GetElement(new FacultySearchModel + { + FacultyName = model.FacultyName, + }); ; + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Факультет с таким же названием уже есть"); + } + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentBusinessLogic/StudentEnrollmentBusinessLogic.csproj b/StudentEnrollment/StudentEnrollmentBusinessLogic/StudentEnrollmentBusinessLogic.csproj new file mode 100644 index 0000000..af55e9e --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentBusinessLogic/StudentEnrollmentBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net7.0 + enable + enable + + + + + + + + + + + diff --git a/StudentEnrollment/StudentEnrollmentBusinessLogic/StudentLogic.cs b/StudentEnrollment/StudentEnrollmentBusinessLogic/StudentLogic.cs new file mode 100644 index 0000000..c87078d --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentBusinessLogic/StudentLogic.cs @@ -0,0 +1,119 @@ +using Microsoft.Extensions.Logging; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.BusinessLogicContracts; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.StorageContracts; +using StudentEnrollmentContracts.ViewModels; + +namespace StudentEnrollmentBusinessLogic +{ + public class StudentLogic : IStudentLogic + { + private readonly ILogger _logger; + private readonly IStudentStorage _studentStorage; + public StudentLogic(ILogger logger, IStudentStorage studentStorage) + { + _logger = logger; + _studentStorage = studentStorage; + } + public List? ReadList(StudentSearchModel? model) + { + _logger.LogInformation("ReadList. TIN: {TIN}. Id:{Id}", model?.TIN, model?.Id); + var list = model == null ? _studentStorage.GetFullList() : _studentStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public StudentViewModel? ReadElement(StudentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadList. TIN: {TIN}. Id:{Id}", model?.TIN, model.Id); + var element = _studentStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(StudentBindingModel model) + { + CheckModel(model); + if (_studentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(StudentBindingModel model) + { + CheckModel(model); + if (_studentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(StudentBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_studentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(StudentBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.LastName)) + { + throw new ArgumentNullException("Нет фамилии студента!", nameof(model.LastName)); + } + if (string.IsNullOrEmpty(model.FirstName)) + { + throw new ArgumentNullException("Нет имени студента!", nameof(model.FirstName)); + } + if (string.IsNullOrEmpty(model.TIN)) + { + throw new ArgumentNullException("Нет ИНН студента!", nameof(model.TIN)); + } + if (string.IsNullOrEmpty(model.Email)) + { + throw new ArgumentNullException("Нет почты студента!", nameof(model.Email)); + } + if (model.StudentCourse.Count == 0) + { + throw new ArgumentNullException("У студента должны быть баллы за экзамены!", nameof(model.StudentCourse)); + } + _logger.LogInformation("Student. LastName: {LastName}, FirstName: {FirstName}, MiddleName: {MiddleName}, TIN: {TIN}, Email: {Email}, Id: {Id}", model.LastName, model.FirstName, model.MiddleName, model.TIN, model.Email, model.Id); + var element = _studentStorage.GetElement(new StudentSearchModel + { + TIN = model.TIN + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Студент с таким ИНН уже есть"); + } + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/CourseBindingModel.cs b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/CourseBindingModel.cs new file mode 100644 index 0000000..786c4ac --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/CourseBindingModel.cs @@ -0,0 +1,11 @@ +using StudentEnrollmentDataModels.Models; + +namespace StudentEnrollmentContracts.BindingModels +{ + public class CourseBindingModel : ICourseModel + { + public long Id { get; set; } + public string CourseName { get; set; } = string.Empty; + public string FacultyName { get; set; } = string.Empty; + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/ExamPointsBindingModel.cs b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/ExamPointsBindingModel.cs new file mode 100644 index 0000000..b70195b --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/ExamPointsBindingModel.cs @@ -0,0 +1,14 @@ +using StudentEnrollmentDataModels.Models; + +namespace StudentEnrollmentContracts.BindingModels +{ + public class ExamPointsBindingModel : IExamPointsModel + { + public long Id { get; set; } + public int FirstExamPoints { get; set; } + public int SecondExamPoints { get; set; } + public int ThirdExamPoints { get; set; } + public int AddPoints { get; set; } = 0; + public int Summary { get; set; } + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/FacultyBindingModel.cs b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/FacultyBindingModel.cs new file mode 100644 index 0000000..8ee6186 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/FacultyBindingModel.cs @@ -0,0 +1,10 @@ +using StudentEnrollmentDataModels.Models; + +namespace StudentEnrollmentContracts.BindingModels +{ + public class FacultyBindingModel : IFacultyModel + { + public long Id { get; set; } + public string FacultyName { get; set; } = string.Empty; + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/StudentBindingModel.cs b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/StudentBindingModel.cs new file mode 100644 index 0000000..3db81a7 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/StudentBindingModel.cs @@ -0,0 +1,20 @@ +using StudentEnrollmentDataModels.Models; + +namespace StudentEnrollmentContracts.BindingModels +{ + public class StudentBindingModel : IStudentModel + { + public long Id { get; set; } + public string FirstName { get; set; } = string.Empty; + public string LastName { get; set; } = string.Empty; + public string MiddleName { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + public string TIN { get; set; } = string.Empty; + public long ExamPointsId { get; set; } + public Dictionary StudentCourse + { + get; + set; + } = new(); + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/ICourseLogic.cs b/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/ICourseLogic.cs new file mode 100644 index 0000000..4c54464 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/ICourseLogic.cs @@ -0,0 +1,15 @@ +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.ViewModels; + +namespace StudentEnrollmentContracts.BusinessLogicContracts +{ + public interface ICourseLogic + { + List? ReadList(CourseSearchModel? model); + CourseViewModel? ReadElement(CourseSearchModel model); + bool Create(CourseBindingModel model); + bool Update(CourseBindingModel model); + bool Delete(CourseBindingModel model); + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/IExamPointsLogic.cs b/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/IExamPointsLogic.cs new file mode 100644 index 0000000..7743344 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/IExamPointsLogic.cs @@ -0,0 +1,15 @@ +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.ViewModels; + +namespace StudentEnrollmentContracts.BusinessLogicContracts +{ + public interface IExamPointsLogic + { + List? ReadList(ExamPointsSearchModel? model); + ExamPointsViewModel? ReadElement(ExamPointsSearchModel model); + bool Create(ExamPointsBindingModel model); + bool Update(ExamPointsBindingModel model); + bool Delete(ExamPointsBindingModel model); + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/IFacultyLogic.cs b/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/IFacultyLogic.cs new file mode 100644 index 0000000..c20ff73 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/IFacultyLogic.cs @@ -0,0 +1,15 @@ +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.ViewModels; + +namespace StudentEnrollmentContracts.BusinessLogicContracts +{ + public interface IFacultyLogic + { + List? ReadList(FacultySearchModel? model); + FacultyViewModel? ReadElement(FacultySearchModel model); + bool Create(FacultyBindingModel model); + bool Update(FacultyBindingModel model); + bool Delete(FacultyBindingModel model); + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/IStudentLogic.cs b/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/IStudentLogic.cs new file mode 100644 index 0000000..c6f47df --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/BusinessLogicContracts/IStudentLogic.cs @@ -0,0 +1,15 @@ +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.ViewModels; + +namespace StudentEnrollmentContracts.BusinessLogicContracts +{ + public interface IStudentLogic + { + List? ReadList(StudentSearchModel? model); + StudentViewModel? ReadElement(StudentSearchModel model); + bool Create(StudentBindingModel model); + bool Update(StudentBindingModel model); + bool Delete(StudentBindingModel model); + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/CourseSearchModel.cs b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/CourseSearchModel.cs new file mode 100644 index 0000000..9846191 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/CourseSearchModel.cs @@ -0,0 +1,8 @@ +namespace StudentEnrollmentContracts.SearchModels +{ + public class CourseSearchModel + { + public long? Id { get; set; } + public string? CourseName { get; set; } + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/ExamPointsSearchModel.cs b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/ExamPointsSearchModel.cs new file mode 100644 index 0000000..d2f1dbd --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/ExamPointsSearchModel.cs @@ -0,0 +1,7 @@ +namespace StudentEnrollmentContracts.SearchModels +{ + public class ExamPointsSearchModel + { + public long? Id { get; set; } + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/FacultySearchModel.cs b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/FacultySearchModel.cs new file mode 100644 index 0000000..33ce5e1 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/FacultySearchModel.cs @@ -0,0 +1,8 @@ +namespace StudentEnrollmentContracts.SearchModels +{ + public class FacultySearchModel + { + public long? Id { get; set; } + public string? FacultyName { get; set; } + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/StudentSearchModel.cs b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/StudentSearchModel.cs new file mode 100644 index 0000000..0b1c2e2 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/StudentSearchModel.cs @@ -0,0 +1,8 @@ +namespace StudentEnrollmentContracts.SearchModels +{ + public class StudentSearchModel + { + public long? Id { get; set; } + public string? TIN { get; set; } + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/ICourseStorage.cs b/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/ICourseStorage.cs new file mode 100644 index 0000000..672417a --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/ICourseStorage.cs @@ -0,0 +1,16 @@ +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.ViewModels; + +namespace StudentEnrollmentContracts.StorageContracts +{ + public interface ICourseStorage + { + List GetFullList(); + List GetFilteredList(CourseSearchModel model); + CourseViewModel? GetElement(CourseSearchModel model); + CourseViewModel? Insert(CourseBindingModel model); + CourseViewModel? Update(CourseBindingModel model); + CourseViewModel? Delete(CourseBindingModel model); + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/IExamPointsStorage.cs b/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/IExamPointsStorage.cs new file mode 100644 index 0000000..cfa7c39 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/IExamPointsStorage.cs @@ -0,0 +1,16 @@ +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.ViewModels; + +namespace StudentEnrollmentContracts.StorageContracts +{ + public interface IExamPointsStorage + { + List GetFullList(); + List GetFilteredList(ExamPointsSearchModel model); + ExamPointsViewModel? GetElement(ExamPointsSearchModel model); + ExamPointsViewModel? Insert(ExamPointsBindingModel model); + ExamPointsViewModel? Update(ExamPointsBindingModel model); + ExamPointsViewModel? Delete(ExamPointsBindingModel model); + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/IFacultyStorage.cs b/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/IFacultyStorage.cs new file mode 100644 index 0000000..7b61dab --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/IFacultyStorage.cs @@ -0,0 +1,16 @@ +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.ViewModels; + +namespace StudentEnrollmentContracts.StorageContracts +{ + public interface IFacultyStorage + { + List GetFullList(); + List GetFilteredList(FacultySearchModel model); + FacultyViewModel? GetElement(FacultySearchModel model); + FacultyViewModel? Insert(FacultyBindingModel model); + FacultyViewModel? Update(FacultyBindingModel model); + FacultyViewModel? Delete(FacultyBindingModel model); + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/IStudentStorage.cs b/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/IStudentStorage.cs new file mode 100644 index 0000000..43fd6cf --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/StorageContracts/IStudentStorage.cs @@ -0,0 +1,16 @@ +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.ViewModels; + +namespace StudentEnrollmentContracts.StorageContracts +{ + public interface IStudentStorage + { + List GetFullList(); + List GetFilteredList(StudentSearchModel model); + StudentViewModel? GetElement(StudentSearchModel model); + StudentViewModel? Insert(StudentBindingModel model); + StudentViewModel? Update(StudentBindingModel model); + StudentViewModel? Delete(StudentBindingModel model); + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/StudentEnrollmentContracts.csproj b/StudentEnrollment/StudentEnrollmentContracts/StudentEnrollmentContracts.csproj new file mode 100644 index 0000000..d2b0810 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/StudentEnrollmentContracts.csproj @@ -0,0 +1,13 @@ + + + + net7.0 + enable + enable + + + + + + + diff --git a/StudentEnrollment/StudentEnrollmentContracts/ViewModels/CourseViewModel.cs b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/CourseViewModel.cs new file mode 100644 index 0000000..b9100d7 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/CourseViewModel.cs @@ -0,0 +1,14 @@ +using StudentEnrollmentDataModels.Models; +using System.ComponentModel; + +namespace StudentEnrollmentContracts.ViewModels +{ + public class CourseViewModel : ICourseModel + { + public long Id { get; set; } + [DisplayName("Название направления")] + public string CourseName { get; set; } = string.Empty; + [DisplayName("Название факультета")] + public string FacultyName { get; set; } = string.Empty; + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/ViewModels/ExamPointsViewModel.cs b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/ExamPointsViewModel.cs new file mode 100644 index 0000000..e2edbe8 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/ExamPointsViewModel.cs @@ -0,0 +1,20 @@ +using StudentEnrollmentDataModels.Models; +using System.ComponentModel; + +namespace StudentEnrollmentContracts.ViewModels +{ + public class ExamPointsViewModel : IExamPointsModel + { + public long Id { get; set; } + [DisplayName("Баллы за первый экзамен")] + public int FirstExamPoints { get; set; } + [DisplayName("Баллы за второй экзамен")] + public int SecondExamPoints { get; set; } + [DisplayName("Баллы за третий экзамен")] + public int ThirdExamPoints { get; set; } + [DisplayName("Дополнительные баллы")] + public int AddPoints { get; set; } = 0; + [DisplayName("Сумма баллов")] + public int Summary { get; set; } + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/ViewModels/FacultyViewModel.cs b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/FacultyViewModel.cs new file mode 100644 index 0000000..72486fc --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/FacultyViewModel.cs @@ -0,0 +1,12 @@ +using StudentEnrollmentDataModels.Models; +using System.ComponentModel; + +namespace StudentEnrollmentContracts.ViewModels +{ + public class FacultyViewModel : IFacultyModel + { + public long Id { get; set; } + [DisplayName("Название факультета")] + public string FacultyName { get; set; } = string.Empty; + } +} diff --git a/StudentEnrollment/StudentEnrollmentContracts/ViewModels/StudentViewModel.cs b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/StudentViewModel.cs new file mode 100644 index 0000000..8442317 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/StudentViewModel.cs @@ -0,0 +1,28 @@ +using StudentEnrollmentDataModels.Models; +using System.ComponentModel; + +namespace StudentEnrollmentContracts.ViewModels +{ + public class StudentViewModel : IStudentModel + { + public long Id { get; set; } + [DisplayName("Имя")] + public string FirstName { get; set; } = string.Empty; + [DisplayName("Фамилия")] + public string LastName { get; set; } = string.Empty; + [DisplayName("Отчество")] + public string MiddleName { get; set; } = string.Empty; + [DisplayName("Почта")] + public string Email { get; set; } = string.Empty; + [DisplayName("ИНН")] + public string TIN { get; set; } = string.Empty; + public long ExamPointsId { get; set; } + [DisplayName("Суммарное количество баллов")] + public int ExamPoints { get; set; } + public Dictionary StudentCourse + { + get; + set; + } = new(); + } +} diff --git a/StudentEnrollment/StudentEnrollmentDataModels/IId.cs b/StudentEnrollment/StudentEnrollmentDataModels/IId.cs new file mode 100644 index 0000000..c160390 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace StudentEnrollmentDataModels +{ + public interface IId + { + long Id { get; } + } +} diff --git a/StudentEnrollment/StudentEnrollmentDataModels/Models/ICourseModel.cs b/StudentEnrollment/StudentEnrollmentDataModels/Models/ICourseModel.cs new file mode 100644 index 0000000..a812f5a --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentDataModels/Models/ICourseModel.cs @@ -0,0 +1,8 @@ +namespace StudentEnrollmentDataModels.Models +{ + public interface ICourseModel : IId + { + string CourseName { get; } + string FacultyName { get; } + } +} diff --git a/StudentEnrollment/StudentEnrollmentDataModels/Models/IExamPointsModel.cs b/StudentEnrollment/StudentEnrollmentDataModels/Models/IExamPointsModel.cs new file mode 100644 index 0000000..df1701e --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentDataModels/Models/IExamPointsModel.cs @@ -0,0 +1,10 @@ +namespace StudentEnrollmentDataModels.Models +{ + public interface IExamPointsModel : IId + { + int FirstExamPoints { get; } + int SecondExamPoints { get; } + int AddPoints { get; } + int Summary { get; } + } +} diff --git a/StudentEnrollment/StudentEnrollmentDataModels/Models/IFacultyModel.cs b/StudentEnrollment/StudentEnrollmentDataModels/Models/IFacultyModel.cs new file mode 100644 index 0000000..21dbd23 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentDataModels/Models/IFacultyModel.cs @@ -0,0 +1,7 @@ +namespace StudentEnrollmentDataModels.Models +{ + public interface IFacultyModel : IId + { + string FacultyName { get; } + } +} diff --git a/StudentEnrollment/StudentEnrollmentDataModels/Models/IStudentModel.cs b/StudentEnrollment/StudentEnrollmentDataModels/Models/IStudentModel.cs new file mode 100644 index 0000000..4470402 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentDataModels/Models/IStudentModel.cs @@ -0,0 +1,13 @@ +namespace StudentEnrollmentDataModels.Models +{ + public interface IStudentModel : IId + { + string LastName { get; } + string FirstName { get; } + string MiddleName { get; } + string Email { get; } + string TIN { get; } + long ExamPointsId { get; } + Dictionary StudentCourse { get; } + } +} diff --git a/StudentEnrollment/StudentEnrollmentDataModels/StudentEnrollmentDataModels.csproj b/StudentEnrollment/StudentEnrollmentDataModels/StudentEnrollmentDataModels.csproj new file mode 100644 index 0000000..cfadb03 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentDataModels/StudentEnrollmentDataModels.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + + diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/StudentEnrollmentDatabaseImplement.csproj b/StudentEnrollment/StudentEnrollmentDatabaseImplement/StudentEnrollmentDatabaseImplement.csproj new file mode 100644 index 0000000..cfadb03 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/StudentEnrollmentDatabaseImplement.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + + diff --git a/StudentEnrollment/StudentEnrollmentView/Program.cs b/StudentEnrollment/StudentEnrollmentView/Program.cs new file mode 100644 index 0000000..41ff170 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/Program.cs @@ -0,0 +1,19 @@ +namespace StudentEnrollmentView +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new Form1()); + + + } + } +} \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/StudentEnrollmentView.csproj b/StudentEnrollment/StudentEnrollmentView/StudentEnrollmentView.csproj new file mode 100644 index 0000000..e1a0735 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/StudentEnrollmentView.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net7.0-windows + enable + true + enable + + + \ No newline at end of file