Сотрудники в БД

This commit is contained in:
kotcheshir73 2021-04-03 09:45:22 +04:00
parent b30c8bdf5b
commit 6c835fd8e5
7 changed files with 910 additions and 4 deletions

View File

@ -1,4 +1,5 @@
using DatabaseCore.Models.Security; using DatabaseCore.Models.Department;
using DatabaseCore.Models.Security;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace DatabaseCore namespace DatabaseCore
@ -30,13 +31,24 @@ namespace DatabaseCore
modelBuilder.Entity<Role>().HasIndex(s => s.RoleName).IsUnique(); modelBuilder.Entity<Role>().HasIndex(s => s.RoleName).IsUnique();
modelBuilder.Entity<User>().HasIndex(s => s.UserName).IsUnique(); modelBuilder.Entity<User>().HasIndex(s => s.UserName).IsUnique();
modelBuilder.Entity<EmployeePost>().HasIndex(s => s.EmployeePostName).IsUnique();
modelBuilder.Entity<Employee>().HasIndex(p => new { p.FirstName, p.LastName, p.Patronymic }).IsUnique();
} }
#region Security
public virtual DbSet<Access> Accesses { set; get; } public virtual DbSet<Access> Accesses { set; get; }
public virtual DbSet<EnviromentSetting> EnviromentSettings { set; get; } public virtual DbSet<EnviromentSetting> EnviromentSettings { set; get; }
public virtual DbSet<Role> Roles { set; get; } public virtual DbSet<Role> Roles { set; get; }
public virtual DbSet<User> Users { set; get; } public virtual DbSet<User> Users { set; get; }
public virtual DbSet<UserRole> UserRoles { set; get; } public virtual DbSet<UserRole> UserRoles { set; get; }
#endregion
#region Department
public virtual DbSet<EmployeePost> EmployeePosts { set; get; }
public virtual DbSet<Employee> Employees { set; get; }
public virtual DbSet<EmployeeEmployeePost> EmployeeEmployeePosts { set; get; }
#endregion
} }
} }

View File

