убрали должность преподавателя, переделка под genericservice

This commit is contained in:
kotcheshir73 2021-04-05 12:25:10 +04:00
parent b0675d3e19
commit de06462404
76 changed files with 3570 additions and 2238 deletions

View File

@ -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
/// <param name="context"></param>
/// <param name="model"></param>
/// <returns></returns>
protected abstract OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, G model);
protected abstract OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, T entity, G model);
/// <summary>
/// Добавление дополнительных фильтров
@ -206,7 +206,7 @@ namespace DatabaseCore
/// Дополнительные удаления зависимых сущностей
/// </summary>
/// <param name="model"></param>
protected abstract void AdditionalDeleting(DbContext context, G model);
protected abstract void AdditionalDeleting(DbContext context, T entity, G model);
/// <summary>
/// Установка сортировок

View File

@ -32,7 +32,7 @@ namespace DatabaseCore
modelBuilder.Entity<User>().HasIndex(s => s.UserName);
modelBuilder.Entity<EmployeePost>().HasIndex(s => s.EmployeePostName).IsUnique();
modelBuilder.Entity<Post>().HasIndex(s => s.PostName).IsUnique();
modelBuilder.Entity<Employee>().HasIndex(p => new { p.FirstName, p.LastName, p.Patronymic }).IsUnique();
@ -46,8 +46,6 @@ namespace DatabaseCore
modelBuilder.Entity<LecturerAcademicRank>().HasIndex(p => new { p.LecturerAcademicRankName }).IsUnique();
modelBuilder.Entity<LecturerPost>().HasIndex(p => new { p.LecturerPostName }).IsUnique();
modelBuilder.Entity<Lecturer>().HasIndex(p => new { p.FirstName, p.LastName, p.Patronymic }).IsUnique();
}
@ -60,15 +58,14 @@ namespace DatabaseCore
#endregion
#region Department
public virtual DbSet<EmployeePost> EmployeePosts { set; get; }
public virtual DbSet<Post> Posts { set; get; }
public virtual DbSet<Employee> Employees { set; get; }
public virtual DbSet<EmployeeEmployeePost> EmployeeEmployeePosts { set; get; }
public virtual DbSet<EmployeePost> EmployeePosts { set; get; }
public virtual DbSet<Classroom> Classrooms { set; get; }
public virtual DbSet<DisciplineBlock> DisciplineBlocks { set; get; }
public virtual DbSet<Discipline> Disciplines { set; get; }
public virtual DbSet<LecturerAcademicDegree> LecturerAcademicDegrees { set; get; }
public virtual DbSet<LecturerAcademicRank> LecturerAcademicRanks { set; get; }
public virtual DbSet<LecturerEmployeePost> LecturerEmployeePosts { set; get; }
public virtual DbSet<LecturerPost> LecturerPosts { set; get; }
public virtual DbSet<Lecturer> Lecturers { set; get; }
#endregion

View File

@ -0,0 +1,810 @@
// <auto-generated />
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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<int>("Capacity")
.HasColumnType("int");
b.Property<int>("ClassroomType")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("HaveProjector")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Number")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Photo")
.HasColumnType("varbinary(max)");
b.Property<string>("SecurityCode")
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Square")
.HasColumnType("decimal(18,2)");
b.Property<string>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("DisciplineBlockId")
.HasColumnType("uniqueidentifier");
b.Property<string>("DisciplineBlueAsteriskName")
.HasColumnType("nvarchar(max)");
b.Property<string>("DisciplineName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("DisciplineShortName")
.HasColumnType("nvarchar(max)");
b.Property<bool>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("DisciplineBlockBlueAsteriskName")
.HasColumnType("nvarchar(max)");
b.Property<int>("DisciplineBlockOrder")
.HasColumnType("int");
b.Property<bool>("DisciplineBlockUseForGrouping")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("Title")
.IsUnique();
b.ToTable("DisciplineBlocks");
});
modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Address")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateBirth")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(450)");
b.Property<string>("GroupElectricalSafety")
.HasColumnType("nvarchar(max)");
b.Property<string>("HomeNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LastName")
.HasColumnType("nvarchar(450)");
b.Property<string>("MobileNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("Patronymic")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Photo")
.HasColumnType("varbinary(max)");
b.Property<Guid>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<Guid>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsExternalCombination")
.HasColumnType("bit");
b.Property<bool>("IsInternalCombination")
.HasColumnType("bit");
b.Property<Guid>("PostId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Abbreviation")
.HasColumnType("nvarchar(max)");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateBirth")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("HomeNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<Guid?>("LecturerAcademicDegreeId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("LecturerAcademicRankId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("LecturerPostId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("LecturerPostRate")
.HasColumnType("decimal(18,2)");
b.Property<string>("MobileNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("OnlyForPrivate")
.HasColumnType("bit");
b.Property<string>("Patronymic")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Photo")
.HasColumnType("varbinary(max)");
b.Property<Guid>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LecturerAcademicDegreeName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerAcademicDegreeName")
.IsUnique();
b.ToTable("LecturerAcademicDegrees");
});
modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LecturerAcademicRankName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerAcademicRankName")
.IsUnique();
b.ToTable("LecturerAcademicRanks");
});
modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsExternalCombination")
.HasColumnType("bit");
b.Property<bool>("IsInternalCombination")
.HasColumnType("bit");
b.Property<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("PostId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<int?>("Hours")
.HasColumnType("int");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<string>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<int>("AccessOperation")
.HasColumnType("int");
b.Property<int>("AccessType")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Accesses");
});
modelBuilder.Entity("DatabaseCore.Models.Security.EnviromentSetting", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Key")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("Key")
.IsUnique();
b.ToTable("EnviromentSettings");
});
modelBuilder.Entity("DatabaseCore.Models.Security.Role", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("RoleName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("RolePriority")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleName")
.IsUnique();
b.ToTable("Roles");
});
modelBuilder.Entity("DatabaseCore.Models.Security.User", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<byte[]>("Avatar")
.HasColumnType("varbinary(max)");
b.Property<int>("CountAttempt")
.HasColumnType("int");
b.Property<DateTime?>("DateBanned")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateLastVisit")
.HasColumnType("datetime2");
b.Property<bool>("IsBanned")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("UserName");
b.ToTable("Users");
});
modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("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
}
}
}

View File

