Базовая логика

This commit is contained in:
kotcheshir73 2022-12-21 09:32:44 +04:00
parent be261d84d4
commit 11db061b1a
10 changed files with 226 additions and 9 deletions

View File

@ -50,7 +50,9 @@
БазовыеКафедры = 112,
СинхронизацияПриказов = 150,
СинхронизацияПриказов = 113,
ОценкиСтудентов = 114,
#endregion
// Меню Учебный процесс

View File

@ -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
{
/// <summary>
/// Логика работы с оценками студентов за дисциплины
/// </summary>
public class StudentMarkPassedDisciplineLogic : GenericBusinessLogic<StudentMarkPassedDisciplineGetBindingModel, StudentMarkPassedDisciplineSetBindingModel, StudentMarkPassedDisciplineListViewModel, StudentMarkPassedDisciplineViewModel>, IStudentMarkPassedDisciplineLogic
{
public StudentMarkPassedDisciplineLogic(IStudentMarkPassedDisciplineService service) : base(service, "Оценки студентов", AccessOperation.ОценкиСтудентов) { }
}
}

View File

@ -45,6 +45,8 @@ namespace DepartmentBusinessLogic
DependencyManager.Instance.RegisterType<IBasicDepartmentLogic, BasicDepartmentBusinessLogic>();
DependencyManager.Instance.RegisterType<IStudentMarkPassedDisciplineLogic, StudentMarkPassedDisciplineLogic>();
DependencyManager.Instance.RegisterType<BuilderWordDocument, BuilderWordDocumentOpenXML>();

View File

@ -0,0 +1,51 @@
using CoreModels.Enums.Department;
using CoreModels.ModelsDepartment;
using System;
using System.ComponentModel.DataAnnotations;
using ToolsModule.ManagmentEntity;
namespace DepartmentContract.BindingModels
{
/// <summary>
/// Получение оценки студента за дисциплину
/// </summary>
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; }
}
/// <summary>
/// Сохранение оценки студента за дисциплину
/// </summary>
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; }
}
}

View File

@ -0,0 +1,11 @@
using DepartmentContract.BindingModels;
using DepartmentContract.ViewModels;
using ToolsModule.ManagmentEntity;
namespace DepartmentContract.Logics.IGenericEntityLogic
{
/// <summary>
/// Логика работы с оценками студентов за дисциплины
/// </summary>
public interface IStudentMarkPassedDisciplineLogic : IGenericEntityLogic<StudentMarkPassedDisciplineGetBindingModel, StudentMarkPassedDisciplineSetBindingModel, StudentMarkPassedDisciplineListViewModel, StudentMarkPassedDisciplineViewModel> { }
}

View File

@ -0,0 +1,10 @@
using DepartmentContract.BindingModels;
using ToolsModule.ManagmentEntity;
namespace DepartmentContract.Services.IGenericEntityService
{
/// <summary>
/// Хранение оценок студентов за дисциплины
/// </summary>
public interface IStudentMarkPassedDisciplineService : IGenericEntityService<StudentMarkPassedDisciplineGetBindingModel, StudentMarkPassedDisciplineSetBindingModel> { }
}

View File

@ -0,0 +1,62 @@
using CoreModels.Enums.Department;
using CoreModels.ModelsDepartment;
using System;
using ToolsModule.ManagmentEntity;
using ToolsModule.ManagmentMapping;
namespace DepartmentContract.ViewModels
{
/// <summary>
/// Список оценок студентов за дисциплины
/// </summary>
public class StudentMarkPassedDisciplineListViewModel : ListViewModel<StudentMarkPassedDisciplineViewModel> { }
/// <summary>
/// Элемент оценка студента за дисциплину
/// </summary>
[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 ? "Да" : "Нет";
}
}

View File

@ -43,6 +43,8 @@ namespace DepartmentDatabaseImplementation
DependencyManager.Instance.RegisterType<IOrderSyncHistoryRecordService, OrderSyncHistoryRecordService>();
DependencyManager.Instance.RegisterType<IBasicDepartmentService, BasicDepartmentService>();
DependencyManager.Instance.RegisterType<IStudentMarkPassedDisciplineService, StudentMarkPassedDisciplineService>();
}
}
}

View File

@ -75,15 +75,12 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
protected override Lecturer GetUniqueEntity(LecturerSetBindingModel model, IQueryable<Lecturer> query) => query.FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName &&
x.Patronymic == model.Patronymic && x.Id != model.Id);
protected override IQueryable<Lecturer> IncludingWhenReading(IQueryable<Lecturer> query)
{
return query
.Include(x => x.LecturerAcademicRank)
.Include(x => x.LecturerAcademicDegree)
.Include(x => x.LecturerPosts).Include("LecturerPosts.Post");
}
protected override IQueryable<Lecturer> IncludingWhenReading(IQueryable<Lecturer> query) => query
.Include(x => x.LecturerAcademicRank)
.Include(x => x.LecturerAcademicDegree)
.Include(x => x.LecturerPosts).Include("LecturerPosts.Post");
protected override IQueryable<Lecturer> OrderingWhenReading(IQueryable<Lecturer> query) => query
protected override IQueryable<Lecturer> OrderingWhenReading(IQueryable<Lecturer> query) => query
.OrderByDescending(x => x.LecturerPosts.Max(y => y.Post.Order))
.ThenBy(x => x.LecturerAcademicRank.Order)
.ThenBy(x => x.LecturerAcademicDegree.Order)

View File

@ -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
{
/// <summary>
/// Реализация IStudentMarkPassedDisciplineService
/// </summary>
public class StudentMarkPassedDisciplineService :
AbstractGenerticEntityService<StudentMarkPassedDisciplineGetBindingModel, StudentMarkPassedDisciplineSetBindingModel, StudentMarkPassedDiscipline, StudentMarkPassedDisciplineListViewModel, StudentMarkPassedDisciplineViewModel>,
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<StudentMarkPassedDiscipline> AdditionalCheckingWhenReadingList(IQueryable<StudentMarkPassedDiscipline> 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<StudentMarkPassedDiscipline> 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<StudentMarkPassedDiscipline> IncludingWhenReading(IQueryable<StudentMarkPassedDiscipline> query) => query
.Include(x => x.Student)
.Include(x => x.Discipline);
protected override IQueryable<StudentMarkPassedDiscipline> OrderingWhenReading(IQueryable<StudentMarkPassedDiscipline> query) => query
.OrderByDescending(x => x.Student)
.ThenBy(x => x.DateAffixing);
}
}