diff --git a/DepartmentPortal/Common/DatabaseCore/AbstractGenerticEntityService.cs b/DepartmentPortal/Common/DatabaseCore/AbstractGenerticEntityService.cs index ed691a6..057681f 100644 --- a/DepartmentPortal/Common/DatabaseCore/AbstractGenerticEntityService.cs +++ b/DepartmentPortal/Common/DatabaseCore/AbstractGenerticEntityService.cs @@ -68,7 +68,7 @@ namespace DatabaseCore return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); } - var result = AdditionalCheckingWhenDeleting(context, model); + var result = AdditionalCheckingWhenDeleting(context, entity, model); if (!result.IsSucceeded) { return result; @@ -79,7 +79,7 @@ namespace DatabaseCore context.SaveChanges(); - AdditionalDeleting(context, model); + AdditionalDeleting(context, entity, model); transaction.Commit(); } @@ -186,7 +186,7 @@ namespace DatabaseCore /// /// /// - protected abstract OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, G model); + protected abstract OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, T entity, G model); /// /// Добавление дополнительных фильтров @@ -206,7 +206,7 @@ namespace DatabaseCore /// Дополнительные удаления зависимых сущностей /// /// - protected abstract void AdditionalDeleting(DbContext context, G model); + protected abstract void AdditionalDeleting(DbContext context, T entity, G model); /// /// Установка сортировок diff --git a/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs b/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs index 0bce762..ed79386 100644 --- a/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs +++ b/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs @@ -32,7 +32,7 @@ namespace DatabaseCore modelBuilder.Entity().HasIndex(s => s.UserName); - modelBuilder.Entity().HasIndex(s => s.EmployeePostName).IsUnique(); + modelBuilder.Entity().HasIndex(s => s.PostName).IsUnique(); modelBuilder.Entity().HasIndex(p => new { p.FirstName, p.LastName, p.Patronymic }).IsUnique(); @@ -46,8 +46,6 @@ namespace DatabaseCore modelBuilder.Entity().HasIndex(p => new { p.LecturerAcademicRankName }).IsUnique(); - modelBuilder.Entity().HasIndex(p => new { p.LecturerPostName }).IsUnique(); - modelBuilder.Entity().HasIndex(p => new { p.FirstName, p.LastName, p.Patronymic }).IsUnique(); } @@ -60,15 +58,14 @@ namespace DatabaseCore #endregion #region Department - public virtual DbSet EmployeePosts { set; get; } + public virtual DbSet Posts { set; get; } public virtual DbSet Employees { set; get; } - public virtual DbSet EmployeeEmployeePosts { set; get; } + public virtual DbSet EmployeePosts { set; get; } public virtual DbSet Classrooms { set; get; } public virtual DbSet DisciplineBlocks { set; get; } public virtual DbSet Disciplines { set; get; } public virtual DbSet LecturerAcademicDegrees { set; get; } public virtual DbSet LecturerAcademicRanks { set; get; } - public virtual DbSet LecturerEmployeePosts { set; get; } public virtual DbSet LecturerPosts { set; get; } public virtual DbSet Lecturers { set; get; } #endregion diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210405080239_RemLecturerPost.Designer.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405080239_RemLecturerPost.Designer.cs new file mode 100644 index 0000000..dd68b65 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405080239_RemLecturerPost.Designer.cs @@ -0,0 +1,810 @@ +// +using System; +using DatabaseCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace DatabaseCore.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20210405080239_RemLecturerPost")] + partial class RemLecturerPost + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.4") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("DatabaseCore.Models.Department.Classroom", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("ClassroomType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("HaveProjector") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Number") + .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() + .HasFilter("[Number] IS NOT NULL"); + + b.ToTable("Classrooms"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisciplineBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("DisciplineShortName") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineBlockId"); + + b.HasIndex("DisciplineName") + .IsUnique(); + + b.ToTable("Disciplines"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockOrder") + .HasColumnType("int"); + + b.Property("DisciplineBlockUseForGrouping") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Title") + .IsUnique(); + + b.ToTable("DisciplineBlocks"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Address") + .HasColumnType("nvarchar(max)"); + + b.Property("DateBirth") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .HasColumnType("nvarchar(450)"); + + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + + b.Property("HomeNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastName") + .HasColumnType("nvarchar(450)"); + + b.Property("MobileNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[FirstName] IS NOT NULL AND [LastName] IS NOT NULL AND [Patronymic] IS NOT NULL"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("PostId"); + + b.ToTable("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Abbreviation") + .HasColumnType("nvarchar(max)"); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateBirth") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("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("LecturerPostId") + .HasColumnType("uniqueidentifier"); + + b.Property("LecturerPostRate") + .HasColumnType("decimal(18,2)"); + + b.Property("MobileNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OnlyForPrivate") + .HasColumnType("bit"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeId"); + + b.HasIndex("LecturerAcademicRankId"); + + b.HasIndex("UserId"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[Patronymic] IS NOT NULL"); + + b.ToTable("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicDegreeName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeName") + .IsUnique(); + + b.ToTable("LecturerAcademicDegrees"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicRankName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicRankName") + .IsUnique(); + + b.ToTable("LecturerAcademicRanks"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("PostId"); + + b.ToTable("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Hours") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("PostName") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("PostName") + .IsUnique() + .HasFilter("[PostName] IS NOT NULL"); + + b.ToTable("Posts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessOperation") + .HasColumnType("int"); + + b.Property("AccessType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Accesses"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.EnviromentSetting", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Key") + .IsUnique(); + + b.ToTable("EnviromentSettings"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("RolePriority") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RoleName") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Avatar") + .HasColumnType("varbinary(max)"); + + b.Property("CountAttempt") + .HasColumnType("int"); + + b.Property("DateBanned") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DateLastVisit") + .HasColumnType("datetime2"); + + b.Property("IsBanned") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserName"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Classroom", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("Classrooms") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("Disciplines") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Employees") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("EmployeePosts") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("EmployeePosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicDegreeId"); + + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicRank", "LecturerAcademicRank") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicRankId"); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Lecturers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LecturerAcademicDegree"); + + b.Navigation("LecturerAcademicRank"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + { + b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") + .WithMany("LecturerPosts") + .HasForeignKey("LecturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("LecturerPosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lecturer"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("Access") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Navigation("Disciplines"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Navigation("Classrooms"); + + b.Navigation("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.Navigation("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => + { + b.Navigation("EmployeePosts"); + + b.Navigation("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Navigation("Access"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.User", b => + { + b.Navigation("Employees"); + + b.Navigation("Lecturers"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210405080239_RemLecturerPost.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405080239_RemLecturerPost.cs new file mode 100644 index 0000000..236e0db --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405080239_RemLecturerPost.cs @@ -0,0 +1,419 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace DatabaseCore.Migrations +{ + public partial class RemLecturerPost : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Lecturers_LecturerPosts_LecturerPostId", + table: "Lecturers"); + + migrationBuilder.DropTable( + name: "EmployeeEmployeePosts"); + + migrationBuilder.DropTable( + name: "LecturerEmployeePosts"); + + migrationBuilder.DropIndex( + name: "IX_Lecturers_LecturerPostId", + table: "Lecturers"); + + migrationBuilder.DropIndex( + name: "IX_LecturerPosts_LecturerPostName", + table: "LecturerPosts"); + + migrationBuilder.DropIndex( + name: "IX_EmployeePosts_EmployeePostName", + table: "EmployeePosts"); + + migrationBuilder.DropColumn( + name: "Hours", + table: "LecturerPosts"); + + migrationBuilder.DropColumn( + name: "LecturerPostName", + table: "LecturerPosts"); + + migrationBuilder.DropColumn( + name: "Order", + table: "LecturerPosts"); + + migrationBuilder.DropColumn( + name: "EmployeePostName", + table: "EmployeePosts"); + + migrationBuilder.DropColumn( + name: "Order", + table: "EmployeePosts"); + + migrationBuilder.AddColumn( + name: "IsExternalCombination", + table: "LecturerPosts", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsInternalCombination", + table: "LecturerPosts", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "LecturerId", + table: "LecturerPosts", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "PostId", + table: "LecturerPosts", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Rate", + table: "LecturerPosts", + type: "decimal(18,2)", + nullable: false, + defaultValue: 0m); + + migrationBuilder.AddColumn( + name: "EmployeeId", + table: "EmployeePosts", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "IsExternalCombination", + table: "EmployeePosts", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsInternalCombination", + table: "EmployeePosts", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "PostId", + table: "EmployeePosts", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Rate", + table: "EmployeePosts", + type: "decimal(18,2)", + nullable: false, + defaultValue: 0m); + + migrationBuilder.CreateTable( + name: "Posts", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + PostName = table.Column(type: "nvarchar(450)", nullable: true), + Hours = table.Column(type: "int", nullable: true), + Order = table.Column(type: "int", nullable: false), + DateCreate = table.Column(type: "datetime2", nullable: false), + DateDelete = table.Column(type: "datetime2", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Posts", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_LecturerPosts_LecturerId", + table: "LecturerPosts", + column: "LecturerId"); + + migrationBuilder.CreateIndex( + name: "IX_LecturerPosts_PostId", + table: "LecturerPosts", + column: "PostId"); + + migrationBuilder.CreateIndex( + name: "IX_EmployeePosts_EmployeeId", + table: "EmployeePosts", + column: "EmployeeId"); + + migrationBuilder.CreateIndex( + name: "IX_EmployeePosts_PostId", + table: "EmployeePosts", + column: "PostId"); + + migrationBuilder.CreateIndex( + name: "IX_Posts_PostName", + table: "Posts", + column: "PostName", + unique: true, + filter: "[PostName] IS NOT NULL"); + + migrationBuilder.AddForeignKey( + name: "FK_EmployeePosts_Employees_EmployeeId", + table: "EmployeePosts", + column: "EmployeeId", + principalTable: "Employees", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_EmployeePosts_Posts_PostId", + table: "EmployeePosts", + column: "PostId", + principalTable: "Posts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_LecturerPosts_Lecturers_LecturerId", + table: "LecturerPosts", + column: "LecturerId", + principalTable: "Lecturers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_LecturerPosts_Posts_PostId", + table: "LecturerPosts", + column: "PostId", + principalTable: "Posts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_EmployeePosts_Employees_EmployeeId", + table: "EmployeePosts"); + + migrationBuilder.DropForeignKey( + name: "FK_EmployeePosts_Posts_PostId", + table: "EmployeePosts"); + + migrationBuilder.DropForeignKey( + name: "FK_LecturerPosts_Lecturers_LecturerId", + table: "LecturerPosts"); + + migrationBuilder.DropForeignKey( + name: "FK_LecturerPosts_Posts_PostId", + table: "LecturerPosts"); + + migrationBuilder.DropTable( + name: "Posts"); + + migrationBuilder.DropIndex( + name: "IX_LecturerPosts_LecturerId", + table: "LecturerPosts"); + + migrationBuilder.DropIndex( + name: "IX_LecturerPosts_PostId", + table: "LecturerPosts"); + + migrationBuilder.DropIndex( + name: "IX_EmployeePosts_EmployeeId", + table: "EmployeePosts"); + + migrationBuilder.DropIndex( + name: "IX_EmployeePosts_PostId", + table: "EmployeePosts"); + + migrationBuilder.DropColumn( + name: "IsExternalCombination", + table: "LecturerPosts"); + + migrationBuilder.DropColumn( + name: "IsInternalCombination", + table: "LecturerPosts"); + + migrationBuilder.DropColumn( + name: "LecturerId", + table: "LecturerPosts"); + + migrationBuilder.DropColumn( + name: "PostId", + table: "LecturerPosts"); + + migrationBuilder.DropColumn( + name: "Rate", + table: "LecturerPosts"); + + migrationBuilder.DropColumn( + name: "EmployeeId", + table: "EmployeePosts"); + + migrationBuilder.DropColumn( + name: "IsExternalCombination", + table: "EmployeePosts"); + + migrationBuilder.DropColumn( + name: "IsInternalCombination", + table: "EmployeePosts"); + + migrationBuilder.DropColumn( + name: "PostId", + table: "EmployeePosts"); + + migrationBuilder.DropColumn( + name: "Rate", + table: "EmployeePosts"); + + migrationBuilder.AddColumn( + name: "Hours", + table: "LecturerPosts", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "LecturerPostName", + table: "LecturerPosts", + type: "nvarchar(450)", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "Order", + table: "LecturerPosts", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EmployeePostName", + table: "EmployeePosts", + type: "nvarchar(450)", + nullable: true); + + migrationBuilder.AddColumn( + name: "Order", + table: "EmployeePosts", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "EmployeeEmployeePosts", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + DateCreate = table.Column(type: "datetime2", nullable: false), + DateDelete = table.Column(type: "datetime2", nullable: true), + EmployeeId = table.Column(type: "uniqueidentifier", nullable: false), + EmployeePostId = table.Column(type: "uniqueidentifier", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + IsExternalCombination = table.Column(type: "bit", nullable: false), + IsInternalCombination = table.Column(type: "bit", nullable: false), + Rate = table.Column(type: "decimal(18,2)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EmployeeEmployeePosts", x => x.Id); + table.ForeignKey( + name: "FK_EmployeeEmployeePosts_EmployeePosts_EmployeePostId", + column: x => x.EmployeePostId, + principalTable: "EmployeePosts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_EmployeeEmployeePosts_Employees_EmployeeId", + column: x => x.EmployeeId, + principalTable: "Employees", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "LecturerEmployeePosts", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + DateCreate = table.Column(type: "datetime2", nullable: false), + DateDelete = table.Column(type: "datetime2", nullable: true), + EmployeePostId = table.Column(type: "uniqueidentifier", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + IsExternalCombination = table.Column(type: "bit", nullable: false), + IsInternalCombination = table.Column(type: "bit", nullable: false), + LecturerId = table.Column(type: "uniqueidentifier", nullable: false), + Rate = table.Column(type: "decimal(18,2)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_LecturerEmployeePosts", x => x.Id); + table.ForeignKey( + name: "FK_LecturerEmployeePosts_EmployeePosts_EmployeePostId", + column: x => x.EmployeePostId, + principalTable: "EmployeePosts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_LecturerEmployeePosts_Lecturers_LecturerId", + column: x => x.LecturerId, + principalTable: "Lecturers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Lecturers_LecturerPostId", + table: "Lecturers", + column: "LecturerPostId"); + + migrationBuilder.CreateIndex( + name: "IX_LecturerPosts_LecturerPostName", + table: "LecturerPosts", + column: "LecturerPostName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_EmployeePosts_EmployeePostName", + table: "EmployeePosts", + column: "EmployeePostName", + unique: true, + filter: "[EmployeePostName] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_EmployeeEmployeePosts_EmployeeId", + table: "EmployeeEmployeePosts", + column: "EmployeeId"); + + migrationBuilder.CreateIndex( + name: "IX_EmployeeEmployeePosts_EmployeePostId", + table: "EmployeeEmployeePosts", + column: "EmployeePostId"); + + migrationBuilder.CreateIndex( + name: "IX_LecturerEmployeePosts_EmployeePostId", + table: "LecturerEmployeePosts", + column: "EmployeePostId"); + + migrationBuilder.CreateIndex( + name: "IX_LecturerEmployeePosts_LecturerId", + table: "LecturerEmployeePosts", + column: "LecturerId"); + + migrationBuilder.AddForeignKey( + name: "FK_Lecturers_LecturerPosts_LecturerPostId", + table: "Lecturers", + column: "LecturerPostId", + principalTable: "LecturerPosts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082110_AddFieldToLecturer.Designer.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082110_AddFieldToLecturer.Designer.cs new file mode 100644 index 0000000..5ed3126 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082110_AddFieldToLecturer.Designer.cs @@ -0,0 +1,813 @@ +// +using System; +using DatabaseCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace DatabaseCore.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20210405082110_AddFieldToLecturer")] + partial class AddFieldToLecturer + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.4") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("DatabaseCore.Models.Department.Classroom", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("ClassroomType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("HaveProjector") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Number") + .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() + .HasFilter("[Number] IS NOT NULL"); + + b.ToTable("Classrooms"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisciplineBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("DisciplineShortName") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineBlockId"); + + b.HasIndex("DisciplineName") + .IsUnique(); + + b.ToTable("Disciplines"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockOrder") + .HasColumnType("int"); + + b.Property("DisciplineBlockUseForGrouping") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Title") + .IsUnique(); + + b.ToTable("DisciplineBlocks"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Address") + .HasColumnType("nvarchar(max)"); + + b.Property("DateBirth") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .HasColumnType("nvarchar(450)"); + + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + + b.Property("HomeNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastName") + .HasColumnType("nvarchar(450)"); + + b.Property("MobileNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[FirstName] IS NOT NULL AND [LastName] IS NOT NULL AND [Patronymic] IS NOT NULL"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("PostId"); + + b.ToTable("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Abbreviation") + .HasColumnType("nvarchar(max)"); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateBirth") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + + b.Property("HomeNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("LecturerAcademicDegreeId") + .HasColumnType("uniqueidentifier"); + + b.Property("LecturerAcademicRankId") + .HasColumnType("uniqueidentifier"); + + b.Property("LecturerPostId") + .HasColumnType("uniqueidentifier"); + + b.Property("LecturerPostRate") + .HasColumnType("decimal(18,2)"); + + b.Property("MobileNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OnlyForPrivate") + .HasColumnType("bit"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeId"); + + b.HasIndex("LecturerAcademicRankId"); + + b.HasIndex("UserId"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[Patronymic] IS NOT NULL"); + + b.ToTable("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicDegreeName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeName") + .IsUnique(); + + b.ToTable("LecturerAcademicDegrees"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicRankName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicRankName") + .IsUnique(); + + b.ToTable("LecturerAcademicRanks"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("PostId"); + + b.ToTable("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Hours") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("PostName") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("PostName") + .IsUnique() + .HasFilter("[PostName] IS NOT NULL"); + + b.ToTable("Posts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessOperation") + .HasColumnType("int"); + + b.Property("AccessType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Accesses"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.EnviromentSetting", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Key") + .IsUnique(); + + b.ToTable("EnviromentSettings"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("RolePriority") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RoleName") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Avatar") + .HasColumnType("varbinary(max)"); + + b.Property("CountAttempt") + .HasColumnType("int"); + + b.Property("DateBanned") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DateLastVisit") + .HasColumnType("datetime2"); + + b.Property("IsBanned") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserName"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Classroom", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("Classrooms") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("Disciplines") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Employees") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("EmployeePosts") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("EmployeePosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicDegreeId"); + + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicRank", "LecturerAcademicRank") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicRankId"); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Lecturers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LecturerAcademicDegree"); + + b.Navigation("LecturerAcademicRank"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + { + b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") + .WithMany("LecturerPosts") + .HasForeignKey("LecturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("LecturerPosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lecturer"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("Access") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Navigation("Disciplines"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Navigation("Classrooms"); + + b.Navigation("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.Navigation("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => + { + b.Navigation("EmployeePosts"); + + b.Navigation("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Navigation("Access"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.User", b => + { + b.Navigation("Employees"); + + b.Navigation("Lecturers"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082110_AddFieldToLecturer.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082110_AddFieldToLecturer.cs new file mode 100644 index 0000000..eaa2054 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082110_AddFieldToLecturer.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace DatabaseCore.Migrations +{ + public partial class AddFieldToLecturer : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "GroupElectricalSafety", + table: "Lecturers", + type: "nvarchar(max)", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "GroupElectricalSafety", + table: "Lecturers"); + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082213_RemFieldToLecturer.Designer.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082213_RemFieldToLecturer.Designer.cs new file mode 100644 index 0000000..25b67b3 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082213_RemFieldToLecturer.Designer.cs @@ -0,0 +1,807 @@ +// +using System; +using DatabaseCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace DatabaseCore.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20210405082213_RemFieldToLecturer")] + partial class RemFieldToLecturer + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.4") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("DatabaseCore.Models.Department.Classroom", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("ClassroomType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("HaveProjector") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Number") + .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() + .HasFilter("[Number] IS NOT NULL"); + + b.ToTable("Classrooms"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisciplineBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("DisciplineShortName") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineBlockId"); + + b.HasIndex("DisciplineName") + .IsUnique(); + + b.ToTable("Disciplines"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockOrder") + .HasColumnType("int"); + + b.Property("DisciplineBlockUseForGrouping") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Title") + .IsUnique(); + + b.ToTable("DisciplineBlocks"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Address") + .HasColumnType("nvarchar(max)"); + + b.Property("DateBirth") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .HasColumnType("nvarchar(450)"); + + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + + b.Property("HomeNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastName") + .HasColumnType("nvarchar(450)"); + + b.Property("MobileNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[FirstName] IS NOT NULL AND [LastName] IS NOT NULL AND [Patronymic] IS NOT NULL"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("PostId"); + + b.ToTable("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Abbreviation") + .HasColumnType("nvarchar(max)"); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateBirth") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + + b.Property("HomeNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("LecturerAcademicDegreeId") + .HasColumnType("uniqueidentifier"); + + b.Property("LecturerAcademicRankId") + .HasColumnType("uniqueidentifier"); + + b.Property("MobileNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OnlyForPrivate") + .HasColumnType("bit"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeId"); + + b.HasIndex("LecturerAcademicRankId"); + + b.HasIndex("UserId"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[Patronymic] IS NOT NULL"); + + b.ToTable("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicDegreeName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeName") + .IsUnique(); + + b.ToTable("LecturerAcademicDegrees"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicRankName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicRankName") + .IsUnique(); + + b.ToTable("LecturerAcademicRanks"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("PostId"); + + b.ToTable("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Hours") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("PostName") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("PostName") + .IsUnique() + .HasFilter("[PostName] IS NOT NULL"); + + b.ToTable("Posts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessOperation") + .HasColumnType("int"); + + b.Property("AccessType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Accesses"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.EnviromentSetting", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Key") + .IsUnique(); + + b.ToTable("EnviromentSettings"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("RolePriority") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RoleName") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Avatar") + .HasColumnType("varbinary(max)"); + + b.Property("CountAttempt") + .HasColumnType("int"); + + b.Property("DateBanned") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DateLastVisit") + .HasColumnType("datetime2"); + + b.Property("IsBanned") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserName"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Classroom", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("Classrooms") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("Disciplines") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Employees") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("EmployeePosts") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("EmployeePosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicDegreeId"); + + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicRank", "LecturerAcademicRank") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicRankId"); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Lecturers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LecturerAcademicDegree"); + + b.Navigation("LecturerAcademicRank"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + { + b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") + .WithMany("LecturerPosts") + .HasForeignKey("LecturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("LecturerPosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lecturer"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("Access") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Navigation("Disciplines"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Navigation("Classrooms"); + + b.Navigation("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.Navigation("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => + { + b.Navigation("EmployeePosts"); + + b.Navigation("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Navigation("Access"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.User", b => + { + b.Navigation("Employees"); + + b.Navigation("Lecturers"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082213_RemFieldToLecturer.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082213_RemFieldToLecturer.cs new file mode 100644 index 0000000..2b1c451 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210405082213_RemFieldToLecturer.cs @@ -0,0 +1,36 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace DatabaseCore.Migrations +{ + public partial class RemFieldToLecturer : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LecturerPostId", + table: "Lecturers"); + + migrationBuilder.DropColumn( + name: "LecturerPostRate", + table: "Lecturers"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LecturerPostId", + table: "Lecturers", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "LecturerPostRate", + table: "Lecturers", + type: "decimal(18,2)", + nullable: false, + defaultValue: 0m); + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs index 2ba3e92..6ad44ae 100644 --- a/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs @@ -210,7 +210,7 @@ namespace DatabaseCore.Migrations b.ToTable("Employees"); }); - modelBuilder.Entity("DatabaseCore.Models.Department.EmployeeEmployeePost", b => + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => { b.Property("Id") .HasColumnType("uniqueidentifier"); @@ -224,9 +224,6 @@ namespace DatabaseCore.Migrations b.Property("EmployeeId") .HasColumnType("uniqueidentifier"); - b.Property("EmployeePostId") - .HasColumnType("uniqueidentifier"); - b.Property("IsDeleted") .HasColumnType("bit"); @@ -236,6 +233,9 @@ namespace DatabaseCore.Migrations b.Property("IsInternalCombination") .HasColumnType("bit"); + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + b.Property("Rate") .HasColumnType("decimal(18,2)"); @@ -243,36 +243,7 @@ namespace DatabaseCore.Migrations b.HasIndex("EmployeeId"); - b.HasIndex("EmployeePostId"); - - b.ToTable("EmployeeEmployeePosts"); - }); - - modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateDelete") - .HasColumnType("datetime2"); - - b.Property("EmployeePostName") - .HasColumnType("nvarchar(450)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("Order") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("EmployeePostName") - .IsUnique() - .HasFilter("[EmployeePostName] IS NOT NULL"); + b.HasIndex("PostId"); b.ToTable("EmployeePosts"); }); @@ -309,6 +280,9 @@ namespace DatabaseCore.Migrations .IsRequired() .HasColumnType("nvarchar(450)"); + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + b.Property("HomeNumber") .HasColumnType("nvarchar(max)"); @@ -325,12 +299,6 @@ namespace DatabaseCore.Migrations b.Property("LecturerAcademicRankId") .HasColumnType("uniqueidentifier"); - b.Property("LecturerPostId") - .HasColumnType("uniqueidentifier"); - - b.Property("LecturerPostRate") - .HasColumnType("decimal(18,2)"); - b.Property("MobileNumber") .IsRequired() .HasColumnType("nvarchar(max)"); @@ -353,8 +321,6 @@ namespace DatabaseCore.Migrations b.HasIndex("LecturerAcademicRankId"); - b.HasIndex("LecturerPostId"); - b.HasIndex("UserId"); b.HasIndex("FirstName", "LastName", "Patronymic") @@ -425,7 +391,7 @@ namespace DatabaseCore.Migrations b.ToTable("LecturerAcademicRanks"); }); - modelBuilder.Entity("DatabaseCore.Models.Department.LecturerEmployeePost", b => + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => { b.Property("Id") .HasColumnType("uniqueidentifier"); @@ -436,9 +402,6 @@ namespace DatabaseCore.Migrations b.Property("DateDelete") .HasColumnType("datetime2"); - b.Property("EmployeePostId") - .HasColumnType("uniqueidentifier"); - b.Property("IsDeleted") .HasColumnType("bit"); @@ -451,19 +414,22 @@ namespace DatabaseCore.Migrations b.Property("LecturerId") .HasColumnType("uniqueidentifier"); + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + b.Property("Rate") .HasColumnType("decimal(18,2)"); b.HasKey("Id"); - b.HasIndex("EmployeePostId"); - b.HasIndex("LecturerId"); - b.ToTable("LecturerEmployeePosts"); + b.HasIndex("PostId"); + + b.ToTable("LecturerPosts"); }); - modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => { b.Property("Id") .HasColumnType("uniqueidentifier"); @@ -474,25 +440,25 @@ namespace DatabaseCore.Migrations b.Property("DateDelete") .HasColumnType("datetime2"); - b.Property("Hours") + b.Property("Hours") .HasColumnType("int"); b.Property("IsDeleted") .HasColumnType("bit"); - b.Property("LecturerPostName") - .IsRequired() - .HasColumnType("nvarchar(450)"); - b.Property("Order") .HasColumnType("int"); + b.Property("PostName") + .HasColumnType("nvarchar(450)"); + b.HasKey("Id"); - b.HasIndex("LecturerPostName") - .IsUnique(); + b.HasIndex("PostName") + .IsUnique() + .HasFilter("[PostName] IS NOT NULL"); - b.ToTable("LecturerPosts"); + b.ToTable("Posts"); }); modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => @@ -693,23 +659,23 @@ namespace DatabaseCore.Migrations b.Navigation("User"); }); - modelBuilder.Entity("DatabaseCore.Models.Department.EmployeeEmployeePost", b => + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => { b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") - .WithMany("EmployeeEmployeePosts") + .WithMany("EmployeePosts") .HasForeignKey("EmployeeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DatabaseCore.Models.Department.EmployeePost", "EmployeePost") - .WithMany("EmployeeEmployeePosts") - .HasForeignKey("EmployeePostId") + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("EmployeePosts") + .HasForeignKey("PostId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Employee"); - b.Navigation("EmployeePost"); + b.Navigation("Post"); }); modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => @@ -722,12 +688,6 @@ namespace DatabaseCore.Migrations .WithMany("Lecturers") .HasForeignKey("LecturerAcademicRankId"); - b.HasOne("DatabaseCore.Models.Department.LecturerPost", "LecturerPost") - .WithMany("Lecturers") - .HasForeignKey("LecturerPostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - b.HasOne("DatabaseCore.Models.Security.User", "User") .WithMany("Lecturers") .HasForeignKey("UserId") @@ -738,28 +698,26 @@ namespace DatabaseCore.Migrations b.Navigation("LecturerAcademicRank"); - b.Navigation("LecturerPost"); - b.Navigation("User"); }); - modelBuilder.Entity("DatabaseCore.Models.Department.LecturerEmployeePost", b => + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => { - b.HasOne("DatabaseCore.Models.Department.EmployeePost", "EmployeePost") - .WithMany("LecturerEmployeePosts") - .HasForeignKey("EmployeePostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") - .WithMany("LecturerEmployeePosts") + .WithMany("LecturerPosts") .HasForeignKey("LecturerId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("EmployeePost"); + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("LecturerPosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("Lecturer"); + + b.Navigation("Post"); }); modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => @@ -801,19 +759,12 @@ namespace DatabaseCore.Migrations { b.Navigation("Classrooms"); - b.Navigation("EmployeeEmployeePosts"); - }); - - modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => - { - b.Navigation("EmployeeEmployeePosts"); - - b.Navigation("LecturerEmployeePosts"); + b.Navigation("EmployeePosts"); }); modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => { - b.Navigation("LecturerEmployeePosts"); + b.Navigation("LecturerPosts"); }); modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => @@ -826,9 +777,11 @@ namespace DatabaseCore.Migrations b.Navigation("Lecturers"); }); - modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => { - b.Navigation("Lecturers"); + b.Navigation("EmployeePosts"); + + b.Navigation("LecturerPosts"); }); modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/Employee.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/Employee.cs index 70364d8..78e45ce 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/Employee.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/Employee.cs @@ -71,7 +71,7 @@ namespace DatabaseCore.Models.Department //------------------------------------------------------------------------- [ForeignKey("EmployeeId")] - public virtual List EmployeeEmployeePosts { get; set; } + public virtual List EmployeePosts { get; set; } [ForeignKey("EmployeeId")] public virtual List Classrooms { get; set; } diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeeEmployeePost.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeeEmployeePost.cs deleted file mode 100644 index a22a8ae..0000000 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeeEmployeePost.cs +++ /dev/null @@ -1,49 +0,0 @@ -using ModuleTools.Attributes; -using ModuleTools.Interfaces; -using System; -using System.Runtime.Serialization; - -namespace DatabaseCore.Models.Department -{ - /// - /// Класс, описывающий связь сотрудника и должность кафедры - /// - [DataContract] - [EntityDescription("EmployeeEmployeePost", "Связь сотрудника и должность кафедры")] - [EntityDependency("EmployeePost", "EmployeePostId", "К какой должности относится сотрудник")] - [EntityDependency("Employee", "EmployeeId", "К какой должности относится сотрудник")] - public class EmployeeEmployeePost : BaseEntity, IEntitySecurityExtenstion - { - [DataMember] - [MapConfiguration("EmployeeId")] - public Guid EmployeeId { get; set; } - - [DataMember] - [MapConfiguration("EmployeePostId")] - public Guid EmployeePostId { get; set; } - - [DataMember] - [MapConfiguration("Rate")] - public decimal Rate { get; set; } - - [DataMember] - [MapConfiguration("IsInternalCombination")] - public bool IsInternalCombination { get; set; } - - [DataMember] - [MapConfiguration("IsExternalCombination")] - public bool IsExternalCombination { get; set; } - - //------------------------------------------------------------------------- - - public virtual EmployeePost EmployeePost { get; set; } - - public virtual Employee Employee { get; set; } - - //------------------------------------------------------------------------- - - //------------------------------------------------------------------------- - - public EmployeeEmployeePost SecurityCheck(EmployeeEmployeePost entity, bool allowFullData) => entity; - } -} diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeePost.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeePost.cs index 17358b1..dc3d065 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeePost.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/EmployeePost.cs @@ -1,39 +1,49 @@ using ModuleTools.Attributes; using ModuleTools.Interfaces; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; +using System; using System.Runtime.Serialization; namespace DatabaseCore.Models.Department { /// - /// Класс, описывающий должность сотрудника кафедры + /// Класс, описывающий связь сотрудника и должность кафедры /// [DataContract] - [EntityDescription("EmployeePost", "Должность сотрудника кафедры")] + [EntityDescription("EmployeeEmployeePost", "Связь сотрудника и должность кафедры")] + [EntityDependency("Post", "PostId", "К какой должности относится сотрудник")] + [EntityDependency("Employee", "EmployeeId", "К какой должности относится сотрудник")] public class EmployeePost : BaseEntity, IEntitySecurityExtenstion { [DataMember] - [MapConfiguration("EmployeePostName")] - public string EmployeePostName { get; set; } - + [MapConfiguration("EmployeeId")] + public Guid EmployeeId { get; set; } [DataMember] - [MapConfiguration("Order")] - public int Order { get; set; } + [MapConfiguration("PostId")] + public Guid PostId { get; set; } + + [DataMember] + [MapConfiguration("Rate")] + public decimal Rate { get; set; } + + [DataMember] + [MapConfiguration("IsInternalCombination")] + public bool IsInternalCombination { get; set; } + + [DataMember] + [MapConfiguration("IsExternalCombination")] + public bool IsExternalCombination { get; set; } //------------------------------------------------------------------------- + public virtual Post Post { get; set; } + + public virtual Employee Employee { get; set; } + //------------------------------------------------------------------------- - [ForeignKey("EmployeePostId")] - public virtual List EmployeeEmployeePosts { get; set; } - - [ForeignKey("EmployeePostId")] - public virtual List LecturerEmployeePosts { get; set; } - //------------------------------------------------------------------------- public EmployeePost SecurityCheck(EmployeePost entity, bool allowFullData) => entity; } -} \ No newline at end of file +} diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/Lecturer.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/Lecturer.cs index 3dff614..8d791d1 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/Lecturer.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/Lecturer.cs @@ -15,7 +15,6 @@ namespace DatabaseCore.Models.Department [DataContract] [EntityDescription("Lecturer", "Преподаваетль кафедры")] [EntityDependency("User", "UserId", "К какому пользователю относится преподаватель")] - [EntityDependency("LecturerPost", "LecturerPostId", "К какой должности относится преподаватель")] [EntityDependency("LecturerAcademicRank", "LecturerAcademicRankId", "Какое звание имеет преподаватель")] [EntityDependency("LecturerAcademicDegree", "LecturerAcademicDegreeId", "Какую степень имеет преподаватель")] public class Lecturer : BaseEntity, IEntitySecurityExtenstion @@ -25,16 +24,6 @@ namespace DatabaseCore.Models.Department [MapConfiguration("UserId")] public Guid UserId { get; set; } - [DataMember] - [Required] - [MapConfiguration("LecturerPostId")] - public Guid LecturerPostId { get; set; } - - [DataMember] - [Required] - [MapConfiguration("LecturerPostRate")] - public decimal LecturerPostRate { get; set; } - [DataMember] [MapConfiguration("LecturerAcademicRankId")] public Guid? LecturerAcademicRankId { get; set; } @@ -97,12 +86,14 @@ namespace DatabaseCore.Models.Department [MapConfiguration("OnlyForPrivate")] public bool OnlyForPrivate { get; set; } + [DataMember] + [MapConfiguration("GroupElectricalSafety")] + public string GroupElectricalSafety { get; set; } + //------------------------------------------------------------------------- public virtual User User { get; set; } - public virtual LecturerPost LecturerPost { get; set; } - public virtual LecturerAcademicRank LecturerAcademicRank { get; set; } public virtual LecturerAcademicDegree LecturerAcademicDegree { get; set; } @@ -110,7 +101,7 @@ namespace DatabaseCore.Models.Department //------------------------------------------------------------------------- [ForeignKey("LecturerId")] - public virtual List LecturerEmployeePosts { get; set; } + public virtual List LecturerPosts { get; set; } //------------------------------------------------------------------------- diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/LecturerEmployeePost.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/LecturerEmployeePost.cs deleted file mode 100644 index a9f59d4..0000000 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/LecturerEmployeePost.cs +++ /dev/null @@ -1,53 +0,0 @@ -using ModuleTools.Attributes; -using ModuleTools.Interfaces; -using System; -using System.ComponentModel.DataAnnotations; -using System.Runtime.Serialization; - -namespace DatabaseCore.Models.Department -{ - /// - /// Класс, описывающий связь преподавателя и должность кафедры - /// - [DataContract] - [EntityDescription("LecturerEmployeePost", "Связь преподавателя и должность кафедры")] - [EntityDependency("EmployeePost", "EmployeePostId", "К какой должности относится преподаватель")] - [EntityDependency("Lecturer", "LecturerId", "К какой должности относится преподаватель")] - public class LecturerEmployeePost : BaseEntity, IEntitySecurityExtenstion - { - [DataMember] - [Required] - [MapConfiguration("LecturerId")] - public Guid LecturerId { get; set; } - - [DataMember] - [Required] - [MapConfiguration("EmployeePostId")] - public Guid EmployeePostId { get; set; } - - [DataMember] - [Required] - [MapConfiguration("Rate")] - public decimal Rate { get; set; } - - [DataMember] - [MapConfiguration("IsInternalCombination")] - public bool IsInternalCombination { get; set; } - - [DataMember] - [MapConfiguration("IsExternalCombination")] - public bool IsExternalCombination { get; set; } - - //------------------------------------------------------------------------- - - public virtual EmployeePost EmployeePost { get; set; } - - public virtual Lecturer Lecturer { get; set; } - - //------------------------------------------------------------------------- - - //------------------------------------------------------------------------- - - public LecturerEmployeePost SecurityCheck(LecturerEmployeePost entity, bool allowFullData) => entity; - } -} \ No newline at end of file diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/LecturerPost.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/LecturerPost.cs index 492b0db..a41b919 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/LecturerPost.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/LecturerPost.cs @@ -1,39 +1,50 @@ using ModuleTools.Attributes; using ModuleTools.Interfaces; -using System.Collections.Generic; +using System; using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; using System.Runtime.Serialization; namespace DatabaseCore.Models.Department { /// - /// Класс, описывающий должность преподавателя кафедры + /// Класс, описывающий связь преподавателя и должность кафедры /// [DataContract] - [EntityDescription("LecturerPost", "Должность преподавателя кафедры")] + [EntityDescription("LecturerPost", "Связь преподавателя и должность кафедры")] + [EntityDependency("Post", "PostId", "К какой должности относится преподаватель")] + [EntityDependency("Lecturer", "LecturerId", "К какой должности относится преподаватель")] public class LecturerPost : BaseEntity, IEntitySecurityExtenstion { [DataMember] [Required] - [MapConfiguration("LecturerPostName")] - public string LecturerPostName { get; set; } + [MapConfiguration("LecturerId")] + public Guid LecturerId { get; set; } [DataMember] [Required] - [MapConfiguration("Hours")] - public int Hours { get; set; } + [MapConfiguration("PostId")] + public Guid PostId { get; set; } [DataMember] - [MapConfiguration("Order")] - public int Order { get; set; } + [Required] + [MapConfiguration("Rate")] + public decimal Rate { get; set; } + + [DataMember] + [MapConfiguration("IsInternalCombination")] + public bool IsInternalCombination { get; set; } + + [DataMember] + [MapConfiguration("IsExternalCombination")] + public bool IsExternalCombination { get; set; } //------------------------------------------------------------------------- - //------------------------------------------------------------------------- + public virtual Post Post { get; set; } - [ForeignKey("LecturerPostId")] - public virtual List Lecturers { get; set; } + public virtual Lecturer Lecturer { get; set; } + + //------------------------------------------------------------------------- //------------------------------------------------------------------------- diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/Post.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/Post.cs new file mode 100644 index 0000000..5379300 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/Post.cs @@ -0,0 +1,42 @@ +using ModuleTools.Attributes; +using ModuleTools.Interfaces; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; + +namespace DatabaseCore.Models.Department +{ + /// + /// Класс, описывающий должность на кафедры + /// + [DataContract] + [EntityDescription("Post", "Должность на кафедры")] + public class Post : BaseEntity, IEntitySecurityExtenstion + { + [DataMember] + [MapConfiguration("PostName")] + public string PostName { get; set; } + + [DataMember] + [MapConfiguration("Hours")] + public int? Hours { get; set; } + + [DataMember] + [MapConfiguration("Order")] + public int Order { get; set; } + + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + + [ForeignKey("PostId")] + public virtual List EmployeePosts { get; set; } + + [ForeignKey("PostId")] + public virtual List LecturerPosts { get; set; } + + //------------------------------------------------------------------------- + + public Post SecurityCheck(Post entity, bool allowFullData) => entity; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DatabaseCore/Scripts/DepartmentMigrationScript.cs b/DepartmentPortal/Common/DatabaseCore/Scripts/DepartmentMigrationScript.cs index e5f3413..86906be 100644 --- a/DepartmentPortal/Common/DatabaseCore/Scripts/DepartmentMigrationScript.cs +++ b/DepartmentPortal/Common/DatabaseCore/Scripts/DepartmentMigrationScript.cs @@ -14,7 +14,7 @@ DELETE FROM [DepartmentDatabasePortal].[dbo].[DisciplineBlocks]; GO DELETE FROM [DepartmentDatabasePortal].[dbo].[Disciplines]; GO -DELETE FROM [DepartmentDatabasePortal].[dbo].[LecturerPosts]; +DELETE FROM [DepartmentDatabasePortal].[dbo].[Posts]; GO DELETE FROM [DepartmentDatabasePortal].[dbo].[Lecturers]; GO"; @@ -39,7 +39,7 @@ INSERT INTO [DepartmentDatabasePortal].[dbo].[Disciplines]([Id],[DisciplineBlock SELECT [Id],[DisciplineBlockId],[DisciplineName],[DisciplineShortName],[DisciplineDescription],[DisciplineBlueAsteriskName],[DateCreate],[DateDelete],[IsDeleted] FROM [DepartmentDatabaseContext].[dbo].[Disciplines]"; private static readonly string lecturerpostMigration = -@"INSERT INTO [DepartmentDatabasePortal].[dbo].[LecturerPosts]([Id],[LecturerPostName],[Hours],[Order],[DateCreate],[DateDelete],[IsDeleted]) +@"INSERT INTO [DepartmentDatabasePortal].[dbo].[Posts]([Id],[PostName],[Hours],[Order],[DateCreate],[DateDelete],[IsDeleted]) SELECT [Id],[StudyPostTitle],[Hours],1,[DateCreate],[DateDelete],[IsDeleted] FROM [DepartmentDatabaseContext].[dbo].[LecturerStudyPosts]"; private static readonly string lecturerMigration = @@ -47,8 +47,8 @@ SELECT [Id],[StudyPostTitle],[Hours],1,[DateCreate],[DateDelete],[IsDeleted] FRO SELECT @userId = u.[Id] FROM [DepartmentDatabasePortal].[dbo].[Users] u WHERE u.[UserName]='admin' -INSERT INTO [DepartmentDatabasePortal].[dbo].[Lecturers]([Id],[UserId],[LecturerPostId],[LecturerPostRate],[LastName],[FirstName],[Patronymic],[Abbreviation],[DateBirth],[Address],[Email],[MobileNumber],[HomeNumber],[Description],[Photo],[GroupElectricalSafety],[OnlyForPrivate],[DateCreate],[DateDelete],[IsDeleted]) -SELECT [Id],@userId,[LecturerStudyPostId],1,[LastName],[FirstName],[Patronymic],[Abbreviation],[DateBirth],[Address],[Email],[MobileNumber],[HomeNumber],[Description],[Photo],'I',[OnlyForPrivate],[DateCreate],[DateDelete],[IsDeleted] FROM [DepartmentDatabaseContext].[dbo].[Lecturers]"; +INSERT INTO [DepartmentDatabasePortal].[dbo].[Lecturers]([Id],[UserId],[LastName],[FirstName],[Patronymic],[Abbreviation],[DateBirth],[Address],[Email],[MobileNumber],[HomeNumber],[Description],[Photo],[GroupElectricalSafety],[OnlyForPrivate],[DateCreate],[DateDelete],[IsDeleted]) +SELECT [Id],@userId,[LastName],[FirstName],[Patronymic],[Abbreviation],[DateBirth],[Address],[Email],[MobileNumber],[HomeNumber],[Description],[Photo],'I',[OnlyForPrivate],[DateCreate],[DateDelete],[IsDeleted] FROM [DepartmentDatabaseContext].[dbo].[Lecturers]"; /// /// Перенос данных по безопасности diff --git a/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs b/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs index c9d20f7..1d32f02 100644 --- a/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs +++ b/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs @@ -26,13 +26,15 @@ #region База Кафедра = 100, - Сотрудники = 101, // + должности + Должности = 101, // + должности - Аудитории = 102, + Сотрудники = 102, // + должности - Дисциплины = 103, // + Блоки дисциплин + Аудитории = 103, - Преподаватели = 104, // + должности, звания + Дисциплины = 104, // + Блоки дисциплин + + Преподаватели = 105, // + должности, звания Направления = 102, diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeeBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeeBindingModels.cs index 4da4219..101afb8 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeeBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeeBindingModels.cs @@ -58,6 +58,7 @@ namespace DepartmentBusinessLogic.BindingModels [MapConfiguration("Photo")] public byte[] Photo { get; set; } + [Required(ErrorMessage = "required")] [MapConfiguration("GroupElectricalSafety")] public string GroupElectricalSafety { get; set; } } diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeeEmployeePostBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeeEmployeePostBindingModels.cs deleted file mode 100644 index 9492eb7..0000000 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeeEmployeePostBindingModels.cs +++ /dev/null @@ -1,41 +0,0 @@ -using ModuleTools.Attributes; -using ModuleTools.BindingModels; -using System; -using System.ComponentModel.DataAnnotations; - -namespace DepartmentBusinessLogic.BindingModels -{ - /// - /// Получение связи сотрудника с должностью - /// - public class EmployeeEmployeePostGetBindingModel : GetBindingModel - { - public Guid? EmployeeId { get; set; } - - public Guid? EmployeePostId { get; set; } - } - - /// - /// Сохранение связи сотрудника с должностью - /// - public class EmployeeEmployeePostSetBindingModel : SetBindingModel - { - [Required(ErrorMessage = "required")] - [MapConfiguration("EmployeeId")] - public Guid EmployeeId { get; set; } - - [Required(ErrorMessage = "required")] - [MapConfiguration("EmployeePostId")] - public Guid EmployeePostId { get; set; } - - [Required(ErrorMessage = "required")] - [MapConfiguration("Rate")] - public decimal Rate { get; set; } - - [MapConfiguration("IsInternalCombination")] - public bool IsInternalCombination { get; set; } - - [MapConfiguration("IsExternalCombination")] - public bool IsExternalCombination { get; set; } - } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeePostBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeePostBindingModels.cs index a2a4a15..d2aec24 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeePostBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeePostBindingModels.cs @@ -1,27 +1,41 @@ using ModuleTools.Attributes; using ModuleTools.BindingModels; +using System; using System.ComponentModel.DataAnnotations; namespace DepartmentBusinessLogic.BindingModels { - /// - /// Получение должности сотрудника - /// + /// + /// Получение связи сотрудника с должностью + /// public class EmployeePostGetBindingModel : GetBindingModel - { - } + { + public Guid? EmployeeId { get; set; } - /// - /// Сохранение должности сотрудника - /// - public class EmployeePostSetBindingModel : SetBindingModel - { - [Required(ErrorMessage = "required")] - [MapConfiguration("EmployeePostName")] - public string EmployeePostName { get; set; } + public Guid? PostId { get; set; } + } - [Required(ErrorMessage = "required")] - [MapConfiguration("Order")] - public int Order { get; set; } - } + /// + /// Сохранение связи сотрудника с должностью + /// + public class EmployeePostSetBindingModel : SetBindingModel + { + [Required(ErrorMessage = "required")] + [MapConfiguration("EmployeeId")] + public Guid EmployeeId { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("PostId")] + public Guid PostId { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("Rate")] + public decimal Rate { get; set; } + + [MapConfiguration("IsInternalCombination")] + public bool IsInternalCombination { get; set; } + + [MapConfiguration("IsExternalCombination")] + public bool IsExternalCombination { get; set; } + } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/LecturerBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/LecturerBindingModels.cs index 4b3e91a..d4177e7 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/LecturerBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/LecturerBindingModels.cs @@ -12,8 +12,6 @@ namespace DepartmentBusinessLogic.BindingModels { public Guid? UserId { get; set; } - public Guid? LecturerPostId { get; set; } - public Guid? LecturerAcademicRankId { get; set; } public Guid? LecturerAcademicDegreeId { get; set; } @@ -28,14 +26,6 @@ namespace DepartmentBusinessLogic.BindingModels [MapConfiguration("UserId")] public Guid UserId { get; set; } - [Required(ErrorMessage = "required")] - [MapConfiguration("LecturerPostId")] - public Guid LecturerPostId { get; set; } - - [Required(ErrorMessage = "required")] - [MapConfiguration("LecturerPostRate")] - public decimal LecturerPostRate { get; set; } - [MapConfiguration("LecturerAcademicRankId")] public Guid? LecturerAcademicRankId { get; set; } @@ -83,5 +73,9 @@ namespace DepartmentBusinessLogic.BindingModels [MapConfiguration("OnlyForPrivate")] public bool OnlyForPrivate { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("GroupElectricalSafety")] + public string GroupElectricalSafety { get; set; } } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/LecturerEmployeePostBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/LecturerEmployeePostBindingModels.cs deleted file mode 100644 index 90c04e7..0000000 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/LecturerEmployeePostBindingModels.cs +++ /dev/null @@ -1,41 +0,0 @@ -using ModuleTools.Attributes; -using ModuleTools.BindingModels; -using System; -using System.ComponentModel.DataAnnotations; - -namespace DepartmentBusinessLogic.BindingModels -{ - /// - /// Получение связи преподавателя с должностью - /// - public class LecturerEmployeePostGetBindingModel : GetBindingModel - { - public Guid? LecturerId { get; set; } - - public Guid? EmployeePostId { get; set; } - } - - /// - /// Сохранение связи преподавателя с должностью - /// - public class LecturerEmployeePostSetBindingModel : SetBindingModel - { - [Required(ErrorMessage = "required")] - [MapConfiguration("LecturerId")] - public Guid LecturerId { get; set; } - - [Required(ErrorMessage = "required")] - [MapConfiguration("EmployeePostId")] - public Guid EmployeePostId { get; set; } - - [Required(ErrorMessage = "required")] - [MapConfiguration("Rate")] - public decimal Rate { get; set; } - - [MapConfiguration("IsInternalCombination")] - public bool IsInternalCombination { get; set; } - - [MapConfiguration("IsExternalCombination")] - public bool IsExternalCombination { get; set; } - } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/LecturerPostBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/LecturerPostBindingModels.cs index a03f96f..74e9ff3 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/LecturerPostBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/LecturerPostBindingModels.cs @@ -1,31 +1,41 @@ using ModuleTools.Attributes; using ModuleTools.BindingModels; +using System; using System.ComponentModel.DataAnnotations; namespace DepartmentBusinessLogic.BindingModels { /// - /// Получение должности преподавателя + /// Получение связи преподавателя с должностью /// public class LecturerPostGetBindingModel : GetBindingModel - { - } + { + public Guid? LecturerId { get; set; } - /// - /// Сохранение должности преподавателя - /// - public class LecturerPostSetBindingModel : SetBindingModel - { - [Required(ErrorMessage = "required")] - [MapConfiguration("LecturerPostName")] - public string LecturerPostName { get; set; } + public Guid? PostId { get; set; } + } - [Required(ErrorMessage = "required")] - [MapConfiguration("Hours")] - public int Hours { get; set; } + /// + /// Сохранение связи преподавателя с должностью + /// + public class LecturerPostSetBindingModel : SetBindingModel + { + [Required(ErrorMessage = "required")] + [MapConfiguration("LecturerId")] + public Guid LecturerId { get; set; } - [Required(ErrorMessage = "required")] - [MapConfiguration("Order")] - public int Order { get; set; } - } + [Required(ErrorMessage = "required")] + [MapConfiguration("PostId")] + public Guid PostId { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("Rate")] + public decimal Rate { get; set; } + + [MapConfiguration("IsInternalCombination")] + public bool IsInternalCombination { get; set; } + + [MapConfiguration("IsExternalCombination")] + public bool IsExternalCombination { get; set; } + } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/PostBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/PostBindingModels.cs new file mode 100644 index 0000000..7288944 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/PostBindingModels.cs @@ -0,0 +1,31 @@ +using ModuleTools.Attributes; +using ModuleTools.BindingModels; +using System.ComponentModel.DataAnnotations; + +namespace DepartmentBusinessLogic.BindingModels +{ + /// + /// Получение должности сотрудника + /// + public class PostGetBindingModel : GetBindingModel + { + } + + /// + /// Сохранение должности сотрудника + /// + public class PostSetBindingModel : SetBindingModel + { + [Required(ErrorMessage = "required")] + [MapConfiguration("PostName")] + public string PostName { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("Hours")] + public int? Hours { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("Order")] + public int Order { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/EmployeeEmployeePostBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/EmployeeEmployeePostBusinessLogic.cs deleted file mode 100644 index 8e95cb8..0000000 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/EmployeeEmployeePostBusinessLogic.cs +++ /dev/null @@ -1,16 +0,0 @@ -using DepartmentBusinessLogic.BindingModels; -using DepartmentBusinessLogic.Interfaces; -using DepartmentBusinessLogic.ViewModels; -using ModuleTools.BusinessLogics; -using ModuleTools.Enums; - -namespace DepartmentBusinessLogic.BusinessLogics -{ - /// - /// Логика работы со связями сотрудников и должностей - /// - public class EmployeeEmployeePostBusinessLogic : GenericBusinessLogic - { - public EmployeeEmployeePostBusinessLogic(IEmployeeEmployeePostService service) : base(service, "Должности сотрудников", AccessOperation.Сотрудники) { } - } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/EmployeePostBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/EmployeePostBusinessLogic.cs index 9e3878d..98b23ea 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/EmployeePostBusinessLogic.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/EmployeePostBusinessLogic.cs @@ -7,7 +7,7 @@ using ModuleTools.Enums; namespace DepartmentBusinessLogic.BusinessLogics { /// - /// Логика работы с должностями сотрудников + /// Логика работы со связями сотрудников и должностей /// public class EmployeePostBusinessLogic : GenericBusinessLogic { diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/LecturerEmployeePostBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/LecturerEmployeePostBusinessLogic.cs deleted file mode 100644 index 26a9c40..0000000 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/LecturerEmployeePostBusinessLogic.cs +++ /dev/null @@ -1,16 +0,0 @@ -using DepartmentBusinessLogic.BindingModels; -using DepartmentBusinessLogic.Interfaces; -using DepartmentBusinessLogic.ViewModels; -using ModuleTools.BusinessLogics; -using ModuleTools.Enums; - -namespace DepartmentBusinessLogic.BusinessLogics -{ - /// - /// Логика работы со связями преподавателей и должностей - /// - public class LecturerEmployeePostBusinessLogic : GenericBusinessLogic - { - public LecturerEmployeePostBusinessLogic(ILecturerEmployeePostService service) : base(service, "Преподаватели", AccessOperation.Преподаватели) { } - } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/LecturerPostBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/LecturerPostBusinessLogic.cs index 99adad0..696211f 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/LecturerPostBusinessLogic.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/LecturerPostBusinessLogic.cs @@ -7,7 +7,7 @@ using ModuleTools.Enums; namespace DepartmentBusinessLogic.BusinessLogics { /// - /// Логика работы с должностями преподавателей + /// Логика работы со связями преподавателей и должностей /// public class LecturerPostBusinessLogic : GenericBusinessLogic { diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/PostBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/PostBusinessLogic.cs new file mode 100644 index 0000000..bc81cc9 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/PostBusinessLogic.cs @@ -0,0 +1,16 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Interfaces; +using DepartmentBusinessLogic.ViewModels; +using ModuleTools.BusinessLogics; +using ModuleTools.Enums; + +namespace DepartmentBusinessLogic.BusinessLogics +{ + /// + /// Логика работы с должностями + /// + public class PostBusinessLogic : GenericBusinessLogic + { + public PostBusinessLogic(IPostService service) : base(service, "Должности", AccessOperation.Сотрудники) { } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IEmployeeEmployeePostService.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IEmployeeEmployeePostService.cs deleted file mode 100644 index 4af5d78..0000000 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IEmployeeEmployeePostService.cs +++ /dev/null @@ -1,10 +0,0 @@ -using DepartmentBusinessLogic.BindingModels; -using ModuleTools.Interfaces; - -namespace DepartmentBusinessLogic.Interfaces -{ - /// - /// Хранение связей сотрудников и должностей - /// - public interface IEmployeeEmployeePostService : IGenerticEntityService { } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IEmployeePostService.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IEmployeePostService.cs index 57c5dd7..bb79fe4 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IEmployeePostService.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IEmployeePostService.cs @@ -4,7 +4,7 @@ using ModuleTools.Interfaces; namespace DepartmentBusinessLogic.Interfaces { /// - /// Хранение должностей сотрудников + /// Хранение связей сотрудников и должностей /// public interface IEmployeePostService : IGenerticEntityService { } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/ILecturerEmployeePostService.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/ILecturerEmployeePostService.cs deleted file mode 100644 index f465c19..0000000 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/ILecturerEmployeePostService.cs +++ /dev/null @@ -1,10 +0,0 @@ -using DepartmentBusinessLogic.BindingModels; -using ModuleTools.Interfaces; - -namespace DepartmentBusinessLogic.Interfaces -{ - /// - /// Хранение должностей преподавателей - /// - public interface ILecturerEmployeePostService : IGenerticEntityService { } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IPostService.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IPostService.cs new file mode 100644 index 0000000..3316cc3 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IPostService.cs @@ -0,0 +1,10 @@ +using DepartmentBusinessLogic.BindingModels; +using ModuleTools.Interfaces; + +namespace DepartmentBusinessLogic.Interfaces +{ + /// + /// Хранение должностей + /// + public interface IPostService : IGenerticEntityService { } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeEmployeePostViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeEmployeePostViewModels.cs deleted file mode 100644 index 510f5f1..0000000 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeEmployeePostViewModels.cs +++ /dev/null @@ -1,56 +0,0 @@ -using ModuleTools.Attributes; -using ModuleTools.Enums; -using ModuleTools.ViewModels; -using System; - -namespace DepartmentBusinessLogic.ViewModels -{ - /// - /// Список связей сотрудников и должностей - /// - public class EmployeeEmployeePostListViewModel : ListViewModel { } - - /// - /// Связь сотрудника и должности - /// - [ViewModelControlElementClass()] - public class EmployeeEmployeePostViewModel : ElementViewModel - { - [ViewModelControlElementProperty("Сотрудник", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeeList, DepartmentWindowsDesktop")] - [MapConfiguration("EmployeeId", AllowCopyWithoutRigth = false)] - public Guid EmployeeId { get; set; } - - [ViewModelControlListProperty("Сотрудник")] - [MapConfiguration("Employee.LastName", IsDifficle = true)] - public string EmployeeName { get; set; } - - [ViewModelControlElementProperty("Должность", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeePostList, DepartmentWindowsDesktop")] - [MapConfiguration("EmployeePostId")] - public Guid EmployeePostId { get; set; } - - [ViewModelControlListProperty("Должность")] - [MapConfiguration("EmployeePost.EmployeePostName", IsDifficle = true)] - public string EmployeePostName { get; set; } - - [ViewModelControlListProperty("Ставка", ColumnWidth = 80, DefaultCellStyleFormat = "N1")] - [ViewModelControlElementProperty("Ставка", ControlType.ControlDecimal, DecimalPlaces = 1, MustHaveValue = true)] - [MapConfiguration("Rate")] - public decimal Rate { get; set; } - - [ViewModelControlElementProperty("Внутр. совм.", ControlType.ControlBool, MustHaveValue = true)] - [MapConfiguration("IsInternalCombination")] - public bool IsInternalCombination { get; set; } - - [ViewModelControlListProperty("Внутр. совм.", ColumnWidth = 80)] - public string InternalCombination => IsInternalCombination ? "Да" : "Нет"; - - [ViewModelControlElementProperty("Внеш. совм.", ControlType.ControlBool, MustHaveValue = true)] - [MapConfiguration("IsExternalCombination")] - public bool IsExternalCombination { get; set; } - - [ViewModelControlListProperty("Внеш. совм.", ColumnWidth = 80)] - public string ExternalCombination => IsExternalCombination ? "Да" : "Нет"; - - public override string ToString() => $"{EmployeeName}-{EmployeePostName}"; - } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeePostViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeePostViewModels.cs index d3b3589..a028770 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeePostViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeePostViewModels.cs @@ -1,34 +1,56 @@ using ModuleTools.Attributes; using ModuleTools.Enums; using ModuleTools.ViewModels; +using System; namespace DepartmentBusinessLogic.ViewModels { - /// - /// Список должностей сотрудников - /// - public class EmployeePostListViewModel : ListViewModel { } + /// + /// Список связей сотрудников и должностей + /// + public class EmployeePostListViewModel : ListViewModel { } - /// - /// Элемент должности сотрудников - /// - [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)] - [ViewModelControlElementDependenceEntity(Title = "Сотрудники", Order = 1, ParentPropertyName = "EmployeePostId", - ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeeEmployeePostList, DepartmentWindowsDesktop")] - [ViewModelControlElementDependenceEntity(Title = "Сотрудники", Order = 1, ParentPropertyName = "EmployeePostId", - ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerEmployeePostList, DepartmentWindowsDesktop")] - public class EmployeePostViewModel : ElementViewModel - { - [ViewModelControlListProperty("Название должности")] - [ViewModelControlElementProperty("Название должности", ControlType.ControlString, MustHaveValue = true)] - [MapConfiguration("EmployeePostName")] - public string EmployeePostName { get; set; } + /// + /// Связь сотрудника и должности + /// + [ViewModelControlElementClass()] + public class EmployeePostViewModel : ElementViewModel + { + [ViewModelControlElementProperty("Сотрудник", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeeList, DepartmentWindowsDesktop")] + [MapConfiguration("EmployeeId", AllowCopyWithoutRigth = false)] + public Guid EmployeeId { get; set; } - [ViewModelControlListProperty("Порядок", ColumnWidth = 100)] - [ViewModelControlElementProperty("Порядок", ControlType.ControlInt, MustHaveValue = true)] - [MapConfiguration("Order")] - public int Order { get; set; } + [ViewModelControlListProperty("Сотрудник")] + [MapConfiguration("Employee.LastName", IsDifficle = true)] + public string EmployeeName { get; set; } - public override string ToString() => EmployeePostName; - } + [ViewModelControlElementProperty("Должность", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlPostList, DepartmentWindowsDesktop")] + [MapConfiguration("PostId")] + public Guid PostId { get; set; } + + [ViewModelControlListProperty("Должность")] + [MapConfiguration("Post.PostName", IsDifficle = true)] + public string PostName { get; set; } + + [ViewModelControlListProperty("Ставка", ColumnWidth = 80, DefaultCellStyleFormat = "N1")] + [ViewModelControlElementProperty("Ставка", ControlType.ControlDecimal, DecimalPlaces = 1, MustHaveValue = true)] + [MapConfiguration("Rate")] + public decimal Rate { get; set; } + + [ViewModelControlElementProperty("Внутр. совм.", ControlType.ControlBool, MustHaveValue = true)] + [MapConfiguration("IsInternalCombination")] + public bool IsInternalCombination { get; set; } + + [ViewModelControlListProperty("Внутр. совм.", ColumnWidth = 80)] + public string InternalCombination => IsInternalCombination ? "Да" : "Нет"; + + [ViewModelControlElementProperty("Внеш. совм.", ControlType.ControlBool, MustHaveValue = true)] + [MapConfiguration("IsExternalCombination")] + public bool IsExternalCombination { get; set; } + + [ViewModelControlListProperty("Внеш. совм.", ColumnWidth = 80)] + public string ExternalCombination => IsExternalCombination ? "Да" : "Нет"; + + public override string ToString() => $"{EmployeeName}-{PostName}"; + } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs index 01b5611..d69b1b7 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs @@ -16,7 +16,7 @@ namespace DepartmentBusinessLogic.ViewModels /// [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 700)] [ViewModelControlElementDependenceEntity(Title = "Должности", Order = 1, ParentPropertyName = "EmployeeId", - ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeeEmployeePostList, DepartmentWindowsDesktop")] + ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeePostList, DepartmentWindowsDesktop")] [ViewModelControlElementDependenceEntity(Title = "Аудитории", Order = 1, ParentPropertyName = "EmployeeId", ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlClassroomList, DepartmentWindowsDesktop")] public class EmployeeViewModel : ElementViewModel diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/LecturerEmployeePostViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/LecturerEmployeePostViewModels.cs index af03dcc..c9d3eb6 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/LecturerEmployeePostViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/LecturerEmployeePostViewModels.cs @@ -8,13 +8,13 @@ namespace DepartmentBusinessLogic.ViewModels /// /// Список связей преподавателей и должностей /// - public class LecturerEmployeePostListViewModel : ListViewModel { } + public class LecturerPostListViewModel : ListViewModel { } /// /// Связь преподавателя и должности /// [ViewModelControlElementClass()] - public class LecturerEmployeePostViewModel : ElementViewModel + public class LecturerPostViewModel : ElementViewModel { [ViewModelControlElementProperty("Сотрудник", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerList, DepartmentWindowsDesktop")] [MapConfiguration("LecturerId", AllowCopyWithoutRigth = false)] @@ -24,13 +24,13 @@ namespace DepartmentBusinessLogic.ViewModels [MapConfiguration("Lecturer.LastName", IsDifficle = true)] public string LecturerName { get; set; } - [ViewModelControlElementProperty("Должность", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeePostList, DepartmentWindowsDesktop")] - [MapConfiguration("EmployeePostId")] - public Guid EmployeePostId { get; set; } + [ViewModelControlElementProperty("Должность", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlPostList, DepartmentWindowsDesktop")] + [MapConfiguration("PostId")] + public Guid PostId { get; set; } [ViewModelControlListProperty("Должность")] - [MapConfiguration("EmployeePost.EmployeePostName", IsDifficle = true)] - public string EmployeePostName { get; set; } + [MapConfiguration("Post.PostName", IsDifficle = true)] + public string PostName { get; set; } [ViewModelControlListProperty("Ставка", ColumnWidth = 80, DefaultCellStyleFormat = "N1")] [ViewModelControlElementProperty("Ставка", ControlType.ControlDecimal, DecimalPlaces = 1, MustHaveValue = true)] @@ -51,6 +51,6 @@ namespace DepartmentBusinessLogic.ViewModels [ViewModelControlListProperty("Внеш. совм.", ColumnWidth = 80)] public string ExternalCombination => IsExternalCombination ? "Да" : "Нет"; - public override string ToString() => $"{LecturerName}-{EmployeePostName}"; + public override string ToString() => $"{LecturerName}-{PostName}"; } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/LecturerViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/LecturerViewModels.cs index 673d626..d45b4f3 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/LecturerViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/LecturerViewModels.cs @@ -16,26 +16,13 @@ namespace DepartmentBusinessLogic.ViewModels /// [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 700)] [ViewModelControlElementDependenceEntity(Title = "Должности", Order = 1, ParentPropertyName = "LecturerId", - ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerEmployeePostList, DepartmentWindowsDesktop")] + ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerPostList, DepartmentWindowsDesktop")] public class LecturerViewModel : ElementViewModel { [ViewModelControlElementProperty("Пользователь", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlUserList, SecurityWindowsDesktop")] [MapConfiguration("UserId")] public Guid UserId { get; set; } - [ViewModelControlElementProperty("Должность", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerPostList, DepartmentWindowsDesktop")] - [MapConfiguration("LecturerPostId")] - public Guid LecturerPostId { get; set; } - - [ViewModelControlListProperty("Должность")] - [MapConfiguration("LecturerPost.LecturerPostName", IsDifficle = true)] - public string EmployeePostName { get; set; } - - [ViewModelControlListProperty("Ставка")] - [ViewModelControlElementProperty("Ставка", ControlType.ControlDecimal, MustHaveValue = true)] - [MapConfiguration("LecturerPostRate")] - public decimal LecturerPostRate { get; set; } - [ViewModelControlElementProperty("Уч. степень", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerAcademicDegreeList, DepartmentWindowsDesktop")] [MapConfiguration("LecturerAcademicDegreeId")] public Guid? LecturerAcademicDegreeId { get; set; } @@ -108,6 +95,11 @@ namespace DepartmentBusinessLogic.ViewModels [MapConfiguration("OnlyForPrivate")] public bool OnlyForPrivate { get; set; } + [ViewModelControlListProperty("Гр. эл.без.", ColumnWidth = 90)] + [ViewModelControlElementProperty("Группа эл.безоп", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("GroupElectricalSafety")] + public string GroupElectricalSafety { get; set; } + public override string ToString() => $"{LastName}{(FirstName.IsNotEmpty() ? $" {FirstName[0]}." : string.Empty)}{(Patronymic.IsNotEmpty() ? $"{Patronymic[0]}." : string.Empty)}"; } diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/LecturerPostViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/PostViewModels.cs similarity index 55% rename from DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/LecturerPostViewModels.cs rename to DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/PostViewModels.cs index 3578cc7..acf908a 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/LecturerPostViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/PostViewModels.cs @@ -5,33 +5,37 @@ using ModuleTools.ViewModels; namespace DepartmentBusinessLogic.ViewModels { /// - /// Список должностей преподавателей + /// Список должностей /// - public class LecturerPostListViewModel : ListViewModel { } + public class PostListViewModel : ListViewModel { } /// - /// Элемент должности преподавателей + /// Элемент должности /// [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)] - [ViewModelControlElementDependenceEntity(Title = "Преподаватели", Order = 1, ParentPropertyName = "LecturerPostId", - ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerList, DepartmentWindowsDesktop")] - public class LecturerPostViewModel : ElementViewModel + [ViewModelControlElementDependenceEntity(Title = "Сотрудники", Order = 1, ParentPropertyName = "PostId", + ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeePostList, DepartmentWindowsDesktop")] + [ViewModelControlElementDependenceEntity(Title = "Преподаватели", Order = 1, ParentPropertyName = "PostId", + ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerPostList, DepartmentWindowsDesktop")] + public class PostViewModel : ElementViewModel { [ViewModelControlListProperty("Название должности")] [ViewModelControlElementProperty("Название должности", ControlType.ControlString, MustHaveValue = true)] - [MapConfiguration("LecturerPostName")] - public string LecturerPostName { get; set; } + [MapConfiguration("PostName")] + public string PostName { get; set; } + + [ViewModelControlElementProperty("Часы", ControlType.ControlInt, MustHaveValue = false)] + [MapConfiguration("Hours")] + public int? Hours { get; set; } [ViewModelControlListProperty("Часы", ColumnWidth = 100)] - [ViewModelControlElementProperty("Часы", ControlType.ControlInt, MustHaveValue = true)] - [MapConfiguration("Hours")] - public int Hours { get; set; } + public string HoursStr => Hours.HasValue ? Hours.ToString() : string.Empty; [ViewModelControlListProperty("Порядок", ColumnWidth = 100)] [ViewModelControlElementProperty("Порядок", ControlType.ControlInt, MustHaveValue = true)] [MapConfiguration("Order")] public int Order { get; set; } - public override string ToString() => LecturerPostName; + public override string ToString() => PostName; } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs index 10a269b..3d044e2 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs @@ -9,9 +9,9 @@ namespace DepartmentDatabaseImplementation { public void RegisterServices() { - DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); @@ -20,7 +20,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/ClassroomService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/ClassroomService.cs index eb3adb1..76e27e8 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/ClassroomService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/ClassroomService.cs @@ -5,10 +5,7 @@ using DepartmentBusinessLogic.Enums; using DepartmentBusinessLogic.Interfaces; using DepartmentBusinessLogic.ViewModels; using Microsoft.EntityFrameworkCore; -using ModuleTools.BusinessLogics; -using ModuleTools.Enums; using ModuleTools.Models; -using System; using System.Linq; namespace DepartmentDatabaseImplementation.Implementations @@ -16,74 +13,16 @@ namespace DepartmentDatabaseImplementation.Implementations /// /// Реализация интерфейса IClassroomService /// - public class ClassroomService : IClassroomService + public class ClassroomService : + AbstractGenerticEntityService, + IClassroomService { - public OperationResultModel Create(ClassroomSetBindingModel model) + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, ClassroomSetBindingModel model) => OperationResultModel.Success(null); + + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, Classroom entity, ClassroomGetBindingModel model) => OperationResultModel.Success(null); + + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, ClassroomGetBindingModel model) { - using var context = DatabaseManager.GetContext; - - var exsistEntity = context.Classrooms.FirstOrDefault(x => x.Number == model.Number); - if (exsistEntity == null) - { - var entity = Mapper.MapToClass(model, true); - context.Classrooms.Add(entity); - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } - else - { - if (exsistEntity.IsDeleted) - { - exsistEntity = Mapper.MapToClass(model, exsistEntity, true); - exsistEntity.IsDeleted = false; - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); - } - else - { - return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); - } - } - } - - public OperationResultModel Delete(ClassroomGetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var entity = context.Classrooms.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity.IsDeleted = true; - entity.DateDelete = DateTime.Now; - - context.SaveChanges(); - - return OperationResultModel.Success(true); - } - - public OperationResultModel Read(ClassroomGetBindingModel model) - { - int countPages = 0; - using var context = DatabaseManager.GetContext; - - // для одной записи - if (model.Id.HasValue) - { - var entity = context.Classrooms.FirstOrDefault(x => x.Id == model.Id.Value); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); - } - - var query = context.Classrooms.Where(x => !x.IsDeleted).AsQueryable(); if (model.UseInSchedule.HasValue) { query = query.Where(x => x.ClassroomType == (int)ClassroomType.Дисплейный || x.ClassroomType == (int)ClassroomType.Лекционный || @@ -93,46 +32,17 @@ namespace DepartmentDatabaseImplementation.Implementations { query = query.Where(x => x.EmployeeId == model.EmployeeId.Value); } - - query = query.OrderBy(x => x.Number); - - if (model.PageNumber.HasValue && model.PageSize.HasValue) - { - countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); - query = query - .Skip(model.PageSize.Value * model.PageNumber.Value) - .Take(model.PageSize.Value); - } - - query = query.Include(x => x.Employee); - - var result = new ClassroomListViewModel - { - MaxCount = countPages, - List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() - }; - - return OperationResultModel.Success(result); + return query; } - public OperationResultModel Update(ClassroomSetBindingModel model) - { - using var context = DatabaseManager.GetContext; + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, ClassroomSetBindingModel model) => OperationResultModel.Success(null); - var entity = context.Classrooms.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity = Mapper.MapToClass(model, entity, true); + protected override void AdditionalDeleting(DbContext context, Classroom entity, ClassroomGetBindingModel model) { } - context.SaveChanges(); + protected override Classroom GetUniqueEntity(ClassroomSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.Number == model.Number && x.Id != model.Id); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } + protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.Employee); + + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.Number); } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineBlockService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineBlockService.cs index 7dc9a54..620e46a 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineBlockService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineBlockService.cs @@ -3,10 +3,9 @@ using DatabaseCore.Models.Department; using DepartmentBusinessLogic.BindingModels; using DepartmentBusinessLogic.Interfaces; using DepartmentBusinessLogic.ViewModels; -using ModuleTools.BusinessLogics; +using Microsoft.EntityFrameworkCore; using ModuleTools.Enums; using ModuleTools.Models; -using System; using System.Linq; namespace DepartmentDatabaseImplementation.Implementations @@ -14,115 +13,31 @@ namespace DepartmentDatabaseImplementation.Implementations /// /// Реализация IDisciplineBlockService /// - public class DisciplineBlockService : IDisciplineBlockService + public class DisciplineBlockService : + AbstractGenerticEntityService, + IDisciplineBlockService { - public OperationResultModel Create(DisciplineBlockSetBindingModel model) - { - using var context = DatabaseManager.GetContext; + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, DisciplineBlockSetBindingModel model) => OperationResultModel.Success(null); - var exsistEntity = context.DisciplineBlocks.FirstOrDefault(x => x.Title == model.Title); - if (exsistEntity == null) - { - var entity = Mapper.MapToClass(model, true); - context.DisciplineBlocks.Add(entity); - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } - else - { - if (exsistEntity.IsDeleted) - { - exsistEntity = Mapper.MapToClass(model, exsistEntity, true); - exsistEntity.IsDeleted = false; - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); - } - else - { - return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); - } - } - } - - public OperationResultModel Delete(DisciplineBlockGetBindingModel model) + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, DisciplineBlock entity, DisciplineBlockGetBindingModel model) { - using var context = DatabaseManager.GetContext; - var entity = context.DisciplineBlocks.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - if (context.Disciplines.Any(x => x.DisciplineBlockId == model.Id && !x.IsDeleted)) + if (context.Set().Any(x => x.DisciplineBlockId == model.Id && !x.IsDeleted)) { return OperationResultModel.Error("Error:", "Есть дисциплины, относящиеся к этому блоку", ResultServiceStatusCode.ExsistItem); } - entity.IsDeleted = true; - entity.DateDelete = DateTime.Now; - - context.SaveChanges(); - - return OperationResultModel.Success(true); + return OperationResultModel.Success(null); } - public OperationResultModel Read(DisciplineBlockGetBindingModel model) - { - int countPages = 0; - using var context = DatabaseManager.GetContext; + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, DisciplineBlockGetBindingModel model) => query; - // для одной записи - if (model.Id.HasValue) - { - var entity = context.DisciplineBlocks.FirstOrDefault(x => x.Id == model.Id.Value); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); - } + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, DisciplineBlockSetBindingModel model) => OperationResultModel.Success(null); - var query = context.DisciplineBlocks.Where(x => !x.IsDeleted).AsQueryable(); + protected override void AdditionalDeleting(DbContext context, DisciplineBlock entity, DisciplineBlockGetBindingModel model) { } - query = query.OrderBy(x => x.DisciplineBlockOrder); + protected override DisciplineBlock GetUniqueEntity(DisciplineBlockSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.Title == model.Title && x.Id != model.Id); - if (model.PageNumber.HasValue && model.PageSize.HasValue) - { - countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); - query = query - .Skip(model.PageSize.Value * model.PageNumber.Value) - .Take(model.PageSize.Value); - } + protected override IQueryable IncludingWhenReading(IQueryable query) => query; - var result = new DisciplineBlockListViewModel - { - MaxCount = countPages, - List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() - }; - - return OperationResultModel.Success(result); - } - - public OperationResultModel Update(DisciplineBlockSetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var entity = context.DisciplineBlocks.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity = Mapper.MapToClass(model, entity, true); - - context.SaveChanges(); - - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.DisciplineBlockOrder); } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineService.cs index 47fedcf..1269465 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/DisciplineService.cs @@ -4,11 +4,8 @@ using DepartmentBusinessLogic.BindingModels; using DepartmentBusinessLogic.Interfaces; using DepartmentBusinessLogic.ViewModels; using Microsoft.EntityFrameworkCore; -using ModuleTools.BusinessLogics; -using ModuleTools.Enums; using ModuleTools.Extensions; using ModuleTools.Models; -using System; using System.Linq; namespace DepartmentDatabaseImplementation.Implementations @@ -16,74 +13,16 @@ namespace DepartmentDatabaseImplementation.Implementations /// /// Реализация IDisciplineService /// - public class DisciplineService : IDisciplineService + public class DisciplineService : + AbstractGenerticEntityService, + IDisciplineService { - public OperationResultModel Create(DisciplineSetBindingModel model) + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, DisciplineSetBindingModel model) => OperationResultModel.Success(null); + + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, Discipline entity, DisciplineGetBindingModel model) => OperationResultModel.Success(null); + + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, DisciplineGetBindingModel model) { - using var context = DatabaseManager.GetContext; - - var exsistEntity = context.Disciplines.FirstOrDefault(x => x.DisciplineName == model.DisciplineName); - if (exsistEntity == null) - { - var entity = Mapper.MapToClass(model, true); - context.Disciplines.Add(entity); - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } - else - { - if (exsistEntity.IsDeleted) - { - exsistEntity = Mapper.MapToClass(model, exsistEntity, true); - exsistEntity.IsDeleted = false; - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); - } - else - { - return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); - } - } - } - - public OperationResultModel Delete(DisciplineGetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var entity = context.Disciplines.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity.IsDeleted = true; - entity.DateDelete = DateTime.Now; - - context.SaveChanges(); - - return OperationResultModel.Success(true); - } - - public OperationResultModel Read(DisciplineGetBindingModel model) - { - int countPages = 0; - using var context = DatabaseManager.GetContext; - - // для одной записи - if (model.Id.HasValue) - { - var entity = context.Disciplines.FirstOrDefault(x => x.Id == model.Id.Value); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); - } - - var query = context.Disciplines.Where(x => !x.IsDeleted).AsQueryable(); if (model.DisciplineName.IsNotEmpty()) { query = query.Where(x => x.DisciplineName.Contains(model.DisciplineName)); @@ -92,46 +31,17 @@ namespace DepartmentDatabaseImplementation.Implementations { query = query.Where(x => x.DisciplineBlockId == model.DisciplineBlockId.Value); } - - query = query.OrderBy(x => x.DisciplineBlock.DisciplineBlockOrder).ThenBy(x => x.DisciplineName); - - if (model.PageNumber.HasValue && model.PageSize.HasValue) - { - countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); - query = query - .Skip(model.PageSize.Value * model.PageNumber.Value) - .Take(model.PageSize.Value); - } - - query = query.Include(x => x.DisciplineBlock); - - var result = new DisciplineListViewModel - { - MaxCount = countPages, - List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() - }; - - return OperationResultModel.Success(result); + return query; } - public OperationResultModel Update(DisciplineSetBindingModel model) - { - using var context = DatabaseManager.GetContext; + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, DisciplineSetBindingModel model) => OperationResultModel.Success(null); - var entity = context.Disciplines.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity = Mapper.MapToClass(model, entity, true); + protected override void AdditionalDeleting(DbContext context, Discipline entity, DisciplineGetBindingModel model) { } - context.SaveChanges(); + protected override Discipline GetUniqueEntity(DisciplineSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.DisciplineName == model.DisciplineName && x.Id != model.Id); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } + protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.DisciplineBlock); + + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.DisciplineBlock.DisciplineBlockOrder).ThenBy(x => x.DisciplineName); } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EmployeeEmployeePostService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EmployeeEmployeePostService.cs deleted file mode 100644 index 6f37d23..0000000 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EmployeeEmployeePostService.cs +++ /dev/null @@ -1,136 +0,0 @@ -using DatabaseCore; -using DatabaseCore.Models.Department; -using DepartmentBusinessLogic.BindingModels; -using DepartmentBusinessLogic.Interfaces; -using DepartmentBusinessLogic.ViewModels; -using Microsoft.EntityFrameworkCore; -using ModuleTools.BusinessLogics; -using ModuleTools.Enums; -using ModuleTools.Models; -using System; -using System.Linq; - -namespace DepartmentDatabaseImplementation.Implementations -{ - /// - /// Реализация IEmployeeEmployeePostService - /// - public class EmployeeEmployeePostService : IEmployeeEmployeePostService - { - public OperationResultModel Create(EmployeeEmployeePostSetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var exsistEntity = context.EmployeeEmployeePosts.FirstOrDefault(x => x.EmployeeId == model.EmployeeId && x.EmployeePostId == model.EmployeePostId); - if (exsistEntity == null) - { - var entity = Mapper.MapToClass(model, true); - context.EmployeeEmployeePosts.Add(entity); - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } - else - { - if (exsistEntity.IsDeleted) - { - exsistEntity = Mapper.MapToClass(model, exsistEntity, true); - exsistEntity.IsDeleted = false; - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); - } - else - { - return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); - } - } - } - - public OperationResultModel Delete(EmployeeEmployeePostGetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var entity = context.EmployeeEmployeePosts.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity.IsDeleted = true; - entity.DateDelete = DateTime.Now; - - context.SaveChanges(); - - return OperationResultModel.Success(true); - } - - public OperationResultModel Read(EmployeeEmployeePostGetBindingModel model) - { - int countPages = 0; - using var context = DatabaseManager.GetContext; - - // для одной записи - if (model.Id.HasValue) - { - var entity = context.EmployeeEmployeePosts.FirstOrDefault(x => x.Id == model.Id.Value); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); - } - - var query = context.EmployeeEmployeePosts.Where(x => !x.IsDeleted).AsQueryable(); - if (model.EmployeePostId.HasValue) - { - query = query.Where(x => x.EmployeePostId == model.EmployeePostId); - } - if (model.EmployeeId.HasValue) - { - query = query.Where(x => x.EmployeeId == model.EmployeeId); - } - - query = query.OrderBy(x => x.Employee.LastName); - - if (model.PageNumber.HasValue && model.PageSize.HasValue) - { - countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); - query = query - .Skip(model.PageSize.Value * model.PageNumber.Value) - .Take(model.PageSize.Value); - } - - query = query.Include(x => x.EmployeePost).Include(x => x.Employee); - - var result = new EmployeeEmployeePostListViewModel - { - MaxCount = countPages, - List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() - }; - - return OperationResultModel.Success(result); - } - - public OperationResultModel Update(EmployeeEmployeePostSetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var entity = context.EmployeeEmployeePosts.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity = Mapper.MapToClass(model, entity, true); - - context.SaveChanges(); - - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } - } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EmployeePostService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EmployeePostService.cs index 2bdf769..994ebd5 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EmployeePostService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EmployeePostService.cs @@ -3,10 +3,8 @@ using DatabaseCore.Models.Department; using DepartmentBusinessLogic.BindingModels; using DepartmentBusinessLogic.Interfaces; using DepartmentBusinessLogic.ViewModels; -using ModuleTools.BusinessLogics; -using ModuleTools.Enums; +using Microsoft.EntityFrameworkCore; using ModuleTools.Models; -using System; using System.Linq; namespace DepartmentDatabaseImplementation.Implementations @@ -14,119 +12,35 @@ namespace DepartmentDatabaseImplementation.Implementations /// /// Реализация IEmployeePostService /// - public class EmployeePostService : IEmployeePostService + public class EmployeePostService : + AbstractGenerticEntityService, + IEmployeePostService { - public OperationResultModel Create(EmployeePostSetBindingModel model) - { - using var context = DatabaseManager.GetContext; + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, EmployeePostSetBindingModel model) => OperationResultModel.Success(null); - var exsistEntity = context.EmployeePosts.FirstOrDefault(x => x.EmployeePostName == model.EmployeePostName); - if (exsistEntity == null) + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, EmployeePost entity, EmployeePostGetBindingModel model) => OperationResultModel.Success(null); + + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, EmployeePostGetBindingModel model) + { + if (model.PostId.HasValue) { - var entity = Mapper.MapToClass(model, true); - context.EmployeePosts.Add(entity); - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + query = query.Where(x => x.PostId == model.PostId); } - else + if (model.EmployeeId.HasValue) { - if (exsistEntity.IsDeleted) - { - exsistEntity = Mapper.MapToClass(model, exsistEntity, true); - exsistEntity.IsDeleted = false; - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); - } - else - { - return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); - } + query = query.Where(x => x.EmployeeId == model.EmployeeId); } + return query; } - public OperationResultModel Delete(EmployeePostGetBindingModel model) - { - using var context = DatabaseManager.GetContext; - var entity = context.EmployeePosts.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - if (context.EmployeeEmployeePosts.Any(x => x.EmployeePostId == model.Id && !x.IsDeleted)) - { - return OperationResultModel.Error("Error:", "Существуют сотрудники с этой должностью", ResultServiceStatusCode.ExsistItem); - } - if (context.LecturerEmployeePosts.Any(x => x.EmployeePostId == model.Id && !x.IsDeleted)) - { - return OperationResultModel.Error("Error:", "Существуют преподаватели с этой должностью", ResultServiceStatusCode.ExsistItem); - } - entity.IsDeleted = true; - entity.DateDelete = DateTime.Now; + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, EmployeePostSetBindingModel model) => OperationResultModel.Success(null); - context.SaveChanges(); + protected override void AdditionalDeleting(DbContext context, EmployeePost entity, EmployeePostGetBindingModel model) { } - return OperationResultModel.Success(true); - } + protected override EmployeePost GetUniqueEntity(EmployeePostSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.EmployeeId == model.EmployeeId && x.PostId == model.PostId && x.Id != model.Id); - public OperationResultModel Read(EmployeePostGetBindingModel model) - { - int countPages = 0; - using var context = DatabaseManager.GetContext; + protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.Post).Include(x => x.Employee); - // для одной записи - if (model.Id.HasValue) - { - var entity = context.EmployeePosts.FirstOrDefault(x => x.Id == model.Id.Value); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); - } - - var query = context.EmployeePosts.Where(x => !x.IsDeleted).AsQueryable(); - - query = query.OrderBy(x => x.Order); - - if (model.PageNumber.HasValue && model.PageSize.HasValue) - { - countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); - query = query - .Skip(model.PageSize.Value * model.PageNumber.Value) - .Take(model.PageSize.Value); - } - - var result = new EmployeePostListViewModel - { - MaxCount = countPages, - List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() - }; - - return OperationResultModel.Success(result); - } - - public OperationResultModel Update(EmployeePostSetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var entity = context.EmployeePosts.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity = Mapper.MapToClass(model, entity, true); - - context.SaveChanges(); - - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.Employee.LastName); } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EmployeeService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EmployeeService.cs index e149983..207a2be 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EmployeeService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/EmployeeService.cs @@ -4,7 +4,6 @@ using DepartmentBusinessLogic.BindingModels; using DepartmentBusinessLogic.Interfaces; using DepartmentBusinessLogic.ViewModels; using Microsoft.EntityFrameworkCore; -using ModuleTools.BusinessLogics; using ModuleTools.Enums; using ModuleTools.Models; using System; @@ -15,146 +14,61 @@ namespace DepartmentDatabaseImplementation.Implementations /// /// Реализация IEmployeeService /// - public class EmployeeService : IEmployeeService + public class EmployeeService : + AbstractGenerticEntityService, + IEmployeeService { - public OperationResultModel Create(EmployeeSetBindingModel model) - { - using var context = DatabaseManager.GetContext; + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, EmployeeSetBindingModel model) => OperationResultModel.Success(null); - var exsistEntity = context.Employees.FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName && - x.Patronymic == model.Patronymic); - if (exsistEntity == null) + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, Employee entity, EmployeeGetBindingModel model) + { + if (entity.User == null) { - var entity = Mapper.MapToClass(model, true); - context.Employees.Add(entity); - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + return OperationResultModel.Error("Error:", "Не найден пользователь от сотрудника", ResultServiceStatusCode.NotFound); } - else + if (context.Set().Any(x => x.EmployeeId == model.Id && !x.IsDeleted)) { - if (exsistEntity.IsDeleted) - { - exsistEntity = Mapper.MapToClass(model, exsistEntity, true); - exsistEntity.IsDeleted = false; - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); - } - else - { - return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); - } + return OperationResultModel.Error("Error:", "Есть аудитории, у которых этот сотрудник указан ответственным", ResultServiceStatusCode.ExsistItem); } + return OperationResultModel.Success(null); } - public OperationResultModel Delete(EmployeeGetBindingModel model) + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, EmployeeGetBindingModel model) { - using var context = DatabaseManager.GetContext; - using var transaction = context.Database.BeginTransaction(); - try - { - var entity = context.Employees.Include(x => x.User).FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - else if (entity.User == null) - { - return OperationResultModel.Error("Error:", "Не найден пользователь от сотрудника", ResultServiceStatusCode.NotFound); - } - if (context.Classrooms.Any(x => x.EmployeeId == model.Id && !x.IsDeleted)) - { - return OperationResultModel.Error("Error:", "Есть аудитории, у которых этот сотрудник указан ответственным", ResultServiceStatusCode.ExsistItem); - } - entity.IsDeleted = true; - entity.DateDelete = DateTime.Now; - entity.User.IsDeleted = true; - entity.User.DateDelete = DateTime.Now; - - context.SaveChanges(); - - var links = context.EmployeeEmployeePosts.Where(x => x.EmployeeId == model.Id); - foreach (var link in links) - { - link.IsDeleted = true; - link.DateDelete = DateTime.Now; - } - context.SaveChanges(); - - - transaction.Commit(); - } - catch (Exception) - { - transaction.Rollback(); - throw; - } - - return OperationResultModel.Success(true); - } - - public OperationResultModel Read(EmployeeGetBindingModel model) - { - int countPages = 0; - using var context = DatabaseManager.GetContext; - - // для одной записи - if (model.Id.HasValue) - { - var entity = context.Employees.FirstOrDefault(x => x.Id == model.Id.Value); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); - } - - var query = context.Employees.Where(x => !x.IsDeleted).AsQueryable(); if (model.UserId.HasValue) { query = query.Where(x => x.UserId == model.UserId); } - - query = query.OrderBy(x => x.LastName); - - if (model.PageNumber.HasValue && model.PageSize.HasValue) - { - countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); - query = query - .Skip(model.PageSize.Value * model.PageNumber.Value) - .Take(model.PageSize.Value); - } - - var result = new EmployeeListViewModel - { - MaxCount = countPages, - List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() - }; - - return OperationResultModel.Success(result); + return query; } - public OperationResultModel Update(EmployeeSetBindingModel model) - { - using var context = DatabaseManager.GetContext; + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, EmployeeSetBindingModel model) => OperationResultModel.Success(null); - var entity = context.Employees.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity = Mapper.MapToClass(model, entity, true); + protected override void AdditionalDeleting(DbContext context, Employee entity, EmployeeGetBindingModel model) + { + entity.User.IsDeleted = true; + entity.User.DateDelete = DateTime.Now; context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + var links = context.Set().Where(x => x.EmployeeId == model.Id); + foreach (var link in links) + { + link.IsDeleted = true; + link.DateDelete = DateTime.Now; + } + context.SaveChanges(); } + + protected override Employee GetUniqueEntity(EmployeeSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName && + x.Patronymic == model.Patronymic && x.Id != model.Id); + + protected override IQueryable IncludingWhenReading(IQueryable query) => query + .Include(x => x.EmployeePosts).Include("EmployeePosts.Post"); + + protected override IQueryable OrderingWhenReading(IQueryable query) => query + .OrderByDescending(x => x.EmployeePosts.Max(y => y.Post.Order)) + .ThenBy(x => x.LastName) + .ThenBy(x => x.FirstName); } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerAcademicDegreeService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerAcademicDegreeService.cs index ba657ec..fa1dd00 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerAcademicDegreeService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerAcademicDegreeService.cs @@ -3,10 +3,9 @@ using DatabaseCore.Models.Department; using DepartmentBusinessLogic.BindingModels; using DepartmentBusinessLogic.Interfaces; using DepartmentBusinessLogic.ViewModels; -using ModuleTools.BusinessLogics; +using Microsoft.EntityFrameworkCore; using ModuleTools.Enums; using ModuleTools.Models; -using System; using System.Linq; namespace DepartmentDatabaseImplementation.Implementations @@ -14,115 +13,31 @@ namespace DepartmentDatabaseImplementation.Implementations /// /// Реализация ILecturerAcademicDegreeService /// - public class LecturerAcademicDegreeService : ILecturerAcademicDegreeService + public class LecturerAcademicDegreeService : + AbstractGenerticEntityService, + ILecturerAcademicDegreeService { - public OperationResultModel Create(LecturerAcademicDegreeSetBindingModel model) - { - using var context = DatabaseManager.GetContext; + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, LecturerAcademicDegreeSetBindingModel model) => OperationResultModel.Success(null); - var exsistEntity = context.LecturerAcademicDegrees.FirstOrDefault(x => x.LecturerAcademicDegreeName == model.LecturerAcademicDegreeName); - if (exsistEntity == null) - { - var entity = Mapper.MapToClass(model, true); - context.LecturerAcademicDegrees.Add(entity); - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } - else - { - if (exsistEntity.IsDeleted) - { - exsistEntity = Mapper.MapToClass(model, exsistEntity, true); - exsistEntity.IsDeleted = false; - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); - } - else - { - return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); - } - } - } - - public OperationResultModel Delete(LecturerAcademicDegreeGetBindingModel model) + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, LecturerAcademicDegree entity, LecturerAcademicDegreeGetBindingModel model) { - using var context = DatabaseManager.GetContext; - var entity = context.LecturerAcademicDegrees.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - if (context.Lecturers.Any(x => x.LecturerAcademicDegreeId == model.Id && !x.IsDeleted)) + if (context.Set().Any(x => x.LecturerAcademicDegreeId == model.Id && !x.IsDeleted)) { return OperationResultModel.Error("Error:", "Имеются сотрудники, использующую эту запись", ResultServiceStatusCode.ExsistItem); } - entity.IsDeleted = true; - entity.DateDelete = DateTime.Now; - - context.SaveChanges(); - - return OperationResultModel.Success(true); + return OperationResultModel.Success(null); } - public OperationResultModel Read(LecturerAcademicDegreeGetBindingModel model) - { - int countPages = 0; - using var context = DatabaseManager.GetContext; + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, LecturerAcademicDegreeGetBindingModel model) => query; - // для одной записи - if (model.Id.HasValue) - { - var entity = context.LecturerAcademicDegrees.FirstOrDefault(x => x.Id == model.Id.Value); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); - } + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, LecturerAcademicDegreeSetBindingModel model) => OperationResultModel.Success(null); - var query = context.LecturerAcademicDegrees.Where(x => !x.IsDeleted).AsQueryable(); + protected override void AdditionalDeleting(DbContext context, LecturerAcademicDegree entity, LecturerAcademicDegreeGetBindingModel model) { } - query = query.OrderBy(x => x.Order); + protected override LecturerAcademicDegree GetUniqueEntity(LecturerAcademicDegreeSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.LecturerAcademicDegreeName == model.LecturerAcademicDegreeName && x.Id != model.Id); - if (model.PageNumber.HasValue && model.PageSize.HasValue) - { - countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); - query = query - .Skip(model.PageSize.Value * model.PageNumber.Value) - .Take(model.PageSize.Value); - } + protected override IQueryable IncludingWhenReading(IQueryable query) => query; - var result = new LecturerAcademicDegreeListViewModel - { - MaxCount = countPages, - List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() - }; - - return OperationResultModel.Success(result); - } - - public OperationResultModel Update(LecturerAcademicDegreeSetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var entity = context.LecturerAcademicDegrees.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity = Mapper.MapToClass(model, entity, true); - - context.SaveChanges(); - - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.Order); } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerAcademicRankService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerAcademicRankService.cs index 69cafe8..6a49bf8 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerAcademicRankService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerAcademicRankService.cs @@ -3,10 +3,9 @@ using DatabaseCore.Models.Department; using DepartmentBusinessLogic.BindingModels; using DepartmentBusinessLogic.Interfaces; using DepartmentBusinessLogic.ViewModels; -using ModuleTools.BusinessLogics; +using Microsoft.EntityFrameworkCore; using ModuleTools.Enums; using ModuleTools.Models; -using System; using System.Linq; namespace DepartmentDatabaseImplementation.Implementations @@ -14,115 +13,31 @@ namespace DepartmentDatabaseImplementation.Implementations /// /// Реализация ILecturerAcademicRankService /// - public class LecturerAcademicRankService : ILecturerAcademicRankService + public class LecturerAcademicRankService : + AbstractGenerticEntityService, + ILecturerAcademicRankService { - public OperationResultModel Create(LecturerAcademicRankSetBindingModel model) - { - using var context = DatabaseManager.GetContext; + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, LecturerAcademicRankSetBindingModel model) => OperationResultModel.Success(null); - var exsistEntity = context.LecturerAcademicRanks.FirstOrDefault(x => x.LecturerAcademicRankName == model.LecturerAcademicRankName); - if (exsistEntity == null) - { - var entity = Mapper.MapToClass(model, true); - context.LecturerAcademicRanks.Add(entity); - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } - else - { - if (exsistEntity.IsDeleted) - { - exsistEntity = Mapper.MapToClass(model, exsistEntity, true); - exsistEntity.IsDeleted = false; - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); - } - else - { - return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); - } - } - } - - public OperationResultModel Delete(LecturerAcademicRankGetBindingModel model) + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, LecturerAcademicRank entity, LecturerAcademicRankGetBindingModel model) { - using var context = DatabaseManager.GetContext; - var entity = context.LecturerAcademicRanks.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - if (context.Lecturers.Any(x => x.LecturerAcademicRankId == model.Id && !x.IsDeleted)) + if (context.Set().Any(x => x.LecturerAcademicRankId == model.Id && !x.IsDeleted)) { return OperationResultModel.Error("Error:", "Имеются сотрудники, использующую эту запись", ResultServiceStatusCode.ExsistItem); } - entity.IsDeleted = true; - entity.DateDelete = DateTime.Now; - - context.SaveChanges(); - - return OperationResultModel.Success(true); + return OperationResultModel.Success(null); } - public OperationResultModel Read(LecturerAcademicRankGetBindingModel model) - { - int countPages = 0; - using var context = DatabaseManager.GetContext; + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, LecturerAcademicRankGetBindingModel model) => query; - // для одной записи - if (model.Id.HasValue) - { - var entity = context.LecturerAcademicRanks.FirstOrDefault(x => x.Id == model.Id.Value); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); - } + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, LecturerAcademicRankSetBindingModel model) => OperationResultModel.Success(null); - var query = context.LecturerAcademicRanks.Where(x => !x.IsDeleted).AsQueryable(); + protected override void AdditionalDeleting(DbContext context, LecturerAcademicRank entity, LecturerAcademicRankGetBindingModel model) { } - query = query.OrderBy(x => x.Order); + protected override LecturerAcademicRank GetUniqueEntity(LecturerAcademicRankSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.LecturerAcademicRankName == model.LecturerAcademicRankName && x.Id != model.Id); - if (model.PageNumber.HasValue && model.PageSize.HasValue) - { - countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); - query = query - .Skip(model.PageSize.Value * model.PageNumber.Value) - .Take(model.PageSize.Value); - } + protected override IQueryable IncludingWhenReading(IQueryable query) => query; - var result = new LecturerAcademicRankListViewModel - { - MaxCount = countPages, - List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() - }; - - return OperationResultModel.Success(result); - } - - public OperationResultModel Update(LecturerAcademicRankSetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var entity = context.LecturerAcademicRanks.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity = Mapper.MapToClass(model, entity, true); - - context.SaveChanges(); - - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.Order); } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerEmployeePostService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerEmployeePostService.cs deleted file mode 100644 index e463023..0000000 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerEmployeePostService.cs +++ /dev/null @@ -1,135 +0,0 @@ -using DatabaseCore; -using DatabaseCore.Models.Department; -using DepartmentBusinessLogic.BindingModels; -using DepartmentBusinessLogic.Interfaces; -using DepartmentBusinessLogic.ViewModels; -using Microsoft.EntityFrameworkCore; -using ModuleTools.BusinessLogics; -using ModuleTools.Enums; -using ModuleTools.Models; -using System; -using System.Linq; - -namespace DepartmentDatabaseImplementation.Implementations -{ - /// - /// Реализация ILecturerEmployeePostService - /// - public class LecturerEmployeePostService : ILecturerEmployeePostService - { - public OperationResultModel Create(LecturerEmployeePostSetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var exsistEntity = context.LecturerEmployeePosts.FirstOrDefault(x => x.LecturerId == model.LecturerId && x.EmployeePostId == model.EmployeePostId); - if (exsistEntity == null) - { - var entity = Mapper.MapToClass(model, true); - context.LecturerEmployeePosts.Add(entity); - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } - else - { - if (exsistEntity.IsDeleted) - { - exsistEntity = Mapper.MapToClass(model, exsistEntity, true); - exsistEntity.IsDeleted = false; - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); - } - else - { - return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); - } - } - } - - public OperationResultModel Delete(LecturerEmployeePostGetBindingModel model) - { - using var context = DatabaseManager.GetContext; - var entity = context.LecturerEmployeePosts.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity.IsDeleted = true; - entity.DateDelete = DateTime.Now; - - context.SaveChanges(); - - return OperationResultModel.Success(true); - } - - public OperationResultModel Read(LecturerEmployeePostGetBindingModel model) - { - int countPages = 0; - using var context = DatabaseManager.GetContext; - - // для одной записи - if (model.Id.HasValue) - { - var entity = context.LecturerEmployeePosts.FirstOrDefault(x => x.Id == model.Id.Value); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); - } - - var query = context.LecturerEmployeePosts.Where(x => !x.IsDeleted).AsQueryable(); - if (model.EmployeePostId.HasValue) - { - query = query.Where(x => x.EmployeePostId == model.EmployeePostId); - } - if (model.LecturerId.HasValue) - { - query = query.Where(x => x.LecturerId == model.LecturerId); - } - - query = query.OrderBy(x => x.Lecturer.LastName); - - if (model.PageNumber.HasValue && model.PageSize.HasValue) - { - countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); - query = query - .Skip(model.PageSize.Value * model.PageNumber.Value) - .Take(model.PageSize.Value); - } - - query = query.Include(x => x.EmployeePost).Include(x => x.Lecturer); - - var result = new LecturerEmployeePostListViewModel - { - MaxCount = countPages, - List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() - }; - - return OperationResultModel.Success(result); - } - - public OperationResultModel Update(LecturerEmployeePostSetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var entity = context.LecturerEmployeePosts.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity = Mapper.MapToClass(model, entity, true); - - context.SaveChanges(); - - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } - } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerPostService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerPostService.cs index 4189b04..aee2a79 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerPostService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerPostService.cs @@ -3,10 +3,8 @@ using DatabaseCore.Models.Department; using DepartmentBusinessLogic.BindingModels; using DepartmentBusinessLogic.Interfaces; using DepartmentBusinessLogic.ViewModels; -using ModuleTools.BusinessLogics; -using ModuleTools.Enums; +using Microsoft.EntityFrameworkCore; using ModuleTools.Models; -using System; using System.Linq; namespace DepartmentDatabaseImplementation.Implementations @@ -14,115 +12,35 @@ namespace DepartmentDatabaseImplementation.Implementations /// /// Реализация ILecturerPostService /// - public class LecturerPostService : ILecturerPostService + public class LecturerPostService : + AbstractGenerticEntityService, + ILecturerPostService { - public OperationResultModel Create(LecturerPostSetBindingModel model) - { - using var context = DatabaseManager.GetContext; + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, LecturerPostSetBindingModel model) => OperationResultModel.Success(null); - var exsistEntity = context.LecturerPosts.FirstOrDefault(x => x.LecturerPostName == model.LecturerPostName); - if (exsistEntity == null) + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, LecturerPost entity, LecturerPostGetBindingModel model) => OperationResultModel.Success(null); + + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, LecturerPostGetBindingModel model) + { + if (model.PostId.HasValue) { - var entity = Mapper.MapToClass(model, true); - context.LecturerPosts.Add(entity); - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + query = query.Where(x => x.PostId == model.PostId); } - else + if (model.LecturerId.HasValue) { - if (exsistEntity.IsDeleted) - { - exsistEntity = Mapper.MapToClass(model, exsistEntity, true); - exsistEntity.IsDeleted = false; - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); - } - else - { - return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); - } + query = query.Where(x => x.LecturerId == model.LecturerId); } + return query; } - public OperationResultModel Delete(LecturerPostGetBindingModel model) - { - using var context = DatabaseManager.GetContext; - var entity = context.LecturerPosts.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - if (context.Lecturers.Any(x => x.LecturerPostId == model.Id && !x.IsDeleted)) - { - return OperationResultModel.Error("Error:", "Существуют преподаватели с этой должностью", ResultServiceStatusCode.ExsistItem); - } - entity.IsDeleted = true; - entity.DateDelete = DateTime.Now; + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, LecturerPostSetBindingModel model) => OperationResultModel.Success(null); - context.SaveChanges(); + protected override void AdditionalDeleting(DbContext context, LecturerPost entity, LecturerPostGetBindingModel model) { } - return OperationResultModel.Success(true); - } + protected override LecturerPost GetUniqueEntity(LecturerPostSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.LecturerId == model.LecturerId && x.PostId == model.PostId && x.Id != model.Id); - public OperationResultModel Read(LecturerPostGetBindingModel model) - { - int countPages = 0; - using var context = DatabaseManager.GetContext; + protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.Post).Include(x => x.Lecturer); - // для одной записи - if (model.Id.HasValue) - { - var entity = context.LecturerPosts.FirstOrDefault(x => x.Id == model.Id.Value); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); - } - - var query = context.LecturerPosts.Where(x => !x.IsDeleted).AsQueryable(); - - query = query.OrderBy(x => x.Order); - - if (model.PageNumber.HasValue && model.PageSize.HasValue) - { - countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); - query = query - .Skip(model.PageSize.Value * model.PageNumber.Value) - .Take(model.PageSize.Value); - } - - var result = new LecturerPostListViewModel - { - MaxCount = countPages, - List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() - }; - - return OperationResultModel.Success(result); - } - - public OperationResultModel Update(LecturerPostSetBindingModel model) - { - using var context = DatabaseManager.GetContext; - - var entity = context.LecturerPosts.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity = Mapper.MapToClass(model, entity, true); - - context.SaveChanges(); - - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.Lecturer.LastName); } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerService.cs index 426f465..ed0111a 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/LecturerService.cs @@ -4,7 +4,6 @@ using DepartmentBusinessLogic.BindingModels; using DepartmentBusinessLogic.Interfaces; using DepartmentBusinessLogic.ViewModels; using Microsoft.EntityFrameworkCore; -using ModuleTools.BusinessLogics; using ModuleTools.Enums; using ModuleTools.Models; using System; @@ -15,101 +14,25 @@ namespace DepartmentDatabaseImplementation.Implementations /// /// Реализация ILecturerService /// - public class LecturerService : ILecturerService + public class LecturerService : + AbstractGenerticEntityService, + ILecturerService { - public OperationResultModel Create(LecturerSetBindingModel model) - { - using var context = DatabaseManager.GetContext; + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, LecturerSetBindingModel model) => OperationResultModel.Success(null); - var exsistEntity = context.Lecturers.FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName && - x.Patronymic == model.Patronymic); - if (exsistEntity == null) + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, Lecturer entity, LecturerGetBindingModel model) + { + if (entity.User == null) { - var entity = Mapper.MapToClass(model, true); - context.Lecturers.Add(entity); - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); - } - else - { - if (exsistEntity.IsDeleted) - { - exsistEntity = Mapper.MapToClass(model, exsistEntity, true); - exsistEntity.IsDeleted = false; - context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(exsistEntity, true)); - } - else - { - return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem); - } + return OperationResultModel.Error("Error:", "Не найден пользователь от сотрудника", ResultServiceStatusCode.NotFound); } + return OperationResultModel.Success(null); ; } - public OperationResultModel Delete(LecturerGetBindingModel model) + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, LecturerGetBindingModel model) { - using var context = DatabaseManager.GetContext; - using var transaction = context.Database.BeginTransaction(); - try - { - var entity = context.Lecturers.Include(x => x.User).FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - else if (entity.User == null) - { - return OperationResultModel.Error("Error:", "Не найден пользователь от сотрудника", ResultServiceStatusCode.NotFound); - } - entity.IsDeleted = true; - entity.DateDelete = DateTime.Now; - entity.User.IsDeleted = true; - entity.User.DateDelete = DateTime.Now; - context.SaveChanges(); - - var links = context.LecturerEmployeePosts.Where(x => x.LecturerId == model.Id); - foreach (var link in links) - { - link.IsDeleted = true; - link.DateDelete = DateTime.Now; - } - context.SaveChanges(); - - - transaction.Commit(); - } - catch (Exception) - { - transaction.Rollback(); - throw; - } - - return OperationResultModel.Success(true); - } - - public OperationResultModel Read(LecturerGetBindingModel model) - { - int countPages = 0; - using var context = DatabaseManager.GetContext; - - // для одной записи - if (model.Id.HasValue) - { - var entity = context.Lecturers.FirstOrDefault(x => x.Id == model.Id.Value); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); - } - - var query = context.Lecturers.Where(x => !x.IsDeleted).AsQueryable(); - if(model.UserId.HasValue) + if (model.UserId.HasValue) { query = query.Where(x => x.UserId == model.UserId); } @@ -121,60 +44,43 @@ namespace DepartmentDatabaseImplementation.Implementations { query = query.Where(x => x.LecturerAcademicRankId == model.LecturerAcademicRankId); } - if (model.LecturerPostId.HasValue) - { - query = query.Where(x => x.LecturerPostId == model.LecturerPostId); - } - - query = query - .OrderByDescending(x => x.LecturerEmployeePosts.Max(y => y.EmployeePost.Order)) - .ThenBy(x => x.LecturerAcademicRank.Order) - .ThenBy(x => x.LecturerAcademicDegree.Order) - .ThenBy(x => x.LecturerPost.Order) - .ThenBy(x => x.LastName); - - if (model.PageNumber.HasValue && model.PageSize.HasValue) - { - countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); - query = query - .Skip(model.PageSize.Value * model.PageNumber.Value) - .Take(model.PageSize.Value); - } - - query = query - .Include(x => x.LecturerPost) - .Include(x => x.LecturerAcademicRank) - .Include(x => x.LecturerAcademicDegree) - .Include(x => x.LecturerEmployeePosts) - .Include(x => x.LecturerEmployeePosts).Include("LecturerEmployeePosts.EmployeePost"); - - var result = new LecturerListViewModel - { - MaxCount = countPages, - List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() - }; - - return OperationResultModel.Success(result); + return query; } - public OperationResultModel Update(LecturerSetBindingModel model) - { - using var context = DatabaseManager.GetContext; + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, LecturerSetBindingModel model) => OperationResultModel.Success(null); - var entity = context.Lecturers.FirstOrDefault(x => x.Id == model.Id); - if (entity == null) - { - return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); - } - else if (entity.IsDeleted) - { - return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); - } - entity = Mapper.MapToClass(model, entity, true); + protected override void AdditionalDeleting(DbContext context, Lecturer entity, LecturerGetBindingModel model) + { + entity.User.IsDeleted = true; + entity.User.DateDelete = DateTime.Now; context.SaveChanges(); - return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + var links = context.Set().Where(x => x.LecturerId == model.Id); + foreach (var link in links) + { + link.IsDeleted = true; + link.DateDelete = DateTime.Now; + } + context.SaveChanges(); } + + protected override Lecturer GetUniqueEntity(LecturerSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName && + x.Patronymic == model.Patronymic && x.Id != model.Id); + + protected override IQueryable IncludingWhenReading(IQueryable query) + { + return query + .Include(x => x.LecturerAcademicRank) + .Include(x => x.LecturerAcademicDegree) + .Include(x => x.LecturerPosts).Include("LecturerPosts.Post"); + } + + protected override IQueryable OrderingWhenReading(IQueryable query) => query + .OrderByDescending(x => x.LecturerPosts.Max(y => y.Post.Order)) + .ThenBy(x => x.LecturerAcademicRank.Order) + .ThenBy(x => x.LecturerAcademicDegree.Order) + .ThenBy(x => x.LastName) + .ThenBy(x => x.FirstName); } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/PostService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/PostService.cs new file mode 100644 index 0000000..f08a438 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/PostService.cs @@ -0,0 +1,47 @@ +using DatabaseCore; +using DatabaseCore.Models.Department; +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Interfaces; +using DepartmentBusinessLogic.ViewModels; +using Microsoft.EntityFrameworkCore; +using ModuleTools.Enums; +using ModuleTools.Models; +using System.Linq; + +namespace DepartmentDatabaseImplementation.Implementations +{ + /// + /// Реализация IEmployeePostService + /// + public class PostService : + AbstractGenerticEntityService, + IPostService + { + protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, PostSetBindingModel model) => OperationResultModel.Success(null); + + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, Post entity, PostGetBindingModel model) + { + if (context.Set().Any(x => x.PostId == model.Id && !x.IsDeleted)) + { + return OperationResultModel.Error("Error:", "Существуют сотрудники с этой должностью", ResultServiceStatusCode.ExsistItem); + } + if (context.Set().Any(x => x.PostId == model.Id && !x.IsDeleted)) + { + return OperationResultModel.Error("Error:", "Существуют преподаватели с этой должностью", ResultServiceStatusCode.ExsistItem); + } + return OperationResultModel.Success(null); + } + + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, PostGetBindingModel model) => query; + + protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, PostSetBindingModel model) => OperationResultModel.Success(null); + + protected override void AdditionalDeleting(DbContext context, Post entity, PostGetBindingModel model) { } + + protected override Post GetUniqueEntity(PostSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.PostName == model.PostName && x.Id != model.Id); + + protected override IQueryable IncludingWhenReading(IQueryable query) => query; + + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.Order); + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs index ab26af1..1ec0fa6 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs @@ -32,14 +32,13 @@ namespace DepartmentWindowsDesktop }; List _controls = new() { - new ControlEmployeePostList(), + new ControlPostList(), new ControlEmployeeList(), new ControlClassroomList(), new ControlDisciplineBlockList(), new ControlDisciplineList(), new ControlLecturerAcademicDegreeList(), new ControlLecturerAcademicRankList(), - new ControlLecturerPostList(), new ControlLecturerList() }; diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostElement.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostElement.Designer.cs deleted file mode 100644 index 8108cb3..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostElement.Designer.cs +++ /dev/null @@ -1,33 +0,0 @@ - -namespace DepartmentWindowsDesktop.EntityControls -{ - partial class ControlEmployeeEmployeePostElement - { - /// - /// Освободить все используемые ресурсы. - /// - /// истинно, если управляемый ресурс должен быть удален; иначе ложно. - 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/EmployeeEmployeePost/ControlEmployeeEmployeePostElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostElement.cs deleted file mode 100644 index 8af5368..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostElement.cs +++ /dev/null @@ -1,27 +0,0 @@ -using DepartmentBusinessLogic.BindingModels; -using DepartmentBusinessLogic.BusinessLogics; -using DepartmentBusinessLogic.ViewModels; -using DesktopTools.Controls; -using DesktopTools.Interfaces; -using System; - -namespace DepartmentWindowsDesktop.EntityControls -{ - /// - /// Реализация контрола для связи сотрудника с должностью - /// - public partial class ControlEmployeeEmployeePostElement : - GenericControlEntityElement, - IGenericControlEntityElement - { - public ControlEmployeeEmployeePostElement() - { - InitializeComponent(); - Title = "Связи сотрудников с должностями"; - ControlId = new Guid("bdc9a6ef-968c-4d8e-bc19-aa15485cc855"); - _genericControlViewEntityElement = this; - } - - public IControl GetInstanceGenericControl() => new ControlEmployeeEmployeePostElement() { ControlId = Guid.NewGuid() }; - } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeePost/ControlEmployeePostElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeePost/ControlEmployeePostElement.cs index c59e69f..d324c87 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeePost/ControlEmployeePostElement.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeePost/ControlEmployeePostElement.cs @@ -8,7 +8,7 @@ using System; namespace DepartmentWindowsDesktop.EntityControls { /// - /// Реализация контрола для должности + /// Реализация контрола для связи сотрудника с должностью /// public partial class ControlEmployeePostElement : GenericControlEntityElement, @@ -17,8 +17,8 @@ namespace DepartmentWindowsDesktop.EntityControls public ControlEmployeePostElement() { InitializeComponent(); - Title = "Должность"; - ControlId = new Guid("25700525-7765-46c3-bbbf-a842f31bd898"); + Title = "Связи сотрудников с должностями"; + ControlId = new Guid("bdc9a6ef-968c-4d8e-bc19-aa15485cc855"); _genericControlViewEntityElement = this; } diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeePost/ControlEmployeePostList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeePost/ControlEmployeePostList.cs index 0a54e3b..a102afb 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeePost/ControlEmployeePostList.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeePost/ControlEmployeePostList.cs @@ -12,7 +12,7 @@ using System.Collections.Generic; namespace DepartmentWindowsDesktop.EntityControls { /// - /// Реализация контрола для списка должностей сотрудников + /// Реализация контрола для списка должностней сотрудника /// public partial class ControlEmployeePostList : GenericControlEntityList, @@ -21,9 +21,9 @@ namespace DepartmentWindowsDesktop.EntityControls public ControlEmployeePostList() { InitializeComponent(); - Title = "Должности сотрудников"; - ControlId = new Guid("643f2ec7-9e77-4b8a-8074-5a7915fa16c0"); - AccessOperation = AccessOperation.Сотрудники; + Title = "Связи сотрудников с должностями"; + ControlId = new Guid("5d8ef8a4-8f76-4333-97a6-0beee5be8999"); + AccessOperation = AccessOperation.Должности; ControlViewEntityElement = new ControlEmployeePostElement(); _genericControlViewEntityList = this; } @@ -35,6 +35,7 @@ namespace DepartmentWindowsDesktop.EntityControls PaginationOn = false, HideToolStripButton = new List { + ToolStripButtonListNames.toolStripButtonUpd, ToolStripButtonListNames.toolStripButtonSearch } }; diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostElement.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostElement.Designer.cs deleted file mode 100644 index 0f761a3..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostElement.Designer.cs +++ /dev/null @@ -1,33 +0,0 @@ - -namespace DepartmentWindowsDesktop.EntityControls -{ - partial class ControlLecturerEmployeePostElement - { - /// - /// Освободить все используемые ресурсы. - /// - /// истинно, если управляемый ресурс должен быть удален; иначе ложно. - 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/LecturerEmployeePost/ControlLecturerEmployeePostElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostElement.cs deleted file mode 100644 index 267d81a..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostElement.cs +++ /dev/null @@ -1,27 +0,0 @@ -using DepartmentBusinessLogic.BindingModels; -using DepartmentBusinessLogic.BusinessLogics; -using DepartmentBusinessLogic.ViewModels; -using DesktopTools.Controls; -using DesktopTools.Interfaces; -using System; - -namespace DepartmentWindowsDesktop.EntityControls -{ - /// - /// Реализация контрола для сязи преподавателя и должности - /// - public partial class ControlLecturerEmployeePostElement : - GenericControlEntityElement, - IGenericControlEntityElement - { - public ControlLecturerEmployeePostElement() - { - InitializeComponent(); - Title = "Связи преподавателей с должностями"; - ControlId = new Guid("88f4b4e5-68ff-4a84-9f38-dc9952cc635f"); - _genericControlViewEntityElement = this; - } - - public IControl GetInstanceGenericControl() => new ControlLecturerEmployeePostElement() { ControlId = Guid.NewGuid() }; - } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostElement.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostElement.resx deleted file mode 100644 index 1af7de1..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostElement.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/LecturerEmployeePost/ControlLecturerEmployeePostList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostList.cs deleted file mode 100644 index eb1133e..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostList.cs +++ /dev/null @@ -1,40 +0,0 @@ -using DepartmentBusinessLogic.BindingModels; -using DepartmentBusinessLogic.BusinessLogics; -using DepartmentBusinessLogic.ViewModels; -using DesktopTools.Controls; -using DesktopTools.Enums; -using DesktopTools.Interfaces; -using DesktopTools.Models; -using ModuleTools.Enums; -using System; -using System.Collections.Generic; - -namespace DepartmentWindowsDesktop.EntityControls -{ - public partial class ControlLecturerEmployeePostList : - GenericControlEntityList, - IGenericControlEntityList - { - public ControlLecturerEmployeePostList() - { - InitializeComponent(); - Title = "Связи преподавателей с должностями"; - ControlId = new Guid("3f5ed02d-643f-49fc-81df-1dcf75392492"); - AccessOperation = AccessOperation.Преподаватели; - ControlViewEntityElement = new ControlLecturerEmployeePostElement(); - _genericControlViewEntityList = this; - } - - public IControl GetInstanceGenericControl() => new ControlLecturerEmployeePostList() { ControlId = Guid.NewGuid() }; - - public ControlViewEntityListConfiguration GetConfigControl() => new() - { - PaginationOn = false, - HideToolStripButton = new List - { - ToolStripButtonListNames.toolStripButtonUpd, - ToolStripButtonListNames.toolStripButtonSearch - } - }; - } -} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostList.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostList.resx deleted file mode 100644 index 1af7de1..0000000 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostList.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/LecturerPost/ControlLecturerPostElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerPost/ControlLecturerPostElement.cs index 45b24ee..4cf35c2 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerPost/ControlLecturerPostElement.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerPost/ControlLecturerPostElement.cs @@ -8,7 +8,7 @@ using System; namespace DepartmentWindowsDesktop.EntityControls { /// - /// Реализация контрола для должности преподавателя + /// Реализация контрола для сязи преподавателя и должности /// public partial class ControlLecturerPostElement : GenericControlEntityElement, @@ -17,8 +17,8 @@ namespace DepartmentWindowsDesktop.EntityControls public ControlLecturerPostElement() { InitializeComponent(); - Title = "Должность преподавателя"; - ControlId = new Guid("25700525-7765-46c3-bbbf-a842f31bd898"); + Title = "Связи преподавателей с должностями"; + ControlId = new Guid("88f4b4e5-68ff-4a84-9f38-dc9952cc635f"); _genericControlViewEntityElement = this; } diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerPost/ControlLecturerPostList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerPost/ControlLecturerPostList.cs index a922447..b07c55a 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerPost/ControlLecturerPostList.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerPost/ControlLecturerPostList.cs @@ -11,9 +11,6 @@ using System.Collections.Generic; namespace DepartmentWindowsDesktop.EntityControls { - /// - /// Реализация контрола для списка должностей преподавателей - /// public partial class ControlLecturerPostList : GenericControlEntityList, IGenericControlEntityList @@ -21,9 +18,9 @@ namespace DepartmentWindowsDesktop.EntityControls public ControlLecturerPostList() { InitializeComponent(); - Title = "Должности преподавателей"; - ControlId = new Guid("ffbb6972-e720-42f7-a0ce-005ee36753e6"); - AccessOperation = AccessOperation.Преподаватели; + Title = "Связи преподавателей с должностями"; + ControlId = new Guid("3f5ed02d-643f-49fc-81df-1dcf75392492"); + AccessOperation = AccessOperation.Должности; ControlViewEntityElement = new ControlLecturerPostElement(); _genericControlViewEntityList = this; } @@ -35,6 +32,7 @@ namespace DepartmentWindowsDesktop.EntityControls PaginationOn = false, HideToolStripButton = new List { + ToolStripButtonListNames.toolStripButtonUpd, ToolStripButtonListNames.toolStripButtonSearch } }; diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostList.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostElement.Designer.cs similarity index 95% rename from DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostList.Designer.cs rename to DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostElement.Designer.cs index 1f3964c..2070722 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/LecturerEmployeePost/ControlLecturerEmployeePostList.Designer.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostElement.Designer.cs @@ -1,7 +1,7 @@  namespace DepartmentWindowsDesktop.EntityControls { - partial class ControlLecturerEmployeePostList + partial class ControlPostElement { /// /// Освободить все используемые ресурсы. diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostElement.cs new file mode 100644 index 0000000..36ba485 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostElement.cs @@ -0,0 +1,27 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.BusinessLogics; +using DepartmentBusinessLogic.ViewModels; +using DesktopTools.Controls; +using DesktopTools.Interfaces; +using System; + +namespace DepartmentWindowsDesktop.EntityControls +{ + /// + /// Реализация контрола для должности + /// + public partial class ControlPostElement : + GenericControlEntityElement, + IGenericControlEntityElement + { + public ControlPostElement() + { + InitializeComponent(); + Title = "Должность"; + ControlId = new Guid("25700525-7765-46c3-bbbf-a842f31bd898"); + _genericControlViewEntityElement = this; + } + + public IControl GetInstanceGenericControl() => new ControlPostElement() { ControlId = Guid.NewGuid() }; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostElement.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostElement.resx similarity index 100% rename from DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostElement.resx rename to DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostElement.resx diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostList.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostList.Designer.cs similarity index 95% rename from DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostList.Designer.cs rename to DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostList.Designer.cs index 9f4200c..8b7cc9c 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostList.Designer.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostList.Designer.cs @@ -1,7 +1,7 @@  namespace DepartmentWindowsDesktop.EntityControls { - partial class ControlEmployeeEmployeePostList + partial class ControlPostList { /// /// Освободить все используемые ресурсы. diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostList.cs similarity index 50% rename from DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostList.cs rename to DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostList.cs index 8b1057c..e9e6bbf 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostList.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostList.cs @@ -12,30 +12,29 @@ using System.Collections.Generic; namespace DepartmentWindowsDesktop.EntityControls { /// - /// Реализация контрола для списка должностней сотрудника + /// Реализация контрола для списка должностей /// - public partial class ControlEmployeeEmployeePostList : - GenericControlEntityList, + public partial class ControlPostList : + GenericControlEntityList, IGenericControlEntityList { - public ControlEmployeeEmployeePostList() + public ControlPostList() { InitializeComponent(); - Title = "Связи сотрудников с должностями"; - ControlId = new Guid("5d8ef8a4-8f76-4333-97a6-0beee5be8999"); - AccessOperation = AccessOperation.Сотрудники; - ControlViewEntityElement = new ControlEmployeeEmployeePostElement(); + Title = "Должности"; + ControlId = new Guid("643f2ec7-9e77-4b8a-8074-5a7915fa16c0"); + AccessOperation = AccessOperation.Должности; + ControlViewEntityElement = new ControlPostElement(); _genericControlViewEntityList = this; } - public IControl GetInstanceGenericControl() => new ControlEmployeeEmployeePostList() { ControlId = Guid.NewGuid() }; + public IControl GetInstanceGenericControl() => new ControlPostList() { ControlId = Guid.NewGuid() }; public ControlViewEntityListConfiguration GetConfigControl() => new() { PaginationOn = false, HideToolStripButton = new List { - ToolStripButtonListNames.toolStripButtonUpd, ToolStripButtonListNames.toolStripButtonSearch } }; diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostList.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostList.resx similarity index 100% rename from DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/EmployeeEmployeePost/ControlEmployeeEmployeePostList.resx rename to DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Post/ControlPostList.resx diff --git a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/AccessService.cs b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/AccessService.cs index 772fc3b..aee6aa6 100644 --- a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/AccessService.cs +++ b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/AccessService.cs @@ -18,7 +18,7 @@ namespace SecurityDatabaseImplementation.Implementations { protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, AccessSetBindingModel model) => OperationResultModel.Success(null); - protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, AccessGetBindingModel model) { return OperationResultModel.Success(null); } + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, Access entity, AccessGetBindingModel model) { return OperationResultModel.Success(null); } protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, AccessGetBindingModel model) { @@ -31,7 +31,7 @@ namespace SecurityDatabaseImplementation.Implementations protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, AccessSetBindingModel model) => OperationResultModel.Success(null); - protected override void AdditionalDeleting(DbContext context, AccessGetBindingModel model) { } + protected override void AdditionalDeleting(DbContext context, Access entity, AccessGetBindingModel model) { } protected override Access GetUniqueEntity(AccessSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.AccessOperation == model.AccessOperation && x.RoleId == model.RoleId && x.AccessType == model.AccessType && x.Id != model.Id); diff --git a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/EnviromentSettingService.cs b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/EnviromentSettingService.cs index 5a5185c..5502dc6 100644 --- a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/EnviromentSettingService.cs +++ b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/EnviromentSettingService.cs @@ -18,13 +18,13 @@ namespace SecurityDatabaseImplementation.Implementations { protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, EnviromentSettingSetBindingModel model) => OperationResultModel.Success(null); - protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, EnviromentSettingGetBindingModel model) => OperationResultModel.Success(null); + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, EnviromentSetting entity, EnviromentSettingGetBindingModel model) => OperationResultModel.Success(null); protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, EnviromentSettingGetBindingModel model) => query; protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, EnviromentSettingSetBindingModel model) => OperationResultModel.Success(null); - protected override void AdditionalDeleting(DbContext context, EnviromentSettingGetBindingModel model) { } + protected override void AdditionalDeleting(DbContext context, EnviromentSetting entity, EnviromentSettingGetBindingModel model) { } protected override EnviromentSetting GetUniqueEntity(EnviromentSettingSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.Key == model.Key && x.Id != model.Id); diff --git a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/RoleService.cs b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/RoleService.cs index 5049f9f..b6fff9a 100644 --- a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/RoleService.cs +++ b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/RoleService.cs @@ -20,7 +20,7 @@ namespace SecurityDatabaseImplementation.Implementations { protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, RoleSetBindingModel model) => OperationResultModel.Success(null); - protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, RoleGetBindingModel model) + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, Role entity, RoleGetBindingModel model) { if (context.Set().Any(x => x.RoleId == model.Id && !x.IsDeleted)) { @@ -33,7 +33,7 @@ namespace SecurityDatabaseImplementation.Implementations protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, RoleSetBindingModel model) => OperationResultModel.Success(null); - protected override void AdditionalDeleting(DbContext context, RoleGetBindingModel model) + protected override void AdditionalDeleting(DbContext context, Role entity, RoleGetBindingModel model) { var access = context.Set().Where(x => x.RoleId == model.Id); foreach (var ac in access) diff --git a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserRoleService.cs b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserRoleService.cs index 8bddd47..755e084 100644 --- a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserRoleService.cs +++ b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserRoleService.cs @@ -18,7 +18,7 @@ namespace SecurityDatabaseImplementation.Implementations { protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, UserRoleSetBindingModel model) => OperationResultModel.Success(null); - protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, UserRoleGetBindingModel model) => OperationResultModel.Success(null); + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, UserRole entity, UserRoleGetBindingModel model) => OperationResultModel.Success(null); protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, UserRoleGetBindingModel model) { @@ -35,7 +35,7 @@ namespace SecurityDatabaseImplementation.Implementations protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, UserRoleSetBindingModel model) => OperationResultModel.Success(null); - protected override void AdditionalDeleting(DbContext context, UserRoleGetBindingModel model) { } + protected override void AdditionalDeleting(DbContext context, UserRole entity, UserRoleGetBindingModel model) { } protected override UserRole GetUniqueEntity(UserRoleSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.UserId == model.UserId && x.RoleId == model.RoleId && x.Id != model.Id); diff --git a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs index b731942..d31306f 100644 --- a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs +++ b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs @@ -30,7 +30,7 @@ namespace SecurityDatabaseImplementation.Implementations return OperationResultModel.Success(null); } - protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, UserGetBindingModel model) + protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, User entity, UserGetBindingModel model) { if (context.Set().Any(x => x.UserId == model.Id && !x.IsDeleted)) { @@ -54,7 +54,7 @@ namespace SecurityDatabaseImplementation.Implementations protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, UserSetBindingModel model) => OperationResultModel.Success(null); - protected override void AdditionalDeleting(DbContext context, UserGetBindingModel model) + protected override void AdditionalDeleting(DbContext context, User entity, UserGetBindingModel model) { var users = context.Set().Where(x => x.UserId == model.Id); foreach (var u in users)