From 8169b49a9474f72e8d504e14f1846a672e2c60a5 Mon Sep 17 00:00:00 2001 From: kotcheshir73 Date: Tue, 27 Apr 2021 18:04:01 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BF=D0=BE=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF?= =?UTF-8?q?=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/DatabaseCore/DatabaseContext.cs | 2 +- ...0427134459_ChangeStudentGroups.Designer.cs | 1450 +++++++++++++++++ .../20210427134459_ChangeStudentGroups.cs | 67 + .../DatabaseContextModelSnapshot.cs | 20 +- .../Models/Department/AcademicPlan.cs | 3 - .../Models/Department/EducationDirection.cs | 3 + .../Models/Department/StudentGroup.cs | 28 +- .../StudentGroupBindingModels.cs | 13 +- .../Enums/AcademicCourse.cs | 16 + .../ViewModels/AcademicPlanViewModels.cs | 2 - .../EducationDirectionViewModels.cs | 2 + .../ViewModels/StudentGroupViewModels.cs | 53 +- .../Implementations/AcademicPlanService.cs | 11 +- .../EducationDirectionService.cs | 4 + .../Implementations/StudentGroupService.cs | 10 +- .../Implementations/StudentService.cs | 2 +- 16 files changed, 1593 insertions(+), 93 deletions(-) create mode 100644 DepartmentPortal/Common/DatabaseCore/Migrations/20210427134459_ChangeStudentGroups.Designer.cs create mode 100644 DepartmentPortal/Common/DatabaseCore/Migrations/20210427134459_ChangeStudentGroups.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/Enums/AcademicCourse.cs diff --git a/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs b/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs index 7a0cb03..046e6a7 100644 --- a/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs +++ b/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs @@ -64,7 +64,7 @@ namespace DatabaseCore .WithMany(x => x.AcademicPlanRecordTimeNormHours) .OnDelete(DeleteBehavior.NoAction); - modelBuilder.Entity().HasIndex(d => new { d.AcademicPlanId, d.EnrollmentYear, d.GroupNumber }).IsUnique(); + modelBuilder.Entity().HasIndex(d => new { d.EducationDirectionId, d.AcademicCourse, d.GroupNumber }).IsUnique(); modelBuilder.Entity().HasIndex(d => new { d.NumberOfBook }).IsUnique(); diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210427134459_ChangeStudentGroups.Designer.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210427134459_ChangeStudentGroups.Designer.cs new file mode 100644 index 0000000..830e198 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210427134459_ChangeStudentGroups.Designer.cs @@ -0,0 +1,1450 @@ +// +using System; +using DatabaseCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace DatabaseCore.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20210427134459_ChangeStudentGroups")] + partial class ChangeStudentGroups + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.5") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlan", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EducationDirectionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("YearEntrance") + .HasColumnType("int"); + + b.Property("YearFinish") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EducationDirectionId", "YearEntrance") + .IsUnique() + .HasFilter("[EducationDirectionId] IS NOT NULL"); + + b.ToTable("AcademicPlans"); + }); + + modelBuilder.Entity("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.Models.Department.OrderSyncHistory", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("SyncDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("OrderSyncHistories"); + }); + + modelBuilder.Entity("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .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") + .IsRequired() + .HasColumnType("uniqueidentifier"); + + b.Property("StudentState") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("NumberOfBook") + .IsUnique(); + + b.HasIndex("StudentGroupId"); + + b.HasIndex("UserId"); + + b.ToTable("Students"); + }); + + modelBuilder.Entity("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.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("DatabaseCore.Models.Department.AcademicPlan", b => + { + b.HasOne("DatabaseCore.Models.Department.EducationDirection", "EducationDirection") + .WithMany("AcademicPlans") + .HasForeignKey("EducationDirectionId"); + + b.Navigation("EducationDirection"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecord", b => + { + b.HasOne("DatabaseCore.Models.Department.AcademicPlan", "AcademicPlan") + .WithMany("AcademicPlanRecords") + .HasForeignKey("AcademicPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Discipline", "Discipline") + .WithMany("AcademicPlanRecords") + .HasForeignKey("DisciplineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicPlan"); + + b.Navigation("Discipline"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecordTimeNormHour", b => + { + b.HasOne("DatabaseCore.Models.Department.AcademicPlanRecord", "AcademicPlanRecord") + .WithMany("AcademicPlanRecordTimeNormHours") + .HasForeignKey("AcademicPlanRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.TimeNorm", "TimeNorm") + .WithMany("AcademicPlanRecordTimeNormHours") + .HasForeignKey("TimeNormId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("AcademicPlanRecord"); + + b.Navigation("TimeNorm"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Classroom", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("Classrooms") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("Disciplines") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EducationDirection", b => + { + b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") + .WithMany("EducationDirections") + .HasForeignKey("LecturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lecturer"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Employees") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("EmployeePosts") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("EmployeePosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicDegreeId"); + + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicRank", "LecturerAcademicRank") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicRankId"); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Lecturers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LecturerAcademicDegree"); + + b.Navigation("LecturerAcademicRank"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + { + b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") + .WithMany("LecturerPosts") + .HasForeignKey("LecturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("LecturerPosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lecturer"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.OrderStudentRecord", b => + { + b.HasOne("DatabaseCore.Models.Department.Order", "Order") + .WithMany("OrderStudentRecords") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.StudentGroup", "StudentGroupFrom") + .WithMany("OrderStudentRecordFroms") + .HasForeignKey("StudentGroupFromId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("DatabaseCore.Models.Department.StudentGroup", "StudentGroupTo") + .WithMany("OrderStudentRecordTos") + .HasForeignKey("StudentGroupToId") + .OnDelete(DeleteBehavior.NoAction); + + b.HasOne("DatabaseCore.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("DatabaseCore.Models.Department.OrderSyncHistoryRecord", b => + { + b.HasOne("DatabaseCore.Models.Department.OrderSyncHistory", "OrderSyncHistory") + .WithMany("OrderSyncHistoryRecords") + .HasForeignKey("OrderSyncHistoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderSyncHistory"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Student", b => + { + b.HasOne("DatabaseCore.Models.Department.StudentGroup", "StudentGroup") + .WithMany("Students") + .HasForeignKey("StudentGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Students") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("StudentGroup"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.StudentGroup", b => + { + b.HasOne("DatabaseCore.Models.Department.EducationDirection", "EducationDirection") + .WithMany("StudentGroups") + .HasForeignKey("EducationDirectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") + .WithMany("StudentGroups") + .HasForeignKey("LecturerId"); + + b.Navigation("EducationDirection"); + + b.Navigation("Lecturer"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.TimeNorm", b => + { + b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("TimeNorms") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("Access") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlan", b => + { + b.Navigation("AcademicPlanRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecord", b => + { + b.Navigation("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.Navigation("AcademicPlanRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Navigation("Disciplines"); + + b.Navigation("TimeNorms"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EducationDirection", b => + { + b.Navigation("AcademicPlans"); + + b.Navigation("StudentGroups"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Navigation("Classrooms"); + + b.Navigation("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.Navigation("EducationDirections"); + + b.Navigation("LecturerPosts"); + + b.Navigation("StudentGroups"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Order", b => + { + b.Navigation("OrderStudentRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.OrderSyncHistory", b => + { + b.Navigation("OrderSyncHistoryRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => + { + b.Navigation("EmployeePosts"); + + b.Navigation("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Student", b => + { + b.Navigation("OrderStudentRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.StudentGroup", b => + { + b.Navigation("OrderStudentRecordFroms"); + + b.Navigation("OrderStudentRecordTos"); + + b.Navigation("Students"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.TimeNorm", b => + { + b.Navigation("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Navigation("Access"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.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/DatabaseCore/Migrations/20210427134459_ChangeStudentGroups.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210427134459_ChangeStudentGroups.cs new file mode 100644 index 0000000..4cb3857 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210427134459_ChangeStudentGroups.cs @@ -0,0 +1,67 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace DatabaseCore.Migrations +{ + public partial class ChangeStudentGroups : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_StudentGroups_AcademicPlans_AcademicPlanId", + table: "StudentGroups"); + + migrationBuilder.RenameColumn( + name: "EnrollmentYear", + table: "StudentGroups", + newName: "AcademicCourse"); + + migrationBuilder.RenameColumn( + name: "AcademicPlanId", + table: "StudentGroups", + newName: "EducationDirectionId"); + + migrationBuilder.RenameIndex( + name: "IX_StudentGroups_AcademicPlanId_EnrollmentYear_GroupNumber", + table: "StudentGroups", + newName: "IX_StudentGroups_EducationDirectionId_AcademicCourse_GroupNumber"); + + migrationBuilder.AddForeignKey( + name: "FK_StudentGroups_EducationDirections_EducationDirectionId", + table: "StudentGroups", + column: "EducationDirectionId", + principalTable: "EducationDirections", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_StudentGroups_EducationDirections_EducationDirectionId", + table: "StudentGroups"); + + migrationBuilder.RenameColumn( + name: "EducationDirectionId", + table: "StudentGroups", + newName: "AcademicPlanId"); + + migrationBuilder.RenameColumn( + name: "AcademicCourse", + table: "StudentGroups", + newName: "EnrollmentYear"); + + migrationBuilder.RenameIndex( + name: "IX_StudentGroups_EducationDirectionId_AcademicCourse_GroupNumber", + table: "StudentGroups", + newName: "IX_StudentGroups_AcademicPlanId_EnrollmentYear_GroupNumber"); + + migrationBuilder.AddForeignKey( + name: "FK_StudentGroups_AcademicPlans_AcademicPlanId", + table: "StudentGroups", + column: "AcademicPlanId", + principalTable: "AcademicPlans", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs index c93c182..e90d637 100644 --- a/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs @@ -802,8 +802,8 @@ namespace DatabaseCore.Migrations b.Property("Id") .HasColumnType("uniqueidentifier"); - b.Property("AcademicPlanId") - .HasColumnType("uniqueidentifier"); + b.Property("AcademicCourse") + .HasColumnType("int"); b.Property("DateCreate") .HasColumnType("datetime2"); @@ -811,8 +811,8 @@ namespace DatabaseCore.Migrations b.Property("DateDelete") .HasColumnType("datetime2"); - b.Property("EnrollmentYear") - .HasColumnType("int"); + b.Property("EducationDirectionId") + .HasColumnType("uniqueidentifier"); b.Property("GroupNumber") .HasColumnType("int"); @@ -827,7 +827,7 @@ namespace DatabaseCore.Migrations b.HasIndex("LecturerId"); - b.HasIndex("AcademicPlanId", "EnrollmentYear", "GroupNumber") + b.HasIndex("EducationDirectionId", "AcademicCourse", "GroupNumber") .IsUnique(); b.ToTable("StudentGroups"); @@ -1278,9 +1278,9 @@ namespace DatabaseCore.Migrations modelBuilder.Entity("DatabaseCore.Models.Department.StudentGroup", b => { - b.HasOne("DatabaseCore.Models.Department.AcademicPlan", "AcademicPlan") + b.HasOne("DatabaseCore.Models.Department.EducationDirection", "EducationDirection") .WithMany("StudentGroups") - .HasForeignKey("AcademicPlanId") + .HasForeignKey("EducationDirectionId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -1288,7 +1288,7 @@ namespace DatabaseCore.Migrations .WithMany("StudentGroups") .HasForeignKey("LecturerId"); - b.Navigation("AcademicPlan"); + b.Navigation("EducationDirection"); b.Navigation("Lecturer"); }); @@ -1337,8 +1337,6 @@ namespace DatabaseCore.Migrations modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlan", b => { b.Navigation("AcademicPlanRecords"); - - b.Navigation("StudentGroups"); }); modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecord", b => @@ -1361,6 +1359,8 @@ namespace DatabaseCore.Migrations modelBuilder.Entity("DatabaseCore.Models.Department.EducationDirection", b => { b.Navigation("AcademicPlans"); + + b.Navigation("StudentGroups"); }); modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/AcademicPlan.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/AcademicPlan.cs index 321f57d..cd1c907 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/AcademicPlan.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/AcademicPlan.cs @@ -39,9 +39,6 @@ namespace DatabaseCore.Models.Department [ForeignKey("AcademicPlanId")] public virtual List AcademicPlanRecords { get; set; } - [ForeignKey("AcademicPlanId")] - public virtual List StudentGroups { get; set; } - //------------------------------------------------------------------------- public AcademicPlan SecurityCheck(AcademicPlan entity, bool allowFullData) => entity; diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/EducationDirection.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/EducationDirection.cs index 8cdf230..b7b0c00 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/EducationDirection.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/EducationDirection.cs @@ -56,6 +56,9 @@ namespace DatabaseCore.Models.Department [ForeignKey("EducationDirectionId")] public virtual List AcademicPlans { get; set; } + [ForeignKey("EducationDirectionId")] + public virtual List StudentGroups { get; set; } + //------------------------------------------------------------------------- public EducationDirection SecurityCheck(EducationDirection entity, bool allowFullData) => entity; diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/StudentGroup.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/StudentGroup.cs index 059a2fb..a1064e2 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/StudentGroup.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/StudentGroup.cs @@ -14,14 +14,14 @@ namespace DatabaseCore.Models.Department /// [DataContract] [EntityDescription("StudentGroup", "Учебная группа кафедры")] - [EntityDependency("AcademicPlan", "AcademicPlanId", "Учебный план, по которму учится группа")] + [EntityDependency("EducationDirection", "EducationDirectionId", "Направление, по которому учится группа")] [EntityDependency("Lecturer", "LecturerId", "Куратор группы")] public class StudentGroup : BaseEntity, IEntitySecurityExtenstion { [DataMember] [Required(ErrorMessage = "required")] - [MapConfiguration("AcademicPlanId")] - public Guid AcademicPlanId { get; set; } + [MapConfiguration("EducationDirectionId")] + public Guid EducationDirectionId { get; set; } [DataMember] [Required(ErrorMessage = "required")] @@ -30,8 +30,8 @@ namespace DatabaseCore.Models.Department [DataMember] [Required(ErrorMessage = "required")] - [MapConfiguration("EnrollmentYear")] - public int EnrollmentYear { get; set; } + [MapConfiguration("AcademicCourse")] + public int AcademicCourse { get; set; } [DataMember] [MapConfiguration("LecturerId")] @@ -39,7 +39,7 @@ namespace DatabaseCore.Models.Department //------------------------------------------------------------------------- - public virtual AcademicPlan AcademicPlan { get; set; } + public virtual EducationDirection EducationDirection { get; set; } public virtual Lecturer Lecturer { get; set; } @@ -58,20 +58,6 @@ namespace DatabaseCore.Models.Department public StudentGroup SecurityCheck(StudentGroup entity, bool allowFullData) => entity; - public override string ToString() - { - var builder = new StringBuilder(); - builder.Append(AcademicPlan?.EducationDirection?.ShortName); - builder.Append('-'); - var year = DateTime.Now.Year - EnrollmentYear; - if (DateTime.Now.Month > 8) - { - year++; - } - builder.Append(year); - builder.Append(GroupNumber); - - return builder.ToString(); - } + public override string ToString() => $"{EducationDirection?.ShortName}-{AcademicCourse}{GroupNumber}"; } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/StudentGroupBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/StudentGroupBindingModels.cs index a6b8330..7ca901f 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/StudentGroupBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/StudentGroupBindingModels.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using DepartmentBusinessLogic.Enums; +using ModuleTools.Attributes; using ModuleTools.BindingModels; using System; using System.ComponentModel.DataAnnotations; @@ -10,7 +11,7 @@ namespace DepartmentBusinessLogic.BindingModels /// public class StudentGroupGetBindingModel : GetBindingModel { - public Guid? AcademicPlanId { get; set; } + public Guid? EducationDirectionId { get; set; } public Guid? LecturerId { get; set; } } @@ -21,16 +22,16 @@ namespace DepartmentBusinessLogic.BindingModels public class StudentGroupSetBindingModel : SetBindingModel { [Required(ErrorMessage = "required")] - [MapConfiguration("AcademicPlanId")] - public Guid AcademicPlanId { get; set; } + [MapConfiguration("EducationDirectionId")] + public Guid EducationDirectionId { get; set; } [Required(ErrorMessage = "required")] [MapConfiguration("GroupNumber")] public int GroupNumber { get; set; } [Required(ErrorMessage = "required")] - [MapConfiguration("EnrollmentYear")] - public int EnrollmentYear { get; set; } + [MapConfiguration("AcademicCourse")] + public AcademicCourse AcademicCourse { get; set; } [MapConfiguration("LecturerId")] public Guid? LecturerId { get; set; } diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Enums/AcademicCourse.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Enums/AcademicCourse.cs new file mode 100644 index 0000000..e721de2 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/Enums/AcademicCourse.cs @@ -0,0 +1,16 @@ +namespace DepartmentBusinessLogic.Enums +{ + /// + /// Учебный курс + /// + public enum AcademicCourse + { + Курс_1 = 1, + + Курс_2 = 2, + + Курс_3 = 3, + + Курс_4 = 4 + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanViewModels.cs index e9464c5..a57662e 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/AcademicPlanViewModels.cs @@ -16,8 +16,6 @@ namespace DepartmentBusinessLogic.ViewModels [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 1200, Height = 800)] [ViewModelControlElementDependenceEntity(Title = "Записи плана", Order = 1, ParentPropertyName = "AcademicPlanId", ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlAcademicPlanRecordList, DepartmentWindowsDesktop")] - [ViewModelControlElementDependenceEntity(Title = "Группы", Order = 2, ParentPropertyName = "AcademicPlanId", - ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentGroupList, DepartmentWindowsDesktop")] public class AcademicPlanViewModel : ElementViewModel { [ViewModelControlElementProperty("Направление", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEducationDirectionList, DepartmentWindowsDesktop")] diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EducationDirectionViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EducationDirectionViewModels.cs index 34002b3..68dea62 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EducationDirectionViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EducationDirectionViewModels.cs @@ -17,6 +17,8 @@ namespace DepartmentBusinessLogic.ViewModels [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)] [ViewModelControlElementDependenceEntity(Title = "Учебные планы", Order = 1, ParentPropertyName = "EducationDirectionId", ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlAcademicPlanList, DepartmentWindowsDesktop")] + [ViewModelControlElementDependenceEntity(Title = "Группы", Order = 2, ParentPropertyName = "EducationDirectionId", + ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentGroupList, DepartmentWindowsDesktop")] public class EducationDirectionViewModel : ElementViewModel { [ViewModelControlListProperty("Шифр", ColumnWidth = 80)] diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/StudentGroupViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/StudentGroupViewModels.cs index 7231313..235af9b 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/StudentGroupViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/StudentGroupViewModels.cs @@ -1,8 +1,8 @@ -using ModuleTools.Attributes; +using DepartmentBusinessLogic.Enums; +using ModuleTools.Attributes; using ModuleTools.Enums; using ModuleTools.ViewModels; using System; -using System.Text; namespace DepartmentBusinessLogic.ViewModels { @@ -21,51 +21,36 @@ namespace DepartmentBusinessLogic.ViewModels ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlOrderStudentRecordList, DepartmentWindowsDesktop")] public class StudentGroupViewModel : ElementViewModel { - [ViewModelControlElementProperty("Учебный план", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlAcademicPlanList, DepartmentWindowsDesktop")] - [MapConfiguration("AcademicPlanId")] - public Guid AcademicPlanId { get; set; } + [ViewModelControlElementProperty("Направление", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEducationDirectionList, DepartmentWindowsDesktop")] + [MapConfiguration("EducationDirectionId")] + public Guid EducationDirectionId { get; set; } [ViewModelControlListProperty("Шифр", ColumnWidth = 80)] - [MapConfiguration("AcademicPlan.EducationDirection.Cipher", IsDifficle = true)] - public string AcademicPlanEducationDirectionCipher { get; set; } + [MapConfiguration("EducationDirection.Cipher", IsDifficle = true)] + public string EducationDirectionCipher { get; set; } [ViewModelControlListProperty("Профиль")] - [MapConfiguration("AcademicPlan.EducationDirection.Profile", IsDifficle = true)] - public string AcademicPlanEducationDirectionProfile { get; set; } + [MapConfiguration("EducationDirection.Profile", IsDifficle = true)] + public string EducationDirectionProfile { get; set; } - [MapConfiguration("AcademicPlan.EducationDirection.ShortName", IsDifficle = true)] - public string AcademicPlanEducationDirectionShortName { get; set; } + [MapConfiguration("EducationDirection.ShortName", IsDifficle = true)] + public string EducationDirectionShortName { get; set; } [ViewModelControlListProperty("Группа")] - public string GroupName - { - get - { - var builder = new StringBuilder(); - builder.Append(AcademicPlanEducationDirectionShortName); - builder.Append('-'); - var year = DateTime.Now.Year - EnrollmentYear; - if (DateTime.Now.Month > 8) - { - year++; - } - builder.Append(year); - builder.Append(GroupNumber); + public string GroupName => $"{EducationDirectionShortName}-{(int)AcademicCourse}{GroupNumber}"; - return builder.ToString(); - } - } + [ViewModelControlElementProperty("Курс", ControlType.ControlEnum, MustHaveValue = true)] + [MapConfiguration("AcademicCourse")] + public AcademicCourse AcademicCourse { get; set; } + + [ViewModelControlListProperty("Курс")] + public string AcademicCourseTitle => AcademicCourse.ToString("G"); [ViewModelControlListProperty("Номер группы")] - [ViewModelControlElementProperty("Номер группы", ControlType.ControlInt, MustHaveValue = true, MinValue = 1, MaxValue = 4)] + [ViewModelControlElementProperty("Номер группы", ControlType.ControlInt, MustHaveValue = true, MinValue = 0, MaxValue = 4)] [MapConfiguration("GroupNumber")] public int GroupNumber { get; set; } - [ViewModelControlListProperty("Год зачисления")] - [ViewModelControlElementProperty("Год зачисления", ControlType.ControlInt, MustHaveValue = true)] - [MapConfiguration("EnrollmentYear")] - public int EnrollmentYear { get; set; } - [ViewModelControlElementProperty("Куратор", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerList, DepartmentWindowsDesktop")] [MapConfiguration("LecturerId")] public Guid? LecturerId { get; set; } diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AcademicPlanService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AcademicPlanService.cs index 697d8a9..ad4b092 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AcademicPlanService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AcademicPlanService.cs @@ -12,8 +12,6 @@ using ModuleTools.Models; using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Xml; using System.Xml.Linq; namespace DepartmentDatabaseImplementation.Implementations @@ -27,14 +25,7 @@ namespace DepartmentDatabaseImplementation.Implementations { protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, AcademicPlanSetBindingModel model) => OperationResultModel.Success(null); - protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, AcademicPlan entity, AcademicPlanGetBindingModel model) - { - if (context.Set().Any(x => x.AcademicPlanId == model.Id && !x.IsDeleted)) - { - return OperationResultModel.Error("Error:", "Есть учебные группы, относящиеся к этому учебному плану", ResultServiceStatusCode.ExsistItem); - } - return OperationResultModel.Success(null); - } + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, AcademicPlan entity, AcademicPlanGetBindingModel model) => OperationResultModel.Success(null); protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, AcademicPlanGetBindingModel model) { diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EducationDirectionService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EducationDirectionService.cs index 8a3d410..c4d7207 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EducationDirectionService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EducationDirectionService.cs @@ -26,6 +26,10 @@ namespace DepartmentDatabaseImplementation.Implementations { return OperationResultModel.Error("Error:", "Есть учебные планы, относящиеся к этому направлению", ResultServiceStatusCode.ExsistItem); } + if (context.Set().Any(x => x.EducationDirectionId == model.Id && !x.IsDeleted)) + { + return OperationResultModel.Error("Error:", "Есть учебные группы, относящиеся к этому направлению", ResultServiceStatusCode.ExsistItem); + } return OperationResultModel.Success(null); } diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentGroupService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentGroupService.cs index bb0d3e9..52dd8a8 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentGroupService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentGroupService.cs @@ -31,9 +31,9 @@ namespace DepartmentDatabaseImplementation.Implementations protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, StudentGroupGetBindingModel model) { - if (model.AcademicPlanId.HasValue) + if (model.EducationDirectionId.HasValue) { - query = query.Where(x => x.AcademicPlanId == model.AcademicPlanId.Value); + query = query.Where(x => x.EducationDirectionId == model.EducationDirectionId.Value); } if (model.LecturerId.HasValue) { @@ -55,10 +55,10 @@ namespace DepartmentDatabaseImplementation.Implementations context.SaveChanges(); } - protected override StudentGroup GetUniqueEntity(StudentGroupSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.AcademicPlanId == model.AcademicPlanId && x.EnrollmentYear == model.EnrollmentYear && x.GroupNumber == model.GroupNumber && x.Id != model.Id); + protected override StudentGroup GetUniqueEntity(StudentGroupSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.AcademicCourse == (int)model.AcademicCourse && x.GroupNumber == model.GroupNumber && x.Id != model.Id); - protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.AcademicPlan).Include(x => x.AcademicPlan.EducationDirection).Include(x => x.Lecturer); + protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.EducationDirection).Include(x => x.Lecturer); - protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.AcademicPlan.EducationDirection.Cipher).ThenBy(x => x.EnrollmentYear).ThenBy(x => x.GroupNumber); + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.EducationDirection.Cipher).ThenBy(x => x.AcademicCourse).ThenBy(x => x.GroupNumber); } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentService.cs index 869a303..1b0c02d 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentService.cs @@ -55,6 +55,6 @@ namespace DepartmentDatabaseImplementation.Implementations protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.StudentGroup).Include(x => x.User); - protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.StudentGroup.EnrollmentYear).ThenBy(x => x.StudentGroup.GroupNumber).ThenBy(x => x.LastName).ThenBy(x => x.FirstName); + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.StudentGroup.AcademicCourse).ThenBy(x => x.StudentGroup.GroupNumber).ThenBy(x => x.LastName).ThenBy(x => x.FirstName); } } \ No newline at end of file