diff --git a/DepartmentPortal/Common/CoreDatabase/CoreDatabase.csproj b/DepartmentPortal/Common/CoreDatabase/CoreDatabase.csproj index eacb4a7..4fbf5da 100644 --- a/DepartmentPortal/Common/CoreDatabase/CoreDatabase.csproj +++ b/DepartmentPortal/Common/CoreDatabase/CoreDatabase.csproj @@ -7,6 +7,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/DepartmentPortal/Common/CoreDatabase/DatabaseContext.cs b/DepartmentPortal/Common/CoreDatabase/DatabaseContext.cs index 0ea55ee..fbf90ef 100644 --- a/DepartmentPortal/Common/CoreDatabase/DatabaseContext.cs +++ b/DepartmentPortal/Common/CoreDatabase/DatabaseContext.cs @@ -52,12 +52,14 @@ namespace CoreDatabase modelBuilder.Entity().HasIndex(d => new { d.TimeNormName, d.TimeNormShortName }).IsUnique(); - modelBuilder.Entity().HasIndex(d => new { d.EducationDirectionId, d.YearEntrance }).IsUnique(); + modelBuilder.Entity().HasIndex(d => new { d.EducationDirectionId, d.CreateDate }).IsUnique(); modelBuilder.Entity().HasIndex(d => new { d.AcademicPlanId, d.DisciplineId, d.Semester }).IsUnique(); modelBuilder.Entity().HasIndex(d => new { d.AcademicPlanRecordId, d.TimeNormId }).IsUnique(); + modelBuilder.Entity().HasIndex(d => new { d.AcademicPlanId, d.YearEntrance }).IsUnique(); + // ругается на циклическое каскадное удаление, так что по нормам времени убираем ее modelBuilder.Entity() .HasOne(x => x.TimeNorm) @@ -122,6 +124,7 @@ namespace CoreDatabase public virtual DbSet OrderStudentRecords { set; get; } public virtual DbSet OrderSyncHistories { set; get; } public virtual DbSet OrderSyncHistoryRecords { set; get; } + public virtual DbSet EnrollmentYears { set; get; } #endregion } } \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreDatabase/Migrations/20220326210022_AddEnrollmentYear.Designer.cs b/DepartmentPortal/Common/CoreDatabase/Migrations/20220326210022_AddEnrollmentYear.Designer.cs new file mode 100644 index 0000000..125816e --- /dev/null +++ b/DepartmentPortal/Common/CoreDatabase/Migrations/20220326210022_AddEnrollmentYear.Designer.cs @@ -0,0 +1,1508 @@ +// +using System; +using CoreDatabase; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace CoreDatabase.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20220326210022_AddEnrollmentYear")] + partial class AddEnrollmentYear + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.15") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlan", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EducationDirectionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastUpdateDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("EducationDirectionId", "CreateDate") + .IsUnique() + .HasFilter("[EducationDirectionId] IS NOT NULL"); + + b.ToTable("AcademicPlans"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlanRecord", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanRecordParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineId") + .HasColumnType("uniqueidentifier"); + + b.Property("InDepartment") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsFacultative") + .HasColumnType("bit"); + + b.Property("IsParent") + .HasColumnType("bit"); + + b.Property("Semester") + .HasColumnType("int"); + + b.Property("Zet") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineId"); + + b.HasIndex("AcademicPlanId", "DisciplineId", "Semester") + .IsUnique(); + + b.ToTable("AcademicPlanRecords"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlanRecordTimeNormHour", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanRecordId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("PlanHours") + .HasColumnType("decimal(18,2)"); + + b.Property("TimeNormId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TimeNormId"); + + b.HasIndex("AcademicPlanRecordId", "TimeNormId") + .IsUnique(); + + b.ToTable("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Classroom", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("ClassroomType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("HaveProjector") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Number") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("SecurityCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Square") + .HasColumnType("decimal(18,2)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("Number") + .IsUnique(); + + b.ToTable("Classrooms"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisciplineBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("DisciplineShortName") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineBlockId"); + + b.HasIndex("DisciplineName") + .IsUnique(); + + b.ToTable("Disciplines"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockOrder") + .HasColumnType("int"); + + b.Property("DisciplineBlockUseForGrouping") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Title") + .IsUnique(); + + b.ToTable("DisciplineBlocks"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.EducationDirection", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Cipher") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.Property("Profile") + .HasColumnType("nvarchar(450)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("Title", "Profile") + .IsUnique() + .HasFilter("[Profile] IS NOT NULL"); + + b.ToTable("EducationDirections"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Address") + .HasColumnType("nvarchar(max)"); + + b.Property("DateBirth") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .HasColumnType("nvarchar(450)"); + + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + + b.Property("HomeNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastName") + .HasColumnType("nvarchar(450)"); + + b.Property("MobileNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[FirstName] IS NOT NULL AND [LastName] IS NOT NULL AND [Patronymic] IS NOT NULL"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("PostId"); + + b.ToTable("EmployeePosts"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.EnrollmentYear", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("YearEntrance") + .HasColumnType("int"); + + b.Property("YearFinish") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AcademicPlanId", "YearEntrance") + .IsUnique(); + + b.ToTable("EnrollmentYears"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Abbreviation") + .HasColumnType("nvarchar(max)"); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateBirth") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + + b.Property("HomeNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("LecturerAcademicDegreeId") + .HasColumnType("uniqueidentifier"); + + b.Property("LecturerAcademicRankId") + .HasColumnType("uniqueidentifier"); + + b.Property("MobileNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OnlyForPrivate") + .HasColumnType("bit"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeId"); + + b.HasIndex("LecturerAcademicRankId"); + + b.HasIndex("UserId"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[Patronymic] IS NOT NULL"); + + b.ToTable("Lecturers"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicDegreeName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeName") + .IsUnique(); + + b.ToTable("LecturerAcademicDegrees"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicRankName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicRankName") + .IsUnique(); + + b.ToTable("LecturerAcademicRanks"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("PostId"); + + b.ToTable("LecturerPosts"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("OrderDate") + .HasColumnType("datetime2"); + + b.Property("OrderNumber") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("OrderType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OrderNumber") + .IsUnique(); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.OrderStudentRecord", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Info") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("OrderStudentMoveType") + .HasColumnType("int"); + + b.Property("StudentGroupFromId") + .HasColumnType("uniqueidentifier"); + + b.Property("StudentGroupToId") + .HasColumnType("uniqueidentifier"); + + b.Property("StudentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("StudentGroupFromId"); + + b.HasIndex("StudentGroupToId"); + + b.HasIndex("StudentId", "OrderId") + .IsUnique(); + + b.ToTable("OrderStudentRecords"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.OrderSyncHistory", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("SyncDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("OrderSyncHistories"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.OrderSyncHistoryRecord", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Information") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderSyncHistoryId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderSyncHistoryId"); + + b.ToTable("OrderSyncHistoryRecords"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Post", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Hours") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("PostName") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("PostName") + .IsUnique() + .HasFilter("[PostName] IS NOT NULL"); + + b.ToTable("Posts"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Student", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EnrollmentYearId") + .HasColumnType("uniqueidentifier"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Iduniv") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsSteward") + .HasColumnType("bit"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NumberOfBook") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(max)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("StudentGroupId") + .HasColumnType("uniqueidentifier"); + + b.Property("StudentState") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("EnrollmentYearId"); + + b.HasIndex("NumberOfBook") + .IsUnique(); + + b.HasIndex("StudentGroupId"); + + b.HasIndex("UserId"); + + b.ToTable("Students"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.StudentGroup", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicCourse") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EducationDirectionId") + .HasColumnType("uniqueidentifier"); + + b.Property("GroupNumber") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("EducationDirectionId", "AcademicCourse", "GroupNumber") + .IsUnique(); + + b.ToTable("StudentGroups"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.TimeNorm", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("KindOfLoadAttributeName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadBlueAsteriskAttributeName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadBlueAsteriskPracticName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TimeNormEducationDirectionQualification") + .HasColumnType("int"); + + b.Property("TimeNormName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("TimeNormOrder") + .HasColumnType("int"); + + b.Property("TimeNormShortName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("UseInLearningProgress") + .HasColumnType("bit"); + + b.Property("UseInSite") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineBlockId"); + + b.HasIndex("TimeNormName", "TimeNormShortName") + .IsUnique(); + + b.ToTable("TimeNorms"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Security.Access", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessOperation") + .HasColumnType("int"); + + b.Property("AccessType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Accesses"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Security.EnviromentSetting", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Key") + .IsUnique(); + + b.ToTable("EnviromentSettings"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Security.Role", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("RolePriority") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RoleName") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Security.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Avatar") + .HasColumnType("varbinary(max)"); + + b.Property("CountAttempt") + .HasColumnType("int"); + + b.Property("DateBanned") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DateLastVisit") + .HasColumnType("datetime2"); + + b.Property("IsBanned") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserName"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlan", b => + { + b.HasOne("CoreDatabase.Models.Department.EducationDirection", "EducationDirection") + .WithMany("AcademicPlans") + .HasForeignKey("EducationDirectionId"); + + b.Navigation("EducationDirection"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlanRecord", b => + { + b.HasOne("CoreDatabase.Models.Department.AcademicPlan", "AcademicPlan") + .WithMany("AcademicPlanRecords") + .HasForeignKey("AcademicPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CoreDatabase.Models.Department.Discipline", "Discipline") + .WithMany("AcademicPlanRecords") + .HasForeignKey("DisciplineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicPlan"); + + b.Navigation("Discipline"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlanRecordTimeNormHour", b => + { + b.HasOne("CoreDatabase.Models.Department.AcademicPlanRecord", "AcademicPlanRecord") + .WithMany("AcademicPlanRecordTimeNormHours") + .HasForeignKey("AcademicPlanRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CoreDatabase.Models.Department.TimeNorm", "TimeNorm") + .WithMany("AcademicPlanRecordTimeNormHours") + .HasForeignKey("TimeNormId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("AcademicPlanRecord"); + + b.Navigation("TimeNorm"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Classroom", b => + { + b.HasOne("CoreDatabase.Models.Department.Employee", "Employee") + .WithMany("Classrooms") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b => + { + b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("Disciplines") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.EducationDirection", b => + { + b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer") + .WithMany("EducationDirections") + .HasForeignKey("LecturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lecturer"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b => + { + b.HasOne("CoreDatabase.Models.Security.User", "User") + .WithMany("Employees") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b => + { + b.HasOne("CoreDatabase.Models.Department.Employee", "Employee") + .WithMany("EmployeePosts") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CoreDatabase.Models.Department.Post", "Post") + .WithMany("EmployeePosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.EnrollmentYear", b => + { + b.HasOne("CoreDatabase.Models.Department.AcademicPlan", "AcademicPlan") + .WithMany() + .HasForeignKey("AcademicPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicPlan"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b => + { + b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicDegreeId"); + + b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicRankId"); + + b.HasOne("CoreDatabase.Models.Security.User", "User") + .WithMany("Lecturers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LecturerAcademicDegree"); + + b.Navigation("LecturerAcademicRank"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b => + { + b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer") + .WithMany("LecturerPosts") + .HasForeignKey("LecturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CoreDatabase.Models.Department.Post", "Post") + .WithMany("LecturerPosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lecturer"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.OrderStudentRecord", b => + { + b.HasOne("CoreDatabase.Models.Department.Order", "Order") + .WithMany("OrderStudentRecords") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CoreDatabase.Models.Department.StudentGroup", "StudentGroupFrom") + .WithMany("OrderStudentRecordFroms") + .HasForeignKey("StudentGroupFromId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("CoreDatabase.Models.Department.StudentGroup", "StudentGroupTo") + .WithMany("OrderStudentRecordTos") + .HasForeignKey("StudentGroupToId") + .OnDelete(DeleteBehavior.NoAction); + + b.HasOne("CoreDatabase.Models.Department.Student", "Student") + .WithMany("OrderStudentRecords") + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Student"); + + b.Navigation("StudentGroupFrom"); + + b.Navigation("StudentGroupTo"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.OrderSyncHistoryRecord", b => + { + b.HasOne("CoreDatabase.Models.Department.OrderSyncHistory", "OrderSyncHistory") + .WithMany("OrderSyncHistoryRecords") + .HasForeignKey("OrderSyncHistoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderSyncHistory"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Student", b => + { + b.HasOne("CoreDatabase.Models.Department.EnrollmentYear", "EnrollmentYear") + .WithMany("Students") + .HasForeignKey("EnrollmentYearId"); + + b.HasOne("CoreDatabase.Models.Department.StudentGroup", "StudentGroup") + .WithMany("Students") + .HasForeignKey("StudentGroupId"); + + b.HasOne("CoreDatabase.Models.Security.User", "User") + .WithMany("Students") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EnrollmentYear"); + + b.Navigation("StudentGroup"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.StudentGroup", b => + { + b.HasOne("CoreDatabase.Models.Department.EducationDirection", "EducationDirection") + .WithMany("StudentGroups") + .HasForeignKey("EducationDirectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer") + .WithMany("StudentGroups") + .HasForeignKey("LecturerId"); + + b.Navigation("EducationDirection"); + + b.Navigation("Lecturer"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.TimeNorm", b => + { + b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("TimeNorms") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Security.Access", b => + { + b.HasOne("CoreDatabase.Models.Security.Role", "Role") + .WithMany("Access") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b => + { + b.HasOne("CoreDatabase.Models.Security.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CoreDatabase.Models.Security.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlan", b => + { + b.Navigation("AcademicPlanRecords"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlanRecord", b => + { + b.Navigation("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b => + { + b.Navigation("AcademicPlanRecords"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b => + { + b.Navigation("Disciplines"); + + b.Navigation("TimeNorms"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.EducationDirection", b => + { + b.Navigation("AcademicPlans"); + + b.Navigation("StudentGroups"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b => + { + b.Navigation("Classrooms"); + + b.Navigation("EmployeePosts"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.EnrollmentYear", b => + { + b.Navigation("Students"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b => + { + b.Navigation("EducationDirections"); + + b.Navigation("LecturerPosts"); + + b.Navigation("StudentGroups"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Order", b => + { + b.Navigation("OrderStudentRecords"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.OrderSyncHistory", b => + { + b.Navigation("OrderSyncHistoryRecords"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Post", b => + { + b.Navigation("EmployeePosts"); + + b.Navigation("LecturerPosts"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Student", b => + { + b.Navigation("OrderStudentRecords"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.StudentGroup", b => + { + b.Navigation("OrderStudentRecordFroms"); + + b.Navigation("OrderStudentRecordTos"); + + b.Navigation("Students"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.TimeNorm", b => + { + b.Navigation("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Security.Role", b => + { + b.Navigation("Access"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Security.User", b => + { + b.Navigation("Employees"); + + b.Navigation("Lecturers"); + + b.Navigation("Students"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/DepartmentPortal/Common/CoreDatabase/Migrations/20220326210022_AddEnrollmentYear.cs b/DepartmentPortal/Common/CoreDatabase/Migrations/20220326210022_AddEnrollmentYear.cs new file mode 100644 index 0000000..4a04d90 --- /dev/null +++ b/DepartmentPortal/Common/CoreDatabase/Migrations/20220326210022_AddEnrollmentYear.cs @@ -0,0 +1,153 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace CoreDatabase.Migrations +{ + public partial class AddEnrollmentYear : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_AcademicPlans_EducationDirectionId_YearEntrance", + table: "AcademicPlans"); + + migrationBuilder.DropColumn( + name: "YearEntrance", + table: "AcademicPlans"); + + migrationBuilder.DropColumn( + name: "YearFinish", + table: "AcademicPlans"); + + migrationBuilder.AddColumn( + name: "EnrollmentYearId", + table: "Students", + type: "uniqueidentifier", + nullable: true); + + migrationBuilder.AddColumn( + name: "CreateDate", + table: "AcademicPlans", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "LastUpdateDate", + table: "AcademicPlans", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + //требуется для создания уникального индекса IX_AcademicPlans_EducationDirectionId_CreateDate, если уже есть записи в AcademicPlans + migrationBuilder.Sql( +@" +declare @i int = 45869 + UPDATE AcademicPlans + SET CreateDate = convert(datetime, @i), + SET LastUpdateDate = convert(datetime, @i), +@i = @i + 100; +"); + + migrationBuilder.CreateTable( + name: "EnrollmentYears", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + AcademicPlanId = table.Column(type: "uniqueidentifier", nullable: false), + YearEntrance = table.Column(type: "int", nullable: false), + YearFinish = table.Column(type: "int", nullable: false), + DateCreate = table.Column(type: "datetime2", nullable: false), + DateDelete = table.Column(type: "datetime2", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EnrollmentYears", x => x.Id); + table.ForeignKey( + name: "FK_EnrollmentYears_AcademicPlans_AcademicPlanId", + column: x => x.AcademicPlanId, + principalTable: "AcademicPlans", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Students_EnrollmentYearId", + table: "Students", + column: "EnrollmentYearId"); + + migrationBuilder.CreateIndex( + name: "IX_AcademicPlans_EducationDirectionId_CreateDate", + table: "AcademicPlans", + columns: new[] { "EducationDirectionId", "CreateDate" }, + unique: true, + filter: "[EducationDirectionId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_EnrollmentYears_AcademicPlanId_YearEntrance", + table: "EnrollmentYears", + columns: new[] { "AcademicPlanId", "YearEntrance" }, + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_Students_EnrollmentYears_EnrollmentYearId", + table: "Students", + column: "EnrollmentYearId", + principalTable: "EnrollmentYears", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Students_EnrollmentYears_EnrollmentYearId", + table: "Students"); + + migrationBuilder.DropTable( + name: "EnrollmentYears"); + + migrationBuilder.DropIndex( + name: "IX_Students_EnrollmentYearId", + table: "Students"); + + migrationBuilder.DropIndex( + name: "IX_AcademicPlans_EducationDirectionId_CreateDate", + table: "AcademicPlans"); + + migrationBuilder.DropColumn( + name: "EnrollmentYearId", + table: "Students"); + + migrationBuilder.DropColumn( + name: "CreateDate", + table: "AcademicPlans"); + + migrationBuilder.DropColumn( + name: "LastUpdateDate", + table: "AcademicPlans"); + + migrationBuilder.AddColumn( + name: "YearEntrance", + table: "AcademicPlans", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "YearFinish", + table: "AcademicPlans", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateIndex( + name: "IX_AcademicPlans_EducationDirectionId_YearEntrance", + table: "AcademicPlans", + columns: new[] { "EducationDirectionId", "YearEntrance" }, + unique: true, + filter: "[EducationDirectionId] IS NOT NULL"); + } + } +} diff --git a/DepartmentPortal/Common/CoreDatabase/Migrations/DatabaseContextModelSnapshot.cs b/DepartmentPortal/Common/CoreDatabase/Migrations/DatabaseContextModelSnapshot.cs index 44ba888..7e2e951 100644 --- a/DepartmentPortal/Common/CoreDatabase/Migrations/DatabaseContextModelSnapshot.cs +++ b/DepartmentPortal/Common/CoreDatabase/Migrations/DatabaseContextModelSnapshot.cs @@ -16,7 +16,7 @@ namespace CoreDatabase.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("ProductVersion", "5.0.5") + .HasAnnotation("ProductVersion", "5.0.15") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlan", b => @@ -24,6 +24,9 @@ namespace CoreDatabase.Migrations b.Property("Id") .HasColumnType("uniqueidentifier"); + b.Property("CreateDate") + .HasColumnType("datetime2"); + b.Property("DateCreate") .HasColumnType("datetime2"); @@ -36,15 +39,12 @@ namespace CoreDatabase.Migrations b.Property("IsDeleted") .HasColumnType("bit"); - b.Property("YearEntrance") - .HasColumnType("int"); - - b.Property("YearFinish") - .HasColumnType("int"); + b.Property("LastUpdateDate") + .HasColumnType("datetime2"); b.HasKey("Id"); - b.HasIndex("EducationDirectionId", "YearEntrance") + b.HasIndex("EducationDirectionId", "CreateDate") .IsUnique() .HasFilter("[EducationDirectionId] IS NOT NULL"); @@ -410,6 +410,37 @@ namespace CoreDatabase.Migrations b.ToTable("EmployeePosts"); }); + modelBuilder.Entity("CoreDatabase.Models.Department.EnrollmentYear", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("YearEntrance") + .HasColumnType("int"); + + b.Property("YearFinish") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AcademicPlanId", "YearEntrance") + .IsUnique(); + + b.ToTable("EnrollmentYears"); + }); + modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b => { b.Property("Id") @@ -750,6 +781,9 @@ namespace CoreDatabase.Migrations b.Property("Email") .HasColumnType("nvarchar(max)"); + b.Property("EnrollmentYearId") + .HasColumnType("uniqueidentifier"); + b.Property("FirstName") .IsRequired() .HasColumnType("nvarchar(max)"); @@ -789,6 +823,8 @@ namespace CoreDatabase.Migrations b.HasKey("Id"); + b.HasIndex("EnrollmentYearId"); + b.HasIndex("NumberOfBook") .IsUnique(); @@ -1173,6 +1209,17 @@ namespace CoreDatabase.Migrations b.Navigation("Post"); }); + modelBuilder.Entity("CoreDatabase.Models.Department.EnrollmentYear", b => + { + b.HasOne("CoreDatabase.Models.Department.AcademicPlan", "AcademicPlan") + .WithMany() + .HasForeignKey("AcademicPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicPlan"); + }); + modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b => { b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree") @@ -1261,6 +1308,10 @@ namespace CoreDatabase.Migrations modelBuilder.Entity("CoreDatabase.Models.Department.Student", b => { + b.HasOne("CoreDatabase.Models.Department.EnrollmentYear", "EnrollmentYear") + .WithMany("Students") + .HasForeignKey("EnrollmentYearId"); + b.HasOne("CoreDatabase.Models.Department.StudentGroup", "StudentGroup") .WithMany("Students") .HasForeignKey("StudentGroupId"); @@ -1271,6 +1322,8 @@ namespace CoreDatabase.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("EnrollmentYear"); + b.Navigation("StudentGroup"); b.Navigation("User"); @@ -1370,6 +1423,11 @@ namespace CoreDatabase.Migrations b.Navigation("EmployeePosts"); }); + modelBuilder.Entity("CoreDatabase.Models.Department.EnrollmentYear", b => + { + b.Navigation("Students"); + }); + modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b => { b.Navigation("EducationDirections"); diff --git a/DepartmentPortal/Common/CoreDatabase/Models/Department/AcademicPlan.cs b/DepartmentPortal/Common/CoreDatabase/Models/Department/AcademicPlan.cs index 3d2f100..a20e1fb 100644 --- a/DepartmentPortal/Common/CoreDatabase/Models/Department/AcademicPlan.cs +++ b/DepartmentPortal/Common/CoreDatabase/Models/Department/AcademicPlan.cs @@ -16,11 +16,11 @@ namespace CoreDatabase.Models.Department [DataMember] [Required(ErrorMessage = "required")] - public int YearEntrance { get; set; } + public DateTime CreateDate { get; set; } [DataMember] [Required(ErrorMessage = "required")] - public int YearFinish { get; set; } + public DateTime LastUpdateDate { get; set; } //------------------------------------------------------------------------- @@ -31,10 +31,10 @@ namespace CoreDatabase.Models.Department [ForeignKey("AcademicPlanId")] public virtual List AcademicPlanRecords { get; set; } - //------------------------------------------------------------------------- + //------------------------------------------------------------------------- - public AcademicPlan SecurityCheck(AcademicPlan entity, bool allowFullData) => entity; + public AcademicPlan SecurityCheck(AcademicPlan entity, bool allowFullData) => entity; - public override string ToString() => $"{EducationDirection?.ShortName}({EducationDirection?.Profile}): {YearEntrance}-{YearFinish}"; + public override string ToString() => $"{EducationDirection?.ShortName}({EducationDirection?.Profile}): {CreateDate:d}"; } } \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreDatabase/Models/Department/EnrollmentYear.cs b/DepartmentPortal/Common/CoreDatabase/Models/Department/EnrollmentYear.cs new file mode 100644 index 0000000..16de661 --- /dev/null +++ b/DepartmentPortal/Common/CoreDatabase/Models/Department/EnrollmentYear.cs @@ -0,0 +1,40 @@ +using CoreModels.ModelsDepartment; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; +using ToolsModule.ManagmentSecurity; + +namespace CoreDatabase.Models.Department +{ + [DataContract] + public class EnrollmentYear : BaseEntity, IEntitySecurityExtenstion, IEnrollmentYearModel + { + [DataMember] + public Guid AcademicPlanId { get; set; } + + [DataMember] + [Required(ErrorMessage = "required")] + public int YearEntrance { get; set; } + + [DataMember] + [Required(ErrorMessage = "required")] + public int YearFinish { get; set; } + + //------------------------------------------------------------------------- + + public virtual AcademicPlan AcademicPlan { get; set; } + + //------------------------------------------------------------------------- + + [ForeignKey("EnrollmentYearId")] + public virtual List Students { get; set; } + + //------------------------------------------------------------------------- + + public EnrollmentYear SecurityCheck(EnrollmentYear entity, bool allowFullData) => entity; + + public override string ToString() => $"{AcademicPlan?.EducationDirection?.ShortName}({AcademicPlan?.EducationDirection?.Profile}): {YearEntrance}-{YearFinish}"; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreDatabase/Models/Department/Student.cs b/DepartmentPortal/Common/CoreDatabase/Models/Department/Student.cs index 31e8040..943b333 100644 --- a/DepartmentPortal/Common/CoreDatabase/Models/Department/Student.cs +++ b/DepartmentPortal/Common/CoreDatabase/Models/Department/Student.cs @@ -21,6 +21,9 @@ namespace CoreDatabase.Models.Department [DataMember] public Guid? StudentGroupId { get; set; } + [DataMember] + public Guid? EnrollmentYearId { get; set; } + [DataMember] [Required] public string Iduniv { get; set; } @@ -61,6 +64,8 @@ namespace CoreDatabase.Models.Department public virtual StudentGroup StudentGroup { get; set; } + public virtual EnrollmentYear EnrollmentYear { get; set; } + //------------------------------------------------------------------------- [ForeignKey("StudentId")] diff --git a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IAcademicPlanModel.cs b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IAcademicPlanModel.cs index 61cba8e..6644c7c 100644 --- a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IAcademicPlanModel.cs +++ b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IAcademicPlanModel.cs @@ -4,14 +4,14 @@ using ToolsModule.ManagmentEntity; namespace CoreModels.ModelsDepartment { - [EntityDescription("AcademicPlan", "Учебный план кафедры (на каждый учебный год новый план)")] + [EntityDescription("AcademicPlan", "Учебный план кафедры")] [EntityDependency("EducationDirection", "EducationDirectionId", "Направление, к которму относится учебный план")] public interface IAcademicPlanModel : IId { Guid? EducationDirectionId { get; } - int YearEntrance { get; } + DateTime CreateDate { get; } - int YearFinish { get; } + DateTime LastUpdateDate { get; } } } \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IEnrollmentYearModel.cs b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IEnrollmentYearModel.cs new file mode 100644 index 0000000..e8cedfd --- /dev/null +++ b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IEnrollmentYearModel.cs @@ -0,0 +1,17 @@ +using CoreModels.Tools; +using System; +using ToolsModule.ManagmentEntity; + +namespace CoreModels.ModelsDepartment +{ + [EntityDescription("EnrollmentYear", "Год зачисления")] + [EntityDependency("AcademicPlan", "AcademicPlanId", "Учебный план, по которому учатся зачисленные")] + public interface IEnrollmentYearModel : IId + { + Guid AcademicPlanId { get; } + + int YearEntrance { get; } + + int YearFinish { get; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IStudentModel.cs b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IStudentModel.cs index a59b9ae..2d65e74 100644 --- a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IStudentModel.cs +++ b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IStudentModel.cs @@ -8,12 +8,15 @@ namespace CoreModels.ModelsDepartment [EntityDescription("Student", "Студент кафедры")] [EntityDependency("User", "UserId", "К какому пользователю относится студент")] [EntityDependency("StudentGroup", "StudentGroupId", "К какой группе относится студент")] + [EntityDependency("EnrollmentYear", "EnrollmentYearId", "К какому году поступления/выпуска относится")] public interface IStudentModel : IId { Guid UserId { get; } Guid? StudentGroupId { get; } + Guid? EnrollmentYearId { get; } + string Iduniv { get; } string NumberOfBook { get; } diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/EnrollmentYearBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/EnrollmentYearBusinessLogic.cs new file mode 100644 index 0000000..421af07 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/EnrollmentYearBusinessLogic.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 EnrollmentYearBusinessLogic : GenericBusinessLogic, IEnrollmentYearLogic + { + public EnrollmentYearBusinessLogic(IEnrollmentYearService 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 433483b..82b0c8a 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentLogicDependencyRegistration.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentLogicDependencyRegistration.cs @@ -30,6 +30,7 @@ namespace DepartmentBusinessLogic DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); diff --git a/DepartmentPortal/Department/DepartmentContract/BindingModels/AcademicPlanBindingModels.cs b/DepartmentPortal/Department/DepartmentContract/BindingModels/AcademicPlanBindingModels.cs index 66ff96e..34a8ca9 100644 --- a/DepartmentPortal/Department/DepartmentContract/BindingModels/AcademicPlanBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/BindingModels/AcademicPlanBindingModels.cs @@ -21,10 +21,10 @@ namespace DepartmentContract.BindingModels public Guid? EducationDirectionId { get; set; } [Required(ErrorMessage = "required")] - public int YearEntrance { get; set; } + public DateTime CreateDate { get; set; } [Required(ErrorMessage = "required")] - public int YearFinish { get; set; } + public DateTime LastUpdateDate { get; set; } } /// diff --git a/DepartmentPortal/Department/DepartmentContract/BindingModels/EnrollmentYearBindingModels.cs b/DepartmentPortal/Department/DepartmentContract/BindingModels/EnrollmentYearBindingModels.cs new file mode 100644 index 0000000..0855bbf --- /dev/null +++ b/DepartmentPortal/Department/DepartmentContract/BindingModels/EnrollmentYearBindingModels.cs @@ -0,0 +1,29 @@ +using CoreModels.ModelsDepartment; +using System; +using System.ComponentModel.DataAnnotations; +using ToolsModule.ManagmentEntity; + +namespace DepartmentContract.BindingModels +{ + /// + /// Получение года поступления + /// + public class EnrollmentYearGetBindingModel : GetBindingModel + { + public Guid? AcademicPlanId { get; set; } + } + + /// + /// Сохранение года поступления + /// + public class EnrollmentYearSetBindingModel : SetBindingModel, IEnrollmentYearModel + { + public Guid AcademicPlanId { get; set; } + + [Required(ErrorMessage = "required")] + public int YearEntrance { get; set; } + + [Required(ErrorMessage = "required")] + public int YearFinish { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentBindingModels.cs b/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentBindingModels.cs index 0b83828..8b089b5 100644 --- a/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentBindingModels.cs @@ -15,6 +15,8 @@ namespace DepartmentContract.BindingModels public Guid? StudentGroupId { get; set; } + public Guid? EnrollmentYearId { get; set; } + public StudentState? StudentState { get; set; } public string NumberOfBook { get; set; } @@ -30,6 +32,8 @@ namespace DepartmentContract.BindingModels public Guid? StudentGroupId { get; set; } + public Guid? EnrollmentYearId { get; set; } + [Required(ErrorMessage = "required")] public string Iduniv { get; set; } @@ -54,5 +58,5 @@ namespace DepartmentContract.BindingModels public byte[] Photo { get; set; } public bool IsSteward { get; set; } - } + } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentContract/Logics/IGenericEntityLogic/IEnrollmentYearLogic.cs b/DepartmentPortal/Department/DepartmentContract/Logics/IGenericEntityLogic/IEnrollmentYearLogic.cs new file mode 100644 index 0000000..e7970dc --- /dev/null +++ b/DepartmentPortal/Department/DepartmentContract/Logics/IGenericEntityLogic/IEnrollmentYearLogic.cs @@ -0,0 +1,11 @@ +using DepartmentContract.BindingModels; +using DepartmentContract.ViewModels; +using ToolsModule.ManagmentEntity; + +namespace DepartmentContract.Logics.IGenericEntityLogic +{ + /// + /// Логика работы с годом поступления + /// + public interface IEnrollmentYearLogic : IGenericEntityLogic { } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentContract/Services/IGenericEntityService/IEnrollmentYearService.cs b/DepartmentPortal/Department/DepartmentContract/Services/IGenericEntityService/IEnrollmentYearService.cs new file mode 100644 index 0000000..59473c4 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentContract/Services/IGenericEntityService/IEnrollmentYearService.cs @@ -0,0 +1,10 @@ +using DepartmentContract.BindingModels; +using ToolsModule.ManagmentEntity; + +namespace DepartmentContract.Services.IGenericEntityService +{ + /// + /// Хранение годов поступления + /// + public interface IEnrollmentYearService : IGenericEntityService { } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanViewModels.cs index 3573967..1b3a6d8 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanViewModels.cs @@ -16,6 +16,8 @@ namespace DepartmentContract.ViewModels [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 1200, Height = 800)] [ViewModelControlElementDependenceEntity(Title = "Записи плана", Order = 1, ParentPropertyName = "AcademicPlanId", ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlAcademicPlanRecordList, DepartmentWindowsDesktop")] + [ViewModelControlElementDependenceEntity(Title = "Года поступления", Order = 1, ParentPropertyName = "AcademicPlanId", + ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEnrollmentYearList, DepartmentWindowsDesktop")] public class AcademicPlanViewModel : ElementViewModel, IAcademicPlanModel { [ViewModelControlElementProperty("Направление", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEducationDirectionList, DepartmentWindowsDesktop")] @@ -29,12 +31,12 @@ namespace DepartmentContract.ViewModels [MapConfiguration("EducationDirection.Profile")] public string EducationDirectionProfile { get; set; } - [ViewModelControlListProperty("Дата начала", ColumnWidth = 120)] - [ViewModelControlElementProperty("Дата начала", ControlType.ControlInt, MustHaveValue = true)] - public int YearEntrance { get; set; } + [ViewModelControlListProperty("Дата создания", ColumnWidth = 120)] + [ViewModelControlElementProperty("Дата создания", ControlType.ControlDateTime, MustHaveValue = true)] + public DateTime CreateDate { get; set; } - [ViewModelControlListProperty("Дата окончания", ColumnWidth = 120)] - [ViewModelControlElementProperty("Дата окончания", ControlType.ControlInt, MustHaveValue = true)] - public int YearFinish { get; set; } + [ViewModelControlListProperty("Дата последнего изменения", ColumnWidth = 120)] + [ViewModelControlElementProperty("Дата последнего изменения", ControlType.ControlDateTime, MustHaveValue = true)] + public DateTime LastUpdateDate { get; set; } } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/EnrollmentYearViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/EnrollmentYearViewModels.cs new file mode 100644 index 0000000..f054faa --- /dev/null +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/EnrollmentYearViewModels.cs @@ -0,0 +1,40 @@ +using CoreModels.ModelsDepartment; +using System; +using ToolsModule.ManagmentEntity; +using ToolsModule.ManagmentMapping; + +namespace DepartmentContract.ViewModels +{ + /// + /// Список учбеных планов + /// + public class EnrollmentYearListViewModel : ListViewModel { } + + /// + /// Элемент учебного плана + /// + [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 1200, Height = 800)] + [ViewModelControlElementDependenceEntity(Title = "Студенты", Order = 1, ParentPropertyName = "EnrollmentYearId", + ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentList, DepartmentWindowsDesktop")] + public class EnrollmentYearViewModel : ElementViewModel, IEnrollmentYearModel + { + [ViewModelControlElementProperty("Учебный план", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlAcademicPlanList, DepartmentWindowsDesktop")] + public Guid AcademicPlanId { get; set; } + + [ViewModelControlListProperty("Направление")] + [MapConfiguration("AcademicPlan.EducationDirection.Cipher")] + public string EducationDirectionCipher { get; set; } + + [ViewModelControlListProperty("Профиль")] + [MapConfiguration("AcademicPlan.EducationDirection.Profile")] + public string EducationDirectionProfile { get; set; } + + [ViewModelControlListProperty("Дата начала", ColumnWidth = 120)] + [ViewModelControlElementProperty("Дата начала", ControlType.ControlInt, MustHaveValue = true)] + public int YearEntrance { get; set; } + + [ViewModelControlListProperty("Дата окончания", ColumnWidth = 120)] + [ViewModelControlElementProperty("Дата окончания", ControlType.ControlInt, MustHaveValue = true)] + public int YearFinish { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs index ca77c0a..df25260 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs @@ -28,6 +28,9 @@ namespace DepartmentContract.ViewModels [MapConfiguration("StudentGroup.ToString")] public string StudentGroupName { get; set; } + [ViewModelControlElementProperty("Год выпуска", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEnrollmentYearList, DepartmentWindowsDesktop")] + public Guid? EnrollmentYearId { get; set; } + [ViewModelControlElementProperty("Идентификатор универа", ControlType.ControlString, MustHaveValue = true, ReadOnly = true)] public string Iduniv { get; set; } @@ -65,5 +68,5 @@ namespace DepartmentContract.ViewModels [ViewModelControlElementProperty("Староста", ControlType.ControlBool, MustHaveValue = true)] public bool IsSteward { get; set; } - } + } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs index 3202e2b..5042da7 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs @@ -31,6 +31,7 @@ namespace DepartmentDatabaseImplementation DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/AcademicPlanService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/AcademicPlanService.cs index bf160f2..cea940a 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/AcademicPlanService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/AcademicPlanService.cs @@ -56,11 +56,11 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit context.SaveChanges(); } - protected override AcademicPlan GetUniqueEntity(AcademicPlanSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.YearEntrance == model.YearEntrance && x.Id != model.Id); + protected override AcademicPlan GetUniqueEntity(AcademicPlanSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.CreateDate == model.CreateDate && x.Id != model.Id); protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.EducationDirection); - protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.EducationDirection.Cipher).ThenBy(x => x.YearEntrance); + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.EducationDirection.Cipher).ThenBy(x => x.CreateDate); public OperationResultModel LoadPlx(AcademicPlanLoadPlxModel model) { diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/EnrollmentYearService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/EnrollmentYearService.cs new file mode 100644 index 0000000..de55cdf --- /dev/null +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/EnrollmentYearService.cs @@ -0,0 +1,50 @@ +using CoreDatabase; +using CoreDatabase.Models.Department; +using DepartmentContract.BindingModels; +using DepartmentContract.Services.IGenericEntityService; +using DepartmentContract.ViewModels; +using Microsoft.EntityFrameworkCore; +using System.Linq; +using ToolsModule.ManagmentEntity; + +namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntityService +{ + /// + /// Реализация IEnrollmentYearService + /// + public class EnrollmentYearService : + AbstractGenerticEntityService, + IEnrollmentYearService + { + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, EnrollmentYearSetBindingModel model) => OperationResultModel.Success(null); + + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, EnrollmentYear entity, EnrollmentYearGetBindingModel model) => OperationResultModel.Success(null); + + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, EnrollmentYearGetBindingModel model) + { + if (model.AcademicPlanId.HasValue) + { + query = query.Where(x => x.AcademicPlanId == model.AcademicPlanId.Value); + } + return query; + } + + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, EnrollmentYearSetBindingModel model) => OperationResultModel.Success(null); + + protected override void AdditionalDeleting(DbContext context, EnrollmentYear entity, EnrollmentYearGetBindingModel model) + { + var records = context.Set().Where(x => x.EnrollmentYearId == model.Id); + foreach (var record in records) + { + record.EnrollmentYearId = null; + } + context.SaveChanges(); + } + + protected override EnrollmentYear GetUniqueEntity(EnrollmentYearSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.AcademicPlanId == model.AcademicPlanId && x.YearEntrance == model.YearEntrance && x.Id != model.Id); + + protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.AcademicPlan).Include(x => x.AcademicPlan.EducationDirection); + + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.AcademicPlan.EducationDirection.Cipher).ThenBy(x => x.YearEntrance); + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentService.cs index 5b32d6b..ca37a28 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentService.cs @@ -32,6 +32,10 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit { query = query.Where(x => x.StudentGroupId == model.StudentGroupId.Value); } + if (model.EnrollmentYearId.HasValue) + { + query = query.Where(x => x.EnrollmentYearId == model.EnrollmentYearId.Value); + } if (model.StudentState.HasValue) { query = query.Where(x => x.StudentState == model.StudentState.Value); diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.Designer.cs new file mode 100644 index 0000000..e82f98e --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.Designer.cs @@ -0,0 +1,33 @@ + +namespace DepartmentWindowsDesktop.EntityControls +{ + partial class ControlEnrollmentYearElement + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.cs new file mode 100644 index 0000000..8a222c5 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.cs @@ -0,0 +1,30 @@ +using DepartmentContract.BindingModels; +using DepartmentContract.Logics.IGenericEntityLogic; +using DepartmentContract.ViewModels; +using System; +using ToolsDesktop.Controls; +using ToolsDesktop.Interfaces; +using ToolsDesktop.Models; + +namespace DepartmentWindowsDesktop.EntityControls +{ + /// + /// Реализация контрола для года поступления + /// + public partial class ControlEnrollmentYearElement : + GenericControlEntityElement, + IGenericControlEntityElement + { + public ControlEnrollmentYearElement() + { + InitializeComponent(); + Title = "Год поступления"; + ControlId = new Guid("363636d3-b3d0-4374-a573-2bcc78ca4eea"); + _genericControlViewEntityElement = this; + } + + public IControl GetInstanceGenericControl() => new ControlEnrollmentYearElement() { ControlId = Guid.NewGuid() }; + + public ControlViewEntityElementConfiguration GetConfigControl() => new(); + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.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/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.Designer.cs new file mode 100644 index 0000000..e3ba44a --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.Designer.cs @@ -0,0 +1,33 @@ + +namespace DepartmentWindowsDesktop.EntityControls +{ + partial class ControlEnrollmentYearList + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.cs new file mode 100644 index 0000000..3777ef4 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.cs @@ -0,0 +1,42 @@ +using DepartmentContract.BindingModels; +using DepartmentContract.Logics.IGenericEntityLogic; +using DepartmentContract.ViewModels; +using System; +using System.Collections.Generic; +using ToolsDesktop.Controls; +using ToolsDesktop.Enums; +using ToolsDesktop.Interfaces; +using ToolsDesktop.Models; +using ToolsModule.ManagmentSecurity; + +namespace DepartmentWindowsDesktop.EntityControls +{ + /// + /// Реализация контрола для списка годов поступления + /// + public partial class ControlEnrollmentYearList : + GenericControlEntityList, + IGenericControlEntityList + { + public ControlEnrollmentYearList() + { + InitializeComponent(); + Title = "Года поступления"; + ControlId = new Guid("c0b26e65-78fa-40b6-b6ab-2f9c5a0b19dc"); + AccessOperation = AccessOperation.Должности; + ControlViewEntityElement = new ControlEmployeePostElement(); + _genericControlViewEntityList = this; + } + + public IControl GetInstanceGenericControl() => new ControlEnrollmentYearList() { ControlId = Guid.NewGuid() }; + + public ControlViewEntityListConfiguration GetConfigControl() => new() + { + PaginationOn = false, + HideToolStripButton = new List + { + ToolStripButtonListNames.toolStripButtonSearch + } + }; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.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