From d60d364d1629eb48ed4422a4450a79ed352db2b8 Mon Sep 17 00:00:00 2001 From: DavidMakarov Date: Mon, 6 May 2024 20:26:16 +0400 Subject: [PATCH] fix in many files, add Forms --- .../CourseLogic.cs | 6 +- .../ExamPointsLogic.cs | 4 +- .../FacultyLogic.cs | 8 +- .../StudentLogic.cs | 8 +- .../BindingModels/CourseBindingModel.cs | 4 +- .../BindingModels/ExamPointsBindingModel.cs | 2 +- .../BindingModels/FacultyBindingModel.cs | 2 +- .../BindingModels/StudentBindingModel.cs | 8 +- .../SearchModels/CourseSearchModel.cs | 4 +- .../SearchModels/ExamPointsSearchModel.cs | 2 +- .../SearchModels/FacultySearchModel.cs | 4 +- .../SearchModels/StudentSearchModel.cs | 4 +- .../ViewModels/CourseViewModel.cs | 4 +- .../ViewModels/ExamPointsViewModel.cs | 2 +- .../ViewModels/FacultyViewModel.cs | 2 +- .../ViewModels/StudentViewModel.cs | 8 +- .../StudentEnrollmentDataModels/IId.cs | 2 +- .../Models/ICourseModel.cs | 2 +- .../Models/IExamPointsModel.cs | 1 + .../Models/IStudentModel.cs | 6 +- .../Implements/CourseStorage.cs | 82 ++++- .../Implements/ExamPoints.cs | 9 - .../Implements/ExamPointsStorage.cs | 79 +++++ .../Implements/FacultyStorage.cs | 73 +++- .../Implements/StudentStorage.cs | 79 ++++- .../20240506162134_InitCreate.Designer.cs | 213 ++++++++++++ .../Migrations/20240506162134_InitCreate.cs | 156 +++++++++ .../StudentEnrollmentDatabaseModelSnapshot.cs | 210 ++++++++++++ .../Models/Course.cs | 31 +- .../Models/ExamPoints.cs | 49 ++- .../Models/Faculty.cs | 17 +- .../Models/Student.cs | 64 ++-- .../Models/StudentCourse.cs | 7 +- .../StudentEnrollmentDatabase.cs | 12 +- .../StudentEnrollmentDatabaseImplement.csproj | 8 +- .../FormCourse.Designer.cs | 125 +++++++ .../StudentEnrollmentView/FormCourse.cs | 83 +++++ .../StudentEnrollmentView/FormCourse.resx | 120 +++++++ .../FormCourses.Designer.cs | 114 +++++++ .../StudentEnrollmentView/FormCourses.cs | 101 ++++++ .../StudentEnrollmentView/FormCourses.resx | 120 +++++++ .../FormExamPoints.Designer.cs | 167 ++++++++++ .../StudentEnrollmentView/FormExamPoints.cs | 61 ++++ .../StudentEnrollmentView/FormExamPoints.resx | 120 +++++++ .../FormFaculties.Designer.cs | 114 +++++++ .../StudentEnrollmentView/FormFaculties.cs | 102 ++++++ .../StudentEnrollmentView/FormFaculties.resx | 120 +++++++ .../FormFaculty.Designer.cs | 100 ++++++ .../StudentEnrollmentView/FormFaculty.cs | 79 +++++ .../StudentEnrollmentView/FormFaculty.resx | 120 +++++++ .../FormMain.Designer.cs | 130 ++++++++ .../StudentEnrollmentView/FormMain.cs | 40 +++ .../StudentEnrollmentView/FormMain.resx | 123 +++++++ .../FormStudent.Designer.cs | 314 ++++++++++++++++++ .../StudentEnrollmentView/FormStudent.cs | 232 +++++++++++++ .../StudentEnrollmentView/FormStudent.resx | 123 +++++++ .../FormStudentCourse.Designer.cs | 101 ++++++ .../FormStudentCourse.cs | 67 ++++ .../FormStudentCourse.resx | 120 +++++++ .../FormStudents.Designer.cs | 120 +++++++ .../StudentEnrollmentView/FormStudents.cs | 59 ++++ .../StudentEnrollmentView/FormStudents.resx | 120 +++++++ .../StudentEnrollmentView/Program.cs | 42 ++- .../StudentEnrollmentView.csproj | 17 + 64 files changed, 4295 insertions(+), 131 deletions(-) delete mode 100644 StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/ExamPoints.cs create mode 100644 StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/ExamPointsStorage.cs create mode 100644 StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/20240506162134_InitCreate.Designer.cs create mode 100644 StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/20240506162134_InitCreate.cs create mode 100644 StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/StudentEnrollmentDatabaseModelSnapshot.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormCourse.Designer.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormCourse.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormCourse.resx create mode 100644 StudentEnrollment/StudentEnrollmentView/FormCourses.Designer.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormCourses.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormCourses.resx create mode 100644 StudentEnrollment/StudentEnrollmentView/FormExamPoints.Designer.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormExamPoints.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormExamPoints.resx create mode 100644 StudentEnrollment/StudentEnrollmentView/FormFaculties.Designer.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormFaculties.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormFaculties.resx create mode 100644 StudentEnrollment/StudentEnrollmentView/FormFaculty.Designer.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormFaculty.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormFaculty.resx create mode 100644 StudentEnrollment/StudentEnrollmentView/FormMain.Designer.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormMain.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormMain.resx create mode 100644 StudentEnrollment/StudentEnrollmentView/FormStudent.Designer.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormStudent.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormStudent.resx create mode 100644 StudentEnrollment/StudentEnrollmentView/FormStudentCourse.Designer.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormStudentCourse.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormStudentCourse.resx create mode 100644 StudentEnrollment/StudentEnrollmentView/FormStudents.Designer.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormStudents.cs create mode 100644 StudentEnrollment/StudentEnrollmentView/FormStudents.resx diff --git a/StudentEnrollment/StudentEnrollmentBusinessLogic/CourseLogic.cs b/StudentEnrollment/StudentEnrollmentBusinessLogic/CourseLogic.cs index 959e992..e172fe7 100644 --- a/StudentEnrollment/StudentEnrollmentBusinessLogic/CourseLogic.cs +++ b/StudentEnrollment/StudentEnrollmentBusinessLogic/CourseLogic.cs @@ -19,7 +19,7 @@ namespace StudentEnrollmentBusinessLogic } public List? ReadList(CourseSearchModel? model) { - _logger.LogInformation("ReadList. CourseName:{CourseName}.Id:{ Id}", model?.CourseName, model?.Id); + _logger.LogInformation("ReadList. CourseName:{CourseName}.Id:{ Id}", model?.name, model?.course_id); var list = model == null ? _courseStorage.GetFullList() : _courseStorage.GetFilteredList(model); if (list == null) @@ -36,7 +36,7 @@ namespace StudentEnrollmentBusinessLogic { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. CourseName:{CourseName}.Id:{ Id}", model.CourseName, model.Id); + _logger.LogInformation("ReadElement. CourseName:{CourseName}.Id:{ Id}", model.name, model.course_id); var element = _courseStorage.GetElement(model); if (element == null) { @@ -95,7 +95,7 @@ namespace StudentEnrollmentBusinessLogic _logger.LogInformation("Course. CourseName:{CourseName}. Id: { Id}", model.CourseName, model.Id); var element = _courseStorage.GetElement(new CourseSearchModel { - CourseName = model.CourseName + name = model.CourseName }); if (element != null && element.Id != model.Id) { diff --git a/StudentEnrollment/StudentEnrollmentBusinessLogic/ExamPointsLogic.cs b/StudentEnrollment/StudentEnrollmentBusinessLogic/ExamPointsLogic.cs index fb77049..a39294b 100644 --- a/StudentEnrollment/StudentEnrollmentBusinessLogic/ExamPointsLogic.cs +++ b/StudentEnrollment/StudentEnrollmentBusinessLogic/ExamPointsLogic.cs @@ -19,7 +19,7 @@ namespace StudentEnrollmentBusinessLogic } public List? ReadList(ExamPointsSearchModel? model) { - _logger.LogInformation("ReadList. Id:{ Id}", model?.Id); + _logger.LogInformation("ReadList. Id:{ Id}", model?.exampoints_id); var list = model == null ? _examPointsStorage.GetFullList() : _examPointsStorage.GetFilteredList(model); if (list == null) @@ -36,7 +36,7 @@ namespace StudentEnrollmentBusinessLogic { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement .Id:{ Id}", model.Id); + _logger.LogInformation("ReadElement .Id:{ Id}", model.exampoints_id); var element = _examPointsStorage.GetElement(model); if (element == null) { diff --git a/StudentEnrollment/StudentEnrollmentBusinessLogic/FacultyLogic.cs b/StudentEnrollment/StudentEnrollmentBusinessLogic/FacultyLogic.cs index 32227ed..67ac971 100644 --- a/StudentEnrollment/StudentEnrollmentBusinessLogic/FacultyLogic.cs +++ b/StudentEnrollment/StudentEnrollmentBusinessLogic/FacultyLogic.cs @@ -12,14 +12,14 @@ namespace StudentEnrollmentBusinessLogic private readonly IFacultyStorage _facultyStorage; private readonly ILogger _logger; - public FacultyLogic(IFacultyStorage facultyStorage, 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); + _logger.LogInformation("ReadList. FacultyName:{FacultyName}.Id:{ Id}", model?.name, model?.faculty_id); var list = model == null ? _facultyStorage.GetFullList() : _facultyStorage.GetFilteredList(model); if (list == null) @@ -36,7 +36,7 @@ namespace StudentEnrollmentBusinessLogic { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. FacultyName:{FacultyName}.Id:{ Id}", model.FacultyName, model.Id); + _logger.LogInformation("ReadElement. FacultyName:{FacultyName}.Id:{ Id}", model.name, model.faculty_id); var element = _facultyStorage.GetElement(model); if (element == null) { @@ -97,7 +97,7 @@ namespace StudentEnrollmentBusinessLogic _logger.LogInformation("Faculty. FacultyName:{FacultyName}. Id: { Id}", model.FacultyName, model.Id); var element = _facultyStorage.GetElement(new FacultySearchModel { - FacultyName = model.FacultyName, + name = model.FacultyName, }); ; if (element != null && element.Id != model.Id) { diff --git a/StudentEnrollment/StudentEnrollmentBusinessLogic/StudentLogic.cs b/StudentEnrollment/StudentEnrollmentBusinessLogic/StudentLogic.cs index 77df5ec..d699ad0 100644 --- a/StudentEnrollment/StudentEnrollmentBusinessLogic/StudentLogic.cs +++ b/StudentEnrollment/StudentEnrollmentBusinessLogic/StudentLogic.cs @@ -18,7 +18,7 @@ namespace StudentEnrollmentBusinessLogic } public List? ReadList(StudentSearchModel? model) { - _logger.LogInformation("ReadList. TIN: {TIN}. Id:{Id}", model?.TIN, model?.Id); + _logger.LogInformation("ReadList. TIN: {TIN}. Id:{Id}", model?.tin, model?.student_id); var list = model == null ? _studentStorage.GetFullList() : _studentStorage.GetFilteredList(model); if (list == null) { @@ -34,7 +34,7 @@ namespace StudentEnrollmentBusinessLogic { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadList. TIN: {TIN}. Id:{Id}", model?.TIN, model?.Id); + _logger.LogInformation("ReadList. TIN: {TIN}. Id:{Id}", model?.tin, model?.student_id); var element = _studentStorage.GetElement(model); if (element == null) { @@ -93,7 +93,7 @@ namespace StudentEnrollmentBusinessLogic { throw new ArgumentNullException("Нет имени студента!", nameof(model.FirstName)); } - if (string.IsNullOrEmpty(model.TIN)) + if (model.TIN == 0) { throw new ArgumentNullException("Нет ИНН студента!", nameof(model.TIN)); } @@ -108,7 +108,7 @@ namespace StudentEnrollmentBusinessLogic _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 + tin = model.TIN }); if (element != null && element.Id != model.Id) { diff --git a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/CourseBindingModel.cs b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/CourseBindingModel.cs index a3ab1fe..61e2553 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/CourseBindingModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/CourseBindingModel.cs @@ -4,8 +4,8 @@ namespace StudentEnrollmentContracts.BindingModels { public class CourseBindingModel : ICourseModel { - public long Id { get; set; } + public int Id { get; set; } public string CourseName { get; set; } = string.Empty; - public long FacultyId { get; set; } + public int FacultyId { get; set; } } } diff --git a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/ExamPointsBindingModel.cs b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/ExamPointsBindingModel.cs index b70195b..7dbeef4 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/ExamPointsBindingModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/ExamPointsBindingModel.cs @@ -4,7 +4,7 @@ namespace StudentEnrollmentContracts.BindingModels { public class ExamPointsBindingModel : IExamPointsModel { - public long Id { get; set; } + public int Id { get; set; } public int FirstExamPoints { get; set; } public int SecondExamPoints { get; set; } public int ThirdExamPoints { get; set; } diff --git a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/FacultyBindingModel.cs b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/FacultyBindingModel.cs index 8ee6186..ae109cf 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/FacultyBindingModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/FacultyBindingModel.cs @@ -4,7 +4,7 @@ namespace StudentEnrollmentContracts.BindingModels { public class FacultyBindingModel : IFacultyModel { - public long Id { get; set; } + public int Id { get; set; } public string FacultyName { get; set; } = string.Empty; } } diff --git a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/StudentBindingModel.cs b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/StudentBindingModel.cs index abfbbbb..b18b386 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/BindingModels/StudentBindingModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/BindingModels/StudentBindingModel.cs @@ -4,14 +4,14 @@ namespace StudentEnrollmentContracts.BindingModels { public class StudentBindingModel : IStudentModel { - public long Id { get; set; } + public int 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 + public long TIN { get; set; } + public int ExamPointsId { get; set; } + public Dictionary StudentCourse { get; set; diff --git a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/CourseSearchModel.cs b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/CourseSearchModel.cs index 9846191..7ff39ee 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/CourseSearchModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/CourseSearchModel.cs @@ -2,7 +2,7 @@ { public class CourseSearchModel { - public long? Id { get; set; } - public string? CourseName { get; set; } + public int? course_id { get; set; } + public string? name { get; set; } } } diff --git a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/ExamPointsSearchModel.cs b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/ExamPointsSearchModel.cs index d2f1dbd..871b21b 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/ExamPointsSearchModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/ExamPointsSearchModel.cs @@ -2,6 +2,6 @@ { public class ExamPointsSearchModel { - public long? Id { get; set; } + public int? exampoints_id { get; set; } } } diff --git a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/FacultySearchModel.cs b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/FacultySearchModel.cs index 33ce5e1..d4abd40 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/FacultySearchModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/FacultySearchModel.cs @@ -2,7 +2,7 @@ { public class FacultySearchModel { - public long? Id { get; set; } - public string? FacultyName { get; set; } + public int? faculty_id { get; set; } + public string? name { get; set; } } } diff --git a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/StudentSearchModel.cs b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/StudentSearchModel.cs index 0b1c2e2..bbeca94 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/SearchModels/StudentSearchModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/SearchModels/StudentSearchModel.cs @@ -2,7 +2,7 @@ { public class StudentSearchModel { - public long? Id { get; set; } - public string? TIN { get; set; } + public int? student_id { get; set; } + public long? tin { get; set; } } } diff --git a/StudentEnrollment/StudentEnrollmentContracts/ViewModels/CourseViewModel.cs b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/CourseViewModel.cs index 9203669..99d4437 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/ViewModels/CourseViewModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/CourseViewModel.cs @@ -5,11 +5,11 @@ namespace StudentEnrollmentContracts.ViewModels { public class CourseViewModel : ICourseModel { - public long Id { get; set; } + public int Id { get; set; } [DisplayName("Название направления")] public string CourseName { get; set; } = string.Empty; [DisplayName("Название факультета")] public string FacultyName { get; set; } = string.Empty; - public long FacultyId { get; set; } + public int FacultyId { get; set; } } } diff --git a/StudentEnrollment/StudentEnrollmentContracts/ViewModels/ExamPointsViewModel.cs b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/ExamPointsViewModel.cs index e2edbe8..a134b74 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/ViewModels/ExamPointsViewModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/ExamPointsViewModel.cs @@ -5,7 +5,7 @@ namespace StudentEnrollmentContracts.ViewModels { public class ExamPointsViewModel : IExamPointsModel { - public long Id { get; set; } + public int Id { get; set; } [DisplayName("Баллы за первый экзамен")] public int FirstExamPoints { get; set; } [DisplayName("Баллы за второй экзамен")] diff --git a/StudentEnrollment/StudentEnrollmentContracts/ViewModels/FacultyViewModel.cs b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/FacultyViewModel.cs index 72486fc..d715f63 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/ViewModels/FacultyViewModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/FacultyViewModel.cs @@ -5,7 +5,7 @@ namespace StudentEnrollmentContracts.ViewModels { public class FacultyViewModel : IFacultyModel { - public long Id { get; set; } + public int 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 index f7be59d..ae66c00 100644 --- a/StudentEnrollment/StudentEnrollmentContracts/ViewModels/StudentViewModel.cs +++ b/StudentEnrollment/StudentEnrollmentContracts/ViewModels/StudentViewModel.cs @@ -5,7 +5,7 @@ namespace StudentEnrollmentContracts.ViewModels { public class StudentViewModel : IStudentModel { - public long Id { get; set; } + public int Id { get; set; } [DisplayName("Имя")] public string FirstName { get; set; } = string.Empty; [DisplayName("Фамилия")] @@ -15,11 +15,11 @@ namespace StudentEnrollmentContracts.ViewModels [DisplayName("Почта")] public string Email { get; set; } = string.Empty; [DisplayName("ИНН")] - public string TIN { get; set; } = string.Empty; - public long ExamPointsId { get; set; } + public long TIN { get; set; } + public int ExamPointsId { get; set; } [DisplayName("Суммарное количество баллов")] public int ExamPoints { get; set; } - public Dictionary StudentCourse + public Dictionary StudentCourse { get; set; diff --git a/StudentEnrollment/StudentEnrollmentDataModels/IId.cs b/StudentEnrollment/StudentEnrollmentDataModels/IId.cs index c160390..4e66768 100644 --- a/StudentEnrollment/StudentEnrollmentDataModels/IId.cs +++ b/StudentEnrollment/StudentEnrollmentDataModels/IId.cs @@ -2,6 +2,6 @@ { public interface IId { - long Id { get; } + int Id { get; } } } diff --git a/StudentEnrollment/StudentEnrollmentDataModels/Models/ICourseModel.cs b/StudentEnrollment/StudentEnrollmentDataModels/Models/ICourseModel.cs index 8114ee9..4784b82 100644 --- a/StudentEnrollment/StudentEnrollmentDataModels/Models/ICourseModel.cs +++ b/StudentEnrollment/StudentEnrollmentDataModels/Models/ICourseModel.cs @@ -3,6 +3,6 @@ public interface ICourseModel : IId { string CourseName { get; } - long FacultyId { get; } + int FacultyId { get; } } } diff --git a/StudentEnrollment/StudentEnrollmentDataModels/Models/IExamPointsModel.cs b/StudentEnrollment/StudentEnrollmentDataModels/Models/IExamPointsModel.cs index df1701e..575518a 100644 --- a/StudentEnrollment/StudentEnrollmentDataModels/Models/IExamPointsModel.cs +++ b/StudentEnrollment/StudentEnrollmentDataModels/Models/IExamPointsModel.cs @@ -4,6 +4,7 @@ { int FirstExamPoints { get; } int SecondExamPoints { get; } + int ThirdExamPoints { get; } int AddPoints { get; } int Summary { get; } } diff --git a/StudentEnrollment/StudentEnrollmentDataModels/Models/IStudentModel.cs b/StudentEnrollment/StudentEnrollmentDataModels/Models/IStudentModel.cs index f74c9ff..5dbd5be 100644 --- a/StudentEnrollment/StudentEnrollmentDataModels/Models/IStudentModel.cs +++ b/StudentEnrollment/StudentEnrollmentDataModels/Models/IStudentModel.cs @@ -6,8 +6,8 @@ string FirstName { get; } string MiddleName { get; } string Email { get; } - string TIN { get; } - long ExamPointsId { get; } - Dictionary StudentCourse { get; } + long TIN { get; } + int ExamPointsId { get; } + Dictionary StudentCourse { get; } } } diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/CourseStorage.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/CourseStorage.cs index c72392b..239b9c9 100644 --- a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/CourseStorage.cs +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/CourseStorage.cs @@ -1,9 +1,85 @@ -using StudentEnrollmentContracts.StorageContracts; +using Microsoft.EntityFrameworkCore; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.StorageContracts; +using StudentEnrollmentContracts.ViewModels; +using StudentEnrollmentDatabaseImplement.Models; namespace StudentEnrollmentDatabaseImplement.Implements { public class CourseStorage : ICourseStorage { - // TODO: Implement this - } + public List GetFullList() + { + using var context = new StudentEnrollmentDatabase(); + return context.course + .Include(x => x.Faculty) + .Select(x => x.GetViewModel) + .ToList(); + } + public List GetFilteredList(CourseSearchModel model) + { + if (string.IsNullOrEmpty(model.name)) + { + return new(); + } + using var context = new StudentEnrollmentDatabase(); + return context.course + .Include(x => x.Faculty) + .Where(x => (model.course_id.HasValue && x.course_id == model.course_id) || (string.IsNullOrEmpty(model.name) && x.name == model.name)) + .Select(x => x.GetViewModel) + .ToList(); + } + public CourseViewModel? GetElement(CourseSearchModel model) + { + if (string.IsNullOrEmpty(model.name) && !model.course_id.HasValue) + { + return null; + } + using var context = new StudentEnrollmentDatabase(); + return context.course + .Include(x => x.Faculty) + .FirstOrDefault(x => (model.course_id.HasValue && x.course_id == model.course_id) || (string.IsNullOrEmpty(model.name) && x.name == model.name))? + .GetViewModel; + } + public CourseViewModel? Insert(CourseBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var newCourse = Course.Create(model); + if (newCourse == null) + { + return null; + } + context.course.Add(newCourse); + context.SaveChanges(); + return context.course + .Include(x => x.Faculty) + .FirstOrDefault(x => x.course_id == newCourse.course_id)? + .GetViewModel; + } + public CourseViewModel? Update(CourseBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var course = context.course.Include(x => x.Faculty).FirstOrDefault(x => x.course_id == model.Id); + if (course == null) + { + return null; + } + course.Update(model); + context.SaveChanges(); + return course.GetViewModel; + } + public CourseViewModel? Delete(CourseBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var element = context.course.Include(x => x.Faculty).FirstOrDefault(rec => rec.course_id == model.Id); + if (element != null) + { + context.course.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } } diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/ExamPoints.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/ExamPoints.cs deleted file mode 100644 index c27c6bc..0000000 --- a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/ExamPoints.cs +++ /dev/null @@ -1,9 +0,0 @@ -using StudentEnrollmentContracts.StorageContracts; - -namespace StudentEnrollmentDatabaseImplement.Implements -{ - public class ExamPoints : IExamPointsStorage - { - // TODO: Implement this - } -} diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/ExamPointsStorage.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/ExamPointsStorage.cs new file mode 100644 index 0000000..584fbb7 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/ExamPointsStorage.cs @@ -0,0 +1,79 @@ +using Microsoft.EntityFrameworkCore; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.StorageContracts; +using StudentEnrollmentContracts.ViewModels; +using StudentEnrollmentDatabaseImplement.Models; + +namespace StudentEnrollmentDatabaseImplement.Implements +{ + public class ExamPointsStorage : IExamPointsStorage + { + public List GetFullList() + { + using var context = new StudentEnrollmentDatabase(); + return context.exampoints + .Select(x => x.GetViewModel) + .ToList(); + } + public List GetFilteredList(ExamPointsSearchModel model) + { + if (!model.exampoints_id.HasValue) + { + return new(); + } + using var context = new StudentEnrollmentDatabase(); + return context.exampoints + .Where(x => model.exampoints_id.HasValue && x.exampoints_id == model.exampoints_id) + .Select(x => x.GetViewModel) + .ToList(); + } + public ExamPointsViewModel? GetElement(ExamPointsSearchModel model) + { + if (!model.exampoints_id.HasValue) + { + return null; + } + using var context = new StudentEnrollmentDatabase(); + return context.exampoints + .FirstOrDefault(x => model.exampoints_id.HasValue && x.exampoints_id == model.exampoints_id)? + .GetViewModel; + } + public ExamPointsViewModel? Insert(ExamPointsBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var newExamPoints = ExamPoints.Create(model); + if (newExamPoints == null) + { + return null; + } + context.exampoints.Add(newExamPoints); + context.SaveChanges(); + return newExamPoints.GetViewModel; + } + public ExamPointsViewModel? Update(ExamPointsBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var examPoints = context.exampoints.FirstOrDefault(x => x.exampoints_id == model.Id); + if (examPoints == null) + { + return null; + } + examPoints.Update(model); + context.SaveChanges(); + return examPoints.GetViewModel; + } + public ExamPointsViewModel? Delete(ExamPointsBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var element = context.exampoints.FirstOrDefault(rec => rec.exampoints_id == model.Id); + if (element != null) + { + context.exampoints.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/FacultyStorage.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/FacultyStorage.cs index cb74514..a321e69 100644 --- a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/FacultyStorage.cs +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/FacultyStorage.cs @@ -1,12 +1,79 @@ -using StudentEnrollmentContracts.BindingModels; +using Microsoft.EntityFrameworkCore; +using StudentEnrollmentContracts.BindingModels; using StudentEnrollmentContracts.SearchModels; using StudentEnrollmentContracts.StorageContracts; using StudentEnrollmentContracts.ViewModels; +using StudentEnrollmentDatabaseImplement.Models; namespace StudentEnrollmentDatabaseImplement.Implements { public class FacultyStorage : IFacultyStorage { - // TODO: Implement this - } + public List GetFullList() + { + using var context = new StudentEnrollmentDatabase(); + return context.faculty + .Select(x => x.GetViewModel) + .ToList(); + } + public List GetFilteredList(FacultySearchModel model) + { + if (string.IsNullOrEmpty(model.name)) + { + return new(); + } + using var context = new StudentEnrollmentDatabase(); + return context.faculty + .Where(x => (model.faculty_id.HasValue && x.faculty_id == model.faculty_id) || (string.IsNullOrEmpty(model.name) && x.name == model.name)) + .Select(x => x.GetViewModel) + .ToList(); + } + public FacultyViewModel? GetElement(FacultySearchModel model) + { + if (string.IsNullOrEmpty(model.name) && !model.faculty_id.HasValue) + { + return null; + } + using var context = new StudentEnrollmentDatabase(); + return context.faculty + .FirstOrDefault(x => (model.faculty_id.HasValue && x.faculty_id == model.faculty_id) || (string.IsNullOrEmpty(model.name) && x.name == model.name))? + .GetViewModel; + } + public FacultyViewModel? Insert(FacultyBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var newFaculty = Faculty.Create(model); + if (newFaculty == null) + { + return null; + } + context.faculty.Add(newFaculty); + context.SaveChanges(); + return newFaculty.GetViewModel; + } + public FacultyViewModel? Update(FacultyBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var faculty = context.faculty.FirstOrDefault(x => x.faculty_id == model.Id); + if (faculty == null) + { + return null; + } + faculty.Update(model); + context.SaveChanges(); + return faculty.GetViewModel; + } + public FacultyViewModel? Delete(FacultyBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var element = context.faculty.FirstOrDefault(rec => rec.faculty_id == model.Id); + if (element != null) + { + context.faculty.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } } diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/StudentStorage.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/StudentStorage.cs index 04ae528..bca9112 100644 --- a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/StudentStorage.cs +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Implements/StudentStorage.cs @@ -1,9 +1,82 @@ -using StudentEnrollmentContracts.StorageContracts; +using Microsoft.EntityFrameworkCore; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentContracts.StorageContracts; +using StudentEnrollmentContracts.ViewModels; +using StudentEnrollmentDatabaseImplement.Models; namespace StudentEnrollmentDatabaseImplement.Implements { public class StudentStorage : IStudentStorage { - // TODO: Implement this - } + public List GetFullList() + { + using var context = new StudentEnrollmentDatabase(); + return context.student + .Include(x => x.ExamPoints) + .Select(x => x.GetViewModel) + .ToList(); + } + public List GetFilteredList(StudentSearchModel model) + { + if (model.tin == 0) + { + return new(); + } + using var context = new StudentEnrollmentDatabase(); + return context.student + .Include(x => x.ExamPoints) + .Where(x => (model.student_id.HasValue && x.student_id == model.student_id) || (model.tin == 0 && x.tin == model.tin)) + .Select(x => x.GetViewModel) + .ToList(); + } + public StudentViewModel? GetElement(StudentSearchModel model) + { + if (model.tin == 0 && !model.student_id.HasValue) + { + return null; + } + using var context = new StudentEnrollmentDatabase(); + return context.student + .Include(x => x.ExamPoints) + .FirstOrDefault(x => (model.student_id.HasValue && x.student_id == model.student_id) || (model.tin == 0 && x.tin == model.tin))? + .GetViewModel; + } + public StudentViewModel? Insert(StudentBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var newStudent = Student.Create(context, model); + if (newStudent == null) + { + return null; + } + context.student.Add(newStudent); + context.SaveChanges(); + return context.student.Include(x => x.ExamPoints).FirstOrDefault(x => x.student_id == newStudent.student_id)?.GetViewModel; + } + public StudentViewModel? Update(StudentBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var student = context.student.FirstOrDefault(x => x.student_id == model.Id); + if (student == null) + { + return null; + } + student.Update(model); + context.SaveChanges(); + return student.GetViewModel; + } + public StudentViewModel? Delete(StudentBindingModel model) + { + using var context = new StudentEnrollmentDatabase(); + var element = context.student.FirstOrDefault(rec => rec.student_id == model.Id); + if (element != null) + { + context.student.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } } diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/20240506162134_InitCreate.Designer.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/20240506162134_InitCreate.Designer.cs new file mode 100644 index 0000000..b8f7fd4 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/20240506162134_InitCreate.Designer.cs @@ -0,0 +1,213 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using StudentEnrollmentDatabaseImplement; + +#nullable disable + +namespace StudentEnrollmentDatabaseImplement.Migrations +{ + [DbContext(typeof(StudentEnrollmentDatabase))] + [Migration("20240506162134_InitCreate")] + partial class InitCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.18") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Course", b => + { + b.Property("course_id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("course_id")); + + b.Property("facultyid") + .HasColumnType("integer"); + + b.Property("name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("course_id"); + + b.HasIndex("facultyid"); + + b.ToTable("course"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.ExamPoints", b => + { + b.Property("exampoints_id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("exampoints_id")); + + b.Property("addpoints") + .HasColumnType("integer"); + + b.Property("firstexampoints") + .HasColumnType("integer"); + + b.Property("secondexampoints") + .HasColumnType("integer"); + + b.Property("summary") + .HasColumnType("integer"); + + b.Property("thirdexampoints") + .HasColumnType("integer"); + + b.HasKey("exampoints_id"); + + b.ToTable("exampoints"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Faculty", b => + { + b.Property("faculty_id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("faculty_id")); + + b.Property("name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("faculty_id"); + + b.ToTable("faculty"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Student", b => + { + b.Property("student_id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("student_id")); + + b.Property("email") + .IsRequired() + .HasColumnType("text"); + + b.Property("exampointsid") + .HasColumnType("integer"); + + b.Property("firstname") + .IsRequired() + .HasColumnType("text"); + + b.Property("lastname") + .IsRequired() + .HasColumnType("text"); + + b.Property("middlename") + .IsRequired() + .HasColumnType("text"); + + b.Property("tin") + .HasColumnType("bigint"); + + b.HasKey("student_id"); + + b.HasIndex("exampointsid"); + + b.ToTable("student"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.StudentCourse", b => + { + b.Property("student_course_id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("student_course_id")); + + b.Property("CourseId") + .HasColumnType("integer"); + + b.Property("StudentId") + .HasColumnType("integer"); + + b.Property("courseid") + .HasColumnType("integer"); + + b.Property("studentid") + .HasColumnType("integer"); + + b.HasKey("student_course_id"); + + b.HasIndex("CourseId"); + + b.HasIndex("StudentId"); + + b.ToTable("student_course"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Course", b => + { + b.HasOne("StudentEnrollmentDatabaseImplement.Models.Faculty", "Faculty") + .WithMany() + .HasForeignKey("facultyid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Faculty"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Student", b => + { + b.HasOne("StudentEnrollmentDatabaseImplement.Models.ExamPoints", "ExamPoints") + .WithMany() + .HasForeignKey("exampointsid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ExamPoints"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.StudentCourse", b => + { + b.HasOne("StudentEnrollmentDatabaseImplement.Models.Course", "Course") + .WithMany("StudentCourses") + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("StudentEnrollmentDatabaseImplement.Models.Student", "Student") + .WithMany("Courses") + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Course", b => + { + b.Navigation("StudentCourses"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Student", b => + { + b.Navigation("Courses"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/20240506162134_InitCreate.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/20240506162134_InitCreate.cs new file mode 100644 index 0000000..ee26827 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/20240506162134_InitCreate.cs @@ -0,0 +1,156 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace StudentEnrollmentDatabaseImplement.Migrations +{ + /// + public partial class InitCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "exampoints", + columns: table => new + { + exampoints_id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + firstexampoints = table.Column(type: "integer", nullable: false), + secondexampoints = table.Column(type: "integer", nullable: false), + thirdexampoints = table.Column(type: "integer", nullable: false), + addpoints = table.Column(type: "integer", nullable: false), + summary = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_exampoints", x => x.exampoints_id); + }); + + migrationBuilder.CreateTable( + name: "faculty", + columns: table => new + { + faculty_id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_faculty", x => x.faculty_id); + }); + + migrationBuilder.CreateTable( + name: "student", + columns: table => new + { + student_id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + firstname = table.Column(type: "text", nullable: false), + lastname = table.Column(type: "text", nullable: false), + middlename = table.Column(type: "text", nullable: false), + email = table.Column(type: "text", nullable: false), + tin = table.Column(type: "bigint", nullable: false), + exampointsid = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_student", x => x.student_id); + table.ForeignKey( + name: "FK_student_exampoints_exampointsid", + column: x => x.exampointsid, + principalTable: "exampoints", + principalColumn: "exampoints_id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "course", + columns: table => new + { + course_id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + name = table.Column(type: "text", nullable: false), + facultyid = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_course", x => x.course_id); + table.ForeignKey( + name: "FK_course_faculty_facultyid", + column: x => x.facultyid, + principalTable: "faculty", + principalColumn: "faculty_id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "student_course", + columns: table => new + { + student_course_id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + studentid = table.Column(type: "integer", nullable: false), + courseid = table.Column(type: "integer", nullable: false), + StudentId = table.Column(type: "integer", nullable: false), + CourseId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_student_course", x => x.student_course_id); + table.ForeignKey( + name: "FK_student_course_course_CourseId", + column: x => x.CourseId, + principalTable: "course", + principalColumn: "course_id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_student_course_student_StudentId", + column: x => x.StudentId, + principalTable: "student", + principalColumn: "student_id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_course_facultyid", + table: "course", + column: "facultyid"); + + migrationBuilder.CreateIndex( + name: "IX_student_exampointsid", + table: "student", + column: "exampointsid"); + + migrationBuilder.CreateIndex( + name: "IX_student_course_CourseId", + table: "student_course", + column: "CourseId"); + + migrationBuilder.CreateIndex( + name: "IX_student_course_StudentId", + table: "student_course", + column: "StudentId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "student_course"); + + migrationBuilder.DropTable( + name: "course"); + + migrationBuilder.DropTable( + name: "student"); + + migrationBuilder.DropTable( + name: "faculty"); + + migrationBuilder.DropTable( + name: "exampoints"); + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/StudentEnrollmentDatabaseModelSnapshot.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/StudentEnrollmentDatabaseModelSnapshot.cs new file mode 100644 index 0000000..cf2a5c7 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Migrations/StudentEnrollmentDatabaseModelSnapshot.cs @@ -0,0 +1,210 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using StudentEnrollmentDatabaseImplement; + +#nullable disable + +namespace StudentEnrollmentDatabaseImplement.Migrations +{ + [DbContext(typeof(StudentEnrollmentDatabase))] + partial class StudentEnrollmentDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.18") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Course", b => + { + b.Property("course_id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("course_id")); + + b.Property("facultyid") + .HasColumnType("integer"); + + b.Property("name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("course_id"); + + b.HasIndex("facultyid"); + + b.ToTable("course"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.ExamPoints", b => + { + b.Property("exampoints_id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("exampoints_id")); + + b.Property("addpoints") + .HasColumnType("integer"); + + b.Property("firstexampoints") + .HasColumnType("integer"); + + b.Property("secondexampoints") + .HasColumnType("integer"); + + b.Property("summary") + .HasColumnType("integer"); + + b.Property("thirdexampoints") + .HasColumnType("integer"); + + b.HasKey("exampoints_id"); + + b.ToTable("exampoints"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Faculty", b => + { + b.Property("faculty_id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("faculty_id")); + + b.Property("name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("faculty_id"); + + b.ToTable("faculty"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Student", b => + { + b.Property("student_id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("student_id")); + + b.Property("email") + .IsRequired() + .HasColumnType("text"); + + b.Property("exampointsid") + .HasColumnType("integer"); + + b.Property("firstname") + .IsRequired() + .HasColumnType("text"); + + b.Property("lastname") + .IsRequired() + .HasColumnType("text"); + + b.Property("middlename") + .IsRequired() + .HasColumnType("text"); + + b.Property("tin") + .HasColumnType("bigint"); + + b.HasKey("student_id"); + + b.HasIndex("exampointsid"); + + b.ToTable("student"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.StudentCourse", b => + { + b.Property("student_course_id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("student_course_id")); + + b.Property("CourseId") + .HasColumnType("integer"); + + b.Property("StudentId") + .HasColumnType("integer"); + + b.Property("courseid") + .HasColumnType("integer"); + + b.Property("studentid") + .HasColumnType("integer"); + + b.HasKey("student_course_id"); + + b.HasIndex("CourseId"); + + b.HasIndex("StudentId"); + + b.ToTable("student_course"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Course", b => + { + b.HasOne("StudentEnrollmentDatabaseImplement.Models.Faculty", "Faculty") + .WithMany() + .HasForeignKey("facultyid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Faculty"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Student", b => + { + b.HasOne("StudentEnrollmentDatabaseImplement.Models.ExamPoints", "ExamPoints") + .WithMany() + .HasForeignKey("exampointsid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ExamPoints"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.StudentCourse", b => + { + b.HasOne("StudentEnrollmentDatabaseImplement.Models.Course", "Course") + .WithMany("StudentCourses") + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("StudentEnrollmentDatabaseImplement.Models.Student", "Student") + .WithMany("Courses") + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Course", b => + { + b.Navigation("StudentCourses"); + }); + + modelBuilder.Entity("StudentEnrollmentDatabaseImplement.Models.Student", b => + { + b.Navigation("Courses"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Course.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Course.cs index a662616..4c68ffd 100644 --- a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Course.cs +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Course.cs @@ -6,17 +6,17 @@ using System.ComponentModel.DataAnnotations.Schema; namespace StudentEnrollmentDatabaseImplement.Models { - public class Course : ICourseModel + public class Course // : ICourseModel { - public long Id { get; private set; } + [Key] + public int course_id { get; private set; } [Required] - public string CourseName { get; private set; } = string.Empty; + public string name { get; private set; } = string.Empty; [Required] - public long FacultyId { get; private set; } - - [ForeignKey("CourseId")] + public int facultyid { get; private set; } + public virtual Faculty Faculty { get; set; } + [ForeignKey("CourseId")] public virtual List StudentCourses { get; set; } = new(); - public static Course? Create(CourseBindingModel model) { if (model == null) @@ -25,9 +25,9 @@ namespace StudentEnrollmentDatabaseImplement.Models } return new Course() { - Id = model.Id, - CourseName = model.CourseName, - FacultyId = model.FacultyId, + course_id = model.Id, + name = model.CourseName, + facultyid = model.FacultyId, }; } public void Update(CourseBindingModel model) @@ -36,14 +36,15 @@ namespace StudentEnrollmentDatabaseImplement.Models { return; } - CourseName = model.CourseName; - FacultyId = model.FacultyId; + name = model.CourseName; + facultyid = model.FacultyId; } public CourseViewModel GetViewModel => new() { - Id = Id, - CourseName = CourseName, - FacultyId = FacultyId, + Id = course_id, + CourseName = name, + FacultyId = facultyid, + FacultyName = Faculty.name, }; } } diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/ExamPoints.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/ExamPoints.cs index 46c15d1..10d92a6 100644 --- a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/ExamPoints.cs +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/ExamPoints.cs @@ -1,33 +1,35 @@ using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.ViewModels; using StudentEnrollmentDataModels.Models; using System.ComponentModel.DataAnnotations; namespace StudentEnrollmentDatabaseImplement.Models { - public class ExamPoints : IExamPointsModel + public class ExamPoints //: IExamPointsModel { - public long Id { get; private set; } + [Key] + public int exampoints_id { get; private set; } [Required] - public int FirstExamPoints { get; private set; } + public int firstexampoints { get; private set; } [Required] - public int SecondExamPoints { get; private set; } + public int secondexampoints { get; private set; } [Required] - public int ThirdExamPoints { get; private set; } - public int AddPoints { get; private set; } - public int Summary { get; private set; } + public int thirdexampoints { get; private set; } + public int addpoints { get; private set; } + public int summary { get; private set; } public static ExamPoints? Create(ExamPointsBindingModel model) { - if (model == null) { - return null; + if (model == null) { + return null; } return new ExamPoints() { - Id = model.Id, - FirstExamPoints = model.FirstExamPoints, - SecondExamPoints = model.SecondExamPoints, - ThirdExamPoints = model.ThirdExamPoints, - AddPoints = model.AddPoints, - Summary = model.Summary, + exampoints_id = model.Id, + firstexampoints = model.FirstExamPoints, + secondexampoints = model.SecondExamPoints, + thirdexampoints = model.ThirdExamPoints, + addpoints = model.AddPoints, + summary = model.FirstExamPoints + model.SecondExamPoints + model.ThirdExamPoints + model.AddPoints, }; } public void Update(ExamPointsBindingModel model) @@ -36,8 +38,19 @@ namespace StudentEnrollmentDatabaseImplement.Models { return; } - AddPoints = model.AddPoints; - Summary = model.Summary; - } + summary -= addpoints; + addpoints = model.AddPoints; + summary += model.AddPoints; + } + + public ExamPointsViewModel GetViewModel => new() + { + Id = exampoints_id, + FirstExamPoints = firstexampoints, + SecondExamPoints = secondexampoints, + ThirdExamPoints = thirdexampoints, + AddPoints = addpoints, + Summary = summary, + }; } } diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Faculty.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Faculty.cs index 3a67287..22d26ab 100644 --- a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Faculty.cs +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Faculty.cs @@ -5,19 +5,20 @@ using System.ComponentModel.DataAnnotations; namespace StudentEnrollmentDatabaseImplement.Models { - public class Faculty : IFacultyModel + public class Faculty // : IFacultyModel { - public long Id { get; private set; } + [Key] + public int faculty_id { get; private set; } [Required] - public string FacultyName { get; private set;} = string.Empty; + public string name { get; private set;} = string.Empty; public static Faculty? Create(FacultyBindingModel model) { if (model == null) return null; return new Faculty() { - Id = model.Id, - FacultyName = model.FacultyName, + faculty_id = model.Id, + name = model.FacultyName, }; } @@ -25,13 +26,13 @@ namespace StudentEnrollmentDatabaseImplement.Models { if (model == null) return; - FacultyName = model.FacultyName; + name = model.FacultyName; } public FacultyViewModel GetViewModel => new() { - Id = Id, - FacultyName = FacultyName, + Id = faculty_id, + FacultyName = name, }; } } diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Student.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Student.cs index b8bcc88..b6132e6 100644 --- a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Student.cs +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/Student.cs @@ -1,32 +1,35 @@ using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.ViewModels; using StudentEnrollmentDataModels.Models; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace StudentEnrollmentDatabaseImplement.Models { - public class Student : IStudentModel + public class Student //: IStudentModel { - public long Id { get; private set; } + [Key] + public int student_id { get; private set; } [Required] - public string FirstName { get; private set; } = string.Empty; + public string firstname { get; private set; } = string.Empty; [Required] - public string LastName { get; private set; } = string.Empty; - public string MiddleName { get; private set; } = string.Empty; + public string lastname { get; private set; } = string.Empty; + public string middlename { get; private set; } = string.Empty; [Required] - public string Email { get; private set; } = string.Empty; + public string email { get; private set; } = string.Empty; [Required] - public string TIN { get; private set; } = string.Empty; + public long tin { get; private set; } [Required] - public long ExamPointsId { get; private set; } - private Dictionary? _StudentCourse = null; - public Dictionary StudentCourse + public int exampointsid { get; private set; } + public virtual ExamPoints ExamPoints { get; private set; } + private Dictionary? _StudentCourse = null; + public Dictionary StudentCourse { get { if (_StudentCourse == null) { - _StudentCourse = Courses.ToDictionary(SC => SC.CourseId, + _StudentCourse = Courses.ToDictionary(SC => SC.courseid, SC => SC.Course as ICourseModel); } return _StudentCourse; @@ -34,7 +37,6 @@ namespace StudentEnrollmentDatabaseImplement.Models } [ForeignKey("StudentId")] public virtual List Courses { get; set; } = new(); - public static Student? Create(StudentEnrollmentDatabase context,StudentBindingModel model) { if (model == null) @@ -43,18 +45,42 @@ namespace StudentEnrollmentDatabaseImplement.Models } return new Student() { - Id = model.Id, - FirstName = model.FirstName, - LastName = model.LastName, - MiddleName = model.MiddleName, - Email = model.Email, - TIN = model.TIN, + student_id = model.Id, + firstname = model.FirstName, + lastname = model.LastName, + middlename = model.MiddleName, + email = model.Email, + tin = model.TIN, Courses = model.StudentCourse.Select(x => new StudentCourse { - Course = context.Courses.First(y => y.Id == x.Key) + Course = context.course.First(y => y.course_id == x.Key) } ).ToList(), }; } + public void Update(StudentBindingModel model) + { + if (model == null) + { + return; + } + firstname = model.FirstName; + lastname = model.LastName; + middlename = model.MiddleName; + tin = model.TIN; + email = model.Email; + } + + public StudentViewModel GetViewModel => new() + { + Id = student_id, + FirstName = firstname, + LastName = lastname, + MiddleName = middlename, + TIN = tin, + Email = email, + ExamPointsId = exampointsid, + ExamPoints = ExamPoints.summary, + }; } } diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/StudentCourse.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/StudentCourse.cs index 28d90d7..25f17d8 100644 --- a/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/StudentCourse.cs +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/Models/StudentCourse.cs @@ -4,11 +4,12 @@ namespace StudentEnrollmentDatabaseImplement.Models { public class StudentCourse { - public long Id { get; set; } + [Key] + public int student_course_id { get; set; } [Required] - public long StudentId { get; set; } + public int studentid { get; set; } [Required] - public long CourseId { get; set; } + public int courseid { get; set; } public virtual Student Student { get; set; } = new(); public virtual Course Course { get; set; } = new(); } diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/StudentEnrollmentDatabase.cs b/StudentEnrollment/StudentEnrollmentDatabaseImplement/StudentEnrollmentDatabase.cs index 23f2b81..02b36d5 100644 --- a/StudentEnrollment/StudentEnrollmentDatabaseImplement/StudentEnrollmentDatabase.cs +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/StudentEnrollmentDatabase.cs @@ -9,17 +9,17 @@ namespace StudentEnrollmentDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseNpgsql(@"Host=localhost;Database=StudentEnrollmentDatabase;Username=postgres;Password=postgres"); + optionsBuilder.UseNpgsql(@"Host=192.168.56.103;Database=postgres;Username=postgres;Password=postgres"); } base.OnConfiguring(optionsBuilder); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); AppContext.SetSwitch("Npgsql.DisableDataTimeInfinityConversions", true); } - public virtual DbSet Faculties { get; set; } - public virtual DbSet Courses { get; set; } - public virtual DbSet Students { get; set; } - public virtual DbSet StudentCourses { get; set; } - public virtual DbSet ExamPointes { get; set; } + public virtual DbSet faculty { get; set; } + public virtual DbSet course { get; set; } + public virtual DbSet student { get; set; } + public virtual DbSet student_course { get; set; } + public virtual DbSet exampoints { get; set; } } } diff --git a/StudentEnrollment/StudentEnrollmentDatabaseImplement/StudentEnrollmentDatabaseImplement.csproj b/StudentEnrollment/StudentEnrollmentDatabaseImplement/StudentEnrollmentDatabaseImplement.csproj index 7f7ba89..2648478 100644 --- a/StudentEnrollment/StudentEnrollmentDatabaseImplement/StudentEnrollmentDatabaseImplement.csproj +++ b/StudentEnrollment/StudentEnrollmentDatabaseImplement/StudentEnrollmentDatabaseImplement.csproj @@ -7,7 +7,13 @@ - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/StudentEnrollment/StudentEnrollmentView/FormCourse.Designer.cs b/StudentEnrollment/StudentEnrollmentView/FormCourse.Designer.cs new file mode 100644 index 0000000..9c51141 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormCourse.Designer.cs @@ -0,0 +1,125 @@ +namespace StudentEnrollmentView +{ + partial class FormCourse + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + comboBoxFaculty = new ComboBox(); + label2 = new Label(); + textBoxName = new TextBox(); + buttonCancel = new Button(); + buttonAdd = new Button(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(9, 20); + label1.Name = "label1"; + label1.Size = new Size(81, 20); + label1.TabIndex = 4; + label1.Text = "Факультет:"; + // + // comboBoxFaculty + // + comboBoxFaculty.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxFaculty.FormattingEnabled = true; + comboBoxFaculty.Location = new Point(101, 16); + comboBoxFaculty.Margin = new Padding(3, 4, 3, 4); + comboBoxFaculty.Name = "comboBoxFaculty"; + comboBoxFaculty.Size = new Size(285, 28); + comboBoxFaculty.TabIndex = 3; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(9, 64); + label2.Name = "label2"; + label2.Size = new Size(80, 20); + label2.TabIndex = 6; + label2.Text = "Название:"; + // + // textBoxName + // + textBoxName.Location = new Point(102, 60); + textBoxName.Margin = new Padding(3, 4, 3, 4); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(285, 27); + textBoxName.TabIndex = 5; + // + // buttonCancel + // + buttonCancel.Location = new Point(320, 112); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(98, 31); + buttonCancel.TabIndex = 10; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(215, 112); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 31); + buttonAdd.TabIndex = 9; + buttonAdd.Text = "Сохранить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonSave_Click; + // + // FormCourse + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(433, 160); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(label2); + Controls.Add(textBoxName); + Controls.Add(label1); + Controls.Add(comboBoxFaculty); + Margin = new Padding(3, 4, 3, 4); + Name = "FormCourse"; + Text = "Направление"; + Load += FormCourse_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private ComboBox comboBoxFaculty; + private Label label2; + private TextBox textBoxName; + private Button buttonCancel; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormCourse.cs b/StudentEnrollment/StudentEnrollmentView/FormCourse.cs new file mode 100644 index 0000000..cd39319 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormCourse.cs @@ -0,0 +1,83 @@ +using Microsoft.Extensions.Logging; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.BusinessLogicContracts; + +namespace StudentEnrollmentView +{ + public partial class FormCourse : Form + { + private readonly ILogger _logger; + private readonly IFacultyLogic _logicF; + private readonly ICourseLogic _logicC; + private int? _id; + public int Id { set { _id = value; } } + public FormCourse(ILogger logger, IFacultyLogic logicF, ICourseLogic logicC) + { + InitializeComponent(); + _logger = logger; + _logicF = logicF; + _logicC = logicC; + } + private void FormCourse_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка факультетов для направления"); + try + { + var _list = _logicF.ReadList(null); + if (_list != null) + { + comboBoxFaculty.DisplayMember = "FacultyName"; + comboBoxFaculty.ValueMember = "Id"; + comboBoxFaculty.DataSource = _list; + comboBoxFaculty.SelectedItem = null; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки факультетов для направления"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните поле название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxFaculty.SelectedValue == null) + { + MessageBox.Show("Выберите факультет", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание направления"); + try + { + var operationResult = _logicC.Create(new CourseBindingModel + { + Id = _id ?? 0, + CourseName = textBoxName.Text, + FacultyId = Convert.ToInt32(comboBoxFaculty.SelectedValue) + }); + if (!operationResult) + { + throw new Exception("Ошибка при создании направления. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания направления"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentView/FormCourse.resx b/StudentEnrollment/StudentEnrollmentView/FormCourse.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormCourse.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormCourses.Designer.cs b/StudentEnrollment/StudentEnrollmentView/FormCourses.Designer.cs new file mode 100644 index 0000000..b31d466 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormCourses.Designer.cs @@ -0,0 +1,114 @@ +namespace StudentEnrollmentView +{ + partial class FormCourses + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + buttonAdd = new Button(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonRef = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.BackgroundColor = Color.White; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 12); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(240, 426); + dataGridView.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.Location = new Point(283, 24); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(103, 28); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonUpd + // + buttonUpd.Location = new Point(283, 58); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(103, 28); + buttonUpd.TabIndex = 2; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonDel + // + buttonDel.Location = new Point(283, 92); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(103, 28); + buttonDel.TabIndex = 3; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonRef + // + buttonRef.Location = new Point(283, 126); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(103, 28); + buttonRef.TabIndex = 4; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += ButtonRef_Click; + // + // FormCourses + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(438, 450); + Controls.Add(buttonRef); + Controls.Add(buttonDel); + Controls.Add(buttonUpd); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Name = "FormCourses"; + Text = "Направления"; + Load += FormCourses_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private Button buttonRef; + } +} \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormCourses.cs b/StudentEnrollment/StudentEnrollmentView/FormCourses.cs new file mode 100644 index 0000000..c4ce72e --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormCourses.cs @@ -0,0 +1,101 @@ +using Microsoft.Extensions.Logging; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.BusinessLogicContracts; + +namespace StudentEnrollmentView +{ + public partial class FormCourses : Form + { + private readonly ILogger _logger; + private readonly ICourseLogic _logic; + public FormCourses(ILogger logger, ICourseLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormCourses_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["FacultyId"].Visible = false; + } + _logger.LogInformation("Загрузка направлений"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки направлений"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCourse)); + if (service is FormCourse form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCourse)); + if (service is FormCourse form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление направления"); + try + { + if (!_logic.Delete(new CourseBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления направления"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentView/FormCourses.resx b/StudentEnrollment/StudentEnrollmentView/FormCourses.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormCourses.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormExamPoints.Designer.cs b/StudentEnrollment/StudentEnrollmentView/FormExamPoints.Designer.cs new file mode 100644 index 0000000..112bef9 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormExamPoints.Designer.cs @@ -0,0 +1,167 @@ +namespace StudentEnrollmentView +{ + partial class FormExamPoints + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label2 = new Label(); + textBoxFirstExamPoints = new TextBox(); + label1 = new Label(); + textBoxSecondExamPoints = new TextBox(); + label3 = new Label(); + textBoxThirdExamPoints = new TextBox(); + label4 = new Label(); + textBoxAddPoints = new TextBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + SuspendLayout(); + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 31); + label2.Name = "label2"; + label2.Size = new Size(129, 20); + label2.TabIndex = 7; + label2.Text = "Первый экзамен:"; + // + // textBoxFirstExamPoints + // + textBoxFirstExamPoints.Location = new Point(180, 28); + textBoxFirstExamPoints.Margin = new Padding(3, 4, 3, 4); + textBoxFirstExamPoints.Name = "textBoxFirstExamPoints"; + textBoxFirstExamPoints.Size = new Size(285, 27); + textBoxFirstExamPoints.TabIndex = 6; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 79); + label1.Name = "label1"; + label1.Size = new Size(124, 20); + label1.TabIndex = 9; + label1.Text = "Второй экзамен:"; + // + // textBoxSecondExamPoints + // + textBoxSecondExamPoints.Location = new Point(180, 76); + textBoxSecondExamPoints.Margin = new Padding(3, 4, 3, 4); + textBoxSecondExamPoints.Name = "textBoxSecondExamPoints"; + textBoxSecondExamPoints.Size = new Size(285, 27); + textBoxSecondExamPoints.TabIndex = 8; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(12, 131); + label3.Name = "label3"; + label3.Size = new Size(122, 20); + label3.TabIndex = 11; + label3.Text = "Третий экзамен:"; + // + // textBoxThirdExamPoints + // + textBoxThirdExamPoints.Location = new Point(180, 128); + textBoxThirdExamPoints.Margin = new Padding(3, 4, 3, 4); + textBoxThirdExamPoints.Name = "textBoxThirdExamPoints"; + textBoxThirdExamPoints.Size = new Size(285, 27); + textBoxThirdExamPoints.TabIndex = 10; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(12, 183); + label4.Name = "label4"; + label4.Size = new Size(91, 20); + label4.TabIndex = 13; + label4.Text = "Доп. баллы:"; + // + // textBoxAddPoints + // + textBoxAddPoints.Location = new Point(180, 180); + textBoxAddPoints.Margin = new Padding(3, 4, 3, 4); + textBoxAddPoints.Name = "textBoxAddPoints"; + textBoxAddPoints.Size = new Size(285, 27); + textBoxAddPoints.TabIndex = 12; + // + // buttonCancel + // + buttonCancel.Location = new Point(352, 258); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(119, 37); + buttonCancel.TabIndex = 15; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(226, 258); + buttonSave.Margin = new Padding(3, 4, 3, 4); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(119, 37); + buttonSave.TabIndex = 14; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // FormExamPoints + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(494, 308); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(label4); + Controls.Add(textBoxAddPoints); + Controls.Add(label3); + Controls.Add(textBoxThirdExamPoints); + Controls.Add(label1); + Controls.Add(textBoxSecondExamPoints); + Controls.Add(label2); + Controls.Add(textBoxFirstExamPoints); + Name = "FormExamPoints"; + Text = "Баллы за экзамены"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label2; + private TextBox textBoxFirstExamPoints; + private Label label1; + private TextBox textBoxSecondExamPoints; + private Label label3; + private TextBox textBoxThirdExamPoints; + private Label label4; + private TextBox textBoxAddPoints; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormExamPoints.cs b/StudentEnrollment/StudentEnrollmentView/FormExamPoints.cs new file mode 100644 index 0000000..9f1d6f3 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormExamPoints.cs @@ -0,0 +1,61 @@ +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.BusinessLogicContracts; +using StudentEnrollmentDataModels.Models; + +namespace StudentEnrollmentView +{ + public partial class FormExamPoints : Form + { + public int? Id { get; set; } + public IExamPointsModel ExamPoints { get; } + private IExamPointsLogic _logic; + public FormExamPoints(IExamPointsLogic logic) + { + _logic = logic; + InitializeComponent(); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxFirstExamPoints.Text)) + { + MessageBox.Show("Заполните баллы за первый экзамен", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxSecondExamPoints.Text)) + { + MessageBox.Show("Заполните баллы за второй экзамен", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var model = new ExamPointsBindingModel + { + Id = Id ?? 0, + FirstExamPoints = Convert.ToInt32(textBoxFirstExamPoints.Text), + SecondExamPoints = Convert.ToInt32(textBoxSecondExamPoints.Text), + ThirdExamPoints = Convert.ToInt32(textBoxThirdExamPoints.Text), + AddPoints = Convert.ToInt32(textBoxAddPoints.Text), + }; + var operationResult = _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentView/FormExamPoints.resx b/StudentEnrollment/StudentEnrollmentView/FormExamPoints.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormExamPoints.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormFaculties.Designer.cs b/StudentEnrollment/StudentEnrollmentView/FormFaculties.Designer.cs new file mode 100644 index 0000000..f72abda --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormFaculties.Designer.cs @@ -0,0 +1,114 @@ +namespace StudentEnrollmentView +{ + partial class FormFaculties + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + buttonAdd = new Button(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonRef = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.BackgroundColor = Color.White; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 12); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(240, 426); + dataGridView.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.Location = new Point(283, 24); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(103, 28); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonUpd + // + buttonUpd.Location = new Point(283, 58); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(103, 28); + buttonUpd.TabIndex = 2; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonDel + // + buttonDel.Location = new Point(283, 92); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(103, 28); + buttonDel.TabIndex = 3; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonRef + // + buttonRef.Location = new Point(283, 126); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(103, 28); + buttonRef.TabIndex = 4; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += ButtonRef_Click; + // + // FormComponents + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(438, 450); + Controls.Add(buttonRef); + Controls.Add(buttonDel); + Controls.Add(buttonUpd); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Name = "FormFaculties"; + Text = "Факультеты"; + Load += FormFaculties_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private Button buttonRef; + } +} \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormFaculties.cs b/StudentEnrollment/StudentEnrollmentView/FormFaculties.cs new file mode 100644 index 0000000..280dfc7 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormFaculties.cs @@ -0,0 +1,102 @@ +using Microsoft.Extensions.Logging; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.BusinessLogicContracts; + +namespace StudentEnrollmentView +{ + public partial class FormFaculties : Form + { + private readonly ILogger _logger; + private readonly IFacultyLogic _logic; + public FormFaculties(ILogger logger, IFacultyLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormFaculties_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["FacultyName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка факультетов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки факультетов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormFaculty)); + if (service is FormFaculty form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormFaculty)); + if (service is FormFaculty form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление факультета"); + try + { + if (!_logic.Delete(new FacultyBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления факультета"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentView/FormFaculties.resx b/StudentEnrollment/StudentEnrollmentView/FormFaculties.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormFaculties.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormFaculty.Designer.cs b/StudentEnrollment/StudentEnrollmentView/FormFaculty.Designer.cs new file mode 100644 index 0000000..decb7df --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormFaculty.Designer.cs @@ -0,0 +1,100 @@ +namespace StudentEnrollmentView +{ + partial class FormFaculty + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + textBoxName = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(31, 20); + label1.Name = "label1"; + label1.Size = new Size(80, 20); + label1.TabIndex = 3; + label1.Text = "Название:"; + // + // textBoxName + // + textBoxName.Location = new Point(129, 17); + textBoxName.Margin = new Padding(3, 4, 3, 4); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(243, 27); + textBoxName.TabIndex = 2; + // + // buttonSave + // + buttonSave.Location = new Point(184, 73); + buttonSave.Margin = new Padding(3, 4, 3, 4); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(95, 31); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(286, 73); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormFaculty + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(391, 126); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(label1); + Controls.Add(textBoxName); + Margin = new Padding(3, 4, 3, 4); + Name = "FormFaculty"; + Text = "Факультет"; + Load += FormFaculty_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private TextBox textBoxName; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormFaculty.cs b/StudentEnrollment/StudentEnrollmentView/FormFaculty.cs new file mode 100644 index 0000000..dcbc8f7 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormFaculty.cs @@ -0,0 +1,79 @@ +using Microsoft.Extensions.Logging; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.BusinessLogicContracts; +using StudentEnrollmentContracts.SearchModels; + +namespace StudentEnrollmentView +{ + public partial class FormFaculty : Form + { + private readonly ILogger _logger; + private readonly IFacultyLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + public FormFaculty(ILogger logger, IFacultyLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormFaculty_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение факультета"); + var view = _logic.ReadElement(new FacultySearchModel + { + faculty_id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.FacultyName; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения факультета"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение факультета"); + try + { + var model = new FacultyBindingModel + { + Id = _id ?? 0, + FacultyName = textBoxName.Text, + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения факультета"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentView/FormFaculty.resx b/StudentEnrollment/StudentEnrollmentView/FormFaculty.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormFaculty.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormMain.Designer.cs b/StudentEnrollment/StudentEnrollmentView/FormMain.Designer.cs new file mode 100644 index 0000000..18f6847 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormMain.Designer.cs @@ -0,0 +1,130 @@ +namespace StudentEnrollmentView +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip1 = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + buttonRefresh = new Button(); + dataGridView = new DataGridView(); + факультетыToolStripMenuItem = new ToolStripMenuItem(); + направленияToolStripMenuItem = new ToolStripMenuItem(); + студентыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.ImageScalingSize = new Size(20, 20); + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(1088, 28); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { факультетыToolStripMenuItem, направленияToolStripMenuItem, студентыToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(117, 24); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(882, 49); + buttonRefresh.Margin = new Padding(3, 4, 3, 4); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(181, 43); + buttonRefresh.TabIndex = 10; + buttonRefresh.Text = "Обновить список"; + buttonRefresh.UseVisualStyleBackColor = true; + // + // dataGridView + // + dataGridView.BackgroundColor = Color.White; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 32); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(845, 548); + dataGridView.TabIndex = 7; + // + // факультетыToolStripMenuItem + // + факультетыToolStripMenuItem.Name = "факультетыToolStripMenuItem"; + факультетыToolStripMenuItem.Size = new Size(224, 26); + факультетыToolStripMenuItem.Text = "Факультеты"; + факультетыToolStripMenuItem.Click += факультетыToolStripMenuItem_Click; + // + // направленияToolStripMenuItem + // + направленияToolStripMenuItem.Name = "направленияToolStripMenuItem"; + направленияToolStripMenuItem.Size = new Size(224, 26); + направленияToolStripMenuItem.Text = "Направления"; + направленияToolStripMenuItem.Click += направленияToolStripMenuItem_Click; + // + // студентыToolStripMenuItem + // + студентыToolStripMenuItem.Name = "студентыToolStripMenuItem"; + студентыToolStripMenuItem.Size = new Size(224, 26); + студентыToolStripMenuItem.Text = "Студенты"; + студентыToolStripMenuItem.Click += студентыToolStripMenuItem_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1088, 587); + Controls.Add(buttonRefresh); + Controls.Add(dataGridView); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormMain"; + Text = "Списки студентов на зачисление"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private Button buttonRefresh; + private DataGridView dataGridView; + private ToolStripMenuItem факультетыToolStripMenuItem; + private ToolStripMenuItem направленияToolStripMenuItem; + private ToolStripMenuItem студентыToolStripMenuItem; + } +} \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormMain.cs b/StudentEnrollment/StudentEnrollmentView/FormMain.cs new file mode 100644 index 0000000..2203380 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormMain.cs @@ -0,0 +1,40 @@ +namespace StudentEnrollmentView +{ + public partial class FormMain : Form + { + public FormMain() + { + InitializeComponent(); + } + + private void факультетыToolStripMenuItem_Click(object sender, EventArgs e) + { + var Service = Program.ServiceProvider?.GetService(typeof(FormFaculties)); + + if (Service is FormFaculties Form) + { + Form.ShowDialog(); + } + } + + private void направленияToolStripMenuItem_Click(object sender, EventArgs e) + { + var Service = Program.ServiceProvider?.GetService(typeof(FormCourses)); + + if (Service is FormCourses Form) + { + Form.ShowDialog(); + } + } + + private void студентыToolStripMenuItem_Click(object sender, EventArgs e) + { + var Service = Program.ServiceProvider?.GetService(typeof(FormStudents)); + + if (Service is FormStudents Form) + { + Form.ShowDialog(); + } + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentView/FormMain.resx b/StudentEnrollment/StudentEnrollmentView/FormMain.resx new file mode 100644 index 0000000..a0623c8 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormMain.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormStudent.Designer.cs b/StudentEnrollment/StudentEnrollmentView/FormStudent.Designer.cs new file mode 100644 index 0000000..ed9d703 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormStudent.Designer.cs @@ -0,0 +1,314 @@ +namespace StudentEnrollmentView +{ + partial class FormStudent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label2 = new Label(); + textBoxLastName = new TextBox(); + groupBox1 = new GroupBox(); + buttonRef = new Button(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + ColumnId = new DataGridViewTextBoxColumn(); + ColumnCourseName = new DataGridViewTextBoxColumn(); + buttonCancel = new Button(); + buttonSave = new Button(); + label1 = new Label(); + textBoxFirstName = new TextBox(); + label3 = new Label(); + textBoxMiddleName = new TextBox(); + label4 = new Label(); + textBoxEmail = new TextBox(); + label5 = new Label(); + textBoxTIN = new TextBox(); + buttonAddPoints = new Button(); + groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(19, 20); + label2.Name = "label2"; + label2.Size = new Size(76, 20); + label2.TabIndex = 5; + label2.Text = "Фамилия:"; + // + // textBoxLastName + // + textBoxLastName.Location = new Point(109, 16); + textBoxLastName.Margin = new Padding(3, 4, 3, 4); + textBoxLastName.Name = "textBoxLastName"; + textBoxLastName.Size = new Size(285, 27); + textBoxLastName.TabIndex = 4; + // + // groupBox1 + // + groupBox1.Controls.Add(buttonRef); + groupBox1.Controls.Add(buttonDel); + groupBox1.Controls.Add(buttonUpd); + groupBox1.Controls.Add(buttonAdd); + groupBox1.Controls.Add(dataGridView); + groupBox1.Location = new Point(420, 20); + groupBox1.Margin = new Padding(3, 4, 3, 4); + groupBox1.Name = "groupBox1"; + groupBox1.Padding = new Padding(3, 4, 3, 4); + groupBox1.Size = new Size(341, 333); + groupBox1.TabIndex = 8; + groupBox1.TabStop = false; + groupBox1.Text = "Направление"; + // + // buttonRef + // + buttonRef.Location = new Point(205, 176); + buttonRef.Margin = new Padding(3, 4, 3, 4); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(118, 37); + buttonRef.TabIndex = 8; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += buttonRef_Click; + // + // buttonDel + // + buttonDel.Location = new Point(205, 131); + buttonDel.Margin = new Padding(3, 4, 3, 4); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(118, 37); + buttonDel.TabIndex = 7; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.Location = new Point(205, 86); + buttonUpd.Margin = new Padding(3, 4, 3, 4); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(118, 37); + buttonUpd.TabIndex = 6; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(205, 40); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(118, 37); + buttonAdd.TabIndex = 5; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + dataGridView.BackgroundColor = Color.White; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnCourseName }); + dataGridView.Location = new Point(7, 29); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(180, 290); + dataGridView.TabIndex = 0; + // + // ColumnId + // + ColumnId.HeaderText = "ColumnId"; + ColumnId.MinimumWidth = 6; + ColumnId.Name = "ColumnId"; + ColumnId.Visible = false; + ColumnId.Width = 125; + // + // ColumnCourseName + // + ColumnCourseName.HeaderText = "Направление"; + ColumnCourseName.MinimumWidth = 6; + ColumnCourseName.Name = "ColumnCourseName"; + ColumnCourseName.Width = 125; + // + // buttonCancel + // + buttonCancel.Location = new Point(642, 368); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(119, 37); + buttonCancel.TabIndex = 10; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(516, 368); + buttonSave.Margin = new Padding(3, 4, 3, 4); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(119, 37); + buttonSave.TabIndex = 9; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(19, 63); + label1.Name = "label1"; + label1.Size = new Size(42, 20); + label1.TabIndex = 12; + label1.Text = "Имя:"; + // + // textBoxFirstName + // + textBoxFirstName.Location = new Point(109, 59); + textBoxFirstName.Margin = new Padding(3, 4, 3, 4); + textBoxFirstName.Name = "textBoxFirstName"; + textBoxFirstName.Size = new Size(285, 27); + textBoxFirstName.TabIndex = 11; + // + // label3 + // + label3.Location = new Point(16, 98); + label3.Name = "label3"; + label3.Size = new Size(130, 44); + label3.TabIndex = 14; + label3.Text = "Отчество (при наличии):"; + // + // textBoxMiddleName + // + textBoxMiddleName.Location = new Point(155, 106); + textBoxMiddleName.Margin = new Padding(3, 4, 3, 4); + textBoxMiddleName.Name = "textBoxMiddleName"; + textBoxMiddleName.Size = new Size(239, 27); + textBoxMiddleName.TabIndex = 13; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(19, 159); + label4.Name = "label4"; + label4.Size = new Size(54, 20); + label4.TabIndex = 16; + label4.Text = "Почта:"; + // + // textBoxEmail + // + textBoxEmail.Location = new Point(109, 155); + textBoxEmail.Margin = new Padding(3, 4, 3, 4); + textBoxEmail.Name = "textBoxEmail"; + textBoxEmail.Size = new Size(285, 27); + textBoxEmail.TabIndex = 15; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(19, 213); + label5.Name = "label5"; + label5.Size = new Size(45, 20); + label5.TabIndex = 18; + label5.Text = "ИНН:"; + // + // textBoxTIN + // + textBoxTIN.Location = new Point(109, 209); + textBoxTIN.Margin = new Padding(3, 4, 3, 4); + textBoxTIN.Name = "textBoxTIN"; + textBoxTIN.Size = new Size(285, 27); + textBoxTIN.TabIndex = 17; + // + // buttonAddPoints + // + buttonAddPoints.Location = new Point(19, 368); + buttonAddPoints.Margin = new Padding(3, 4, 3, 4); + buttonAddPoints.Name = "buttonAddPoints"; + buttonAddPoints.Size = new Size(229, 37); + buttonAddPoints.TabIndex = 19; + buttonAddPoints.Text = "Добавить баллы студента"; + buttonAddPoints.UseVisualStyleBackColor = true; + buttonAddPoints.Click += buttonAddPoints_Click; + // + // FormStudent + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(773, 418); + Controls.Add(buttonAddPoints); + Controls.Add(label5); + Controls.Add(textBoxTIN); + Controls.Add(label4); + Controls.Add(textBoxEmail); + Controls.Add(label3); + Controls.Add(textBoxMiddleName); + Controls.Add(label1); + Controls.Add(textBoxFirstName); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(groupBox1); + Controls.Add(label2); + Controls.Add(textBoxLastName); + Margin = new Padding(3, 4, 3, 4); + Name = "FormStudent"; + Text = "Студент"; + Load += FormStudent_Load; + groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label2; + private TextBox textBoxLastName; + private GroupBox groupBox1; + private DataGridView dataGridView; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private Button buttonCancel; + private Button buttonSave; + private DataGridViewTextBoxColumn ColumnId; + private DataGridViewTextBoxColumn ColumnCourseName; + private Label label1; + private TextBox textBoxFirstName; + private Label label3; + private TextBox textBoxMiddleName; + private Label label4; + private TextBox textBoxEmail; + private Label label5; + private TextBox textBoxTIN; + private Button buttonAddPoints; + } +} \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormStudent.cs b/StudentEnrollment/StudentEnrollmentView/FormStudent.cs new file mode 100644 index 0000000..340a698 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormStudent.cs @@ -0,0 +1,232 @@ +using Microsoft.Extensions.Logging; +using StudentEnrollmentContracts.BindingModels; +using StudentEnrollmentContracts.BusinessLogicContracts; +using StudentEnrollmentContracts.SearchModels; +using StudentEnrollmentDataModels.Models; + +namespace StudentEnrollmentView +{ + public partial class FormStudent : Form + { + private readonly ILogger _logger; + private readonly IStudentLogic _logic; + private int? _id; + private Dictionary _studentCourses; + private IExamPointsModel _examPoints; + public int Id { set { _id = value; } } + public FormStudent(ILogger logger, IStudentLogic logic) + { + InitializeComponent(); + dataGridView.AllowUserToAddRows = false; + _logger = logger; + _logic = logic; + _studentCourses = new Dictionary(); + } + + private void FormStudent_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка студента"); + try + { + var view = _logic.ReadElement(new StudentSearchModel + { + student_id = _id.Value + }); + if (view != null) + { + textBoxLastName.Text = view.LastName; + textBoxFirstName.Text = view.FirstName; + textBoxMiddleName.Text = view.MiddleName; + textBoxEmail.Text = view.Email; + textBoxTIN.Text = view.TIN.ToString(); + _studentCourses = view.StudentCourse ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки студента"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка направлений студента"); + try + { + if (_studentCourses != null) + { + dataGridView.Rows.Clear(); + foreach (var pc in _studentCourses) + { + dataGridView.Rows.Add(new object[] { pc.Key, pc.Value }); + } + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки направлений студента"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void buttonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormStudentCourse)); + if (service is FormStudentCourse form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.CourseModel == null) + { + return; + } + _logger.LogInformation("Добавление нового направления:{ CourseName}", form.CourseModel.CourseName); + if (_studentCourses.ContainsKey(form.Id)) + { + _studentCourses[form.Id] = form.CourseModel; + } + else + { + _studentCourses.Add(form.Id, form.CourseModel); + } + LoadData(); + } + } + } + + private void buttonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormStudentCourse)); + if (service is FormStudentCourse form) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.CourseModel == null) + { + return; + } + _logger.LogInformation("Изменение направления:{ CourseName }", form.CourseModel.CourseName); + _studentCourses[form.Id] = form.CourseModel; + LoadData(); + } + } + } + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + _logger.LogInformation("Удаление направления:{ CourseName}", dataGridView.SelectedRows[0].Cells[1].Value); + _studentCourses?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + LoadData(); + } + } + } + + private void buttonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxFirstName.Text)) + { + MessageBox.Show("Заполните имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxLastName.Text)) + { + MessageBox.Show("Заполните фамилию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxEmail.Text)) + { + MessageBox.Show("Заполните почту", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxTIN.Text)) + { + MessageBox.Show("Заполните ИНН", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (_studentCourses.Count == 0 || _studentCourses == null) + { + MessageBox.Show("Заполните направления", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (_examPoints == null + || (_examPoints.FirstExamPoints == 0 + && _examPoints.SecondExamPoints == 0 + && _examPoints.ThirdExamPoints == 0)) + { + MessageBox.Show("Заполните баллы студента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение студента"); + try + { + var model = new StudentBindingModel + { + Id = _id ?? 0, + FirstName = textBoxFirstName.Text, + LastName = textBoxLastName.Text, + MiddleName = !string.IsNullOrEmpty(textBoxMiddleName.Text) ? textBoxMiddleName.Text : string.Empty, + Email = textBoxEmail.Text, + TIN = Convert.ToInt64(textBoxTIN.Text), + StudentCourse = _studentCourses, + ExamPointsId = _examPoints.Id, + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения цветов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void buttonAddPoints_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormExamPoints)); + if (service is FormExamPoints form) + { + form.Id = _id ?? 0; + if (form.ShowDialog() == DialogResult.OK) + { + _examPoints = form.ExamPoints; + } + } + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentView/FormStudent.resx b/StudentEnrollment/StudentEnrollmentView/FormStudent.resx new file mode 100644 index 0000000..36cac3f --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormStudent.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormStudentCourse.Designer.cs b/StudentEnrollment/StudentEnrollmentView/FormStudentCourse.Designer.cs new file mode 100644 index 0000000..41d5067 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormStudentCourse.Designer.cs @@ -0,0 +1,101 @@ +namespace StudentEnrollmentView +{ + partial class FormStudentCourse + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + comboBoxCourse = new ComboBox(); + label1 = new Label(); + buttonAdd = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // comboBoxCourse + // + comboBoxCourse.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxCourse.FormattingEnabled = true; + comboBoxCourse.Location = new Point(154, 13); + comboBoxCourse.Margin = new Padding(3, 4, 3, 4); + comboBoxCourse.Name = "comboBoxCourse"; + comboBoxCourse.Size = new Size(285, 28); + comboBoxCourse.TabIndex = 0; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(11, 16); + label1.Name = "label1"; + label1.Size = new Size(107, 20); + label1.TabIndex = 2; + label1.Text = "Направление:"; + // + // buttonAdd + // + buttonAdd.Location = new Point(215, 58); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 31); + buttonAdd.TabIndex = 4; + buttonAdd.Text = "Сохранить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(320, 58); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(98, 31); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormStudentCourse + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(451, 108); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(label1); + Controls.Add(comboBoxCourse); + Margin = new Padding(3, 4, 3, 4); + Name = "FormStudentCourse"; + Text = "Направление студента"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxCourse; + private Label label1; + private Button buttonAdd; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormStudentCourse.cs b/StudentEnrollment/StudentEnrollmentView/FormStudentCourse.cs new file mode 100644 index 0000000..482cf03 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormStudentCourse.cs @@ -0,0 +1,67 @@ +using StudentEnrollmentContracts.BusinessLogicContracts; +using StudentEnrollmentContracts.ViewModels; +using StudentEnrollmentDataModels.Models; + +namespace StudentEnrollmentView +{ + public partial class FormStudentCourse : Form + { + private readonly List? _list; + public int Id + { + get + { + return Convert.ToInt32(comboBoxCourse.SelectedValue); + } + set + { + comboBoxCourse.SelectedValue = value; + } + } + public ICourseModel? CourseModel + { + get + { + if (_list == null) + { + return null; + } + foreach (var elem in _list) + { + if (elem.Id == Id) + { + return elem; + } + } + return null; + } + } + public FormStudentCourse(ICourseLogic logic) + { + InitializeComponent(); + _list = logic.ReadList(null); + if (_list != null) + { + comboBoxCourse.DisplayMember = "CourseName"; + comboBoxCourse.ValueMember = "Id"; + comboBoxCourse.DataSource = _list; + comboBoxCourse.SelectedItem = null; + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (comboBoxCourse.SelectedValue == null) + { + MessageBox.Show("Выберите направление", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + DialogResult = DialogResult.OK; + Close(); + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentView/FormStudentCourse.resx b/StudentEnrollment/StudentEnrollmentView/FormStudentCourse.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormStudentCourse.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormStudents.Designer.cs b/StudentEnrollment/StudentEnrollmentView/FormStudents.Designer.cs new file mode 100644 index 0000000..90e33f4 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormStudents.Designer.cs @@ -0,0 +1,120 @@ +namespace StudentEnrollmentView +{ + partial class FormStudents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonRef = new Button(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonRef + // + buttonRef.Location = new Point(794, 164); + buttonRef.Margin = new Padding(3, 4, 3, 4); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(118, 37); + buttonRef.TabIndex = 14; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += buttonRef_Click; + // + // buttonDel + // + buttonDel.Location = new Point(794, 119); + buttonDel.Margin = new Padding(3, 4, 3, 4); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(118, 37); + buttonDel.TabIndex = 13; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.Location = new Point(794, 73); + buttonUpd.Margin = new Padding(3, 4, 3, 4); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(118, 37); + buttonUpd.TabIndex = 12; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(794, 28); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(118, 37); + buttonAdd.TabIndex = 11; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + dataGridView.BackgroundColor = Color.White; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 13); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(747, 568); + dataGridView.TabIndex = 10; + // + // FormStudents + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(934, 597); + Controls.Add(buttonRef); + Controls.Add(buttonDel); + Controls.Add(buttonUpd); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Name = "FormStudents"; + Text = "Студенты"; + Load += FormStudents_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/FormStudents.cs b/StudentEnrollment/StudentEnrollmentView/FormStudents.cs new file mode 100644 index 0000000..f320257 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormStudents.cs @@ -0,0 +1,59 @@ +using Microsoft.Extensions.Logging; +using StudentEnrollmentContracts.BusinessLogicContracts; + +namespace StudentEnrollmentView +{ + public partial class FormStudents : Form + { + private readonly ILogger _logger; + private readonly IStudentLogic _logic; + public FormStudents(ILogger logger, IStudentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormStudents_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ExamPoints"].Visible = false; + } + _logger.LogInformation("Загрузка компонентов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонентов"); + } + } + private void buttonAdd_Click(object sender, EventArgs e) + { + + } + + private void buttonUpd_Click(object sender, EventArgs e) + { + + } + + private void buttonDel_Click(object sender, EventArgs e) + { + + } + + private void buttonRef_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/StudentEnrollment/StudentEnrollmentView/FormStudents.resx b/StudentEnrollment/StudentEnrollmentView/FormStudents.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/StudentEnrollment/StudentEnrollmentView/FormStudents.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/Program.cs b/StudentEnrollment/StudentEnrollmentView/Program.cs index 41ff170..d8ab930 100644 --- a/StudentEnrollment/StudentEnrollmentView/Program.cs +++ b/StudentEnrollment/StudentEnrollmentView/Program.cs @@ -1,9 +1,19 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; +using StudentEnrollmentBusinessLogic; +using StudentEnrollmentContracts.BusinessLogicContracts; +using StudentEnrollmentContracts.StorageContracts; +using StudentEnrollmentDatabaseImplement.Implements; + namespace StudentEnrollmentView { internal static class Program { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; /// - /// The main entry point for the application. + /// The main entry point for the application. /// [STAThread] static void Main() @@ -11,9 +21,37 @@ namespace StudentEnrollmentView // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/StudentEnrollment/StudentEnrollmentView/StudentEnrollmentView.csproj b/StudentEnrollment/StudentEnrollmentView/StudentEnrollmentView.csproj index e1a0735..8acc503 100644 --- a/StudentEnrollment/StudentEnrollmentView/StudentEnrollmentView.csproj +++ b/StudentEnrollment/StudentEnrollmentView/StudentEnrollmentView.csproj @@ -8,4 +8,21 @@ enable + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + \ No newline at end of file