@ -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<bool>(
name: "IsExternalCombination",
table: "LecturerPosts",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsInternalCombination",
table: "LecturerPosts",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<Guid>(
name: "LecturerId",
table: "LecturerPosts",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "PostId",
table: "LecturerPosts",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<decimal>(
name: "Rate",
table: "LecturerPosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<Guid>(
name: "EmployeeId",
table: "EmployeePosts",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<bool>(
name: "IsExternalCombination",
table: "EmployeePosts",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsInternalCombination",
table: "EmployeePosts",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<Guid>(
name: "PostId",
table: "EmployeePosts",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<decimal>(
name: "Rate",
table: "EmployeePosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.CreateTable(
name: "Posts",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
PostName = table.Column<string>(type: "nvarchar(450)", nullable: true),
Hours = table.Column<int>(type: "int", nullable: true),
Order = table.Column<int>(type: "int", nullable: false),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
DateDelete = table.Column<DateTime>(type: "datetime2", nullable: true),
IsDeleted = table.Column<bool>(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<int>(
name: "Hours",
table: "LecturerPosts",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "LecturerPostName",
table: "LecturerPosts",
type: "nvarchar(450)",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<int>(
name: "Order",
table: "LecturerPosts",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "EmployeePostName",
table: "EmployeePosts",
type: "nvarchar(450)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "Order",
table: "EmployeePosts",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "EmployeeEmployeePosts",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
DateDelete = table.Column<DateTime>(type: "datetime2", nullable: true),
EmployeeId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
EmployeePostId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
IsExternalCombination = table.Column<bool>(type: "bit", nullable: false),
IsInternalCombination = table.Column<bool>(type: "bit", nullable: false),
Rate = table.Column<decimal>(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<Guid>(type: "uniqueidentifier", nullable: false),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
DateDelete = table.Column<DateTime>(type: "datetime2", nullable: true),
EmployeePostId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
IsExternalCombination = table.Column<bool>(type: "bit", nullable: false),
IsInternalCombination = table.Column<bool>(type: "bit", nullable: false),
LecturerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Rate = table.Column<decimal>(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);
}
}
}

View File

@ -0,0 +1,813 @@
// <auto-generated />
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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<int>("Capacity")
.HasColumnType("int");
b.Property<int>("ClassroomType")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("HaveProjector")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Number")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Photo")
.HasColumnType("varbinary(max)");
b.Property<string>("SecurityCode")
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Square")
.HasColumnType("decimal(18,2)");
b.Property<string>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("DisciplineBlockId")
.HasColumnType("uniqueidentifier");
b.Property<string>("DisciplineBlueAsteriskName")
.HasColumnType("nvarchar(max)");
b.Property<string>("DisciplineName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("DisciplineShortName")
.HasColumnType("nvarchar(max)");
b.Property<bool>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("DisciplineBlockBlueAsteriskName")
.HasColumnType("nvarchar(max)");
b.Property<int>("DisciplineBlockOrder")
.HasColumnType("int");
b.Property<bool>("DisciplineBlockUseForGrouping")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("Title")
.IsUnique();
b.ToTable("DisciplineBlocks");
});
modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Address")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateBirth")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(450)");
b.Property<string>("GroupElectricalSafety")
.HasColumnType("nvarchar(max)");
b.Property<string>("HomeNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LastName")
.HasColumnType("nvarchar(450)");
b.Property<string>("MobileNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("Patronymic")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Photo")
.HasColumnType("varbinary(max)");
b.Property<Guid>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<Guid>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsExternalCombination")
.HasColumnType("bit");
b.Property<bool>("IsInternalCombination")
.HasColumnType("bit");
b.Property<Guid>("PostId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Abbreviation")
.HasColumnType("nvarchar(max)");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateBirth")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("GroupElectricalSafety")
.HasColumnType("nvarchar(max)");
b.Property<string>("HomeNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<Guid?>("LecturerAcademicDegreeId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("LecturerAcademicRankId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("LecturerPostId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("LecturerPostRate")
.HasColumnType("decimal(18,2)");
b.Property<string>("MobileNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("OnlyForPrivate")
.HasColumnType("bit");
b.Property<string>("Patronymic")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Photo")
.HasColumnType("varbinary(max)");
b.Property<Guid>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LecturerAcademicDegreeName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerAcademicDegreeName")
.IsUnique();
b.ToTable("LecturerAcademicDegrees");
});
modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LecturerAcademicRankName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerAcademicRankName")
.IsUnique();
b.ToTable("LecturerAcademicRanks");
});
modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsExternalCombination")
.HasColumnType("bit");
b.Property<bool>("IsInternalCombination")
.HasColumnType("bit");
b.Property<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("PostId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<int?>("Hours")
.HasColumnType("int");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<string>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<int>("AccessOperation")
.HasColumnType("int");
b.Property<int>("AccessType")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Accesses");
});
modelBuilder.Entity("DatabaseCore.Models.Security.EnviromentSetting", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Key")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("Key")
.IsUnique();
b.ToTable("EnviromentSettings");
});
modelBuilder.Entity("DatabaseCore.Models.Security.Role", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("RoleName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("RolePriority")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleName")
.IsUnique();
b.ToTable("Roles");
});
modelBuilder.Entity("DatabaseCore.Models.Security.User", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<byte[]>("Avatar")
.HasColumnType("varbinary(max)");
b.Property<int>("CountAttempt")
.HasColumnType("int");
b.Property<DateTime?>("DateBanned")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateLastVisit")
.HasColumnType("datetime2");
b.Property<bool>("IsBanned")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("UserName");
b.ToTable("Users");
});
modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("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
}
}
}

View File

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace DatabaseCore.Migrations
{
public partial class AddFieldToLecturer : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "GroupElectricalSafety",
table: "Lecturers",
type: "nvarchar(max)",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "GroupElectricalSafety",
table: "Lecturers");
}
}
}

View File

@ -0,0 +1,807 @@
// <auto-generated />
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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<int>("Capacity")
.HasColumnType("int");
b.Property<int>("ClassroomType")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("HaveProjector")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Number")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Photo")
.HasColumnType("varbinary(max)");
b.Property<string>("SecurityCode")
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Square")
.HasColumnType("decimal(18,2)");
b.Property<string>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("DisciplineBlockId")
.HasColumnType("uniqueidentifier");
b.Property<string>("DisciplineBlueAsteriskName")
.HasColumnType("nvarchar(max)");
b.Property<string>("DisciplineName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("DisciplineShortName")
.HasColumnType("nvarchar(max)");
b.Property<bool>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("DisciplineBlockBlueAsteriskName")
.HasColumnType("nvarchar(max)");
b.Property<int>("DisciplineBlockOrder")
.HasColumnType("int");
b.Property<bool>("DisciplineBlockUseForGrouping")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("Title")
.IsUnique();
b.ToTable("DisciplineBlocks");
});
modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Address")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateBirth")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(450)");
b.Property<string>("GroupElectricalSafety")
.HasColumnType("nvarchar(max)");
b.Property<string>("HomeNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LastName")
.HasColumnType("nvarchar(450)");
b.Property<string>("MobileNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("Patronymic")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Photo")
.HasColumnType("varbinary(max)");
b.Property<Guid>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<Guid>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsExternalCombination")
.HasColumnType("bit");
b.Property<bool>("IsInternalCombination")
.HasColumnType("bit");
b.Property<Guid>("PostId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Abbreviation")
.HasColumnType("nvarchar(max)");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateBirth")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("GroupElectricalSafety")
.HasColumnType("nvarchar(max)");
b.Property<string>("HomeNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<Guid?>("LecturerAcademicDegreeId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("LecturerAcademicRankId")
.HasColumnType("uniqueidentifier");
b.Property<string>("MobileNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("OnlyForPrivate")
.HasColumnType("bit");
b.Property<string>("Patronymic")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Photo")
.HasColumnType("varbinary(max)");
b.Property<Guid>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LecturerAcademicDegreeName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerAcademicDegreeName")
.IsUnique();
b.ToTable("LecturerAcademicDegrees");
});
modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LecturerAcademicRankName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerAcademicRankName")
.IsUnique();
b.ToTable("LecturerAcademicRanks");
});
modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsExternalCombination")
.HasColumnType("bit");
b.Property<bool>("IsInternalCombination")
.HasColumnType("bit");
b.Property<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("PostId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<int?>("Hours")
.HasColumnType("int");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<string>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<int>("AccessOperation")
.HasColumnType("int");
b.Property<int>("AccessType")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Accesses");
});
modelBuilder.Entity("DatabaseCore.Models.Security.EnviromentSetting", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Key")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("Key")
.IsUnique();
b.ToTable("EnviromentSettings");
});
modelBuilder.Entity("DatabaseCore.Models.Security.Role", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("RoleName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("RolePriority")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleName")
.IsUnique();
b.ToTable("Roles");
});
modelBuilder.Entity("DatabaseCore.Models.Security.User", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<byte[]>("Avatar")
.HasColumnType("varbinary(max)");
b.Property<int>("CountAttempt")
.HasColumnType("int");
b.Property<DateTime?>("DateBanned")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateLastVisit")
.HasColumnType("datetime2");
b.Property<bool>("IsBanned")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("UserName");
b.ToTable("Users");
});
modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("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
}
}
}