@ -0,0 +1,379 @@
// <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("20210403054350_AddEmployee")]
partial class AddEmployee
{
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.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("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.EmployeeEmployeePost", 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<Guid>("EmployeePostId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsExternalCombination")
.HasColumnType("bit");
b.Property<bool>("IsInternalCombination")
.HasColumnType("bit");
b.Property<decimal>("Rate")
.HasColumnType("decimal(18,2)");
b.HasKey("Id");
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.ToTable("EmployeePosts");
});
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<string>("Description")
.HasColumnType("nvarchar(max)");
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")
.HasColumnType("nvarchar(450)");
b.Property<int>("RolePriority")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleName")
.IsUnique()
.HasFilter("[RoleName] IS NOT NULL");
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")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("UserName")
.IsUnique()
.HasFilter("[UserName] IS NOT NULL");
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.EmployeeEmployeePost", b =>
{
b.HasOne("DatabaseCore.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseCore.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
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.Employee", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("DatabaseCore.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("DatabaseCore.Models.Security.User", b =>
{
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,178 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace DatabaseCore.Migrations
{
public partial class AddEmployee : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "UserName",
table: "Users",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RoleName",
table: "Roles",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.CreateTable(
name: "EmployeePosts",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
EmployeePostName = table.Column<string>(type: "nvarchar(450)", 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_EmployeePosts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Employees",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
FirstName = table.Column<string>(type: "nvarchar(450)", nullable: true),
LastName = table.Column<string>(type: "nvarchar(450)", nullable: true),
Patronymic = table.Column<string>(type: "nvarchar(450)", nullable: true),
DateBirth = table.Column<DateTime>(type: "datetime2", nullable: false),
Address = table.Column<string>(type: "nvarchar(max)", nullable: true),
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
MobileNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
HomeNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
Photo = table.Column<byte[]>(type: "varbinary(max)", nullable: true),
GroupElectricalSafety = table.Column<string>(type: "nvarchar(max)", nullable: true),
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_Employees", x => x.Id);
});
migrationBuilder.CreateTable(
name: "EmployeeEmployeePosts",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
EmployeeId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
EmployeePostId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Rate = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
IsInternalCombination = table.Column<bool>(type: "bit", nullable: false),
IsExternalCombination = table.Column<bool>(type: "bit", 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_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.CreateIndex(
name: "IX_Users_UserName",
table: "Users",
column: "UserName",
unique: true,
filter: "[UserName] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Roles_RoleName",
table: "Roles",
column: "RoleName",
unique: true,
filter: "[RoleName] 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_EmployeePosts_EmployeePostName",
table: "EmployeePosts",
column: "EmployeePostName",
unique: true,
filter: "[EmployeePostName] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Employees_FirstName_LastName_Patronymic",
table: "Employees",
columns: new[] { "FirstName", "LastName", "Patronymic" },
unique: true,
filter: "[FirstName] IS NOT NULL AND [LastName] IS NOT NULL AND [Patronymic] IS NOT NULL");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "EmployeeEmployeePosts");
migrationBuilder.DropTable(
name: "EmployeePosts");
migrationBuilder.DropTable(
name: "Employees");
migrationBuilder.DropIndex(
name: "IX_Users_UserName",
table: "Users");
migrationBuilder.DropIndex(
name: "IX_Roles_RoleName",
table: "Roles");
migrationBuilder.AlterColumn<string>(
name: "UserName",
table: "Users",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RoleName",
table: "Roles",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
}
}
}

View File

@ -19,6 +19,132 @@ namespace DatabaseCore.Migrations
.HasAnnotation("ProductVersion", "5.0.4") .HasAnnotation("ProductVersion", "5.0.4")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
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("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.EmployeeEmployeePost", 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<Guid>("EmployeePostId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsExternalCombination")
.HasColumnType("bit");
b.Property<bool>("IsInternalCombination")
.HasColumnType("bit");
b.Property<decimal>("Rate")
.HasColumnType("decimal(18,2)");
b.HasKey("Id");
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.ToTable("EmployeePosts");
});
modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => modelBuilder.Entity("DatabaseCore.Models.Security.Access", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -88,13 +214,17 @@ namespace DatabaseCore.Migrations
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<string>("RoleName") b.Property<string>("RoleName")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(450)");
b.Property<int>("RolePriority") b.Property<int>("RolePriority")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("RoleName")
.IsUnique()
.HasFilter("[RoleName] IS NOT NULL");
b.ToTable("Roles"); b.ToTable("Roles");
}); });
@ -131,10 +261,14 @@ namespace DatabaseCore.Migrations
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("UserName") b.Property<string>("UserName")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(450)");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("UserName")
.IsUnique()
.HasFilter("[UserName] IS NOT NULL");
b.ToTable("Users"); b.ToTable("Users");
}); });
@ -167,6 +301,25 @@ namespace DatabaseCore.Migrations
b.ToTable("UserRoles"); b.ToTable("UserRoles");
}); });
modelBuilder.Entity("DatabaseCore.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("DatabaseCore.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseCore.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => modelBuilder.Entity("DatabaseCore.Models.Security.Access", b =>
{ {
b.HasOne("DatabaseCore.Models.Security.Role", "Role") b.HasOne("DatabaseCore.Models.Security.Role", "Role")
@ -197,6 +350,16 @@ namespace DatabaseCore.Migrations
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => modelBuilder.Entity("DatabaseCore.Models.Security.Role", b =>
{ {
b.Navigation("Access"); b.Navigation("Access");

View File

@ -0,0 +1,89 @@
using ModuleTools.Attributes;
using ModuleTools.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace DatabaseCore.Models.Department
{
/// <summary>
/// Класс, описывающий сотрудника в системе
/// </summary>
[DataContract]
[EntityDescription("Employee", "Сотрудника в системе")]
public class Employee : BaseEntity, IEntitySecurityExtenstion<Employee>
{
[DataMember]
[MapConfiguration("UserId")]
public Guid UserId { get; set; }
[DataMember]
[MapConfiguration("FirstName")]
public string FirstName { get; set; }
[DataMember]
[MapConfiguration("LastName")]
public string LastName { get; set; }
[DataMember]
[MapConfiguration("Patronymic")]
public string Patronymic { get; set; }
[DataMember]
[MapConfiguration("DateBirth")]
public DateTime DateBirth { get; set; }
[DataMember]
[MapConfiguration("Address")]
public string Address { get; set; }
[DataMember]
[MapConfiguration("Email")]
public string Email { get; set; }
[DataMember]
[MapConfiguration("MobileNumber")]
public string MobileNumber { get; set; }
[DataMember]
[MapConfiguration("HomeNumber")]
public string HomeNumber { get; set; }
[DataMember]
[MapConfiguration("Description")]
public string Description { get; set; }
[DataMember]
[MapConfiguration("Photo")]
public byte[] Photo { get; set; }
[DataMember]
[MapConfiguration("GroupElectricalSafety")]
public string GroupElectricalSafety { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
[ForeignKey("EmployeeId")]
public virtual List<EmployeeEmployeePost> EmployeeEmployeePosts { get; set; }
//-------------------------------------------------------------------------
public Employee SecurityCheck(Employee entity, bool allowFullData)
{
if (!allowFullData)
{
entity.DateBirth = DateTime.Now;
entity.Address = "скрыто";
entity.Email = "скрыто";
entity.MobileNumber = "скрыто";
entity.HomeNumber = "скрыто";
entity.Photo = null;
}
return entity;
}
}
}

View File

@ -0,0 +1,49 @@
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

@ -0,0 +1,36 @@
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("EmployeePost", "Должность сотрудника в системе")]
public class EmployeePost : BaseEntity, IEntitySecurityExtenstion<EmployeePost>
{
[DataMember]
[MapConfiguration("EmployeePostName")]
public string EmployeePostName { get; set; }
[DataMember]
[MapConfiguration("Order")]
public int Order { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
[ForeignKey("EmployeePostId")]
public virtual List<EmployeeEmployeePost> EmployeeEmployeePosts { get; set; }
//-------------------------------------------------------------------------
public EmployeePost SecurityCheck(EmployeePost entity, bool allowFullData) => entity;
}
}