From 11db061b1aec03fb1c2ce51536dfcf82a71cf7c5 Mon Sep 17 00:00:00 2001 From: kotcheshir73 Date: Wed, 21 Dec 2022 09:32:44 +0400 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ManagmentSecurity/AccessOperation.cs | 4 +- .../StudentMarkPassedDisciplineLogic.cs | 17 +++++ .../DepartmentLogicDependencyRegistration.cs | 2 + ...tudentMarkPassedDisciplineBindingModels.cs | 51 +++++++++++++++ .../IStudentMarkPassedDisciplineLogic.cs | 11 ++++ .../IStudentMarkPassedDisciplineService.cs | 10 +++ .../StudentMarkPassedDisciplineViewModels.cs | 62 ++++++++++++++++++ ...entImplementationDependencyRegistration.cs | 2 + .../LecturerService.cs | 13 ++-- .../StudentMarkPassedDisciplineService.cs | 63 +++++++++++++++++++ 10 files changed, 226 insertions(+), 9 deletions(-) create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/StudentMarkPassedDisciplineLogic.cs create mode 100644 DepartmentPortal/Department/DepartmentContract/BindingModels/StudentMarkPassedDisciplineBindingModels.cs create mode 100644 DepartmentPortal/Department/DepartmentContract/Logics/IGenericEntityLogic/IStudentMarkPassedDisciplineLogic.cs create mode 100644 DepartmentPortal/Department/DepartmentContract/Services/IGenericEntityService/IStudentMarkPassedDisciplineService.cs create mode 100644 DepartmentPortal/Department/DepartmentContract/ViewModels/StudentMarkPassedDisciplineViewModels.cs create mode 100644 DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentMarkPassedDisciplineService.cs diff --git a/DepartmentPortal/Common/ToolsModule/ManagmentSecurity/AccessOperation.cs b/DepartmentPortal/Common/ToolsModule/ManagmentSecurity/AccessOperation.cs index d44ca5d..3c52564 100644 --- a/DepartmentPortal/Common/ToolsModule/ManagmentSecurity/AccessOperation.cs +++ b/DepartmentPortal/Common/ToolsModule/ManagmentSecurity/AccessOperation.cs @@ -50,7 +50,9 @@ БазовыеКафедры = 112, - СинхронизацияПриказов = 150, + СинхронизацияПриказов = 113, + + ОценкиСтудентов = 114, #endregion // Меню Учебный процесс diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/StudentMarkPassedDisciplineLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/StudentMarkPassedDisciplineLogic.cs new file mode 100644 index 0000000..c59ee42 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/StudentMarkPassedDisciplineLogic.cs @@ -0,0 +1,17 @@ +using DepartmentContract.BindingModels; +using DepartmentContract.Logics.IGenericEntityLogic; +using DepartmentContract.Services.IGenericEntityService; +using DepartmentContract.ViewModels; +using ToolsModule.ManagmentEntity; +using ToolsModule.ManagmentSecurity; + +namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic +{ + /// + /// Логика работы с оценками студентов за дисциплины + /// + public class StudentMarkPassedDisciplineLogic : GenericBusinessLogic, IStudentMarkPassedDisciplineLogic + { + public StudentMarkPassedDisciplineLogic(IStudentMarkPassedDisciplineService service) : base(service, "Оценки студентов", AccessOperation.ОценкиСтудентов) { } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentLogicDependencyRegistration.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentLogicDependencyRegistration.cs index 9bd6845..8120242 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentLogicDependencyRegistration.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentLogicDependencyRegistration.cs @@ -45,6 +45,8 @@ namespace DepartmentBusinessLogic DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); diff --git a/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentMarkPassedDisciplineBindingModels.cs b/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentMarkPassedDisciplineBindingModels.cs new file mode 100644 index 0000000..e9524e8 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentMarkPassedDisciplineBindingModels.cs @@ -0,0 +1,51 @@ +using CoreModels.Enums.Department; +using CoreModels.ModelsDepartment; +using System; +using System.ComponentModel.DataAnnotations; +using ToolsModule.ManagmentEntity; + +namespace DepartmentContract.BindingModels +{ + /// + /// Получение оценки студента за дисциплину + /// + public class StudentMarkPassedDisciplineGetBindingModel : GetBindingModel + { + public Guid? StudentGroupId { get; set; } + + public Guid? StudentId { get; set; } + + public Guid? DisciplineId { get; set; } + + public DateTime? DateStart { get; set; } + + public DateTime? DateFinish { get; set; } + } + + /// + /// Сохранение оценки студента за дисциплину + /// + public class StudentMarkPassedDisciplineSetBindingModel : SetBindingModel, IStudentMarkPassedDisciplineModel + { + [Required(ErrorMessage = "required")] + public Guid StudentId { get; set; } + + [Required(ErrorMessage = "required")] + public Guid DisciplineId { get; set; } + + [Required(ErrorMessage = "required")] + public Semester Semester { get; set; } + + [Required(ErrorMessage = "required")] + public MarkDisciplinePassedType Mark { get; set; } + + [Required(ErrorMessage = "required")] + public DateTime DateAffixing { get; set; } + + [Required(ErrorMessage = "required")] + public bool IsIncreaseMark { get; set; } + + [Required(ErrorMessage = "required")] + public bool IsDirection { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentContract/Logics/IGenericEntityLogic/IStudentMarkPassedDisciplineLogic.cs b/DepartmentPortal/Department/DepartmentContract/Logics/IGenericEntityLogic/IStudentMarkPassedDisciplineLogic.cs new file mode 100644 index 0000000..e2ba075 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentContract/Logics/IGenericEntityLogic/IStudentMarkPassedDisciplineLogic.cs @@ -0,0 +1,11 @@ +using DepartmentContract.BindingModels; +using DepartmentContract.ViewModels; +using ToolsModule.ManagmentEntity; + +namespace DepartmentContract.Logics.IGenericEntityLogic +{ + /// + /// Логика работы с оценками студентов за дисциплины + /// + public interface IStudentMarkPassedDisciplineLogic : IGenericEntityLogic { } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentContract/Services/IGenericEntityService/IStudentMarkPassedDisciplineService.cs b/DepartmentPortal/Department/DepartmentContract/Services/IGenericEntityService/IStudentMarkPassedDisciplineService.cs new file mode 100644 index 0000000..ec44c74 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentContract/Services/IGenericEntityService/IStudentMarkPassedDisciplineService.cs @@ -0,0 +1,10 @@ +using DepartmentContract.BindingModels; +using ToolsModule.ManagmentEntity; + +namespace DepartmentContract.Services.IGenericEntityService +{ + /// + /// Хранение оценок студентов за дисциплины + /// + public interface IStudentMarkPassedDisciplineService : IGenericEntityService { } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentMarkPassedDisciplineViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentMarkPassedDisciplineViewModels.cs new file mode 100644 index 0000000..aedb29d --- /dev/null +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentMarkPassedDisciplineViewModels.cs @@ -0,0 +1,62 @@ +using CoreModels.Enums.Department; +using CoreModels.ModelsDepartment; +using System; +using ToolsModule.ManagmentEntity; +using ToolsModule.ManagmentMapping; + +namespace DepartmentContract.ViewModels +{ + /// + /// Список оценок студентов за дисциплины + /// + public class StudentMarkPassedDisciplineListViewModel : ListViewModel { } + + /// + /// Элемент оценка студента за дисциплину + /// + [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)] + public class StudentMarkPassedDisciplineViewModel : ElementViewModel, IStudentMarkPassedDisciplineModel + { + [ViewModelControlElementProperty("Студент", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentList, SecurityWindowsDesktop")] + public Guid StudentId { get; set; } + + [ViewModelControlElementProperty("Дисциплина", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentList, DepartmentWindowsDesktop")] + public Guid DisciplineId { get; set; } + + [ViewModelControlListProperty("Студент", ColumnWidth = 120)] + [MapConfiguration("Student.ToString")] + public string Student { get; set; } + + [ViewModelControlListProperty("Дисциплина", ColumnWidth = 120)] + [MapConfiguration("Discipline.ToString")] + public string Discipline { get; set; } + + [ViewModelControlElementProperty("Семестр", ControlType.ControlEnum, MustHaveValue = true)] + public Semester Semester { get; set; } + + [ViewModelControlListProperty("Семестр", ColumnWidth = 120)] + public string SemesterTitle => Semester.ToString("G"); + + [ViewModelControlElementProperty("Оценка", ControlType.ControlEnum, MustHaveValue = true)] + public MarkDisciplinePassedType Mark { get; set; } + + [ViewModelControlListProperty("Оценка", ColumnWidth = 120)] + public string MarkTitle => Mark.ToString("G"); + + [ViewModelControlListProperty("Дата сдачи", ColumnWidth = 120, DefaultCellStyleFormat = "dd.MM.yyyy")] + [ViewModelControlElementProperty("Дата сдачи", ControlType.ControlDateTime, MustHaveValue = true)] + public DateTime DateAffixing { get; set; } + + [ViewModelControlElementProperty("Повышение оценки", ControlType.ControlBool, MustHaveValue = true)] + public bool IsIncreaseMark { get; set; } + + [ViewModelControlListProperty("Повышение оценки", ColumnWidth = 100)] + public string IsIncreaseMarkValue => IsIncreaseMark ? "Да" : "Нет"; + + [ViewModelControlElementProperty("По направлению", ControlType.ControlBool, MustHaveValue = true)] + public bool IsDirection { get; set; } + + [ViewModelControlListProperty("По направлению", ColumnWidth = 100)] + public string IsDirectionValue => IsDirection ? "Да" : "Нет"; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs index ba9bf42..4c7f861 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs @@ -43,6 +43,8 @@ namespace DepartmentDatabaseImplementation DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); + + DependencyManager.Instance.RegisterType(); } } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/LecturerService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/LecturerService.cs index f0c065e..c34f369 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/LecturerService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/LecturerService.cs @@ -75,15 +75,12 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit protected override Lecturer GetUniqueEntity(LecturerSetBindingModel model, IQueryable query) => query.FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName && x.Patronymic == model.Patronymic && x.Id != model.Id); - protected override IQueryable IncludingWhenReading(IQueryable query) - { - return query - .Include(x => x.LecturerAcademicRank) - .Include(x => x.LecturerAcademicDegree) - .Include(x => x.LecturerPosts).Include("LecturerPosts.Post"); - } + protected override IQueryable IncludingWhenReading(IQueryable query) => query + .Include(x => x.LecturerAcademicRank) + .Include(x => x.LecturerAcademicDegree) + .Include(x => x.LecturerPosts).Include("LecturerPosts.Post"); - protected override IQueryable OrderingWhenReading(IQueryable query) => query + protected override IQueryable OrderingWhenReading(IQueryable query) => query .OrderByDescending(x => x.LecturerPosts.Max(y => y.Post.Order)) .ThenBy(x => x.LecturerAcademicRank.Order) .ThenBy(x => x.LecturerAcademicDegree.Order) diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentMarkPassedDisciplineService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentMarkPassedDisciplineService.cs new file mode 100644 index 0000000..ab0c11c --- /dev/null +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentMarkPassedDisciplineService.cs @@ -0,0 +1,63 @@ +using CoreDatabase; +using CoreDatabase.Models.Department; +using DepartmentContract.BindingModels; +using DepartmentContract.Services.IGenericEntityService; +using DepartmentContract.ViewModels; +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using ToolsModule.ManagmentEntity; + +namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntityService +{ + /// + /// Реализация IStudentMarkPassedDisciplineService + /// + public class StudentMarkPassedDisciplineService : + AbstractGenerticEntityService, + IStudentMarkPassedDisciplineService + { + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, StudentMarkPassedDisciplineSetBindingModel model) => OperationResultModel.Success(null); + + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, StudentMarkPassedDiscipline entity, StudentMarkPassedDisciplineGetBindingModel model) => OperationResultModel.Success(null); + + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, StudentMarkPassedDisciplineGetBindingModel model) + { + if (model.DisciplineId.HasValue) + { + query = query.Where(x => x.DisciplineId == model.DisciplineId); + } + if (model.StudentId.HasValue) + { + query = query.Where(x => x.StudentId == model.StudentId); + } + if (model.StudentGroupId.HasValue) + { + query = query.Where(x => x.Student.StudentGroupId == model.StudentGroupId); + } + if (model.DateStart.HasValue && model.DateFinish.HasValue) + { + query = query.Where(x => x.DateAffixing >= model.DateStart.Value && x.DateAffixing <= model.DateFinish.Value); + } + return query; + } + + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, StudentMarkPassedDisciplineSetBindingModel model) => OperationResultModel.Success(null); + + protected override void AdditionalDeleting(DbContext context, StudentMarkPassedDiscipline entity, StudentMarkPassedDisciplineGetBindingModel model) + { + throw new NotImplementedException(); + } + + protected override StudentMarkPassedDiscipline GetUniqueEntity(StudentMarkPassedDisciplineSetBindingModel model, IQueryable query) => query.FirstOrDefault(x => x.StudentId == model.StudentId && x.DisciplineId == model.DisciplineId && + x.Semester == model.Semester && x.Mark == model.Mark && x.Id != model.Id); + + protected override IQueryable IncludingWhenReading(IQueryable query) => query + .Include(x => x.Student) + .Include(x => x.Discipline); + + protected override IQueryable OrderingWhenReading(IQueryable query) => query + .OrderByDescending(x => x.Student) + .ThenBy(x => x.DateAffixing); + } +} \ No newline at end of file