View File

@ -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<Guid>(
name: "LecturerPostId",
table: "Lecturers",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<decimal>(
name: "LecturerPostRate",
table: "Lecturers",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
}
}
}

View File

@ -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<Guid>("Id")
.HasColumnType("uniqueidentifier");
@ -224,9 +224,6 @@ namespace DatabaseCore.Migrations
b.Property<Guid>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("EmployeePostId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
@ -236,6 +233,9 @@ namespace DatabaseCore.Migrations
b.Property<bool>("IsInternalCombination")
.HasColumnType("bit");
b.Property<Guid>("PostId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("EmployeePostName")
.HasColumnType("nvarchar(450)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<int>("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<string>("GroupElectricalSafety")
.HasColumnType("nvarchar(max)");
b.Property<string>("HomeNumber")
.HasColumnType("nvarchar(max)");
@ -325,12 +299,6 @@ namespace DatabaseCore.Migrations
b.Property<Guid?>("LecturerAcademicRankId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("LecturerPostId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("LecturerPostRate")
.HasColumnType("decimal(18,2)");
b.Property<string>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
@ -436,9 +402,6 @@ namespace DatabaseCore.Migrations
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<Guid>("EmployeePostId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
@ -451,19 +414,22 @@ namespace DatabaseCore.Migrations
b.Property<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("PostId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("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<Guid>("Id")
.HasColumnType("uniqueidentifier");
@ -474,25 +440,25 @@ namespace DatabaseCore.Migrations
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<int>("Hours")
b.Property<int?>("Hours")
.HasColumnType("int");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LecturerPostName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<string>("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 =>

View File

@ -71,7 +71,7 @@ namespace DatabaseCore.Models.Department
//-------------------------------------------------------------------------
[ForeignKey("EmployeeId")]
public virtual List<EmployeeEmployeePost> EmployeeEmployeePosts { get; set; }
public virtual List<EmployeePost> EmployeePosts { get; set; }
[ForeignKey("EmployeeId")]
public virtual List<Classroom> Classrooms { get; set; }

View File

@ -1,49 +0,0 @@
using ModuleTools.Attributes;
using ModuleTools.Interfaces;
using System;
using System.Runtime.Serialization;
namespace DatabaseCore.Models.Department
{
/// <summary>
/// Класс, описывающий связь сотрудника и должность кафедры
/// </summary>
[DataContract]
[EntityDescription("EmployeeEmployeePost", "Связь сотрудника и должность кафедры")]
[EntityDependency("EmployeePost", "EmployeePostId", "К какой должности относится сотрудник")]
[EntityDependency("Employee", "EmployeeId", "К какой должности относится сотрудник")]
public class EmployeeEmployeePost : BaseEntity, IEntitySecurityExtenstion<EmployeeEmployeePost>
{
[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;
}
}

View File

@ -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
{
/// <summary>
/// Класс, описывающий должность сотрудника кафедры
/// Класс, описывающий связь сотрудника и должность кафедры
/// </summary>
[DataContract]
[EntityDescription("EmployeePost", "Должность сотрудника кафедры")]
[EntityDescription("EmployeeEmployeePost", "Связь сотрудника и должность кафедры")]
[EntityDependency("Post", "PostId", "К какой должности относится сотрудник")]
[EntityDependency("Employee", "EmployeeId", "К какой должности относится сотрудник")]
public class EmployeePost : BaseEntity, IEntitySecurityExtenstion<EmployeePost>
{
[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<EmployeeEmployeePost> EmployeeEmployeePosts { get; set; }
[ForeignKey("EmployeePostId")]
public virtual List<LecturerEmployeePost> LecturerEmployeePosts { get; set; }
//-------------------------------------------------------------------------
public EmployeePost SecurityCheck(EmployeePost entity, bool allowFullData) => entity;
}
}
}

View File

@ -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<Lecturer>
@ -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<LecturerEmployeePost> LecturerEmployeePosts { get; set; }
public virtual List<LecturerPost> LecturerPosts { get; set; }
//-------------------------------------------------------------------------

View File

@ -1,53 +0,0 @@
using ModuleTools.Attributes;
using ModuleTools.Interfaces;
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace DatabaseCore.Models.Department
{
/// <summary>
/// Класс, описывающий связь преподавателя и должность кафедры
/// </summary>
[DataContract]
[EntityDescription("LecturerEmployeePost", "Связь преподавателя и должность кафедры")]
[EntityDependency("EmployeePost", "EmployeePostId", "К какой должности относится преподаватель")]
[EntityDependency("Lecturer", "LecturerId", "К какой должности относится преподаватель")]
public class LecturerEmployeePost : BaseEntity, IEntitySecurityExtenstion<LecturerEmployeePost>
{
[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;
}
}

View File

@ -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
{
/// <summary>
/// Класс, описывающий должность преподавателя кафедры
/// Класс, описывающий связь преподавателя и должность кафедры
/// </summary>
[DataContract]
[EntityDescription("LecturerPost", "Должность преподавателя кафедры")]
[EntityDescription("LecturerPost", "Связь преподавателя и должность кафедры")]
[EntityDependency("Post", "PostId", "К какой должности относится преподаватель")]
[EntityDependency("Lecturer", "LecturerId", "К какой должности относится преподаватель")]
public class LecturerPost : BaseEntity, IEntitySecurityExtenstion<LecturerPost>
{
[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<Lecturer> Lecturers { get; set; }
public virtual Lecturer Lecturer { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------

View File

@ -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
{
/// <summary>
/// Класс, описывающий должность на кафедры
/// </summary>
[DataContract]
[EntityDescription("Post", "Должность на кафедры")]
public class Post : BaseEntity, IEntitySecurityExtenstion<Post>
{
[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<EmployeePost> EmployeePosts { get; set; }
[ForeignKey("PostId")]
public virtual List<LecturerPost> LecturerPosts { get; set; }
//-------------------------------------------------------------------------
public Post SecurityCheck(Post entity, bool allowFullData) => entity;
}
}

View File

@ -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]";
/// <summary>
/// Перенос данных по безопасности

View File

@ -26,13 +26,15 @@
#region База
Кафедра = 100,
Сотрудники = 101, // + должности
Должности = 101, // + должности
Аудитории = 102,
Сотрудники = 102, // + должности
Дисциплины = 103, // + Блоки дисциплин
Аудитории = 103,
Преподаватели = 104, // + должности, звания
Дисциплины = 104, // + Блоки дисциплин
Преподаватели = 105, // + должности, звания
Направления = 102,

View File

@ -58,6 +58,7 @@ namespace DepartmentBusinessLogic.BindingModels
[MapConfiguration("Photo")]
public byte[] Photo { get; set; }
[Required(ErrorMessage = "required")]
[MapConfiguration("GroupElectricalSafety")]
public string GroupElectricalSafety { get; set; }
}

View File

@ -1,41 +0,0 @@
using ModuleTools.Attributes;
using ModuleTools.BindingModels;
using System;
using System.ComponentModel.DataAnnotations;
namespace DepartmentBusinessLogic.BindingModels
{
/// <summary>
/// Получение связи сотрудника с должностью
/// </summary>
public class EmployeeEmployeePostGetBindingModel : GetBindingModel
{
public Guid? EmployeeId { get; set; }
public Guid? EmployeePostId { get; set; }
}
/// <summary>
/// Сохранение связи сотрудника с должностью
/// </summary>
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; }
}
}

View File

@ -1,27 +1,41 @@
using ModuleTools.Attributes;
using ModuleTools.BindingModels;
using System;
using System.ComponentModel.DataAnnotations;
namespace DepartmentBusinessLogic.BindingModels
{
/// <summary>
/// Получение должности сотрудника
/// </summary>
/// <summary>
/// Получение связи сотрудника с должностью
/// </summary>
public class EmployeePostGetBindingModel : GetBindingModel
{
}
{
public Guid? EmployeeId { get; set; }
/// <summary>
/// Сохранение должности сотрудника
/// </summary>
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; }
}
/// <summary>
/// Сохранение связи сотрудника с должностью
/// </summary>
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; }
}
}

View File

@ -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; }
}
}

View File

@ -1,41 +0,0 @@
using ModuleTools.Attributes;
using ModuleTools.BindingModels;
using System;
using System.ComponentModel.DataAnnotations;
namespace DepartmentBusinessLogic.BindingModels
{
/// <summary>
/// Получение связи преподавателя с должностью
/// </summary>
public class LecturerEmployeePostGetBindingModel : GetBindingModel
{
public Guid? LecturerId { get; set; }
public Guid? EmployeePostId { get; set; }
}
/// <summary>
/// Сохранение связи преподавателя с должностью
/// </summary>
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; }
}
}

View File

@ -1,31 +1,41 @@
using ModuleTools.Attributes;
using ModuleTools.BindingModels;
using System;
using System.ComponentModel.DataAnnotations;
namespace DepartmentBusinessLogic.BindingModels
{
/// <summary>
/// Получение должности преподавателя
/// Получение связи преподавателя с должностью
/// </summary>
public class LecturerPostGetBindingModel : GetBindingModel
{
}
{
public Guid? LecturerId { get; set; }
/// <summary>
/// Сохранение должности преподавателя
/// </summary>
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; }
/// <summary>
/// Сохранение связи преподавателя с должностью
/// </summary>
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; }
}
}

