diff --git a/DepartmentPortal/Common/CoreDatabase/DatabaseContext.cs b/DepartmentPortal/Common/CoreDatabase/DatabaseContext.cs index 174402b..b336b27 100644 --- a/DepartmentPortal/Common/CoreDatabase/DatabaseContext.cs +++ b/DepartmentPortal/Common/CoreDatabase/DatabaseContext.cs @@ -52,21 +52,19 @@ namespace CoreDatabase modelBuilder.Entity().HasIndex(d => new { d.TimeNormName, d.TimeNormShortName }).IsUnique(); - modelBuilder.Entity().HasIndex(d => new { d.EducationDirectionId, d.CreateDate }).IsUnique(); + modelBuilder.Entity().HasIndex(d => new { d.EducationDirectionId, d.YearStart }).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) .WithMany(x => x.AcademicPlanRecordTimeNormHours) .OnDelete(DeleteBehavior.NoAction); - modelBuilder.Entity().HasIndex(d => new { d.EducationDirectionId, d.AcademicCourse, d.GroupNumber }).IsUnique(); + modelBuilder.Entity().HasIndex(d => new { d.AcademicPlanId, d.YearEntrance, d.GroupNumber }).IsUnique(); modelBuilder.Entity().HasIndex(d => new { d.NumberOfBook }).IsUnique(); @@ -124,7 +122,6 @@ 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/20221214163806_ChangeStudentGroupLogic.Designer.cs b/DepartmentPortal/Common/CoreDatabase/Migrations/20221214163806_ChangeStudentGroupLogic.Designer.cs new file mode 100644 index 0000000..044a013 --- /dev/null +++ b/DepartmentPortal/Common/CoreDatabase/Migrations/20221214163806_ChangeStudentGroupLogic.Designer.cs @@ -0,0 +1,1526 @@ +// +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("20221214163806_ChangeStudentGroupLogic")] + partial class ChangeStudentGroupLogic + { + 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.BasicDepartment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("BasicDepartmentDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("BasicDepartmentName") + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EnterprisesName") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.ToTable("BasicDepartment"); + }); + + 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("BasicDepartmentId") + .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("BasicDepartmentId"); + + 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.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", "OrderDate", "OrderType") + .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("BasicDepartmentId") + .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("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("BasicDepartmentId"); + + 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("AcademicPlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("GroupNumber") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.Property("YearEntrance") + .HasColumnType("int"); + + b.Property("YearFinish") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("AcademicPlanId", "YearEntrance", "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.BasicDepartment", b => + { + b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer") + .WithMany("BasicDepartments") + .HasForeignKey("LecturerId"); + + b.Navigation("Lecturer"); + }); + + 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.BasicDepartment", "BasicDepartment") + .WithMany("Disciplines") + .HasForeignKey("BasicDepartmentId"); + + b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("Disciplines") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("BasicDepartment"); + + 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.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.BasicDepartment", "BasicDepartment") + .WithMany("Students") + .HasForeignKey("BasicDepartmentId"); + + 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("BasicDepartment"); + + b.Navigation("StudentGroup"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.StudentGroup", b => + { + b.HasOne("CoreDatabase.Models.Department.AcademicPlan", "AcademicPlan") + .WithMany("StudentGroups") + .HasForeignKey("AcademicPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer") + .WithMany("StudentGroups") + .HasForeignKey("LecturerId"); + + b.Navigation("AcademicPlan"); + + 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"); + + b.Navigation("StudentGroups"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlanRecord", b => + { + b.Navigation("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.BasicDepartment", b => + { + b.Navigation("Disciplines"); + + b.Navigation("Students"); + }); + + 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"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b => + { + b.Navigation("Classrooms"); + + b.Navigation("EmployeePosts"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b => + { + b.Navigation("BasicDepartments"); + + 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/20221214163806_ChangeStudentGroupLogic.cs b/DepartmentPortal/Common/CoreDatabase/Migrations/20221214163806_ChangeStudentGroupLogic.cs new file mode 100644 index 0000000..c29f350 --- /dev/null +++ b/DepartmentPortal/Common/CoreDatabase/Migrations/20221214163806_ChangeStudentGroupLogic.cs @@ -0,0 +1,152 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace CoreDatabase.Migrations +{ + public partial class ChangeStudentGroupLogic : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_StudentGroups_EducationDirections_EducationDirectionId", + table: "StudentGroups"); + + 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_StudentGroups_EducationDirectionId_AcademicCourse_GroupNumber", + table: "StudentGroups"); + + migrationBuilder.DropColumn( + name: "EnrollmentYearId", + table: "Students"); + + migrationBuilder.RenameColumn( + name: "EducationDirectionId", + table: "StudentGroups", + newName: "AcademicPlanId"); + + migrationBuilder.RenameColumn( + name: "AcademicCourse", + table: "StudentGroups", + newName: "YearFinish"); + + migrationBuilder.AddColumn( + name: "YearEntrance", + table: "StudentGroups", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateIndex( + name: "IX_StudentGroups_AcademicPlanId_YearEntrance_GroupNumber", + table: "StudentGroups", + columns: new[] { "AcademicPlanId", "YearEntrance", "GroupNumber" }, + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_StudentGroups_AcademicPlans_AcademicPlanId", + table: "StudentGroups", + column: "AcademicPlanId", + principalTable: "AcademicPlans", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_StudentGroups_AcademicPlans_AcademicPlanId", + table: "StudentGroups"); + + migrationBuilder.DropIndex( + name: "IX_StudentGroups_AcademicPlanId_YearEntrance_GroupNumber", + table: "StudentGroups"); + + migrationBuilder.DropColumn( + name: "YearEntrance", + table: "StudentGroups"); + + migrationBuilder.RenameColumn( + name: "YearFinish", + table: "StudentGroups", + newName: "AcademicCourse"); + + migrationBuilder.RenameColumn( + name: "AcademicPlanId", + table: "StudentGroups", + newName: "EducationDirectionId"); + + migrationBuilder.AddColumn( + name: "EnrollmentYearId", + table: "Students", + type: "uniqueidentifier", + nullable: true); + + migrationBuilder.CreateTable( + name: "EnrollmentYears", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + AcademicPlanId = table.Column(type: "uniqueidentifier", nullable: false), + DateCreate = table.Column(type: "datetime2", nullable: false), + DateDelete = table.Column(type: "datetime2", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false), + YearEntrance = table.Column(type: "int", nullable: false), + YearFinish = table.Column(type: "int", 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_StudentGroups_EducationDirectionId_AcademicCourse_GroupNumber", + table: "StudentGroups", + columns: new[] { "EducationDirectionId", "AcademicCourse", "GroupNumber" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_EnrollmentYears_AcademicPlanId_YearEntrance", + table: "EnrollmentYears", + columns: new[] { "AcademicPlanId", "YearEntrance" }, + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_StudentGroups_EducationDirections_EducationDirectionId", + table: "StudentGroups", + column: "EducationDirectionId", + principalTable: "EducationDirections", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Students_EnrollmentYears_EnrollmentYearId", + table: "Students", + column: "EnrollmentYearId", + principalTable: "EnrollmentYears", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/DepartmentPortal/Common/CoreDatabase/Migrations/20221215062113_UpdateAcademicPlanSetYearStart.Designer.cs b/DepartmentPortal/Common/CoreDatabase/Migrations/20221215062113_UpdateAcademicPlanSetYearStart.Designer.cs new file mode 100644 index 0000000..feda65e --- /dev/null +++ b/DepartmentPortal/Common/CoreDatabase/Migrations/20221215062113_UpdateAcademicPlanSetYearStart.Designer.cs @@ -0,0 +1,1526 @@ +// +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("20221215062113_UpdateAcademicPlanSetYearStart")] + partial class UpdateAcademicPlanSetYearStart + { + 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("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EducationDirectionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastUpdateDate") + .HasColumnType("datetime2"); + + b.Property("YearStart") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EducationDirectionId", "YearStart") + .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.BasicDepartment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("BasicDepartmentDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("BasicDepartmentName") + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EnterprisesName") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.ToTable("BasicDepartment"); + }); + + 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("BasicDepartmentId") + .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("BasicDepartmentId"); + + 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.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", "OrderDate", "OrderType") + .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("BasicDepartmentId") + .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("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("BasicDepartmentId"); + + 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("AcademicPlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("GroupNumber") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.Property("YearEntrance") + .HasColumnType("int"); + + b.Property("YearFinish") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("AcademicPlanId", "YearEntrance", "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.BasicDepartment", b => + { + b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer") + .WithMany("BasicDepartments") + .HasForeignKey("LecturerId"); + + b.Navigation("Lecturer"); + }); + + 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.BasicDepartment", "BasicDepartment") + .WithMany("Disciplines") + .HasForeignKey("BasicDepartmentId"); + + b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("Disciplines") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("BasicDepartment"); + + 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.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.BasicDepartment", "BasicDepartment") + .WithMany("Students") + .HasForeignKey("BasicDepartmentId"); + + 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("BasicDepartment"); + + b.Navigation("StudentGroup"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.StudentGroup", b => + { + b.HasOne("CoreDatabase.Models.Department.AcademicPlan", "AcademicPlan") + .WithMany("StudentGroups") + .HasForeignKey("AcademicPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer") + .WithMany("StudentGroups") + .HasForeignKey("LecturerId"); + + b.Navigation("AcademicPlan"); + + 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"); + + b.Navigation("StudentGroups"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlanRecord", b => + { + b.Navigation("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.BasicDepartment", b => + { + b.Navigation("Disciplines"); + + b.Navigation("Students"); + }); + + 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"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b => + { + b.Navigation("Classrooms"); + + b.Navigation("EmployeePosts"); + }); + + modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b => + { + b.Navigation("BasicDepartments"); + + 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/20221215062113_UpdateAcademicPlanSetYearStart.cs b/DepartmentPortal/Common/CoreDatabase/Migrations/20221215062113_UpdateAcademicPlanSetYearStart.cs new file mode 100644 index 0000000..a7fbd0e --- /dev/null +++ b/DepartmentPortal/Common/CoreDatabase/Migrations/20221215062113_UpdateAcademicPlanSetYearStart.cs @@ -0,0 +1,65 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace CoreDatabase.Migrations +{ + public partial class UpdateAcademicPlanSetYearStart : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_AcademicPlans_EducationDirectionId_CreateDate", + table: "AcademicPlans"); + + migrationBuilder.AddColumn( + name: "YearStart", + table: "AcademicPlans", + type: "int", + nullable: false, + defaultValue: 0); + + //требуется для создания уникального индекса IX_AcademicPlans_EducationDirectionId_YearStart, если уже есть записи в AcademicPlans + migrationBuilder.Sql( +@" + UPDATE AcademicPlans + SET YearStart = YEAR(CreateDate) +"); + + migrationBuilder.DropColumn( + name: "CreateDate", + table: "AcademicPlans"); + + migrationBuilder.CreateIndex( + name: "IX_AcademicPlans_EducationDirectionId_YearStart", + table: "AcademicPlans", + columns: new[] { "EducationDirectionId", "YearStart" }, + unique: true, + filter: "[EducationDirectionId] IS NOT NULL"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_AcademicPlans_EducationDirectionId_YearStart", + table: "AcademicPlans"); + + migrationBuilder.DropColumn( + name: "YearStart", + table: "AcademicPlans"); + + migrationBuilder.AddColumn( + name: "CreateDate", + table: "AcademicPlans", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.CreateIndex( + name: "IX_AcademicPlans_EducationDirectionId_CreateDate", + table: "AcademicPlans", + columns: new[] { "EducationDirectionId", "CreateDate" }, + unique: true, + filter: "[EducationDirectionId] IS NOT NULL"); + } + } +} diff --git a/DepartmentPortal/Common/CoreDatabase/Migrations/DatabaseContextModelSnapshot.cs b/DepartmentPortal/Common/CoreDatabase/Migrations/DatabaseContextModelSnapshot.cs index b7fdb03..a02fea7 100644 --- a/DepartmentPortal/Common/CoreDatabase/Migrations/DatabaseContextModelSnapshot.cs +++ b/DepartmentPortal/Common/CoreDatabase/Migrations/DatabaseContextModelSnapshot.cs @@ -24,9 +24,6 @@ namespace CoreDatabase.Migrations b.Property("Id") .HasColumnType("uniqueidentifier"); - b.Property("CreateDate") - .HasColumnType("datetime2"); - b.Property("DateCreate") .HasColumnType("datetime2"); @@ -42,9 +39,12 @@ namespace CoreDatabase.Migrations b.Property("LastUpdateDate") .HasColumnType("datetime2"); + b.Property("YearStart") + .HasColumnType("int"); + b.HasKey("Id"); - b.HasIndex("EducationDirectionId", "CreateDate") + b.HasIndex("EducationDirectionId", "YearStart") .IsUnique() .HasFilter("[EducationDirectionId] IS NOT NULL"); @@ -448,37 +448,6 @@ 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") @@ -822,9 +791,6 @@ namespace CoreDatabase.Migrations b.Property("Email") .HasColumnType("nvarchar(max)"); - b.Property("EnrollmentYearId") - .HasColumnType("uniqueidentifier"); - b.Property("FirstName") .IsRequired() .HasColumnType("nvarchar(max)"); @@ -866,8 +832,6 @@ namespace CoreDatabase.Migrations b.HasIndex("BasicDepartmentId"); - b.HasIndex("EnrollmentYearId"); - b.HasIndex("NumberOfBook") .IsUnique(); @@ -883,8 +847,8 @@ namespace CoreDatabase.Migrations b.Property("Id") .HasColumnType("uniqueidentifier"); - b.Property("AcademicCourse") - .HasColumnType("int"); + b.Property("AcademicPlanId") + .HasColumnType("uniqueidentifier"); b.Property("DateCreate") .HasColumnType("datetime2"); @@ -892,9 +856,6 @@ namespace CoreDatabase.Migrations b.Property("DateDelete") .HasColumnType("datetime2"); - b.Property("EducationDirectionId") - .HasColumnType("uniqueidentifier"); - b.Property("GroupNumber") .HasColumnType("int"); @@ -904,11 +865,17 @@ namespace CoreDatabase.Migrations b.Property("LecturerId") .HasColumnType("uniqueidentifier"); + b.Property("YearEntrance") + .HasColumnType("int"); + + b.Property("YearFinish") + .HasColumnType("int"); + b.HasKey("Id"); b.HasIndex("LecturerId"); - b.HasIndex("EducationDirectionId", "AcademicCourse", "GroupNumber") + b.HasIndex("AcademicPlanId", "YearEntrance", "GroupNumber") .IsUnique(); b.ToTable("StudentGroups"); @@ -1267,17 +1234,6 @@ 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") @@ -1370,10 +1326,6 @@ namespace CoreDatabase.Migrations .WithMany("Students") .HasForeignKey("BasicDepartmentId"); - b.HasOne("CoreDatabase.Models.Department.EnrollmentYear", "EnrollmentYear") - .WithMany("Students") - .HasForeignKey("EnrollmentYearId"); - b.HasOne("CoreDatabase.Models.Department.StudentGroup", "StudentGroup") .WithMany("Students") .HasForeignKey("StudentGroupId"); @@ -1386,8 +1338,6 @@ namespace CoreDatabase.Migrations b.Navigation("BasicDepartment"); - b.Navigation("EnrollmentYear"); - b.Navigation("StudentGroup"); b.Navigation("User"); @@ -1395,9 +1345,9 @@ namespace CoreDatabase.Migrations modelBuilder.Entity("CoreDatabase.Models.Department.StudentGroup", b => { - b.HasOne("CoreDatabase.Models.Department.EducationDirection", "EducationDirection") + b.HasOne("CoreDatabase.Models.Department.AcademicPlan", "AcademicPlan") .WithMany("StudentGroups") - .HasForeignKey("EducationDirectionId") + .HasForeignKey("AcademicPlanId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -1405,7 +1355,7 @@ namespace CoreDatabase.Migrations .WithMany("StudentGroups") .HasForeignKey("LecturerId"); - b.Navigation("EducationDirection"); + b.Navigation("AcademicPlan"); b.Navigation("Lecturer"); }); @@ -1454,6 +1404,8 @@ namespace CoreDatabase.Migrations modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlan", b => { b.Navigation("AcademicPlanRecords"); + + b.Navigation("StudentGroups"); }); modelBuilder.Entity("CoreDatabase.Models.Department.AcademicPlanRecord", b => @@ -1483,8 +1435,6 @@ namespace CoreDatabase.Migrations modelBuilder.Entity("CoreDatabase.Models.Department.EducationDirection", b => { b.Navigation("AcademicPlans"); - - b.Navigation("StudentGroups"); }); modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b => @@ -1494,11 +1444,6 @@ 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("BasicDepartments"); diff --git a/DepartmentPortal/Common/CoreDatabase/Models/Department/AcademicPlan.cs b/DepartmentPortal/Common/CoreDatabase/Models/Department/AcademicPlan.cs index a20e1fb..df9764c 100644 --- a/DepartmentPortal/Common/CoreDatabase/Models/Department/AcademicPlan.cs +++ b/DepartmentPortal/Common/CoreDatabase/Models/Department/AcademicPlan.cs @@ -16,7 +16,7 @@ namespace CoreDatabase.Models.Department [DataMember] [Required(ErrorMessage = "required")] - public DateTime CreateDate { get; set; } + public int YearStart { get; set; } [DataMember] [Required(ErrorMessage = "required")] @@ -31,10 +31,13 @@ namespace CoreDatabase.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; - public override string ToString() => $"{EducationDirection?.ShortName}({EducationDirection?.Profile}): {CreateDate:d}"; + public override string ToString() => $"{EducationDirection?.ShortName}({EducationDirection?.Profile}): {YearStart}"; } } \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreDatabase/Models/Department/EducationDirection.cs b/DepartmentPortal/Common/CoreDatabase/Models/Department/EducationDirection.cs index d7eea25..81d2c82 100644 --- a/DepartmentPortal/Common/CoreDatabase/Models/Department/EducationDirection.cs +++ b/DepartmentPortal/Common/CoreDatabase/Models/Department/EducationDirection.cs @@ -48,9 +48,6 @@ namespace CoreDatabase.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/CoreDatabase/Models/Department/EnrollmentYear.cs b/DepartmentPortal/Common/CoreDatabase/Models/Department/EnrollmentYear.cs deleted file mode 100644 index 16de661..0000000 --- a/DepartmentPortal/Common/CoreDatabase/Models/Department/EnrollmentYear.cs +++ /dev/null @@ -1,40 +0,0 @@ -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 095012e..e7b76e4 100644 --- a/DepartmentPortal/Common/CoreDatabase/Models/Department/Student.cs +++ b/DepartmentPortal/Common/CoreDatabase/Models/Department/Student.cs @@ -21,9 +21,6 @@ namespace CoreDatabase.Models.Department [DataMember] public Guid? StudentGroupId { get; set; } - [DataMember] - public Guid? EnrollmentYearId { get; set; } - [DataMember] public Guid? BasicDepartmentId { get; set; } @@ -67,8 +64,6 @@ namespace CoreDatabase.Models.Department public virtual StudentGroup StudentGroup { get; set; } - public virtual EnrollmentYear EnrollmentYear { get; set; } - public virtual BasicDepartment BasicDepartment { get; set; } //------------------------------------------------------------------------- diff --git a/DepartmentPortal/Common/CoreDatabase/Models/Department/StudentGroup.cs b/DepartmentPortal/Common/CoreDatabase/Models/Department/StudentGroup.cs index 5565682..540d6d4 100644 --- a/DepartmentPortal/Common/CoreDatabase/Models/Department/StudentGroup.cs +++ b/DepartmentPortal/Common/CoreDatabase/Models/Department/StudentGroup.cs @@ -11,49 +11,66 @@ using ToolsModule.ManagmentSecurity; namespace CoreDatabase.Models.Department { [DataContract] - public class StudentGroup : BaseEntity, IEntitySecurityExtenstion, IStudentGroupModel - { - [DataMember] - [Required(ErrorMessage = "required")] - public Guid EducationDirectionId { get; set; } + public class StudentGroup : BaseEntity, IEntitySecurityExtenstion, IStudentGroupModel + { + [DataMember] + [Required(ErrorMessage = "required")] + public Guid AcademicPlanId { get; set; } - [DataMember] - [Required(ErrorMessage = "required")] - public int GroupNumber { get; set; } + [DataMember] + [Required(ErrorMessage = "required")] + public int YearEntrance { get; set; } - [DataMember] - [Required(ErrorMessage = "required")] - public AcademicCourse AcademicCourse { get; set; } + [DataMember] + [Required(ErrorMessage = "required")] + public int YearFinish { get; set; } - [DataMember] - public Guid? LecturerId { get; set; } + [NotMapped] + public AcademicCourse AcademicCourse => DateTime.Now.Year + DateTime.Now.Month / 8 > YearFinish + ? AcademicCourse.Неопределен + : (DateTime.Now.Year + DateTime.Now.Month / 8 - YearEntrance) switch + { + 1 => AcademicCourse.Курс_1, + 2 => AcademicCourse.Курс_2, + 3 => AcademicCourse.Курс_3, + 4 => AcademicCourse.Курс_4, + 5 => AcademicCourse.Курс_5, + _ => AcademicCourse.Неопределен, + }; - //------------------------------------------------------------------------- + [DataMember] + [Required(ErrorMessage = "required")] + public int GroupNumber { get; set; } - public virtual EducationDirection EducationDirection { get; set; } + [DataMember] + public Guid? LecturerId { get; set; } - public virtual Lecturer Lecturer { get; set; } + //------------------------------------------------------------------------- - //------------------------------------------------------------------------- + public virtual AcademicPlan AcademicPlan { get; set; } - [ForeignKey("StudentGroupId")] - public virtual List Students { get; set; } + public virtual Lecturer Lecturer { get; set; } - [ForeignKey("StudentGroupFromId")] - public virtual List OrderStudentRecordFroms { get; set; } + //------------------------------------------------------------------------- - [ForeignKey("StudentGroupToId")] - public virtual List OrderStudentRecordTos { get; set; } + [ForeignKey("StudentGroupId")] + public virtual List Students { get; set; } - //------------------------------------------------------------------------- + [ForeignKey("StudentGroupFromId")] + public virtual List OrderStudentRecordFroms { get; set; } - public StudentGroup SecurityCheck(StudentGroup entity, bool allowFullData) => entity; + [ForeignKey("StudentGroupToId")] + public virtual List OrderStudentRecordTos { get; set; } - public override string ToString() => $"{EducationDirection?.ShortName}-{AcademicCourse}{GroupNumber}"; + //------------------------------------------------------------------------- - public int GetStudnetsByState(StudentState state) + public StudentGroup SecurityCheck(StudentGroup entity, bool allowFullData) => entity; + + public override string ToString() => $"{AcademicPlan?.EducationDirection?.ShortName}-{((int)AcademicCourse)}{GroupNumber}"; + + public int GetStudnetsByState(StudentState state) { - return Students?.Where(x => x.StudentState == state)?.Count() ?? 0; + return Students?.Where(x => x.StudentState == state)?.Count() ?? 0; } - } + } } \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreDatabase/Models/Security/UserRole.cs b/DepartmentPortal/Common/CoreDatabase/Models/Security/UserRole.cs index 5d06832..50364ea 100644 --- a/DepartmentPortal/Common/CoreDatabase/Models/Security/UserRole.cs +++ b/DepartmentPortal/Common/CoreDatabase/Models/Security/UserRole.cs @@ -26,6 +26,6 @@ namespace CoreDatabase.Models.Security public UserRole SecurityCheck(UserRole entity, bool allowFullData) => entity; - public override string ToString() => $"{Role.RoleName}-{User.UserName}"; + public override string ToString() => $"{Role?.RoleName}-{User?.UserName}"; } } \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreModels/Enums/Department/AcademicCourse.cs b/DepartmentPortal/Common/CoreModels/Enums/Department/AcademicCourse.cs index 0a4d80f..404579a 100644 --- a/DepartmentPortal/Common/CoreModels/Enums/Department/AcademicCourse.cs +++ b/DepartmentPortal/Common/CoreModels/Enums/Department/AcademicCourse.cs @@ -5,12 +5,16 @@ /// public enum AcademicCourse { + Неопределен = 0, + Курс_1 = 1, Курс_2 = 2, Курс_3 = 3, - Курс_4 = 4 + Курс_4 = 4, + + Курс_5 = 5 } } diff --git a/DepartmentPortal/Common/CoreModels/Enums/Department/OrderStudentMoveType.cs b/DepartmentPortal/Common/CoreModels/Enums/Department/OrderStudentMoveType.cs index 0efda45..677e73c 100644 --- a/DepartmentPortal/Common/CoreModels/Enums/Department/OrderStudentMoveType.cs +++ b/DepartmentPortal/Common/CoreModels/Enums/Department/OrderStudentMoveType.cs @@ -42,11 +42,6 @@ /// ПеревестиНаДругоеНаправлениеКафедры = 7, - /// - /// Студент переводится с нашей кафедры на другую - /// - УбратьПоПереводу = 8, - /// /// Уход в акакдем студента /// @@ -68,7 +63,7 @@ ОтчислитьЗаНевыходСАкадема = 13, /// - /// Уход студента в другой ВУЗ + /// Уход студента в другой ВУЗ/ другую кафедру /// ОтчислитьВСвязиСПереводом = 20, @@ -85,6 +80,11 @@ /// /// Восстановление студента после отчисления по собственному /// - Восстановить = 23 + Восстановить = 23, + + /// + /// Отчисление студента из-за неоплаты обучения + /// + ОтчислитьЗаНеоплату = 24 } } \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IAcademicPlanModel.cs b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IAcademicPlanModel.cs index 6644c7c..00db5fe 100644 --- a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IAcademicPlanModel.cs +++ b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IAcademicPlanModel.cs @@ -10,7 +10,7 @@ namespace CoreModels.ModelsDepartment { Guid? EducationDirectionId { get; } - DateTime CreateDate { get; } + int YearStart { get; } DateTime LastUpdateDate { get; } } diff --git a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IEnrollmentYearModel.cs b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IEnrollmentYearModel.cs deleted file mode 100644 index e8cedfd..0000000 --- a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IEnrollmentYearModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -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/IStudentGroupModel.cs b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IStudentGroupModel.cs index 1bf1c5d..2f68261 100644 --- a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IStudentGroupModel.cs +++ b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IStudentGroupModel.cs @@ -6,11 +6,15 @@ using ToolsModule.ManagmentEntity; namespace CoreModels.ModelsDepartment { [EntityDescription("StudentGroup", "Учебная группа кафедры")] - [EntityDependency("EducationDirection", "EducationDirectionId", "Направление, по которому учится группа")] + [EntityDependency("AcademicPlan", "AcademicPlanId", "Учебный план, по которому учится группа")] [EntityDependency("Lecturer", "LecturerId", "Куратор группы")] public interface IStudentGroupModel : IId { - Guid EducationDirectionId { get; } + Guid AcademicPlanId { get; } + + int YearEntrance { get; } + + int YearFinish { get; } int GroupNumber { get; } diff --git a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IStudentModel.cs b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IStudentModel.cs index 159b177..e31a574 100644 --- a/DepartmentPortal/Common/CoreModels/ModelsDepartment/IStudentModel.cs +++ b/DepartmentPortal/Common/CoreModels/ModelsDepartment/IStudentModel.cs @@ -8,7 +8,6 @@ namespace CoreModels.ModelsDepartment [EntityDescription("Student", "Студент кафедры")] [EntityDependency("User", "UserId", "К какому пользователю относится студент")] [EntityDependency("StudentGroup", "StudentGroupId", "К какой группе относится студент")] - [EntityDependency("EnrollmentYear", "EnrollmentYearId", "К какому году поступления/выпуска относится")] [EntityDependency("BasicDepartment", "BasicDepartmentId", "Базовая кафедра, к которой относится студент")] public interface IStudentModel : IId { @@ -16,8 +15,6 @@ namespace CoreModels.ModelsDepartment Guid? StudentGroupId { get; } - Guid? EnrollmentYearId { get; } - Guid? BasicDepartmentId { get; } string Iduniv { get; } diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/EnrollmentYearBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/EnrollmentYearBusinessLogic.cs deleted file mode 100644 index 421af07..0000000 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/EnrollmentYearBusinessLogic.cs +++ /dev/null @@ -1,17 +0,0 @@ -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/BusinessLogics/GenericBusinessLogic/OrderStudentRecordBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/OrderStudentRecordBusinessLogic.cs index c81f6c0..ff23974 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/OrderStudentRecordBusinessLogic.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/OrderStudentRecordBusinessLogic.cs @@ -16,183 +16,181 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic /// Логика работы с записями приказов /// public class OrderStudentRecordBusinessLogic : GenericBusinessLogic, IOrderStudentRecordLogic - { - public OrderStudentRecordBusinessLogic(IOrderStudentRecordService service) : base(service, "Приказы", AccessOperation.Приказы) { } + { + public OrderStudentRecordBusinessLogic(IOrderStudentRecordService service) : base(service, "Приказы", AccessOperation.Приказы) { } - public override OrderStudentRecordViewModel Create(OrderStudentRecordSetBindingModel model) - { - var result = base.Create(model); - if (result != null) - { - var studentLogic = DependencyManager.Instance.Resolve(); - var userLogic = DependencyManager.Instance.Resolve(); - var student = model.StudentModel; - if (student == null) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка при получении студента", $"Не удалось получить студента")); - return null; - } - // изменять студента - var st = Mapper.MapToClass(student, true); - var studentName = student.ToString(); - - bool haveChages = false; - if (student.StudentGroupId != result.StudentGroupToId) - { - st.StudentGroupId = result.StudentGroupToId; - haveChages = true; - } - if (student.Description != model.Info) - { - st.Description = model.Info; - haveChages = true; - } - - if ((result.OrderStudentMoveType == OrderStudentMoveType.ЗачислитьПоПриказу || - result.OrderStudentMoveType == OrderStudentMoveType.Распределить || - result.OrderStudentMoveType == OrderStudentMoveType.ПринятьПоПереводу || - result.OrderStudentMoveType == OrderStudentMoveType.ПринятьПоПереводусДругогоВуза || - result.OrderStudentMoveType == OrderStudentMoveType.ПеревестиНаДругоеНаправлениеКафедры) - && student.StudentState != StudentState.Учится) - { - st.StudentState = StudentState.Учится; - student = studentLogic.Update(st); - haveChages = false; - if (student == null) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}")); - return null; - } - } - - if ((result.OrderStudentMoveType == OrderStudentMoveType.ОтправитьВАкадем || - result.OrderStudentMoveType == OrderStudentMoveType.ПродлитьАкадем) - && student.StudentState != StudentState.Академ) - { - st.StudentState = StudentState.Академ; - student = studentLogic.Update(st); - haveChages = false; - if (student == null) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}")); - return null; - } - } - - if (result.OrderStudentMoveType == OrderStudentMoveType.ВосстановитьИзАкадема && student.StudentState != StudentState.Учится) - { - st.StudentState = StudentState.Учится; - student = studentLogic.Update(st); - haveChages = false; - if (student == null) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}")); - return null; - } - } - - if ((result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьВСвязиСПереводом || - result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьЗаНевыходСАкадема || - result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьЗаНеуспевамость || - result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьПоСобственному || - result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьПоЗавершению) && - student.StudentState != StudentState.Отчислен) - { - st.StudentState = result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьПоЗавершению ? StudentState.Завершил : StudentState.Отчислен; - student = studentLogic.Update(st); - haveChages = false; - if (student == null) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}")); - return null; - } - var delete = studentLogic.Delete(new StudentGetBindingModel { Id = student.Id }); - if (!delete) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка удаления студента", $"Не удалось удалить студента {studentName}")); - return null; - } - delete = userLogic.Delete(new UserGetBindingModel { Id = student.UserId }); - if (!delete) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка удаления пользователя по студенту", $"Не удалось удалить пользователя по студенту {studentName}")); - return null; - } - } - - if (result.OrderStudentMoveType == OrderStudentMoveType.Восстановить && student.StudentState != StudentState.Учится) - { - var deletedStudent = studentLogic.Restore(new StudentGetBindingModel { NumberOfBook = student.NumberOfBook }); - if (deletedStudent == null) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка при восстановлении студента", $"Не удалось восстановить студента {studentName}")); - return null; - } - var deletedUser = userLogic.Restore(new UserGetBindingModel { Id = deletedStudent.UserId }); - if (deletedUser == null) - { - Errors.AddRange(userLogic.Errors); - Errors.Add(("Ошибка при восстановлении пользователя студента", $"Не удалось восстановить пользователя студента {studentName}")); - return null; - } - st.StudentState = StudentState.Учится; - student = studentLogic.Update(st); - haveChages = false; - if (student == null) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}")); - return null; - } - } - - if (result.OrderStudentMoveType == OrderStudentMoveType.УбратьПоПереводу && student.StudentState != StudentState.Ушел) - { - st.StudentState = StudentState.Ушел; - student = studentLogic.Update(st); - haveChages = false; - if (student == null) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}")); - return null; - } - var delete = studentLogic.Delete(new StudentGetBindingModel { Id = student.Id }); - if (!delete) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка удаления студента", $"Не удалось удалить студента {studentName}")); - return null; - } - delete = userLogic.Delete(new UserGetBindingModel { Id = student.UserId }); - if (!delete) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка удаления пользователя по студенту", $"Не удалось удалить пользователя по студенту {studentName}")); - return null; - } - } - - if (haveChages) + public override OrderStudentRecordViewModel Create(OrderStudentRecordSetBindingModel model) + { + var result = base.Create(model); + if (result != null) + { + var studentLogic = DependencyManager.Instance.Resolve(); + var userLogic = DependencyManager.Instance.Resolve(); + var student = studentLogic.GetElement(new StudentGetBindingModel { - student = studentLogic.Update(st); - if (student == null) - { - Errors.AddRange(studentLogic.Errors); - Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить данные у студента {studentName}")); - return null; - } - } - } - return result; - } - } + NumberOfBook = model.StudentModel.NumberOfBook, + IgnoreDeleted = true + }); + if (student == null) + { + Errors.AddRange(studentLogic.Errors); + Errors.Add(("Ошибка при получении студента", $"Не удалось получить студента")); + return null; + } + // изменять студента + var st = Mapper.MapToClass(student, true); + var studentName = student.ToString(); + + bool haveChages = false; + if (student.StudentGroupId != result.StudentGroupToId) + { + st.StudentGroupId = result.StudentGroupToId; + haveChages = true; + } + if (student.Description != model.Info) + { + st.Description = model.Info; + haveChages = true; + } + + if ((result.OrderStudentMoveType == OrderStudentMoveType.ЗачислитьПоПриказу || + result.OrderStudentMoveType == OrderStudentMoveType.Распределить || + result.OrderStudentMoveType == OrderStudentMoveType.ПринятьПоПереводу || + result.OrderStudentMoveType == OrderStudentMoveType.ПринятьПоПереводусДругогоВуза || + result.OrderStudentMoveType == OrderStudentMoveType.ПеревестиНаДругоеНаправлениеКафедры || + result.OrderStudentMoveType == OrderStudentMoveType.ПеревестиНаСтаршийКурс) + && student.StudentState != StudentState.Учится) + { + if (st.StudentState == StudentState.Отчислен || st.StudentState == StudentState.Ушел) + { + var deletedStudent = studentLogic.Restore(new StudentGetBindingModel { NumberOfBook = student.NumberOfBook }); + if (deletedStudent == null) + { + Errors.AddRange(studentLogic.Errors); + Errors.Add(("Ошибка при восстановлении студента", $"Не удалось восстановить студента {studentName}, приказ: {result.OrderStudentMoveType}")); + return null; + } + var deletedUser = userLogic.Restore(new UserGetBindingModel { Id = deletedStudent.UserId }); + if (deletedUser == null) + { + Errors.AddRange(userLogic.Errors); + Errors.Add(("Ошибка при восстановлении пользователя студента", $"Не удалось восстановить пользователя студента {studentName}")); + return null; + } + st = Mapper.MapToClass(deletedStudent, true); + } + st.StudentState = StudentState.Учится; + student = studentLogic.Update(st); + haveChages = false; + if (student == null) + { + Errors.AddRange(studentLogic.Errors); + Errors.Add(("Ошибка изменения по студенту", $"Не удалось перевести в статус 'Учится' студента {studentName}, приказ: {result.OrderStudentMoveType}")); + return null; + } + } + + if ((result.OrderStudentMoveType == OrderStudentMoveType.ОтправитьВАкадем || + result.OrderStudentMoveType == OrderStudentMoveType.ПродлитьАкадем) + && student.StudentState != StudentState.Академ) + { + st.StudentState = StudentState.Академ; + student = studentLogic.Update(st); + haveChages = false; + if (student == null) + { + Errors.AddRange(studentLogic.Errors); + Errors.Add(("Ошибка изменения по студенту", $"Не удалось перевести в статус 'Академ' студента {studentName}, приказ: {result.OrderStudentMoveType}")); + return null; + } + } + + if (result.OrderStudentMoveType == OrderStudentMoveType.ВосстановитьИзАкадема && student.StudentState != StudentState.Учится) + { + st.StudentState = StudentState.Учится; + student = studentLogic.Update(st); + haveChages = false; + if (student == null) + { + Errors.AddRange(studentLogic.Errors); + Errors.Add(("Ошибка изменения по студенту", $"Не удалось восстановить в статус 'Учится' студента {studentName}, приказ: {result.OrderStudentMoveType}")); + return null; + } + } + + if ((result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьВСвязиСПереводом || + result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьЗаНевыходСАкадема || + result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьЗаНеуспевамость || + result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьПоСобственному || + result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьПоЗавершению) && + student.StudentState != StudentState.Отчислен) + { + st.StudentState = result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьПоЗавершению ? StudentState.Завершил : + result.OrderStudentMoveType == OrderStudentMoveType.ОтчислитьВСвязиСПереводом ? StudentState.Ушел : + StudentState.Отчислен; + student = studentLogic.Update(st); + haveChages = false; + if (student == null) + { + Errors.AddRange(studentLogic.Errors); + Errors.Add(("Ошибка изменения по студенту", $"Не удалось перевести в статус 'Отчислен' студента {studentName}, приказ: {result.OrderStudentMoveType}")); + return null; + } + var delete = studentLogic.Delete(new StudentGetBindingModel { Id = student.Id }); + if (!delete) + { + Errors.AddRange(studentLogic.Errors); + Errors.Add(("Ошибка удаления студента", $"Не удалось удалить студента {studentName}")); + return null; + } + delete = userLogic.Delete(new UserGetBindingModel { Id = student.UserId }); + if (!delete) + { + Errors.AddRange(studentLogic.Errors); + Errors.Add(("Ошибка удаления пользователя по студенту", $"Не удалось удалить пользователя по студенту {studentName}")); + return null; + } + } + + if (result.OrderStudentMoveType == OrderStudentMoveType.Восстановить && student.StudentState != StudentState.Учится) + { + var deletedStudent = studentLogic.Restore(new StudentGetBindingModel { NumberOfBook = student.NumberOfBook }); + if (deletedStudent == null) + { + Errors.AddRange(studentLogic.Errors); + Errors.Add(("Ошибка при восстановлении студента", $"Не удалось восстановить студента {studentName}, приказ: {result.OrderStudentMoveType}")); + return null; + } + var deletedUser = userLogic.Restore(new UserGetBindingModel { Id = deletedStudent.UserId }); + if (deletedUser == null) + { + Errors.AddRange(userLogic.Errors); + Errors.Add(("Ошибка при восстановлении пользователя студента", $"Не удалось восстановить пользователя студента {studentName}")); + return null; + } + st.StudentState = StudentState.Учится; + student = studentLogic.Update(st); + haveChages = false; + if (student == null) + { + Errors.AddRange(studentLogic.Errors); + Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить статус у студента {studentName}")); + return null; + } + } + + if (haveChages) + { + student = studentLogic.Update(st); + if (student == null) + { + Errors.AddRange(studentLogic.Errors); + Errors.Add(("Ошибка изменения по студенту", $"Не удалось изменить данные у студента {studentName}")); + return null; + } + } + } + return result; + } + } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/OrderSyncHistoryBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/OrderSyncHistoryBusinessLogic.cs index afb3dd1..5c33842 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/OrderSyncHistoryBusinessLogic.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/GenericBusinessLogic/OrderSyncHistoryBusinessLogic.cs @@ -18,7 +18,6 @@ using System.Threading.Tasks; using ToolsModule.ManagmentDependency; using ToolsModule.ManagmentEntity; using ToolsModule.ManagmentExtension; -using ToolsModule.ManagmentMapping; using ToolsModule.ManagmentSecurity; namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic @@ -32,6 +31,8 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic private IEnviromentSettingLogic _enviromentSettingLogic; + private IAcademicPlanLogic _academicPlanLogic; + private IStudentGroupLogic _groupsLogic; private IStudentLogic _studentLogic; @@ -48,23 +49,32 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic private OrderSyncHistoryViewModel _history; + private StudentGroupListViewModel _groups; + public OrderSyncHistoryBusinessLogic(IOrderSyncHistoryService service) : base(service, "Синхронизация Приказов", AccessOperation.СинхронизацияПриказов) { } + /// + /// Синхронизация приказов по всем студентам + /// + /// public async Task SyncOrders() { InitLogics(); + // создание логов по операции синхронизации приказов if (!CreateHistory()) { return false; } + // получение адреса сервера с приказами var address = GetAddress(); if (address == null) { return false; } + // подключение клиента для отправки запросов к серверу var client = GetClinet(address); if (client == null) { @@ -90,12 +100,7 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic return false; } - var groups = _groupsLogic.GetList(new StudentGroupGetBindingModel()); - if (groups == null || groups.List == null) - { - SaveErrors(_groupsLogic.Errors, "Ошибка получения данных", "Не удалось получить список групп с базы"); - return false; - } + _groups = GetStudentGroups(); var students = _studentLogic.GetList(new StudentGetBindingModel()); if (students == null || students.List == null) @@ -107,38 +112,49 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic foreach (var student in students.List) { var studentSync = studentFromServer.CurrentStudentsList.FirstOrDefault(x => x.recordBookName == student.NumberOfBook); - // студент не найден, значит он ушел с кафедры, выясняем почему - if (studentSync == null) + // студент не найден, значит он ушел с кафедры, выясняем почему ИЛИ не совпадение групп + if (studentSync == null || student.StudentGroupName != studentSync.groupName) { - await SyncStudentOrders(student, groups.List, client, address.Value); - } - // не совпадение групп - else if (student.StudentGroupName != studentSync.groupName) - { - await SyncStudentOrders(student, groups.List, client, address.Value); + await SyncStudentOrders(student, client, address.Value); } studentFromServer.CurrentStudentsList.Remove(studentSync); } // новые студенты и восстановленцы foreach (var student in studentFromServer.CurrentStudentsList) { + // восстановленцы var deletedStudent = _studentLogic.GetElement(new StudentGetBindingModel { NumberOfBook = student.recordBookName, IgnoreDeleted = true }); if (deletedStudent != null) { - await SyncStudentOrders(deletedStudent, groups.List, client, address.Value); + await SyncStudentOrders(deletedStudent, client, address.Value); continue; } - + // новые студенты var newStudent = CreateNewStudent(student); if (newStudent != null) { SaveLog($"Добавлен студент {newStudent}"); - await SyncStudentOrders(newStudent, groups.List, client, address.Value); + await SyncStudentOrders(newStudent, client, address.Value); } } + + foreach(var group in _groups.List) + { + var grStudents = _studentLogic.GetList(new StudentGetBindingModel { StudentGroupId = group.Id }); + if (grStudents?.List?.Count == 0) + { + _groupsLogic.Delete(new StudentGroupGetBindingModel { Id = group.Id }); + } + } + return true; } + /// + /// Синхронизация приказов по студенту + /// + /// + /// public async Task SyncStudentOrders(Guid studentId) { InitLogics(); @@ -161,12 +177,7 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic return false; } - var groups = _groupsLogic.GetList(new StudentGroupGetBindingModel()); - if (groups == null || groups.List == null) - { - SaveErrors(_groupsLogic.Errors, "Ошибка получения данных", "Не удалось получить список групп с базы"); - return false; - } + _groups = GetStudentGroups(); var student = _studentLogic.GetElement(new StudentGetBindingModel { Id = studentId }); if (student == null) @@ -174,14 +185,18 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic SaveErrors(_studentLogic.Errors, "Ошибка получения данных", "Не удалось получить студента с базы"); return false; } - await SyncStudentOrders(student, groups.List, client, address.Value); + await SyncStudentOrders(student, client, address.Value); return true; } + /// + /// Инициализаия всех логик для получения от них данных и сохранения новых + /// private void InitLogics() { _recordLogic = DependencyManager.Instance.Resolve(); _enviromentSettingLogic = DependencyManager.Instance.Resolve(); + _academicPlanLogic = DependencyManager.Instance.Resolve(); _groupsLogic = DependencyManager.Instance.Resolve(); _studentLogic = DependencyManager.Instance.Resolve(); _orderLogic = DependencyManager.Instance.Resolve(); @@ -191,6 +206,10 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic _roleLogic = DependencyManager.Instance.Resolve(); } + /// + /// Создаение логера действий при синхронизации приказов + /// + /// private bool CreateHistory() { _history = Create(new OrderSyncHistorySetBindingModel { SyncDate = DateTime.Now }); @@ -202,6 +221,10 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic return true; } + /// + /// Получение адреса сервера + /// + /// private EnviromentSettingViewModel GetAddress() { var address = _enviromentSettingLogic.GetList(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderIpAddress" })?.List?.FirstOrDefault(); @@ -213,9 +236,13 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic return address; } + /// + /// Получение клиента для работы с сервисом приказов + /// + /// + /// private HttpClient GetClinet(EnviromentSettingViewModel address) { - var username = _enviromentSettingLogic.GetList(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderUserName" })?.List?.FirstOrDefault(); if (username == null || username.Value.IsEmpty()) { @@ -241,6 +268,26 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic return client; } + /// + /// Получение списка групп + /// + /// + private StudentGroupListViewModel GetStudentGroups() + { + var sgs = _groupsLogic.GetList(new StudentGroupGetBindingModel()); + if (sgs == null || sgs.List == null) + { + SaveErrors(_groupsLogic.Errors, "Ошибка получения данных", "Не удалось получить список групп с базы"); + return null; + } + return sgs; + } + + /// + /// Получение пользователя-студента + /// + /// + /// private UserViewModel WorkWithUser(StudentSyncModel student) { var userName = $"{student.lastName}{(student.firstName.IsNotEmpty() ? $" {student.firstName[0]}." : string.Empty)}{(student.patronymicName.IsNotEmpty() ? $"{student.patronymicName[0]}." : string.Empty)}"; @@ -280,6 +327,11 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic return user; } + /// + /// Создание нового студента + /// + /// + /// private StudentViewModel CreateNewStudent(StudentSyncModel student) { var user = WorkWithUser(student); @@ -315,7 +367,7 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic /// /// /// - private async Task SyncStudentOrders(StudentViewModel student, List groups, HttpClient client, string address) + private async Task SyncStudentOrders(StudentViewModel student, HttpClient client, string address) { var response = await client.GetAsync($"{address}/univer/hs/Ulstu_StudentsInfo/v1/GetStudentOrdersByIdAndRecordBook?iduniv={student.Iduniv}&recordBookName={student.NumberOfBook}&allOrders=sppd"); if (!response.IsSuccessStatusCode) @@ -329,6 +381,10 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic SaveLog("Не удалось распознать список приказов по студенту"); return; } + if (student.LastName == "Костенко" || student.LastName == "Киселева") + { + int c = 10; + } foreach (var syncOrder in syncOrders.StudentOrders) { if (syncOrder.orderTypeName == "Утверждение тем курсовых работ" || @@ -363,7 +419,7 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic { if (syncOrder.orderTypeName != "Корректировка" && syncOrder.orderTypeName != "Смена ФИО") { - SaveLog($"Приказ {syncOrder.clericNumber} неопределенного типа {syncOrder.orderTypeName}"); + SaveLog($"Приказ {syncOrder.clericNumber} необрабатываемого типа {syncOrder.orderTypeName} по студенту {student}"); } continue; } @@ -391,20 +447,11 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic } } - StudentGroupViewModel studentGroupFrom = null; - StudentGroupViewModel studentGroupTo = null; - if (syncOrder.groupNameBefore.IsNotEmpty()) - { - syncOrder.groupNameBefore = syncOrder.groupNameBefore.Replace("пбд", "бд"); - studentGroupFrom = groups.FirstOrDefault(x => x.GroupName == syncOrder.groupNameBefore || x.ToString() == syncOrder.groupNameBefore); - } - if (syncOrder.groupNameAfter.IsNotEmpty()) - { - syncOrder.groupNameAfter = syncOrder.groupNameAfter.Replace("пбд", "бд"); - studentGroupTo = groups.FirstOrDefault(x => x.GroupName == syncOrder.groupNameAfter || x.ToString() == syncOrder.groupNameAfter); - } + var studentGroupFrom = GetStudentGroup(syncOrder.groupNameBefore, order, false); + var studentGroupTo = GetStudentGroup(syncOrder.groupNameAfter, order, syncOrder.orderSubTypeName == "Распределение по группам"); // игнорируем приказы, не связанные с нашими группами - if (studentGroupFrom == null && syncOrder.groupNameBefore.IsNotEmpty() && studentGroupTo == null && syncOrder.groupNameAfter.IsNotEmpty()) + if (studentGroupFrom == null && studentGroupTo == null && order.OrderType != OrderType.ЗачислениеСтудентов && + syncOrder.reason != "на другой факультет") { continue; } @@ -430,8 +477,6 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic continue; } - SetYearFinish(student, studentGroupTo, order, orderStudentMoveType); - // создаем, если не нашли var studentOrder = _orderStudentRecordLogic.Create(new OrderStudentRecordSetBindingModel { @@ -450,18 +495,14 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic } SaveLog($"Добавили запись к приказу {order.OrderNumber} по студенту {student} с формулировкой {info}"); - - if (orderStudentMoveType == OrderStudentMoveType.ОтчислитьВСвязиСПереводом || - orderStudentMoveType == OrderStudentMoveType.ОтчислитьЗаНевыходСАкадема || - orderStudentMoveType == OrderStudentMoveType.ОтчислитьЗаНеуспевамость || - orderStudentMoveType == OrderStudentMoveType.ОтчислитьПоЗавершению || - orderStudentMoveType == OrderStudentMoveType.ОтчислитьПоСобственному) - { - return; - } } } + /// + /// Определение типа приказа + /// + /// + /// private static OrderType GetOrderType(string orderTitle) => orderTitle switch { "Зачисление в вуз вне приемной кампании" => OrderType.ЗачислениеСтудентов, @@ -480,6 +521,86 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic _ => OrderType.Неопределено, }; + /// + /// Поиск группы по названию из приказа + /// + /// + /// + /// + /// + private StudentGroupViewModel GetStudentGroup(string studetnGroupName, OrderViewModel order, bool isGrouping) + { + if (string.IsNullOrEmpty(studetnGroupName)) + { + return null; + } + studetnGroupName = studetnGroupName.Replace("пбд", "бд");// когда-то были группы-прикладники + int orderStudyYear = order.OrderDate.Year + (order.OrderDate.Month / 7) - 1; // учебный год + var group = _groups.List.FirstOrDefault(x => GetGroupName(x, orderStudyYear) == studetnGroupName); + if (group == null && isGrouping) + { + var academicPlan = _academicPlanLogic.GetElement(new AcademicPlanGetBindingModel + { + EducationDirectionShortName = studetnGroupName.Split('-')[0], + Year = orderStudyYear + }); + if (academicPlan == null) + { + SaveLog($"Не найден учебный план для группы {studetnGroupName} за {orderStudyYear} год"); + return null; + } + int yearFinish = academicPlan.EducationDirectionQualification == EducationDirectionQualification.Бакалавриат ? orderStudyYear + 4 : + academicPlan.EducationDirectionQualification == EducationDirectionQualification.Магистратура ? orderStudyYear + 2 : 0; + var newGroup = _groupsLogic.Create(new StudentGroupSetBindingModel + { + AcademicPlanId = academicPlan.Id, + GroupNumber = Convert.ToInt32(studetnGroupName[^1].ToString()), + LecturerId = null, + YearEntrance = orderStudyYear, + YearFinish = yearFinish + }); + if (newGroup == null) + { + SaveErrors(_groupsLogic.Errors, "Ошибка созданий группы", "Не удалось создать группу"); + return null; + } + _groups = GetStudentGroups(); + group = _groups.List.FirstOrDefault(x => GetGroupName(x, orderStudyYear) == studetnGroupName); + } + return group; + } + + /// + /// Получение именни группы в зависимости от нужного года + /// + /// + /// + /// + private static string GetGroupName(StudentGroupViewModel group, int orderStudyYear) + { + var course = orderStudyYear > group.YearFinish + ? AcademicCourse.Неопределен + : (orderStudyYear - group.YearEntrance) switch + { + 0 => AcademicCourse.Курс_1, + 1 => AcademicCourse.Курс_2, + 2 => AcademicCourse.Курс_3, + 3 => AcademicCourse.Курс_4, + 4 => AcademicCourse.Курс_5, + _ => AcademicCourse.Неопределен, + }; + return $"{group.EducationDirectionShortName}-{((int)course)}{group.GroupNumber}"; + } + + /// + /// Определение подтипа приказа + /// + /// + /// + /// + /// + /// + /// private static OrderStudentMoveType GetOrderStudentMoveType(StudentViewModel student, StudentOrderSyncModel syncOrder, StudentGroupViewModel studentGroupFrom, StudentGroupViewModel studentGroupTo, out string info) { @@ -502,11 +623,6 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic return OrderStudentMoveType.ПринятьПоПереводу; } if (studentGroupFrom != null && studentGroupTo == null) - { - info = $"Перевод студента {student} из группы {studentGroupFrom} на другую кафедру в группу {syncOrder.groupNameAfter}"; - return OrderStudentMoveType.УбратьПоПереводу; - } - if (syncOrder.reason == "на другой факультет") { info = $"Отчисление студента {student} из группы {studentGroupFrom} в связи с переводом"; return OrderStudentMoveType.ОтчислитьВСвязиСПереводом; @@ -540,27 +656,36 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic info = $"Выход из АО студента {student} в группу {studentGroupTo}"; return OrderStudentMoveType.ВосстановитьИзАкадема; case "Отчисление": - switch (syncOrder.reason) + if (syncOrder.reason.Contains("за невыполнение учебного плана") || + syncOrder.reason.Contains("академическую неуспеваемость") || + syncOrder.reason.Contains("в связи с невыполнением обучающимся обязанностей по добросовестному освоению") || + syncOrder.reason.Contains("за невыполнение обязанностей по добросовестному освоению")) { - case "за невыполнение учебного плана": - info = $"Отчисление студента {student} из группы {studentGroupFrom} за неуспеваемость"; - return OrderStudentMoveType.ОтчислитьЗаНеуспевамость; - case "по собственному желанию": - info = $"Отчисление студента {student} из группы {studentGroupFrom} по собственному желанию"; - return OrderStudentMoveType.ОтчислитьПоСобственному; - case "в связи с невыходом из академического отпуска": - info = $"Отчисление студента {student} из группы {studentGroupFrom} в связи с невыходм из академического отпуска"; - return OrderStudentMoveType.ОтчислитьЗаНевыходСАкадема; - case "за невыполнение обязанностей по добросовестному освоению образовательной программы и выполнению учебного плана": - info = $"Отчисление студента {student} из группы {studentGroupFrom} за неуспеваемость"; - return OrderStudentMoveType.ОтчислитьЗаНеуспевамость; - case "в связи с переводом в ___": - info = $"Отчисление студента {student} из группы {studentGroupFrom} в связи с переводом"; - return OrderStudentMoveType.ОтчислитьВСвязиСПереводом; - default: - info = string.Empty; - return OrderStudentMoveType.Неопределено; + info = $"Отчисление студента {student} из группы {studentGroupFrom} за неуспеваемость"; + return OrderStudentMoveType.ОтчислитьЗаНеуспевамость; } + if (syncOrder.reason.Contains("по собственному желанию")) + { + info = $"Отчисление студента {student} из группы {studentGroupFrom} по собственному желанию"; + return OrderStudentMoveType.ОтчислитьПоСобственному; + } + if (syncOrder.reason.Contains("в связи с невыходом из академического отпуска")) + { + info = $"Отчисление студента {student} из группы {studentGroupFrom} в связи с невыходм из академического отпуска"; + return OrderStudentMoveType.ОтчислитьЗаНевыходСАкадема; + } + if (syncOrder.reason.Contains("в связи с переводом в")) + { + info = $"Отчисление студента {student} из группы {studentGroupFrom} в связи с переводом"; + return OrderStudentMoveType.ОтчислитьВСвязиСПереводом; + } + if (syncOrder.reason.Contains("за невыполнение условий договора")) + { + info = $"Отчисление студента {student} из группы {studentGroupFrom} в связи с не оплатой обучения"; + return OrderStudentMoveType.ОтчислитьЗаНеоплату; + } + info = string.Empty; + return OrderStudentMoveType.Неопределено; case "Восстановление": info = $"Восстановление отчисленного студента {student} в группу {studentGroupTo}"; return OrderStudentMoveType.Восстановить; @@ -573,112 +698,12 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic } } - private void SetYearFinish(StudentViewModel student, StudentGroupViewModel group, OrderViewModel order, OrderStudentMoveType studentOrderType) - { - if (student == null) - { - return; - } - int year = DateTime.Now.Year; - switch (studentOrderType) - { - // у студента не меняется год зачисления - case OrderStudentMoveType.ПродлитьАкадем: - case OrderStudentMoveType.ОтчислитьПоЗавершению: - return; - // студент уходит с текущего года обучения, сбрасываем его - case OrderStudentMoveType.Неопределено: - case OrderStudentMoveType.ОтправитьВАкадем: - case OrderStudentMoveType.ОтчислитьВСвязиСПереводом: - case OrderStudentMoveType.ОтчислитьЗаНевыходСАкадема: - case OrderStudentMoveType.ОтчислитьЗаНеуспевамость: - case OrderStudentMoveType.ОтчислитьПоСобственному: - case OrderStudentMoveType.УбратьПоПереводу: - student.EnrollmentYearId = null; - return; - // проблема с разными направлениями групп на разных курсах - case OrderStudentMoveType.ПеревестиНаСтаршийКурс: - if (student.EnrollmentYearId.HasValue) - { - return; - } - if (group == null || order == null) - { - return; - } - year = order.OrderDate.Year; - switch (group.AcademicCourse) - { - case AcademicCourse.Курс_1: - break; - case AcademicCourse.Курс_2: - year--; - break; - case AcademicCourse.Курс_3: - year -= 2; - break; - case AcademicCourse.Курс_4: - year -= 3; - break; - } - break; - // может быть зачисление проводилось без указания группы, тогда группа определится при распределении - case OrderStudentMoveType.Распределить: - if (student.EnrollmentYearId.HasValue) - { - return; - } - if (group == null || order == null) - { - return; - } - year = order.OrderDate.Year; - break; - case OrderStudentMoveType.ЗачислитьПоПриказу: - if (group == null || order == null) - { - return; - } - year = order.OrderDate.Year; - break; - case OrderStudentMoveType.ПринятьПоПереводу: - case OrderStudentMoveType.ПринятьПоПереводусДругогоВуза: - case OrderStudentMoveType.Восстановить: - case OrderStudentMoveType.ВосстановитьИзАкадема: - case OrderStudentMoveType.ПеревестиНаДругоеНаправлениеКафедры: - if (group == null || order == null) - { - return; - } - year = order.OrderDate.Month < 8 ? order.OrderDate.Year - 1 : order.OrderDate.Year; - switch (group.AcademicCourse) - { - case AcademicCourse.Курс_1: - break; - case AcademicCourse.Курс_2: - year--; - break; - case AcademicCourse.Курс_3: - year -= 2; - break; - case AcademicCourse.Курс_4: - year -= 3; - break; - } - break; - } - - var logic = DependencyManager.Instance.Resolve(); - var yearEnrollment = logic.GetElement(new EnrollmentYearGetBindingModel { EducationDirectionId = group.EducationDirectionId, Year = year }); - if (yearEnrollment == null) - { - SaveErrors(logic.Errors, "Ошибка установки года выпуска студента", $"Не удалось найти год выпуска студента {student.LastName} {student.FirstName} {student.Patronymic}"); - return; - } - - student.EnrollmentYearId = yearEnrollment.Id; - } - + /// + /// Сохранение лога с ошибками + /// + /// + /// + /// private void SaveErrors(List<(string Title, string Message)> errors, string title, string message) { if (_history == null) @@ -691,6 +716,10 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic SaveLog(string.Join(Environment.NewLine, Errors.Select(x => x.Message))); } + /// + /// Сохранение лога + /// + /// private void SaveLog(string info) { _recordLogic.Create(new OrderSyncHistoryRecordSetBindingModel diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentLogicDependencyRegistration.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentLogicDependencyRegistration.cs index 5eb843b..7ea2ca6 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentLogicDependencyRegistration.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentLogicDependencyRegistration.cs @@ -30,7 +30,6 @@ 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 34a8ca9..468ea4e 100644 --- a/DepartmentPortal/Department/DepartmentContract/BindingModels/AcademicPlanBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/BindingModels/AcademicPlanBindingModels.cs @@ -11,6 +11,10 @@ namespace DepartmentContract.BindingModels public class AcademicPlanGetBindingModel : GetBindingModel { public Guid? EducationDirectionId { get; set; } + + public string EducationDirectionShortName { get; set; } + + public int? Year { get; set; } } /// @@ -21,10 +25,11 @@ namespace DepartmentContract.BindingModels public Guid? EducationDirectionId { get; set; } [Required(ErrorMessage = "required")] - public DateTime CreateDate { get; set; } + public int YearStart { get; set; } [Required(ErrorMessage = "required")] public DateTime LastUpdateDate { get; set; } + } /// diff --git a/DepartmentPortal/Department/DepartmentContract/BindingModels/EnrollmentYearBindingModels.cs b/DepartmentPortal/Department/DepartmentContract/BindingModels/EnrollmentYearBindingModels.cs deleted file mode 100644 index d24a8a4..0000000 --- a/DepartmentPortal/Department/DepartmentContract/BindingModels/EnrollmentYearBindingModels.cs +++ /dev/null @@ -1,33 +0,0 @@ -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 Guid? EducationDirectionId { get; set; } - - public int? Year { 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 0309f03..9776c0e 100644 --- a/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentBindingModels.cs @@ -15,8 +15,6 @@ namespace DepartmentContract.BindingModels public Guid? StudentGroupId { get; set; } - public Guid? EnrollmentYearId { get; set; } - public Guid? BasicDepartmentId { get; set; } public StudentState? StudentState { get; set; } @@ -34,8 +32,6 @@ namespace DepartmentContract.BindingModels public Guid? StudentGroupId { get; set; } - public Guid? EnrollmentYearId { get; set; } - public Guid? BasicDepartmentId { get; set; } [Required(ErrorMessage = "required")] diff --git a/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentGroupBindingModels.cs b/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentGroupBindingModels.cs index c18cb68..d086867 100644 --- a/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentGroupBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/BindingModels/StudentGroupBindingModels.cs @@ -13,6 +13,8 @@ namespace DepartmentContract.BindingModels { public Guid? EducationDirectionId { get; set; } + public Guid? AcademicPlanId { get; set; } + public Guid? LecturerId { get; set; } } @@ -22,7 +24,13 @@ namespace DepartmentContract.BindingModels public class StudentGroupSetBindingModel : SetBindingModel, IStudentGroupModel { [Required(ErrorMessage = "required")] - public Guid EducationDirectionId { get; set; } + public Guid AcademicPlanId { get; set; } + + [Required(ErrorMessage = "required")] + public int YearEntrance { get; set; } + + [Required(ErrorMessage = "required")] + public int YearFinish { get; set; } [Required(ErrorMessage = "required")] public int GroupNumber { get; set; } diff --git a/DepartmentPortal/Department/DepartmentContract/Logics/IGenericEntityLogic/IEnrollmentYearLogic.cs b/DepartmentPortal/Department/DepartmentContract/Logics/IGenericEntityLogic/IEnrollmentYearLogic.cs deleted file mode 100644 index e7970dc..0000000 --- a/DepartmentPortal/Department/DepartmentContract/Logics/IGenericEntityLogic/IEnrollmentYearLogic.cs +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 59473c4..0000000 --- a/DepartmentPortal/Department/DepartmentContract/Services/IGenericEntityService/IEnrollmentYearService.cs +++ /dev/null @@ -1,10 +0,0 @@ -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 20dfc46..d89484c 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanViewModels.cs @@ -1,4 +1,5 @@ -using CoreModels.ModelsDepartment; +using CoreModels.Enums.Department; +using CoreModels.ModelsDepartment; using System; using ToolsModule.ManagmentEntity; using ToolsModule.ManagmentMapping; @@ -16,8 +17,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")] + [ViewModelControlElementDependenceEntity(Title = "Группы", Order = 2, ParentPropertyName = "AcademicPlanId", + ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentGroupList, DepartmentWindowsDesktop")] public class AcademicPlanViewModel : ElementViewModel, IAcademicPlanModel { [ViewModelControlElementProperty("Направление", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEducationDirectionList, DepartmentWindowsDesktop")] @@ -30,13 +31,16 @@ namespace DepartmentContract.ViewModels [ViewModelControlListProperty("Профиль")] [MapConfiguration("EducationDirection.Profile")] public string EducationDirectionProfile { get; set; } + [MapConfiguration("EducationDirection.Qualification")] + public EducationDirectionQualification EducationDirectionQualification { get; set; } - [ViewModelControlListProperty("Дата создания", ColumnWidth = 120, DefaultCellStyleFormat = "dd.MM.yyyy")] - [ViewModelControlElementProperty("Дата создания", ControlType.ControlDateTime, MustHaveValue = true)] - public DateTime CreateDate { get; set; } + [ViewModelControlListProperty("Год начала", ColumnWidth = 120)] + [ViewModelControlElementProperty("Год начала", ControlType.ControlInt, MustHaveValue = true)] + public int YearStart { get; set; } [ViewModelControlListProperty("Дата последнего изменения", ColumnWidth = 120, DefaultCellStyleFormat = "dd.MM.yyyy")] [ViewModelControlElementProperty("Дата последнего изменения", ControlType.ControlDateTime, MustHaveValue = true)] public DateTime LastUpdateDate { get; set; } - } + + } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/EducationDirectionViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/EducationDirectionViewModels.cs index 8fc0b62..825e470 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/EducationDirectionViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/EducationDirectionViewModels.cs @@ -17,8 +17,6 @@ namespace DepartmentContract.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, IEducationDirectionModel { [ViewModelControlListProperty("Шифр", ColumnWidth = 80)] diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/EnrollmentYearViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/EnrollmentYearViewModels.cs deleted file mode 100644 index f054faa..0000000 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/EnrollmentYearViewModels.cs +++ /dev/null @@ -1,40 +0,0 @@ -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/StudentGroupViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentGroupViewModels.cs index 669ae5f..3969e86 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentGroupViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentGroupViewModels.cs @@ -19,24 +19,30 @@ namespace DepartmentContract.ViewModels ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentList, DepartmentWindowsDesktop")] public class StudentGroupViewModel : ElementViewModel, IStudentGroupModel { - [ViewModelControlElementProperty("Направление", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEducationDirectionList, DepartmentWindowsDesktop")] - public Guid EducationDirectionId { get; set; } + [ViewModelControlElementProperty("Направление", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlAcademicPlanList, DepartmentWindowsDesktop")] + public Guid AcademicPlanId { get; set; } [ViewModelControlListProperty("Шифр", ColumnWidth = 80)] - [MapConfiguration("EducationDirection.Cipher")] + [MapConfiguration("AcademicPlan.EducationDirection.Cipher")] public string EducationDirectionCipher { get; set; } [ViewModelControlListProperty("Профиль")] - [MapConfiguration("EducationDirection.Profile")] + [MapConfiguration("AcademicPlan.EducationDirection.Profile")] public string EducationDirectionProfile { get; set; } - [MapConfiguration("EducationDirection.ShortName")] + [MapConfiguration("AcademicPlan.EducationDirection.ShortName")] public string EducationDirectionShortName { get; set; } + [ViewModelControlElementProperty("Год начала", ControlType.ControlInt, MustHaveValue = true)] + public int YearEntrance { get; set; } + + [ViewModelControlElementProperty("Год окончания", ControlType.ControlInt, MustHaveValue = true)] + public int YearFinish { get; set; } + [ViewModelControlListProperty("Группа")] public string GroupName => $"{EducationDirectionShortName}-{(int)AcademicCourse}{GroupNumber}"; - [ViewModelControlElementProperty("Курс", ControlType.ControlEnum, MustHaveValue = true)] + [ViewModelControlElementProperty("Курс", ControlType.ControlEnum, ReadOnly = true)] public AcademicCourse AcademicCourse { get; set; } [ViewModelControlListProperty("Курс")] diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs index ed8cf8e..c46ccf7 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs @@ -28,9 +28,6 @@ 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.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlBasicDepartmentList, DepartmentWindowsDesktop")] public Guid? BasicDepartmentId { get; set; } @@ -58,8 +55,9 @@ namespace DepartmentContract.ViewModels public string Email { get; set; } [ViewModelControlListProperty("Базовая кафедра")] - public bool IsBasicDepartmentId => BasicDepartmentId.HasValue ? true : false; + public bool IsBasicDepartmentId => BasicDepartmentId.HasValue; + [ViewModelControlListProperty("Описание")] [ViewModelControlElementProperty("Описание", ControlType.ControlText)] public string Description { get; set; } diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs index 3411d6f..ba9bf42 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationDependencyRegistration.cs @@ -31,7 +31,6 @@ 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 83b6b5c..7328f89 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/AcademicPlanService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/AcademicPlanService.cs @@ -24,7 +24,14 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit { protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, AcademicPlanSetBindingModel model) => OperationResultModel.Success(null); - protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, AcademicPlan entity, AcademicPlanGetBindingModel model) => OperationResultModel.Success(null); + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, AcademicPlan entity, AcademicPlanGetBindingModel model) + { + if (context.Set().Any(x => x.AcademicPlanId == model.Id && x.AcademicCourse != AcademicCourse.Неопределен)) + { + return OperationResultModel.Error("Error:", "Есть учебные группы, относящиеся к этому учебному плану", ResultServiceStatusCode.ExsistItem); + } + return OperationResultModel.Success(null); + } protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, AcademicPlanGetBindingModel model) { @@ -56,11 +63,29 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit context.SaveChanges(); } - protected override AcademicPlan GetUniqueEntity(AcademicPlanSetBindingModel model, IQueryable query) => query.FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.CreateDate == model.CreateDate && x.Id != model.Id); + protected override AcademicPlan GetUniqueEntity(AcademicPlanSetBindingModel model, IQueryable query) => query.FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.YearStart == model.YearStart && 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.CreateDate); + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.EducationDirection.Cipher).ThenBy(x => x.YearStart); + + protected override bool AdditionalCheckForSingleGet(AcademicPlanGetBindingModel model) + { + if (model.EducationDirectionShortName.IsNotEmpty() && model.Year.HasValue) + { + return true; + } + return base.AdditionalCheckForSingleGet(model); + } + + protected override AcademicPlan GetSingleRecord(IQueryable list, AcademicPlanGetBindingModel model) + { + if (model.EducationDirectionShortName.IsNotEmpty() && model.Year.HasValue) + { + return list.FirstOrDefault(x => x.EducationDirection.ShortName == model.EducationDirectionShortName && x.YearStart == model.Year); + } + return base.GetSingleRecord(list, model); + } public OperationResultModel LoadPlx(AcademicPlanLoadPlxModel model) { @@ -311,44 +336,42 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit if (parentValue.IsNotEmpty()) { var parentDiscipilne = plxModel.Disciplines.FirstOrDefault(x => x.Code == parentValue); - if (parentDiscipilne == default) + if (parentDiscipilne != default) { - return OperationResultModel.Error("ошибка", $"Не найдена родительская дисциплина с кодом {parentValue}", ResultServiceStatusCode.NotFound); - } - - parent = context.AcademicPlanRecords.FirstOrDefault(apr => + parent = context.AcademicPlanRecords.FirstOrDefault(apr => apr.AcademicPlanId == model.AcademicPlanId && apr.DisciplineId == parentDiscipilne.Entity.Id && apr.Semester == hour.Semester); - if (parent == null) - { - // возмжно, родитель будет описан позже, заполняем данными дочернего класса пока что - parent = new AcademicPlanRecord + if (parent == null) { - AcademicPlanId = model.AcademicPlanId, - DisciplineId = parentDiscipilne.Entity.Id, - InDepartment = inKafedra, - Semester = hour.Semester, - Zet = zet.IsNotEmpty() ? Convert.ToInt32(zet) : 0, - IsParent = true, - IsFacultative = isFacultative - }; - context.AcademicPlanRecords.Add(parent); - context.SaveChanges(); - } - else if (parent.IsDeleted) - { - parent.IsDeleted = false; - parent.DateDelete = null; - context.SaveChanges(); - } + // возмжно, родитель будет описан позже, заполняем данными дочернего класса пока что + parent = new AcademicPlanRecord + { + AcademicPlanId = model.AcademicPlanId, + DisciplineId = parentDiscipilne.Entity.Id, + InDepartment = inKafedra, + Semester = hour.Semester, + Zet = zet.IsNotEmpty() ? Convert.ToInt32(zet) : 0, + IsParent = true, + IsFacultative = isFacultative + }; + context.AcademicPlanRecords.Add(parent); + context.SaveChanges(); + } + else if (parent.IsDeleted) + { + parent.IsDeleted = false; + parent.DateDelete = null; + context.SaveChanges(); + } - if (!parent.IsParent) - { - parent.IsParent = true; - context.SaveChanges(); - } + if (!parent.IsParent) + { + parent.IsParent = true; + context.SaveChanges(); + } + } } #endregion diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/EducationDirectionService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/EducationDirectionService.cs index 5985331..9c7136d 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/EducationDirectionService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/EducationDirectionService.cs @@ -24,10 +24,6 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit { 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/AbstractGenerticEntityService/EnrollmentYearService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/EnrollmentYearService.cs deleted file mode 100644 index 49455d6..0000000 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/EnrollmentYearService.cs +++ /dev/null @@ -1,76 +0,0 @@ -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); - } - if (model.EducationDirectionId.HasValue) - { - query = query.Where(x => x.AcademicPlan.EducationDirectionId == model.EducationDirectionId.Value); - } - if (model.Year.HasValue) - { - query = query.Where(x => x.YearEntrance == model.Year.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, IQueryable query) => query.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); - - protected override bool AdditionalCheckForSingleGet(EnrollmentYearGetBindingModel model) - { - if (model.EducationDirectionId.HasValue && model.Year.HasValue) - { - return true; - } - return base.AdditionalCheckForSingleGet(model); - } - - protected override EnrollmentYear GetSingleRecord(IQueryable list, EnrollmentYearGetBindingModel model) - { - if (model.EducationDirectionId.HasValue && model.Year.HasValue) - { - return list.FirstOrDefault(x => x.AcademicPlan.EducationDirectionId == model.EducationDirectionId && x.YearEntrance == model.Year); - } - return base.GetSingleRecord(list, model); - } - } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentGroupService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentGroupService.cs index f7a8380..de05548 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentGroupService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentGroupService.cs @@ -32,7 +32,11 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit { if (model.EducationDirectionId.HasValue) { - query = query.Where(x => x.EducationDirectionId == model.EducationDirectionId.Value); + query = query.Where(x => x.AcademicPlan.EducationDirectionId == model.EducationDirectionId.Value); + } + if (model.AcademicPlanId.HasValue) + { + query = query.Where(x => x.AcademicPlanId == model.AcademicPlanId.Value); } if (model.LecturerId.HasValue) { @@ -54,10 +58,10 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit context.SaveChanges(); } - protected override StudentGroup GetUniqueEntity(StudentGroupSetBindingModel model, IQueryable query) => query.FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.AcademicCourse == model.AcademicCourse && x.GroupNumber == model.GroupNumber && x.Id != model.Id); + protected override StudentGroup GetUniqueEntity(StudentGroupSetBindingModel model, IQueryable query) => query.FirstOrDefault(x => x.AcademicPlanId == model.AcademicPlanId && x.YearEntrance == model.YearEntrance && x.GroupNumber == model.GroupNumber && x.Id != model.Id); - protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.EducationDirection).Include(x => x.Lecturer).Include(x => x.Students); + protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.AcademicPlan).Include(x => x.AcademicPlan.EducationDirection).Include(x => x.Lecturer).Include(x => x.Students); - protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.EducationDirection.Cipher).ThenBy(x => x.AcademicCourse).ThenBy(x => x.GroupNumber); + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.AcademicPlan.EducationDirection.Qualification).ThenBy(x => x.AcademicPlan.EducationDirection.Cipher).ThenBy(x => x.YearEntrance).ThenBy(x => x.GroupNumber); } } \ 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 9f732ff..c3d3469 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/StudentService.cs @@ -32,10 +32,6 @@ 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); @@ -64,7 +60,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit 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.AcademicCourse).ThenBy(x => x.StudentGroup.GroupNumber).ThenBy(x => x.LastName).ThenBy(x => x.FirstName); + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.StudentGroup.YearEntrance).ThenBy(x => x.StudentGroup.GroupNumber).ThenBy(x => x.LastName).ThenBy(x => x.FirstName); protected override bool AdditionalCheckForSingleGet(StudentGetBindingModel model) { diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.Designer.cs deleted file mode 100644 index e82f98e..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.Designer.cs +++ /dev/null @@ -1,33 +0,0 @@ - -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 deleted file mode 100644 index 8a222c5..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.cs +++ /dev/null @@ -1,30 +0,0 @@ -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 deleted file mode 100644 index 1af7de1..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearElement.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index e3ba44a..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.Designer.cs +++ /dev/null @@ -1,33 +0,0 @@ - -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 deleted file mode 100644 index fff4650..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.cs +++ /dev/null @@ -1,42 +0,0 @@ -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 ControlEnrollmentYearElement(); - _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 deleted file mode 100644 index 1af7de1..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EnrollmentYear/ControlEnrollmentYearList.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/SqriptsSQL/PrepareForSync.sql b/SqriptsSQL/PrepareForSync.sql new file mode 100644 index 0000000..522f7a0 --- /dev/null +++ b/SqriptsSQL/PrepareForSync.sql @@ -0,0 +1,30 @@ +USE [DepartmentDatabasePortal] +GO + +DELETE FROM [dbo].[OrderSyncHistories] +GO + +DELETE FROM [dbo].[Orders] +GO + +DELETE FROM [dbo].[Students] +GO + +DELETE FROM [dbo].[StudentGroups] +GO + +DECLARE @RoleId uniqueidentifier + +SELECT @RoleId = [Id] +FROM [dbo].[Roles] +WHERE [RoleName] = '' + + +DELETE u FROM [dbo].[Users] u +JOIN [dbo].[UserRoles] ur ON u.[Id] = ur.[UserId] + WHERE ur.[RoleId] = @RoleId + + +DELETE FROM [dbo].[UserRoles] + WHERE [RoleId] = @RoleId +GO \ No newline at end of file