View File

@ -0,0 +1,31 @@
using ModuleTools.Attributes;
using ModuleTools.BindingModels;
using System.ComponentModel.DataAnnotations;
namespace DepartmentBusinessLogic.BindingModels
{
/// <summary>
/// Получение должности сотрудника
/// </summary>
public class PostGetBindingModel : GetBindingModel
{
}
/// <summary>
/// Сохранение должности сотрудника
/// </summary>
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; }
}
}

View File

@ -1,16 +0,0 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.Interfaces;
using DepartmentBusinessLogic.ViewModels;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
namespace DepartmentBusinessLogic.BusinessLogics
{
/// <summary>
/// Логика работы со связями сотрудников и должностей
/// </summary>
public class EmployeeEmployeePostBusinessLogic : GenericBusinessLogic<EmployeeEmployeePostGetBindingModel, EmployeeEmployeePostSetBindingModel, EmployeeEmployeePostListViewModel, EmployeeEmployeePostViewModel>
{
public EmployeeEmployeePostBusinessLogic(IEmployeeEmployeePostService service) : base(service, "Должности сотрудников", AccessOperation.Сотрудники) { }
}
}

View File

@ -7,7 +7,7 @@ using ModuleTools.Enums;
namespace DepartmentBusinessLogic.BusinessLogics
{
/// <summary>
/// Логика работы с должностями сотрудников
/// Логика работы со связями сотрудников и должностей
/// </summary>
public class EmployeePostBusinessLogic : GenericBusinessLogic<EmployeePostGetBindingModel, EmployeePostSetBindingModel, EmployeePostListViewModel, EmployeePostViewModel>
{

View File

@ -1,16 +0,0 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.Interfaces;
using DepartmentBusinessLogic.ViewModels;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
namespace DepartmentBusinessLogic.BusinessLogics
{
/// <summary>
/// Логика работы со связями преподавателей и должностей
/// </summary>
public class LecturerEmployeePostBusinessLogic : GenericBusinessLogic<LecturerEmployeePostGetBindingModel, LecturerEmployeePostSetBindingModel, LecturerEmployeePostListViewModel, LecturerEmployeePostViewModel>
{
public LecturerEmployeePostBusinessLogic(ILecturerEmployeePostService service) : base(service, "Преподаватели", AccessOperation.Преподаватели) { }
}
}

View File

@ -7,7 +7,7 @@ using ModuleTools.Enums;
namespace DepartmentBusinessLogic.BusinessLogics
{
/// <summary>
/// Логика работы с должностями преподавателей
/// Логика работы со связями преподавателей и должностей
/// </summary>
public class LecturerPostBusinessLogic : GenericBusinessLogic<LecturerPostGetBindingModel, LecturerPostSetBindingModel, LecturerPostListViewModel, LecturerPostViewModel>
{

View File

@ -0,0 +1,16 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.Interfaces;
using DepartmentBusinessLogic.ViewModels;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
namespace DepartmentBusinessLogic.BusinessLogics
{
/// <summary>
/// Логика работы с должностями
/// </summary>
public class PostBusinessLogic : GenericBusinessLogic<PostGetBindingModel, PostSetBindingModel, PostListViewModel, PostViewModel>
{
public PostBusinessLogic(IPostService service) : base(service, "Должности", AccessOperation.Сотрудники) { }
}
}

View File

@ -1,10 +0,0 @@
using DepartmentBusinessLogic.BindingModels;
using ModuleTools.Interfaces;
namespace DepartmentBusinessLogic.Interfaces
{
/// <summary>
/// Хранение связей сотрудников и должностей
/// </summary>
public interface IEmployeeEmployeePostService : IGenerticEntityService<EmployeeEmployeePostGetBindingModel, EmployeeEmployeePostSetBindingModel> { }
}

View File

@ -4,7 +4,7 @@ using ModuleTools.Interfaces;
namespace DepartmentBusinessLogic.Interfaces
{
/// <summary>
/// Хранение должностей сотрудников
/// Хранение связей сотрудников и должностей
/// </summary>
public interface IEmployeePostService : IGenerticEntityService<EmployeePostGetBindingModel, EmployeePostSetBindingModel> { }
}

View File

@ -1,10 +0,0 @@
using DepartmentBusinessLogic.BindingModels;
using ModuleTools.Interfaces;
namespace DepartmentBusinessLogic.Interfaces
{
/// <summary>
/// Хранение должностей преподавателей
/// </summary>
public interface ILecturerEmployeePostService : IGenerticEntityService<LecturerEmployeePostGetBindingModel, LecturerEmployeePostSetBindingModel> { }
}

View File

@ -0,0 +1,10 @@
using DepartmentBusinessLogic.BindingModels;
using ModuleTools.Interfaces;
namespace DepartmentBusinessLogic.Interfaces
{
/// <summary>
/// Хранение должностей
/// </summary>
public interface IPostService : IGenerticEntityService<PostGetBindingModel, PostSetBindingModel> { }
}

View File

@ -1,56 +0,0 @@
using ModuleTools.Attributes;
using ModuleTools.Enums;
using ModuleTools.ViewModels;
using System;
namespace DepartmentBusinessLogic.ViewModels
{
/// <summary>
/// Список связей сотрудников и должностей
/// </summary>
public class EmployeeEmployeePostListViewModel : ListViewModel<EmployeeEmployeePostViewModel> { }
/// <summary>
/// Связь сотрудника и должности
/// </summary>
[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}";
}
}

View File

@ -1,34 +1,56 @@
using ModuleTools.Attributes;
using ModuleTools.Enums;
using ModuleTools.ViewModels;
using System;
namespace DepartmentBusinessLogic.ViewModels
{
/// <summary>
/// Список должностей сотрудников
/// </summary>
public class EmployeePostListViewModel : ListViewModel<EmployeePostViewModel> { }
/// <summary>
/// Список связей сотрудников и должностей
/// </summary>
public class EmployeePostListViewModel : ListViewModel<EmployeePostViewModel> { }
/// <summary>
/// Элемент должности сотрудников
/// </summary>
[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; }
/// <summary>
/// Связь сотрудника и должности
/// </summary>
[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}";
}
}

View File

@ -16,7 +16,7 @@ namespace DepartmentBusinessLogic.ViewModels
/// </summary>
[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

View File

@ -8,13 +8,13 @@ namespace DepartmentBusinessLogic.ViewModels
/// <summary>
/// Список связей преподавателей и должностей
/// </summary>
public class LecturerEmployeePostListViewModel : ListViewModel<LecturerEmployeePostViewModel> { }
public class LecturerPostListViewModel : ListViewModel<LecturerPostViewModel> { }
/// <summary>
/// Связь преподавателя и должности
/// </summary>
[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}";
}
}

View File

@ -16,26 +16,13 @@ namespace DepartmentBusinessLogic.ViewModels
/// </summary>
[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)}";
}

View File

@ -5,33 +5,37 @@ using ModuleTools.ViewModels;
namespace DepartmentBusinessLogic.ViewModels
{
/// <summary>
/// Список должностей преподавателей
/// Список должностей
/// </summary>
public class LecturerPostListViewModel : ListViewModel<LecturerPostViewModel> { }
public class PostListViewModel : ListViewModel<PostViewModel> { }
/// <summary>
/// Элемент должности преподавателей
/// Элемент должности
/// </summary>
[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;
}
}

View File

@ -9,9 +9,9 @@ namespace DepartmentDatabaseImplementation
{
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IEmployeePostService, EmployeePostService>();
DependencyManager.Instance.RegisterType<IPostService, PostService>();
DependencyManager.Instance.RegisterType<IEmployeeService, EmployeeService>();
DependencyManager.Instance.RegisterType<IEmployeeEmployeePostService, EmployeeEmployeePostService>();
DependencyManager.Instance.RegisterType<IEmployeePostService, EmployeePostService>();
DependencyManager.Instance.RegisterType<IClassroomService, ClassroomService>();
@ -20,7 +20,6 @@ namespace DepartmentDatabaseImplementation
DependencyManager.Instance.RegisterType<ILecturerAcademicDegreeService, LecturerAcademicDegreeService>();
DependencyManager.Instance.RegisterType<ILecturerAcademicRankService, LecturerAcademicRankService>();
DependencyManager.Instance.RegisterType<ILecturerEmployeePostService, LecturerEmployeePostService>();
DependencyManager.Instance.RegisterType<ILecturerPostService, LecturerPostService>();
DependencyManager.Instance.RegisterType<ILecturerService, LecturerService>();
}

View File

@ -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
/// <summary>
/// Реализация интерфейса IClassroomService
/// </summary>
public class ClassroomService : IClassroomService
public class ClassroomService :
AbstractGenerticEntityService<ClassroomGetBindingModel, ClassroomSetBindingModel, Classroom, ClassroomListViewModel, ClassroomViewModel>,
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<Classroom> AdditionalCheckingWhenReadingList(IQueryable<Classroom> 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<ClassroomSetBindingModel, Classroom>(model, true);
context.Classrooms.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<Classroom, ClassroomViewModel>(entity, true));
}
else
{
if (exsistEntity.IsDeleted)
{
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
exsistEntity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<Classroom, ClassroomViewModel>(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<Classroom, ClassroomViewModel>(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<Classroom, ClassroomViewModel>(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<Classroom>().FirstOrDefault(x => x.Number == model.Number && x.Id != model.Id);
return OperationResultModel.Success(Mapper.MapToClass<Classroom, ClassroomViewModel>(entity, true));
}
protected override IQueryable<Classroom> IncludingWhenReading(IQueryable<Classroom> query) => query.Include(x => x.Employee);
protected override IQueryable<Classroom> OrderingWhenReading(IQueryable<Classroom> query) => query.OrderBy(x => x.Number);
}
}

View File

@ -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
/// <summary>
/// Реализация IDisciplineBlockService
/// </summary>
public class DisciplineBlockService : IDisciplineBlockService
public class DisciplineBlockService :
AbstractGenerticEntityService<DisciplineBlockGetBindingModel, DisciplineBlockSetBindingModel, DisciplineBlock, DisciplineBlockListViewModel, DisciplineBlockViewModel>,
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<DisciplineBlockSetBindingModel, DisciplineBlock>(model, true);
context.DisciplineBlocks.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<DisciplineBlock, DisciplineBlockViewModel>(entity, true));
}
else
{
if (exsistEntity.IsDeleted)
{
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
exsistEntity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<DisciplineBlock, DisciplineBlockViewModel>(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<Discipline>().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<DisciplineBlock> AdditionalCheckingWhenReadingList(IQueryable<DisciplineBlock> 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<DisciplineBlock, DisciplineBlockViewModel>(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<DisciplineBlock>().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<DisciplineBlock> IncludingWhenReading(IQueryable<DisciplineBlock> query) => query;
var result = new DisciplineBlockListViewModel
{
MaxCount = countPages,
List = query.Select(x => Mapper.MapToClass<DisciplineBlock, DisciplineBlockViewModel>(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<DisciplineBlock, DisciplineBlockViewModel>(entity, true));
}
protected override IQueryable<DisciplineBlock> OrderingWhenReading(IQueryable<DisciplineBlock> query) => query.OrderBy(x => x.DisciplineBlockOrder);
}
}

View File

@ -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
/// <summary>
/// Реализация IDisciplineService
/// </summary>
public class DisciplineService : IDisciplineService
public class DisciplineService :
AbstractGenerticEntityService<DisciplineGetBindingModel, DisciplineSetBindingModel, Discipline, DisciplineListViewModel, DisciplineViewModel>,
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<Discipline> AdditionalCheckingWhenReadingList(IQueryable<Discipline> 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<DisciplineSetBindingModel, Discipline>(model, true);
context.Disciplines.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<Discipline, DisciplineViewModel>(entity, true));
}
else
{
if (exsistEntity.IsDeleted)
{
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
exsistEntity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<Discipline, DisciplineViewModel>(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<Discipline, DisciplineViewModel>(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<Discipline, DisciplineViewModel>(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<Discipline>().FirstOrDefault(x => x.DisciplineName == model.DisciplineName && x.Id != model.Id);
return OperationResultModel.Success(Mapper.MapToClass<Discipline, DisciplineViewModel>(entity, true));
}
protected override IQueryable<Discipline> IncludingWhenReading(IQueryable<Discipline> query) => query.Include(x => x.DisciplineBlock);
protected override IQueryable<Discipline> OrderingWhenReading(IQueryable<Discipline> query) => query.OrderBy(x => x.DisciplineBlock.DisciplineBlockOrder).ThenBy(x => x.DisciplineName);
}
}

View File

@ -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
{
/// <summary>
/// Реализация IEmployeeEmployeePostService
/// </summary>
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<EmployeeEmployeePostSetBindingModel, EmployeeEmployeePost>(model, true);
context.EmployeeEmployeePosts.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<EmployeeEmployeePost, EmployeeEmployeePostViewModel>(entity, true));
}
else
{
if (exsistEntity.IsDeleted)
{
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
exsistEntity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<EmployeeEmployeePost, EmployeeEmployeePostViewModel>(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<EmployeeEmployeePost, EmployeeEmployeePostViewModel>(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<EmployeeEmployeePost, EmployeeEmployeePostViewModel>(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<EmployeeEmployeePost, EmployeeEmployeePostViewModel>(entity, true));
}
}
}

View File

@ -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
/// <summary>
/// Реализация IEmployeePostService
/// </summary>
public class EmployeePostService : IEmployeePostService
public class EmployeePostService :
AbstractGenerticEntityService<EmployeePostGetBindingModel, EmployeePostSetBindingModel, EmployeePost, EmployeePostListViewModel, EmployeePostViewModel>,
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<EmployeePost> AdditionalCheckingWhenReadingList(IQueryable<EmployeePost> query, EmployeePostGetBindingModel model)
{
if (model.PostId.HasValue)
{
var entity = Mapper.MapToClass<EmployeePostSetBindingModel, EmployeePost>(model, true);
context.EmployeePosts.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<EmployeePost, EmployeePostViewModel>(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<EmployeePost, EmployeePostViewModel>(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<EmployeePost>().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<EmployeePost> IncludingWhenReading(IQueryable<EmployeePost> 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<EmployeePost, EmployeePostViewModel>(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<EmployeePost, EmployeePostViewModel>(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<EmployeePost, EmployeePostViewModel>(entity, true));
}
protected override IQueryable<EmployeePost> OrderingWhenReading(IQueryable<EmployeePost> query) => query.OrderBy(x => x.Employee.LastName);
}
}

View File

@ -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
/// <summary>
/// Реализация IEmployeeService
/// </summary>
public class EmployeeService : IEmployeeService
public class EmployeeService :
AbstractGenerticEntityService<EmployeeGetBindingModel, EmployeeSetBindingModel, Employee, EmployeeListViewModel, EmployeeViewModel>,
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<EmployeeSetBindingModel, Employee>(model, true);
context.Employees.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<Employee, EmployeeViewModel>(entity, true));
return OperationResultModel.Error("Error:", "Не найден пользователь от сотрудника", ResultServiceStatusCode.NotFound);
}
else
if (context.Set<Classroom>().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<Employee, EmployeeViewModel>(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<Employee> AdditionalCheckingWhenReadingList(IQueryable<Employee> 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<Employee, EmployeeViewModel>(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<Employee, EmployeeViewModel>(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<Employee, EmployeeViewModel>(entity, true));
var links = context.Set<EmployeePost>().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<Employee>().FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName &&
x.Patronymic == model.Patronymic && x.Id != model.Id);
protected override IQueryable<Employee> IncludingWhenReading(IQueryable<Employee> query) => query
.Include(x => x.EmployeePosts).Include("EmployeePosts.Post");
protected override IQueryable<Employee> OrderingWhenReading(IQueryable<Employee> query) => query
.OrderByDescending(x => x.EmployeePosts.Max(y => y.Post.Order))
.ThenBy(x => x.LastName)
.ThenBy(x => x.FirstName);
}
}

View File

@ -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
/// <summary>
/// Реализация ILecturerAcademicDegreeService
/// </summary>
public class LecturerAcademicDegreeService : ILecturerAcademicDegreeService
public class LecturerAcademicDegreeService :
AbstractGenerticEntityService<LecturerAcademicDegreeGetBindingModel, LecturerAcademicDegreeSetBindingModel, LecturerAcademicDegree, LecturerAcademicDegreeListViewModel, LecturerAcademicDegreeViewModel>,
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<LecturerAcademicDegreeSetBindingModel, LecturerAcademicDegree>(model, true);
context.LecturerAcademicDegrees.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<LecturerAcademicDegree, LecturerAcademicDegreeViewModel>(entity, true));
}
else
{
if (exsistEntity.IsDeleted)
{
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
exsistEntity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<LecturerAcademicDegree, LecturerAcademicDegreeViewModel>(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<Lecturer>().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<LecturerAcademicDegree> AdditionalCheckingWhenReadingList(IQueryable<LecturerAcademicDegree> 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<LecturerAcademicDegree, LecturerAcademicDegreeViewModel>(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<LecturerAcademicDegree>().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<LecturerAcademicDegree> IncludingWhenReading(IQueryable<LecturerAcademicDegree> query) => query;
var result = new LecturerAcademicDegreeListViewModel
{
MaxCount = countPages,
List = query.Select(x => Mapper.MapToClass<LecturerAcademicDegree, LecturerAcademicDegreeViewModel>(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<LecturerAcademicDegree, LecturerAcademicDegreeViewModel>(entity, true));
}
protected override IQueryable<LecturerAcademicDegree> OrderingWhenReading(IQueryable<LecturerAcademicDegree> query) => query.OrderBy(x => x.Order);
}
}

View File

@ -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
/// <summary>
/// Реализация ILecturerAcademicRankService
/// </summary>
public class LecturerAcademicRankService : ILecturerAcademicRankService
public class LecturerAcademicRankService :
AbstractGenerticEntityService<LecturerAcademicRankGetBindingModel, LecturerAcademicRankSetBindingModel, LecturerAcademicRank, LecturerAcademicRankListViewModel, LecturerAcademicRankViewModel>,
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<LecturerAcademicRankSetBindingModel, LecturerAcademicRank>(model, true);
context.LecturerAcademicRanks.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<LecturerAcademicRank, LecturerAcademicRankViewModel>(entity, true));
}
else
{
if (exsistEntity.IsDeleted)
{
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
exsistEntity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<LecturerAcademicRank, LecturerAcademicRankViewModel>(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<Lecturer>().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<LecturerAcademicRank> AdditionalCheckingWhenReadingList(IQueryable<LecturerAcademicRank> 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<LecturerAcademicRank, LecturerAcademicRankViewModel>(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<LecturerAcademicRank>().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<LecturerAcademicRank> IncludingWhenReading(IQueryable<LecturerAcademicRank> query) => query;
var result = new LecturerAcademicRankListViewModel
{
MaxCount = countPages,
List = query.Select(x => Mapper.MapToClass<LecturerAcademicRank, LecturerAcademicRankViewModel>(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<LecturerAcademicRank, LecturerAcademicRankViewModel>(entity, true));
}
protected override IQueryable<LecturerAcademicRank> OrderingWhenReading(IQueryable<LecturerAcademicRank> query) => query.OrderBy(x => x.Order);
}
}

View File

@ -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
{
/// <summary>
/// Реализация ILecturerEmployeePostService
/// </summary>
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<LecturerEmployeePostSetBindingModel, LecturerEmployeePost>(model, true);
context.LecturerEmployeePosts.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<LecturerEmployeePost, LecturerEmployeePostViewModel>(entity, true));
}
else
{
if (exsistEntity.IsDeleted)
{
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
exsistEntity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<LecturerEmployeePost, LecturerEmployeePostViewModel>(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<LecturerEmployeePost, LecturerEmployeePostViewModel>(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<LecturerEmployeePost, LecturerEmployeePostViewModel>(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<LecturerEmployeePost, LecturerEmployeePostViewModel>(entity, true));
}
}
}

View File

@ -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
/// <summary>
/// Реализация ILecturerPostService
/// </summary>
public class LecturerPostService : ILecturerPostService
public class LecturerPostService :
AbstractGenerticEntityService<LecturerPostGetBindingModel, LecturerPostSetBindingModel, LecturerPost, LecturerPostListViewModel, LecturerPostViewModel>,
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<LecturerPost> AdditionalCheckingWhenReadingList(IQueryable<LecturerPost> query, LecturerPostGetBindingModel model)
{
if (model.PostId.HasValue)
{
var entity = Mapper.MapToClass<LecturerPostSetBindingModel, LecturerPost>(model, true);
context.LecturerPosts.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<LecturerPost, LecturerPostViewModel>(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<LecturerPost, LecturerPostViewModel>(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<LecturerPost>().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<LecturerPost> IncludingWhenReading(IQueryable<LecturerPost> 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<LecturerPost, LecturerPostViewModel>(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<LecturerPost, LecturerPostViewModel>(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<LecturerPost, LecturerPostViewModel>(entity, true));
}
protected override IQueryable<LecturerPost> OrderingWhenReading(IQueryable<LecturerPost> query) => query.OrderBy(x => x.Lecturer.LastName);
}
}

View File

@ -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
/// <summary>
/// Реализация ILecturerService
/// </summary>
public class LecturerService : ILecturerService
public class LecturerService :
AbstractGenerticEntityService<LecturerGetBindingModel, LecturerSetBindingModel, Lecturer, LecturerListViewModel, LecturerViewModel>,
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<LecturerSetBindingModel, Lecturer>(model, true);
context.Lecturers.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<Lecturer, LecturerViewModel>(entity, true));
}
else
{
if (exsistEntity.IsDeleted)
{
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
exsistEntity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<Lecturer, LecturerViewModel>(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<Lecturer> AdditionalCheckingWhenReadingList(IQueryable<Lecturer> 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<Lecturer, LecturerViewModel>(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<Lecturer, LecturerViewModel>(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<Lecturer, LecturerViewModel>(entity, true));
var links = context.Set<LecturerPost>().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<Lecturer>().FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName &&
x.Patronymic == model.Patronymic && x.Id != model.Id);
protected override IQueryable<Lecturer> IncludingWhenReading(IQueryable<Lecturer> query)
{
return query
.Include(x => x.LecturerAcademicRank)
.Include(x => x.LecturerAcademicDegree)
.Include(x => x.LecturerPosts).Include("LecturerPosts.Post");
}
protected override IQueryable<Lecturer> OrderingWhenReading(IQueryable<Lecturer> 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);
}
}

View File

@ -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
{
/// <summary>
/// Реализация IEmployeePostService
/// </summary>
public class PostService :
AbstractGenerticEntityService<PostGetBindingModel, PostSetBindingModel, Post, PostListViewModel, PostViewModel>,
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<EmployeePost>().Any(x => x.PostId == model.Id && !x.IsDeleted))
{
return OperationResultModel.Error("Error:", "Существуют сотрудники с этой должностью", ResultServiceStatusCode.ExsistItem);
}
if (context.Set<LecturerPost>().Any(x => x.PostId == model.Id && !x.IsDeleted))
{
return OperationResultModel.Error("Error:", "Существуют преподаватели с этой должностью", ResultServiceStatusCode.ExsistItem);
}
return OperationResultModel.Success(null);
}
protected override IQueryable<Post> AdditionalCheckingWhenReadingList(IQueryable<Post> 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<Post>().FirstOrDefault(x => x.PostName == model.PostName && x.Id != model.Id);
protected override IQueryable<Post> IncludingWhenReading(IQueryable<Post> query) => query;
protected override IQueryable<Post> OrderingWhenReading(IQueryable<Post> query) => query.OrderBy(x => x.Order);
}
}

View File

@ -32,14 +32,13 @@ namespace DepartmentWindowsDesktop
};
List<IControl> _controls = new()
{
new ControlEmployeePostList(),
new ControlPostList(),
new ControlEmployeeList(),
new ControlClassroomList(),
new ControlDisciplineBlockList(),
new ControlDisciplineList(),
new ControlLecturerAcademicDegreeList(),
new ControlLecturerAcademicRankList(),
new ControlLecturerPostList(),
new ControlLecturerList()
};

View File

@ -1,33 +0,0 @@

namespace DepartmentWindowsDesktop.EntityControls
{
partial class ControlEmployeeEmployeePostElement
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View File

@ -1,27 +0,0 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using System;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для связи сотрудника с должностью
/// </summary>
public partial class ControlEmployeeEmployeePostElement :
GenericControlEntityElement<EmployeeEmployeePostGetBindingModel, EmployeeEmployeePostSetBindingModel, EmployeeEmployeePostListViewModel, EmployeeEmployeePostViewModel, EmployeeEmployeePostBusinessLogic>,
IGenericControlEntityElement
{
public ControlEmployeeEmployeePostElement()
{
InitializeComponent();
Title = "Связи сотрудников с должностями";
ControlId = new Guid("bdc9a6ef-968c-4d8e-bc19-aa15485cc855");
_genericControlViewEntityElement = this;
}
public IControl GetInstanceGenericControl() => new ControlEmployeeEmployeePostElement() { ControlId = Guid.NewGuid() };
}
}

View File

@ -8,7 +8,7 @@ using System;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для должности
/// Реализация контрола для связи сотрудника с должностью
/// </summary>
public partial class ControlEmployeePostElement :
GenericControlEntityElement<EmployeePostGetBindingModel, EmployeePostSetBindingModel, EmployeePostListViewModel, EmployeePostViewModel, EmployeePostBusinessLogic>,
@ -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;
}

View File

@ -12,7 +12,7 @@ using System.Collections.Generic;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для списка должностей сотрудников
/// Реализация контрола для списка должностней сотрудника
/// </summary>
public partial class ControlEmployeePostList :
GenericControlEntityList<EmployeePostGetBindingModel, EmployeePostSetBindingModel, EmployeePostListViewModel, EmployeePostViewModel, EmployeePostBusinessLogic>,
@ -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>
{
ToolStripButtonListNames.toolStripButtonUpd,
ToolStripButtonListNames.toolStripButtonSearch
}
};

View File

@ -1,33 +0,0 @@

namespace DepartmentWindowsDesktop.EntityControls
{
partial class ControlLecturerEmployeePostElement
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View File

@ -1,27 +0,0 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using System;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для сязи преподавателя и должности
/// </summary>
public partial class ControlLecturerEmployeePostElement :
GenericControlEntityElement<LecturerEmployeePostGetBindingModel, LecturerEmployeePostSetBindingModel, LecturerEmployeePostListViewModel, LecturerEmployeePostViewModel, LecturerEmployeePostBusinessLogic>,
IGenericControlEntityElement
{
public ControlLecturerEmployeePostElement()
{
InitializeComponent();
Title = "Связи преподавателей с должностями";
ControlId = new Guid("88f4b4e5-68ff-4a84-9f38-dc9952cc635f");
_genericControlViewEntityElement = this;
}
public IControl GetInstanceGenericControl() => new ControlLecturerEmployeePostElement() { ControlId = Guid.NewGuid() };
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -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<LecturerEmployeePostGetBindingModel, LecturerEmployeePostSetBindingModel, LecturerEmployeePostListViewModel, LecturerEmployeePostViewModel, LecturerEmployeePostBusinessLogic>,
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>
{
ToolStripButtonListNames.toolStripButtonUpd,
ToolStripButtonListNames.toolStripButtonSearch
}
};
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -8,7 +8,7 @@ using System;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для должности преподавателя
/// Реализация контрола для сязи преподавателя и должности
/// </summary>
public partial class ControlLecturerPostElement :
GenericControlEntityElement<LecturerPostGetBindingModel, LecturerPostSetBindingModel, LecturerPostListViewModel, LecturerPostViewModel, LecturerPostBusinessLogic>,
@ -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;
}

View File

@ -11,9 +11,6 @@ using System.Collections.Generic;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для списка должностей преподавателей
/// </summary>
public partial class ControlLecturerPostList :
GenericControlEntityList<LecturerPostGetBindingModel, LecturerPostSetBindingModel, LecturerPostListViewModel, LecturerPostViewModel, LecturerPostBusinessLogic>,
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>
{
ToolStripButtonListNames.toolStripButtonUpd,
ToolStripButtonListNames.toolStripButtonSearch
}
};

View File

@ -1,7 +1,7 @@

namespace DepartmentWindowsDesktop.EntityControls
{
partial class ControlLecturerEmployeePostList
partial class ControlPostElement
{
/// <summary>
/// Освободить все используемые ресурсы.

View File

@ -0,0 +1,27 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using System;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для должности
/// </summary>
public partial class ControlPostElement :
GenericControlEntityElement<PostGetBindingModel, PostSetBindingModel, PostListViewModel, PostViewModel, PostBusinessLogic>,
IGenericControlEntityElement
{
public ControlPostElement()
{
InitializeComponent();
Title = "Должность";
ControlId = new Guid("25700525-7765-46c3-bbbf-a842f31bd898");
_genericControlViewEntityElement = this;
}
public IControl GetInstanceGenericControl() => new ControlPostElement() { ControlId = Guid.NewGuid() };
}
}

View File

@ -1,7 +1,7 @@

namespace DepartmentWindowsDesktop.EntityControls
{
partial class ControlEmployeeEmployeePostList
partial class ControlPostList
{
/// <summary>
/// Освободить все используемые ресурсы.

View File

@ -12,30 +12,29 @@ using System.Collections.Generic;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для списка должностней сотрудника
/// Реализация контрола для списка должностей
/// </summary>
public partial class ControlEmployeeEmployeePostList :
GenericControlEntityList<EmployeeEmployeePostGetBindingModel, EmployeeEmployeePostSetBindingModel, EmployeeEmployeePostListViewModel, EmployeeEmployeePostViewModel, EmployeeEmployeePostBusinessLogic>,
public partial class ControlPostList :
GenericControlEntityList<PostGetBindingModel, PostSetBindingModel, PostListViewModel, PostViewModel, PostBusinessLogic>,
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>
{
ToolStripButtonListNames.toolStripButtonUpd,
ToolStripButtonListNames.toolStripButtonSearch
}
};

View File

@ -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<Access> AdditionalCheckingWhenReadingList(IQueryable<Access> 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<Access>().FirstOrDefault(x => x.AccessOperation == model.AccessOperation && x.RoleId == model.RoleId && x.AccessType == model.AccessType && x.Id != model.Id);

View File

@ -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<EnviromentSetting> AdditionalCheckingWhenReadingList(IQueryable<EnviromentSetting> 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<EnviromentSetting>().FirstOrDefault(x => x.Key == model.Key && x.Id != model.Id);

View File

@ -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<UserRole>().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<Access>().Where(x => x.RoleId == model.Id);
foreach (var ac in access)

View File

@ -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<UserRole> AdditionalCheckingWhenReadingList(IQueryable<UserRole> 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<UserRole>().FirstOrDefault(x => x.UserId == model.UserId && x.RoleId == model.RoleId && x.Id != model.Id);

View File

@ -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<Employee>().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<UserRole>().Where(x => x.UserId == model.Id);
foreach (var u in users)