Замена на CoreDatabase

This commit is contained in:
kotcheshir73 2022-03-18 22:55:48 +04:00
parent d6c066ec0f
commit 2ccbccd6d4
228 changed files with 36243 additions and 1901 deletions

View File

@ -0,0 +1,268 @@
using CoreDatabase.Models;
using Microsoft.EntityFrameworkCore;
using ToolsModule.BindingModels;
using ToolsModule.BusinessLogics;
using ToolsModule.Enums;
using ToolsModule.Interfaces;
using ToolsModule.Models;
using ToolsModule.ViewModels;
using System;
using System.Linq;
namespace CoreDatabase
{
public abstract class AbstractGenerticEntityService<G, S, T, L, E> : IGenerticEntityService<G, S>
where G : GetBindingModel
where S : SetBindingModel
where T : BaseEntity
where L : ListViewModel<E>, new()
where E : ElementViewModel
{
public OperationResultModel Create(S model)
{
using var context = DatabaseManager.GetContext;
var result = AdditionalCheckingWhenAdding(context, model);
if (!result.IsSucceeded)
{
return result;
}
var exsistEntity = GetUniqueEntity(model, context);
if (exsistEntity == null)
{
var entity = Mapper.MapToClass<S, T>(model, true);
context.Set<T>().Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<T, E>(entity, true));
}
else
{
if (exsistEntity.IsDeleted)
{
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
exsistEntity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<T, E>(exsistEntity, true));
}
else
{
return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem);
}
}
}
public OperationResultModel Delete(G model)
{
using var context = DatabaseManager.GetContext;
using var transaction = context.Database.BeginTransaction();
try
{
var entity = context.Set<T>().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);
}
var result = AdditionalCheckingWhenDeleting(context, entity, model);
if (!result.IsSucceeded)
{
return result;
}
entity.IsDeleted = true;
entity.DateDelete = DateTime.Now;
context.SaveChanges();
AdditionalDeleting(context, entity, model);
transaction.Commit();
}
catch (Exception)
{
transaction.Rollback();
throw;
}
return OperationResultModel.Success(true);
}
public OperationResultModel Restore(G model)
{
if (model.Id.HasValue || AdditionalCheckForSingleGet(model))
{
using var context = DatabaseManager.GetContext;
var entity = model.Id.HasValue ? IncludingWhenReading(context.Set<T>().AsQueryable()).FirstOrDefault(x => x.Id == model.Id.Value)
: GetSingleRecord(context.Set<T>().AsQueryable(), model);
if (entity == null)
{
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
}
else if (!entity.IsDeleted)
{
return OperationResultModel.Error("Error:", "Элемент не был удален", ResultServiceStatusCode.ExsistItem);
}
entity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<T, E>(entity, true));
}
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
}
public OperationResultModel Read(G model)
{
int countPages = 0;
using var context = DatabaseManager.GetContext;
// для одной записи
if (model.Id.HasValue || AdditionalCheckForSingleGet(model))
{
var entity = model.Id.HasValue ? IncludingWhenReading(context.Set<T>().AsQueryable()).FirstOrDefault(x => x.Id == model.Id.Value)
: GetSingleRecord(context.Set<T>().AsQueryable(), model);
if (entity == null)
{
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
}
if (entity.IsDeleted)
{
return OperationResultModel.Error("Error:", "Элемент удален", ResultServiceStatusCode.WasDelete);
}
return OperationResultModel.Success(Mapper.MapToClass<T, E>(entity, model.HaveRight));
}
var query = context.Set<T>().Where(x => !x.IsDeleted).AsQueryable();
query = AdditionalCheckingWhenReadingList(query, model);
query = OrderingWhenReading(query);
query = IncludingWhenReading(query);
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 L
{
MaxCount = countPages,
List = query.Select(x => Mapper.MapToClass<T, E>(x, model.HaveRight)).ToList()
};
return OperationResultModel.Success(result);
}
public OperationResultModel Update(S model)
{
using var context = DatabaseManager.GetContext;
var result = AdditionalCheckingWhenUpdateing(context, model);
if (!result.IsSucceeded)
{
return result;
}
var exsistEntity = GetUniqueEntity(model, context);
if (exsistEntity != null)
{
return OperationResultModel.Error("Error:", "Существует запись с такими значениями", ResultServiceStatusCode.ExsistItem);
}
var entity = context.Set<T>().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<T, E>(entity, true));
}
/// <summary>
/// Поиск записи с уникальными значениями
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
protected abstract T GetUniqueEntity(S model, DbContext context);
/// <summary>
/// Возможные дополнительные проверки при добавлении
/// </summary>
/// <param name="context"></param>
/// <param name="model"></param>
/// <returns></returns>
protected abstract OperationResultModel AdditionalCheckingWhenAdding(DbContext context, S model);
/// <summary>
/// Возможные дополнительные проверки при удалении
/// </summary>
/// <param name="context"></param>
/// <param name="model"></param>
/// <returns></returns>
protected abstract OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, T entity, G model);
/// <summary>
/// Добавление дополнительных фильтров
/// </summary>
/// <param name="query"></param>
/// <param name="model"></param>
/// <returns></returns>
protected abstract IQueryable<T> AdditionalCheckingWhenReadingList(IQueryable<T> query, G model);
/// <summary>
/// Возможные дополнительные проверки модели при изменении
/// </summary>
/// <param name="model"></param>
protected abstract OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, S model);
/// <summary>
/// Дополнительные удаления зависимых сущностей
/// </summary>
/// <param name="model"></param>
protected abstract void AdditionalDeleting(DbContext context, T entity, G model);
/// <summary>
/// Установка сортировок
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
protected abstract IQueryable<T> OrderingWhenReading(IQueryable<T> query);
/// <summary>
/// Добавление Include
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
protected abstract IQueryable<T> IncludingWhenReading(IQueryable<T> query);
/// <summary>
/// Дополнительыне проверки, если требуется получать единичную запись но не по id
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
protected virtual bool AdditionalCheckForSingleGet(G model) => false;
/// <summary>
/// Получение единичной записи но не по id
/// </summary>
/// <param name="list"></param>
/// <param name="model"></param>
/// <returns></returns>
protected virtual T GetSingleRecord(IQueryable<T> list, G model) => null;
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.15" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CoreModels\CoreModels.csproj" />
<ProjectReference Include="..\ToolsModule\ToolsModule.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,127 @@
using CoreDatabase.Models.Department;
using CoreDatabase.Models.Security;
using Microsoft.EntityFrameworkCore;
namespace CoreDatabase
{
public class DatabaseContext : DbContext
{
public DatabaseContext() : base() { }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
#if RELEASE
var connectionString = ToolsModule.ServiceProvider.ServiceProviderLoader.GetConfigData("connectionString");
optionsBuilder.UseSqlServer(connectionString);
#endif
#if DEBUG
optionsBuilder.UseSqlServer(@"Data Source=CHESHIR\SQLEXPRESS;Initial Catalog=DepartmentDatabasePortal;persist security info=True;user id=admin;password=cheshirSA123;MultipleActiveResultSets=True;");
#endif
}
base.OnConfiguring(optionsBuilder);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<EnviromentSetting>().HasIndex(s => s.Key).IsUnique();
modelBuilder.Entity<Role>().HasIndex(s => s.RoleName).IsUnique();
modelBuilder.Entity<User>().HasIndex(s => s.UserName);
modelBuilder.Entity<Post>().HasIndex(s => s.PostName).IsUnique();
modelBuilder.Entity<Employee>().HasIndex(d => new { d.FirstName, d.LastName, d.Patronymic }).IsUnique();
modelBuilder.Entity<Classroom>().HasIndex(d => new { d.Number }).IsUnique();
modelBuilder.Entity<DisciplineBlock>().HasIndex(d => new { d.Title }).IsUnique();
modelBuilder.Entity<Discipline>().HasIndex(d => new { d.DisciplineName }).IsUnique();
modelBuilder.Entity<LecturerAcademicDegree>().HasIndex(d => new { d.LecturerAcademicDegreeName }).IsUnique();
modelBuilder.Entity<LecturerAcademicRank>().HasIndex(d => new { d.LecturerAcademicRankName }).IsUnique();
modelBuilder.Entity<Lecturer>().HasIndex(d => new { d.FirstName, d.LastName, d.Patronymic }).IsUnique();
modelBuilder.Entity<EducationDirection>().HasIndex(d => new { d.Title, d.Profile }).IsUnique();
modelBuilder.Entity<TimeNorm>().HasIndex(d => new { d.TimeNormName, d.TimeNormShortName }).IsUnique();
modelBuilder.Entity<AcademicPlan>().HasIndex(d => new { d.EducationDirectionId, d.YearEntrance }).IsUnique();
modelBuilder.Entity<AcademicPlanRecord>().HasIndex(d => new { d.AcademicPlanId, d.DisciplineId, d.Semester }).IsUnique();
modelBuilder.Entity<AcademicPlanRecordTimeNormHour>().HasIndex(d => new { d.AcademicPlanRecordId, d.TimeNormId }).IsUnique();
// ругается на циклическое каскадное удаление, так что по нормам времени убираем ее
modelBuilder.Entity<AcademicPlanRecordTimeNormHour>()
.HasOne(x => x.TimeNorm)
.WithMany(x => x.AcademicPlanRecordTimeNormHours)
.OnDelete(DeleteBehavior.NoAction);
modelBuilder.Entity<StudentGroup>().HasIndex(d => new { d.EducationDirectionId, d.AcademicCourse, d.GroupNumber }).IsUnique();
modelBuilder.Entity<Student>().HasIndex(d => new { d.NumberOfBook }).IsUnique();
modelBuilder.Entity<Order>().HasIndex(d => new { d.OrderNumber }).IsUnique();
modelBuilder.Entity<OrderStudentRecord>().HasIndex(d => new { d.StudentId, d.OrderId }).IsUnique();
modelBuilder.Entity<OrderStudentRecord>()
.HasOne(x => x.StudentGroupFrom)
.WithMany(p => p.OrderStudentRecordFroms)
.HasForeignKey(pt => pt.StudentGroupFromId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<OrderStudentRecord>()
.HasOne(x => x.StudentGroupTo)
.WithMany(p => p.OrderStudentRecordTos)
.HasForeignKey(pt => pt.StudentGroupToId)
.OnDelete(DeleteBehavior.NoAction);
// ругается на циклическое каскадное удаление, так что по нормам времени убираем ее
modelBuilder.Entity<OrderStudentRecord>()
.HasOne(x => x.Student)
.WithMany(x => x.OrderStudentRecords)
.OnDelete(DeleteBehavior.NoAction);
}
#region Security
public virtual DbSet<Access> Accesses { set; get; }
public virtual DbSet<EnviromentSetting> EnviromentSettings { set; get; }
public virtual DbSet<Role> Roles { set; get; }
public virtual DbSet<User> Users { set; get; }
public virtual DbSet<UserRole> UserRoles { set; get; }
#endregion
#region Department
public virtual DbSet<Post> Posts { set; get; }
public virtual DbSet<Employee> Employees { 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<LecturerPost> LecturerPosts { set; get; }
public virtual DbSet<Lecturer> Lecturers { set; get; }
public virtual DbSet<EducationDirection> EducationDirections { set; get; }
public virtual DbSet<TimeNorm> TimeNorms { set; get; }
public virtual DbSet<AcademicPlan> AcademicPlans { set; get; }
public virtual DbSet<AcademicPlanRecord> AcademicPlanRecords { set; get; }
public virtual DbSet<AcademicPlanRecordTimeNormHour> AcademicPlanRecordTimeNormHours { set; get; }
public virtual DbSet<StudentGroup> StudentGroups { set; get; }
public virtual DbSet<Student> Students { set; get; }
public virtual DbSet<Order> Orders { set; get; }
public virtual DbSet<OrderStudentRecord> OrderStudentRecords { set; get; }
public virtual DbSet<OrderSyncHistory> OrderSyncHistories { set; get; }
public virtual DbSet<OrderSyncHistoryRecord> OrderSyncHistoryRecords { set; get; }
#endregion
}
}

View File

@ -0,0 +1,13 @@
namespace CoreDatabase
{
/// <summary>
/// Работа с БД
/// </summary>
public static class DatabaseManager
{
/// <summary>
/// Получение объекта от класса DbContext
/// </summary>
public static DatabaseContext GetContext => new();
}
}

View File

@ -0,0 +1,211 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210326072923_AddSecurityModels")]
partial class AddSecurityModels
{
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("CoreDatabase.Models.Security.Access", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
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<int>("Operation")
.HasColumnType("int");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Accesses");
});
modelBuilder.Entity("CoreDatabase.Models.Security.EnviromentSetting", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Key")
.HasColumnType("nvarchar(max)");
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("EnviromentSettings");
});
modelBuilder.Entity("CoreDatabase.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(max)");
b.Property<int>("RolePriority")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("CoreDatabase.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<DateTime?>("DateLocked")
.HasColumnType("datetime2");
b.Property<Guid?>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsBanned")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid?>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("StudentId")
.HasColumnType("uniqueidentifier");
b.Property<string>("UserName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
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("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,146 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddSecurityModels : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "EnviromentSettings",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Key = table.Column<string>(type: "nvarchar(max)", nullable: true),
Value = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_EnviromentSettings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Roles",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
RoleName = table.Column<string>(type: "nvarchar(max)", nullable: true),
RolePriority = 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_Roles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserName = table.Column<string>(type: "nvarchar(max)", nullable: true),
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: true),
StudentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LecturerId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
EmployeeId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Avatar = table.Column<byte[]>(type: "varbinary(max)", nullable: true),
DateLastVisit = table.Column<DateTime>(type: "datetime2", nullable: true),
IsBanned = table.Column<bool>(type: "bit", nullable: false),
DateBanned = table.Column<DateTime>(type: "datetime2", nullable: true),
CountAttempt = table.Column<int>(type: "int", nullable: false),
DateLocked = table.Column<DateTime>(type: "datetime2", 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_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Accesses",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Operation = table.Column<int>(type: "int", nullable: false),
AccessType = 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_Accesses", x => x.Id);
table.ForeignKey(
name: "FK_Accesses_Roles_RoleId",
column: x => x.RoleId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserRoles",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserRoles", x => x.Id);
table.ForeignKey(
name: "FK_UserRoles_Roles_RoleId",
column: x => x.RoleId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserRoles_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Accesses_RoleId",
table: "Accesses",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "IX_UserRoles_RoleId",
table: "UserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "IX_UserRoles_UserId",
table: "UserRoles",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Accesses");
migrationBuilder.DropTable(
name: "EnviromentSettings");
migrationBuilder.DropTable(
name: "UserRoles");
migrationBuilder.DropTable(
name: "Roles");
migrationBuilder.DropTable(
name: "Users");
}
}
}

View File

@ -0,0 +1,217 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210327194001_ChangeSecurityFields")]
partial class ChangeSecurityFields
{
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("CoreDatabase.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("CoreDatabase.Models.Security.EnviromentSetting", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Key")
.HasColumnType("nvarchar(max)");
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("EnviromentSettings");
});
modelBuilder.Entity("CoreDatabase.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(max)");
b.Property<int>("RolePriority")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("CoreDatabase.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<Guid?>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsBanned")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid?>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("StudentId")
.HasColumnType("uniqueidentifier");
b.Property<string>("UserName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,66 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class ChangeSecurityFields : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DateLocked",
table: "Users");
migrationBuilder.RenameColumn(
name: "Operation",
table: "Accesses",
newName: "AccessOperation");
migrationBuilder.AddColumn<DateTime>(
name: "DateCreate",
table: "UserRoles",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<DateTime>(
name: "DateDelete",
table: "UserRoles",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
table: "UserRoles",
type: "bit",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DateCreate",
table: "UserRoles");
migrationBuilder.DropColumn(
name: "DateDelete",
table: "UserRoles");
migrationBuilder.DropColumn(
name: "IsDeleted",
table: "UserRoles");
migrationBuilder.RenameColumn(
name: "AccessOperation",
table: "Accesses",
newName: "Operation");
migrationBuilder.AddColumn<DateTime>(
name: "DateLocked",
table: "Users",
type: "datetime2",
nullable: true);
}
}
}

View File

@ -0,0 +1,220 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210328165041_AddDescriptionInEnviromentSettings")]
partial class AddDescriptionInEnviromentSettings
{
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("CoreDatabase.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("CoreDatabase.Models.Security.EnviromentSetting", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Key")
.HasColumnType("nvarchar(max)");
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("EnviromentSettings");
});
modelBuilder.Entity("CoreDatabase.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(max)");
b.Property<int>("RolePriority")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("CoreDatabase.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<Guid?>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsBanned")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid?>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("StudentId")
.HasColumnType("uniqueidentifier");
b.Property<string>("UserName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

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

View File

@ -0,0 +1,216 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210401105731_UpdateSecurityModels")]
partial class UpdateSecurityModels
{
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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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(max)");
b.Property<int>("RolePriority")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("CoreDatabase.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(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,90 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class UpdateSecurityModels : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "EmployeeId",
table: "Users");
migrationBuilder.DropColumn(
name: "LecturerId",
table: "Users");
migrationBuilder.DropColumn(
name: "StudentId",
table: "Users");
migrationBuilder.AlterColumn<string>(
name: "Value",
table: "EnviromentSettings",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Key",
table: "EnviromentSettings",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.CreateIndex(
name: "IX_EnviromentSettings_Key",
table: "EnviromentSettings",
column: "Key",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EnviromentSettings_Key",
table: "EnviromentSettings");
migrationBuilder.AddColumn<Guid>(
name: "EmployeeId",
table: "Users",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "LecturerId",
table: "Users",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "StudentId",
table: "Users",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.AlterColumn<string>(
name: "Value",
table: "EnviromentSettings",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "Key",
table: "EnviromentSettings",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
}
}
}

View File

@ -0,0 +1,379 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,177 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.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",
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

@ -0,0 +1,445 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210403090025_AddClassrooms")]
partial class AddClassrooms
{
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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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");
b.ToTable("Users");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,78 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddClassrooms : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Users_UserName",
table: "Users");
migrationBuilder.CreateTable(
name: "Classrooms",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Number = table.Column<string>(type: "nvarchar(450)", nullable: true),
Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
EmployeeId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ClassroomType = table.Column<int>(type: "int", nullable: false),
Square = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
Capacity = table.Column<int>(type: "int", nullable: false),
SecurityCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
HaveProjector = table.Column<bool>(type: "bit", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
Photo = table.Column<byte[]>(type: "varbinary(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_Classrooms", x => x.Id);
table.ForeignKey(
name: "FK_Classrooms_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Users_UserName",
table: "Users",
column: "UserName");
migrationBuilder.CreateIndex(
name: "IX_Classrooms_EmployeeId",
table: "Classrooms",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_Classrooms_Number",
table: "Classrooms",
column: "Number",
unique: true,
filter: "[Number] IS NOT NULL");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Classrooms");
migrationBuilder.DropIndex(
name: "IX_Users_UserName",
table: "Users");
migrationBuilder.CreateIndex(
name: "IX_Users_UserName",
table: "Users",
column: "UserName",
filter: "[UserName] IS NOT NULL");
}
}
}

View File

@ -0,0 +1,535 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210403143118_AddDisciplines")]
partial class AddDisciplines
{
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("CoreDatabase.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("CoreDatabase.Models.Department.Discipline", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,154 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddDisciplines : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Roles_RoleName",
table: "Roles");
migrationBuilder.AlterColumn<string>(
name: "UserName",
table: "Users",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "PasswordHash",
table: "Users",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RoleName",
table: "Roles",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.CreateTable(
name: "DisciplineBlocks",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Title = table.Column<string>(type: "nvarchar(450)", nullable: false),
DisciplineBlockUseForGrouping = table.Column<bool>(type: "bit", nullable: false),
DisciplineBlockOrder = table.Column<int>(type: "int", nullable: false),
DisciplineBlockBlueAsteriskName = 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_DisciplineBlocks", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Disciplines",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
DisciplineBlockId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
DisciplineName = table.Column<string>(type: "nvarchar(450)", nullable: false),
DisciplineShortName = table.Column<string>(type: "nvarchar(max)", nullable: true),
DisciplineBlueAsteriskName = 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_Disciplines", x => x.Id);
table.ForeignKey(
name: "FK_Disciplines_DisciplineBlocks_DisciplineBlockId",
column: x => x.DisciplineBlockId,
principalTable: "DisciplineBlocks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Roles_RoleName",
table: "Roles",
column: "RoleName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_DisciplineBlocks_Title",
table: "DisciplineBlocks",
column: "Title",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Disciplines_DisciplineBlockId",
table: "Disciplines",
column: "DisciplineBlockId");
migrationBuilder.CreateIndex(
name: "IX_Disciplines_DisciplineName",
table: "Disciplines",
column: "DisciplineName",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Disciplines");
migrationBuilder.DropTable(
name: "DisciplineBlocks");
migrationBuilder.DropIndex(
name: "IX_Roles_RoleName",
table: "Roles");
migrationBuilder.AlterColumn<string>(
name: "UserName",
table: "Users",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.AlterColumn<string>(
name: "PasswordHash",
table: "Users",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "RoleName",
table: "Roles",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.CreateIndex(
name: "IX_Roles_RoleName",
table: "Roles",
column: "RoleName",
unique: true,
filter: "[RoleName] IS NOT NULL");
}
}
}

View File

@ -0,0 +1,829 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210403180333_AddLecturers")]
partial class AddLecturers
{
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("CoreDatabase.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("CoreDatabase.Models.Department.Discipline", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Lecturer", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
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<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("LecturerPostId");
b.HasIndex("UserId");
b.HasIndex("FirstName", "LastName", "Patronymic")
.IsUnique()
.HasFilter("[Patronymic] IS NOT NULL");
b.ToTable("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Property<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>("LecturerAcademicDegreeName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerAcademicDegreeName")
.IsUnique();
b.ToTable("LecturerAcademicDegrees");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
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<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("Rate")
.HasColumnType("decimal(18,2)");
b.HasKey("Id");
b.HasIndex("EmployeePostId");
b.HasIndex("LecturerId");
b.ToTable("LecturerEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", 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<string>("LecturerPostName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerPostName")
.IsUnique();
b.ToTable("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Department.LecturerPost", "LecturerPost")
.WithMany("Lecturers")
.HasForeignKey("LecturerPostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("LecturerPost");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany()
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany()
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("EmployeePost");
b.Navigation("Lecturer");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,239 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddLecturers : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "LecturerAcademicDegrees",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LecturerAcademicDegreeName = table.Column<string>(type: "nvarchar(450)", nullable: false),
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_LecturerAcademicDegrees", x => x.Id);
});
migrationBuilder.CreateTable(
name: "LecturerAcademicRanks",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LecturerAcademicRankName = table.Column<string>(type: "nvarchar(450)", nullable: false),
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_LecturerAcademicRanks", x => x.Id);
});
migrationBuilder.CreateTable(
name: "LecturerPosts",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LecturerPostName = table.Column<string>(type: "nvarchar(450)", nullable: false),
Hours = table.Column<int>(type: "int", nullable: false),
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_LecturerPosts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Lecturers",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LecturerPostId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LecturerPostRate = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
LecturerAcademicRankId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LecturerAcademicDegreeId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastName = table.Column<string>(type: "nvarchar(450)", nullable: false),
FirstName = table.Column<string>(type: "nvarchar(450)", nullable: false),
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: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
MobileNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
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_Lecturers", x => x.Id);
table.ForeignKey(
name: "FK_Lecturers_LecturerAcademicDegrees_LecturerAcademicDegreeId",
column: x => x.LecturerAcademicDegreeId,
principalTable: "LecturerAcademicDegrees",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Lecturers_LecturerAcademicRanks_LecturerAcademicRankId",
column: x => x.LecturerAcademicRankId,
principalTable: "LecturerAcademicRanks",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Lecturers_LecturerPosts_LecturerPostId",
column: x => x.LecturerPostId,
principalTable: "LecturerPosts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Lecturers_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "LecturerEmployeePosts",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LecturerId = 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_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_Employees_UserId",
table: "Employees",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_LecturerAcademicDegrees_LecturerAcademicDegreeName",
table: "LecturerAcademicDegrees",
column: "LecturerAcademicDegreeName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_LecturerAcademicRanks_LecturerAcademicRankName",
table: "LecturerAcademicRanks",
column: "LecturerAcademicRankName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_LecturerEmployeePosts_EmployeePostId",
table: "LecturerEmployeePosts",
column: "EmployeePostId");
migrationBuilder.CreateIndex(
name: "IX_LecturerEmployeePosts_LecturerId",
table: "LecturerEmployeePosts",
column: "LecturerId");
migrationBuilder.CreateIndex(
name: "IX_LecturerPosts_LecturerPostName",
table: "LecturerPosts",
column: "LecturerPostName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Lecturers_FirstName_LastName_Patronymic",
table: "Lecturers",
columns: new[] { "FirstName", "LastName", "Patronymic" },
unique: true,
filter: "[Patronymic] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Lecturers_LecturerAcademicDegreeId",
table: "Lecturers",
column: "LecturerAcademicDegreeId");
migrationBuilder.CreateIndex(
name: "IX_Lecturers_LecturerAcademicRankId",
table: "Lecturers",
column: "LecturerAcademicRankId");
migrationBuilder.CreateIndex(
name: "IX_Lecturers_LecturerPostId",
table: "Lecturers",
column: "LecturerPostId");
migrationBuilder.CreateIndex(
name: "IX_Lecturers_UserId",
table: "Lecturers",
column: "UserId");
migrationBuilder.AddForeignKey(
name: "FK_Employees_Users_UserId",
table: "Employees",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Employees_Users_UserId",
table: "Employees");
migrationBuilder.DropTable(
name: "LecturerEmployeePosts");
migrationBuilder.DropTable(
name: "Lecturers");
migrationBuilder.DropTable(
name: "LecturerAcademicDegrees");
migrationBuilder.DropTable(
name: "LecturerAcademicRanks");
migrationBuilder.DropTable(
name: "LecturerPosts");
migrationBuilder.DropIndex(
name: "IX_Employees_UserId",
table: "Employees");
}
}
}

View File

@ -0,0 +1,832 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210404053131_AddLecturerAcademicDegreeDiscription")]
partial class AddLecturerAcademicDegreeDiscription
{
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("CoreDatabase.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("CoreDatabase.Models.Department.Discipline", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Lecturer", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
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<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("LecturerPostId");
b.HasIndex("UserId");
b.HasIndex("FirstName", "LastName", "Patronymic")
.IsUnique()
.HasFilter("[Patronymic] IS NOT NULL");
b.ToTable("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Property<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("CoreDatabase.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("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
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<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("Rate")
.HasColumnType("decimal(18,2)");
b.HasKey("Id");
b.HasIndex("EmployeePostId");
b.HasIndex("LecturerId");
b.ToTable("LecturerEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", 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<string>("LecturerPostName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerPostName")
.IsUnique();
b.ToTable("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Department.LecturerPost", "LecturerPost")
.WithMany("Lecturers")
.HasForeignKey("LecturerPostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("LecturerPost");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany()
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany()
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("EmployeePost");
b.Navigation("Lecturer");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

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

View File

@ -0,0 +1,835 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210404065039_AddDiciplineDescription")]
partial class AddDiciplineDescription
{
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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Lecturer", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
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<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("LecturerPostId");
b.HasIndex("UserId");
b.HasIndex("FirstName", "LastName", "Patronymic")
.IsUnique()
.HasFilter("[Patronymic] IS NOT NULL");
b.ToTable("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Property<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("CoreDatabase.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("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
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<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("Rate")
.HasColumnType("decimal(18,2)");
b.HasKey("Id");
b.HasIndex("EmployeePostId");
b.HasIndex("LecturerId");
b.ToTable("LecturerEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", 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<string>("LecturerPostName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerPostName")
.IsUnique();
b.ToTable("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Department.LecturerPost", "LecturerPost")
.WithMany("Lecturers")
.HasForeignKey("LecturerPostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("LecturerPost");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany()
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany()
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("EmployeePost");
b.Navigation("Lecturer");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

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

View File

@ -0,0 +1,838 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210404070556_AddLecturer")]
partial class AddLecturer
{
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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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<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("LecturerPostId");
b.HasIndex("UserId");
b.HasIndex("FirstName", "LastName", "Patronymic")
.IsUnique()
.HasFilter("[Patronymic] IS NOT NULL");
b.ToTable("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Property<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("CoreDatabase.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("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
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<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("Rate")
.HasColumnType("decimal(18,2)");
b.HasKey("Id");
b.HasIndex("EmployeePostId");
b.HasIndex("LecturerId");
b.ToTable("LecturerEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", 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<string>("LecturerPostName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerPostName")
.IsUnique();
b.ToTable("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Department.LecturerPost", "LecturerPost")
.WithMany("Lecturers")
.HasForeignKey("LecturerPostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("LecturerPost");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany()
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany()
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("EmployeePost");
b.Navigation("Lecturer");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

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

View File

@ -0,0 +1,841 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210404070734_AddLecturerOnlyForPrivate")]
partial class AddLecturerOnlyForPrivate
{
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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("LecturerPostId");
b.HasIndex("UserId");
b.HasIndex("FirstName", "LastName", "Patronymic")
.IsUnique()
.HasFilter("[Patronymic] IS NOT NULL");
b.ToTable("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Property<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("CoreDatabase.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("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
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<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("Rate")
.HasColumnType("decimal(18,2)");
b.HasKey("Id");
b.HasIndex("EmployeePostId");
b.HasIndex("LecturerId");
b.ToTable("LecturerEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", 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<string>("LecturerPostName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerPostName")
.IsUnique();
b.ToTable("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Department.LecturerPost", "LecturerPost")
.WithMany("Lecturers")
.HasForeignKey("LecturerPostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("LecturerPost");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany()
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany()
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("EmployeePost");
b.Navigation("Lecturer");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddLecturerOnlyForPrivate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "OnlyForPrivate",
table: "Lecturers",
type: "bit",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "OnlyForPrivate",
table: "Lecturers");
}
}
}

View File

@ -0,0 +1,845 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210404170518_RemLecturerField")]
partial class RemLecturerField
{
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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("LecturerPostId");
b.HasIndex("UserId");
b.HasIndex("FirstName", "LastName", "Patronymic")
.IsUnique()
.HasFilter("[Patronymic] IS NOT NULL");
b.ToTable("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Property<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("CoreDatabase.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("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
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<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("Rate")
.HasColumnType("decimal(18,2)");
b.HasKey("Id");
b.HasIndex("EmployeePostId");
b.HasIndex("LecturerId");
b.ToTable("LecturerEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", 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<string>("LecturerPostName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerPostName")
.IsUnique();
b.ToTable("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Department.LecturerPost", "LecturerPost")
.WithMany("Lecturers")
.HasForeignKey("LecturerPostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("LecturerPost");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("LecturerEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany("LecturerEmployeePosts")
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("EmployeePost");
b.Navigation("Lecturer");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
b.Navigation("LecturerEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.Navigation("LecturerEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

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

View File

@ -0,0 +1,854 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210405060128_AddEnviromentSettingsFields")]
partial class AddEnviromentSettingsFields
{
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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("LecturerPostId");
b.HasIndex("UserId");
b.HasIndex("FirstName", "LastName", "Patronymic")
.IsUnique()
.HasFilter("[Patronymic] IS NOT NULL");
b.ToTable("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Property<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("CoreDatabase.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("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
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<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("Rate")
.HasColumnType("decimal(18,2)");
b.HasKey("Id");
b.HasIndex("EmployeePostId");
b.HasIndex("LecturerId");
b.ToTable("LecturerEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", 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<string>("LecturerPostName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LecturerPostName")
.IsUnique();
b.ToTable("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Department.LecturerPost", "LecturerPost")
.WithMany("Lecturers")
.HasForeignKey("LecturerPostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("LecturerPost");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerEmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.EmployeePost", "EmployeePost")
.WithMany("LecturerEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany("LecturerEmployeePosts")
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("EmployeePost");
b.Navigation("Lecturer");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
b.Navigation("LecturerEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.Navigation("LecturerEmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,46 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddEnviromentSettingsFields : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "DateCreate",
table: "EnviromentSettings",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<DateTime>(
name: "DateDelete",
table: "EnviromentSettings",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
table: "EnviromentSettings",
type: "bit",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DateCreate",
table: "EnviromentSettings");
migrationBuilder.DropColumn(
name: "DateDelete",
table: "EnviromentSettings");
migrationBuilder.DropColumn(
name: "IsDeleted",
table: "EnviromentSettings");
}
}
}

View File

@ -0,0 +1,810 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Post", "Post")
.WithMany("EmployeePosts")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("Post");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany("LecturerPosts")
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Post", "Post")
.WithMany("LecturerPosts")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Lecturer");
b.Navigation("Post");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.Navigation("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Post", b =>
{
b.Navigation("EmployeePosts");
b.Navigation("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,419 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.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 CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Post", "Post")
.WithMany("EmployeePosts")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("Post");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany("LecturerPosts")
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Post", "Post")
.WithMany("LecturerPosts")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Lecturer");
b.Navigation("Post");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.Navigation("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Post", b =>
{
b.Navigation("EmployeePosts");
b.Navigation("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.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 CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Post", "Post")
.WithMany("EmployeePosts")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("Post");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany("LecturerPosts")
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Post", "Post")
.WithMany("LecturerPosts")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Lecturer");
b.Navigation("Post");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.Navigation("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Post", b =>
{
b.Navigation("EmployeePosts");
b.Navigation("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,36 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.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

@ -0,0 +1,870 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210405091403_AddEducationDirection")]
partial class AddEducationDirection
{
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("CoreDatabase.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")
.IsRequired()
.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();
b.ToTable("Classrooms");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.EducationDirection", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Cipher")
.IsRequired()
.HasColumnType("nvarchar(max)");
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<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Profile")
.HasColumnType("nvarchar(450)");
b.Property<string>("Qualification")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("LecturerId");
b.HasIndex("Title", "Profile")
.IsUnique()
.HasFilter("[Profile] IS NOT NULL");
b.ToTable("EducationDirections");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Property<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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EducationDirection", b =>
{
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany("EducationDirections")
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Lecturer");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Post", "Post")
.WithMany("EmployeePosts")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("Post");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany("LecturerPosts")
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Post", "Post")
.WithMany("LecturerPosts")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Lecturer");
b.Navigation("Post");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.Navigation("EducationDirections");
b.Navigation("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Post", b =>
{
b.Navigation("EmployeePosts");
b.Navigation("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,95 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddEducationDirection : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Classrooms_Number",
table: "Classrooms");
migrationBuilder.AlterColumn<string>(
name: "Number",
table: "Classrooms",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.CreateTable(
name: "EducationDirections",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Cipher = table.Column<string>(type: "nvarchar(max)", nullable: false),
ShortName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Title = table.Column<string>(type: "nvarchar(450)", nullable: false),
Profile = table.Column<string>(type: "nvarchar(450)", nullable: true),
Qualification = table.Column<string>(type: "nvarchar(max)", nullable: false),
LecturerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Description = 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_EducationDirections", x => x.Id);
table.ForeignKey(
name: "FK_EducationDirections_Lecturers_LecturerId",
column: x => x.LecturerId,
principalTable: "Lecturers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Classrooms_Number",
table: "Classrooms",
column: "Number",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_EducationDirections_LecturerId",
table: "EducationDirections",
column: "LecturerId");
migrationBuilder.CreateIndex(
name: "IX_EducationDirections_Title_Profile",
table: "EducationDirections",
columns: new[] { "Title", "Profile" },
unique: true,
filter: "[Profile] IS NOT NULL");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "EducationDirections");
migrationBuilder.DropIndex(
name: "IX_Classrooms_Number",
table: "Classrooms");
migrationBuilder.AlterColumn<string>(
name: "Number",
table: "Classrooms",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.CreateIndex(
name: "IX_Classrooms_Number",
table: "Classrooms",
column: "Number",
unique: true,
filter: "[Number] IS NOT NULL");
}
}
}

View File

@ -0,0 +1,869 @@
// <auto-generated />
using System;
using CoreDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CoreDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210405095913_UPdFieldEducationDirection")]
partial class UPdFieldEducationDirection
{
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("CoreDatabase.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")
.IsRequired()
.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();
b.ToTable("Classrooms");
});
modelBuilder.Entity("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.EducationDirection", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Cipher")
.IsRequired()
.HasColumnType("nvarchar(max)");
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<Guid>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Profile")
.HasColumnType("nvarchar(450)");
b.Property<int>("Qualification")
.HasColumnType("int");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("LecturerId");
b.HasIndex("Title", "Profile")
.IsUnique()
.HasFilter("[Profile] IS NOT NULL");
b.ToTable("EducationDirections");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Property<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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.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("CoreDatabase.Models.Department.Classroom", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EducationDirection", b =>
{
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany("EducationDirections")
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Lecturer");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Employees")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.EmployeePost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Employee", "Employee")
.WithMany("EmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Post", "Post")
.WithMany("EmployeePosts")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("Post");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicDegreeId");
b.HasOne("CoreDatabase.Models.Department.LecturerAcademicRank", "LecturerAcademicRank")
.WithMany("Lecturers")
.HasForeignKey("LecturerAcademicRankId");
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("Lecturers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LecturerAcademicDegree");
b.Navigation("LecturerAcademicRank");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerPost", b =>
{
b.HasOne("CoreDatabase.Models.Department.Lecturer", "Lecturer")
.WithMany("LecturerPosts")
.HasForeignKey("LecturerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Post", "Post")
.WithMany("LecturerPosts")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Lecturer");
b.Navigation("Post");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Access", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("CoreDatabase.Models.Security.UserRole", b =>
{
b.HasOne("CoreDatabase.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeePosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Lecturer", b =>
{
b.Navigation("EducationDirections");
b.Navigation("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicDegree", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.LecturerAcademicRank", b =>
{
b.Navigation("Lecturers");
});
modelBuilder.Entity("CoreDatabase.Models.Department.Post", b =>
{
b.Navigation("EmployeePosts");
b.Navigation("LecturerPosts");
});
modelBuilder.Entity("CoreDatabase.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("CoreDatabase.Models.Security.User", b =>
{
b.Navigation("Employees");
b.Navigation("Lecturers");
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class UPdFieldEducationDirection : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "Qualification",
table: "EducationDirections",
type: "int",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Qualification",
table: "EducationDirections",
type: "nvarchar(max)",
nullable: false,
oldClrType: typeof(int),
oldType: "int");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,183 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddAcademicPlans : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AcademicPlans",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
EducationDirectionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
YearEntrance = table.Column<DateTime>(type: "datetime2", nullable: false),
YearFinish = table.Column<DateTime>(type: "datetime2", 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_AcademicPlans", x => x.Id);
table.ForeignKey(
name: "FK_AcademicPlans_EducationDirections_EducationDirectionId",
column: x => x.EducationDirectionId,
principalTable: "EducationDirections",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "TimeNorms",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
DisciplineBlockId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TimeNormName = table.Column<string>(type: "nvarchar(450)", nullable: false),
TimeNormShortName = table.Column<string>(type: "nvarchar(max)", nullable: false),
TimeNormOrder = table.Column<int>(type: "int", nullable: false),
TimeNormEducationDirectionQualification = table.Column<int>(type: "int", nullable: true),
KindOfLoadName = table.Column<string>(type: "nvarchar(max)", nullable: false),
KindOfLoadAttributeName = table.Column<string>(type: "nvarchar(max)", nullable: true),
KindOfLoadBlueAsteriskName = table.Column<string>(type: "nvarchar(max)", nullable: true),
KindOfLoadBlueAsteriskAttributeName = table.Column<string>(type: "nvarchar(max)", nullable: true),
KindOfLoadBlueAsteriskPracticName = table.Column<string>(type: "nvarchar(max)", nullable: true),
UseInLearningProgress = table.Column<bool>(type: "bit", nullable: false),
UseInSite = 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_TimeNorms", x => x.Id);
table.ForeignKey(
name: "FK_TimeNorms_DisciplineBlocks_DisciplineBlockId",
column: x => x.DisciplineBlockId,
principalTable: "DisciplineBlocks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AcademicPlanRecords",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
AcademicPlanId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
DisciplineId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
InDepartment = table.Column<bool>(type: "bit", nullable: false),
Semester = table.Column<int>(type: "int", nullable: false),
Zet = table.Column<int>(type: "int", nullable: false),
AcademicPlanRecordParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsParent = table.Column<bool>(type: "bit", nullable: false),
IsFacultative = 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_AcademicPlanRecords", x => x.Id);
table.ForeignKey(
name: "FK_AcademicPlanRecords_AcademicPlans_AcademicPlanId",
column: x => x.AcademicPlanId,
principalTable: "AcademicPlans",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AcademicPlanRecords_Disciplines_DisciplineId",
column: x => x.DisciplineId,
principalTable: "Disciplines",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AcademicPlanRecordTimeNormHours",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
AcademicPlanRecordId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TimeNormId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
PlanHours = table.Column<decimal>(type: "decimal(18,2)", 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_AcademicPlanRecordTimeNormHours", x => x.Id);
table.ForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_AcademicPlanRecords_AcademicPlanRecordId",
column: x => x.AcademicPlanRecordId,
principalTable: "AcademicPlanRecords",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
column: x => x.TimeNormId,
principalTable: "TimeNorms",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
});
migrationBuilder.CreateIndex(
name: "IX_AcademicPlanRecords_AcademicPlanId_DisciplineId_Semester",
table: "AcademicPlanRecords",
columns: new[] { "AcademicPlanId", "DisciplineId", "Semester" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_AcademicPlanRecords_DisciplineId",
table: "AcademicPlanRecords",
column: "DisciplineId");
migrationBuilder.CreateIndex(
name: "IX_AcademicPlanRecordTimeNormHours_AcademicPlanRecordId_TimeNormId",
table: "AcademicPlanRecordTimeNormHours",
columns: new[] { "AcademicPlanRecordId", "TimeNormId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_AcademicPlanRecordTimeNormHours_TimeNormId",
table: "AcademicPlanRecordTimeNormHours",
column: "TimeNormId");
migrationBuilder.CreateIndex(
name: "IX_AcademicPlans_EducationDirectionId_YearEntrance",
table: "AcademicPlans",
columns: new[] { "EducationDirectionId", "YearEntrance" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_TimeNorms_DisciplineBlockId",
table: "TimeNorms",
column: "DisciplineBlockId");
migrationBuilder.CreateIndex(
name: "IX_TimeNorms_TimeNormName",
table: "TimeNorms",
column: "TimeNormName",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AcademicPlanRecordTimeNormHours");
migrationBuilder.DropTable(
name: "AcademicPlanRecords");
migrationBuilder.DropTable(
name: "TimeNorms");
migrationBuilder.DropTable(
name: "AcademicPlans");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,72 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class UpdUniqueTimeNorm : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours");
migrationBuilder.DropIndex(
name: "IX_TimeNorms_TimeNormName",
table: "TimeNorms");
migrationBuilder.AlterColumn<string>(
name: "TimeNormShortName",
table: "TimeNorms",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.CreateIndex(
name: "IX_TimeNorms_TimeNormName_TimeNormShortName",
table: "TimeNorms",
columns: new[] { "TimeNormName", "TimeNormShortName" },
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours",
column: "TimeNormId",
principalTable: "TimeNorms",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours");
migrationBuilder.DropIndex(
name: "IX_TimeNorms_TimeNormName_TimeNormShortName",
table: "TimeNorms");
migrationBuilder.AlterColumn<string>(
name: "TimeNormShortName",
table: "TimeNorms",
type: "nvarchar(max)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.CreateIndex(
name: "IX_TimeNorms_TimeNormName",
table: "TimeNorms",
column: "TimeNormName",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours",
column: "TimeNormId",
principalTable: "TimeNorms",
principalColumn: "Id");
}
}
}

View File

@ -0,0 +1,101 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class ChangeTypeInacademicPlan : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours");
migrationBuilder.DropIndex(
name: "IX_AcademicPlans_EducationDirectionId_YearEntrance",
table: "AcademicPlans");
migrationBuilder.DropColumn(
name: "YearFinish",
table: "AcademicPlans");
migrationBuilder.DropColumn(
name: "YearEntrance",
table: "AcademicPlans");
migrationBuilder.AddColumn<int>(
name: "YearFinish",
table: "AcademicPlans",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "YearEntrance",
table: "AcademicPlans",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours",
column: "TimeNormId",
principalTable: "TimeNorms",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
migrationBuilder.CreateIndex(
name: "IX_AcademicPlans_EducationDirectionId_YearEntrance",
table: "AcademicPlans",
columns: new[] { "EducationDirectionId", "YearEntrance" },
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours");
migrationBuilder.DropIndex(
name: "IX_AcademicPlans_EducationDirectionId_YearEntrance",
table: "AcademicPlans");
migrationBuilder.DropColumn(
name: "YearFinish",
table: "AcademicPlans");
migrationBuilder.DropColumn(
name: "YearEntrance",
table: "AcademicPlans");
migrationBuilder.AddColumn<DateTime>(
name: "YearEntrance",
table: "AcademicPlans",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<DateTime>(
name: "YearFinish",
table: "AcademicPlans",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours",
column: "TimeNormId",
principalTable: "TimeNorms",
principalColumn: "Id");
migrationBuilder.CreateIndex(
name: "IX_AcademicPlans_EducationDirectionId_YearEntrance",
table: "AcademicPlans",
columns: new[] { "EducationDirectionId", "YearEntrance" },
unique: true);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,100 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class ChangeAcademPlan : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours");
migrationBuilder.DropForeignKey(
name: "FK_AcademicPlans_EducationDirections_EducationDirectionId",
table: "AcademicPlans");
migrationBuilder.DropIndex(
name: "IX_AcademicPlans_EducationDirectionId_YearEntrance",
table: "AcademicPlans");
migrationBuilder.AlterColumn<Guid>(
name: "EducationDirectionId",
table: "AcademicPlans",
type: "uniqueidentifier",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uniqueidentifier");
migrationBuilder.CreateIndex(
name: "IX_AcademicPlans_EducationDirectionId_YearEntrance",
table: "AcademicPlans",
columns: new[] { "EducationDirectionId", "YearEntrance" },
unique: true,
filter: "[EducationDirectionId] IS NOT NULL");
migrationBuilder.AddForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours",
column: "TimeNormId",
principalTable: "TimeNorms",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
migrationBuilder.AddForeignKey(
name: "FK_AcademicPlans_EducationDirections_EducationDirectionId",
table: "AcademicPlans",
column: "EducationDirectionId",
principalTable: "EducationDirections",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours");
migrationBuilder.DropForeignKey(
name: "FK_AcademicPlans_EducationDirections_EducationDirectionId",
table: "AcademicPlans");
migrationBuilder.DropIndex(
name: "IX_AcademicPlans_EducationDirectionId_YearEntrance",
table: "AcademicPlans");
migrationBuilder.AlterColumn<Guid>(
name: "EducationDirectionId",
table: "AcademicPlans",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uniqueidentifier",
oldNullable: true);
migrationBuilder.CreateIndex(
name: "IX_AcademicPlans_EducationDirectionId_YearEntrance",
table: "AcademicPlans",
columns: new[] { "EducationDirectionId", "YearEntrance" },
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours",
column: "TimeNormId",
principalTable: "TimeNorms",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_AcademicPlans_EducationDirections_EducationDirectionId",
table: "AcademicPlans",
column: "EducationDirectionId",
principalTable: "EducationDirections",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,81 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddStudentGroups : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours");
migrationBuilder.CreateTable(
name: "StudentGroups",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
AcademicPlanId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
GroupNumber = table.Column<int>(type: "int", nullable: false),
EnrollmentYear = table.Column<int>(type: "int", nullable: false),
LecturerId = table.Column<Guid>(type: "uniqueidentifier", 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_StudentGroups", x => x.Id);
table.ForeignKey(
name: "FK_StudentGroups_AcademicPlans_AcademicPlanId",
column: x => x.AcademicPlanId,
principalTable: "AcademicPlans",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StudentGroups_Lecturers_LecturerId",
column: x => x.LecturerId,
principalTable: "Lecturers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_StudentGroups_AcademicPlanId_EnrollmentYear_GroupNumber",
table: "StudentGroups",
columns: new[] { "AcademicPlanId", "EnrollmentYear", "GroupNumber" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_StudentGroups_LecturerId",
table: "StudentGroups",
column: "LecturerId");
migrationBuilder.AddForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours",
column: "TimeNormId",
principalTable: "TimeNorms",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours");
migrationBuilder.DropTable(
name: "StudentGroups");
migrationBuilder.AddForeignKey(
name: "FK_AcademicPlanRecordTimeNormHours_TimeNorms_TimeNormId",
table: "AcademicPlanRecordTimeNormHours",
column: "TimeNormId",
principalTable: "TimeNorms",
principalColumn: "Id");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,70 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddStudents : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Students",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
StudentGroupId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
NumberOfBook = table.Column<string>(type: "nvarchar(450)", nullable: false),
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Patronymic = table.Column<string>(type: "nvarchar(max)", nullable: true),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
StudentState = table.Column<int>(type: "int", nullable: false),
Photo = table.Column<byte[]>(type: "varbinary(max)", nullable: true),
IsSteward = 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_Students", x => x.Id);
table.ForeignKey(
name: "FK_Students_StudentGroups_StudentGroupId",
column: x => x.StudentGroupId,
principalTable: "StudentGroups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Students_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Students_NumberOfBook",
table: "Students",
column: "NumberOfBook",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Students_StudentGroupId",
table: "Students",
column: "StudentGroupId");
migrationBuilder.CreateIndex(
name: "IX_Students_UserId",
table: "Students",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Students");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,108 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddOrders : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
OrderNumber = table.Column<string>(type: "nvarchar(450)", nullable: false),
OrderDate = table.Column<DateTime>(type: "datetime2", nullable: false),
OrderType = 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_Orders", x => x.Id);
});
migrationBuilder.CreateTable(
name: "OrderStudentRecords",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
OrderId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
StudentId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
StudentGroupFromId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
StudentGroupToId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
OrderStudentMoveType = table.Column<int>(type: "int", nullable: false),
Info = 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_OrderStudentRecords", x => x.Id);
table.ForeignKey(
name: "FK_OrderStudentRecords_Orders_OrderId",
column: x => x.OrderId,
principalTable: "Orders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_OrderStudentRecords_StudentGroups_StudentGroupFromId",
column: x => x.StudentGroupFromId,
principalTable: "StudentGroups",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_OrderStudentRecords_StudentGroups_StudentGroupToId",
column: x => x.StudentGroupToId,
principalTable: "StudentGroups",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
table.ForeignKey(
name: "FK_OrderStudentRecords_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
});
migrationBuilder.CreateIndex(
name: "IX_Orders_OrderNumber",
table: "Orders",
column: "OrderNumber",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_OrderStudentRecords_OrderId",
table: "OrderStudentRecords",
column: "OrderId");
migrationBuilder.CreateIndex(
name: "IX_OrderStudentRecords_StudentGroupFromId",
table: "OrderStudentRecords",
column: "StudentGroupFromId");
migrationBuilder.CreateIndex(
name: "IX_OrderStudentRecords_StudentGroupToId",
table: "OrderStudentRecords",
column: "StudentGroupToId");
migrationBuilder.CreateIndex(
name: "IX_OrderStudentRecords_StudentId_OrderId",
table: "OrderStudentRecords",
columns: new[] { "StudentId", "OrderId" },
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "OrderStudentRecords");
migrationBuilder.DropTable(
name: "Orders");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,102 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddOrderSyncHistories : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_OrderStudentRecords_StudentGroups_StudentGroupToId",
table: "OrderStudentRecords");
migrationBuilder.DropForeignKey(
name: "FK_OrderStudentRecords_Students_StudentId",
table: "OrderStudentRecords");
migrationBuilder.CreateTable(
name: "OrderSyncHistories",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
SyncDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrderSyncHistories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "OrderSyncHistoryRecords",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
OrderSyncHistoryId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Information = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrderSyncHistoryRecords", x => x.Id);
table.ForeignKey(
name: "FK_OrderSyncHistoryRecords_OrderSyncHistories_OrderSyncHistoryId",
column: x => x.OrderSyncHistoryId,
principalTable: "OrderSyncHistories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_OrderSyncHistoryRecords_OrderSyncHistoryId",
table: "OrderSyncHistoryRecords",
column: "OrderSyncHistoryId");
migrationBuilder.AddForeignKey(
name: "FK_OrderStudentRecords_StudentGroups_StudentGroupToId",
table: "OrderStudentRecords",
column: "StudentGroupToId",
principalTable: "StudentGroups",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_OrderStudentRecords_Students_StudentId",
table: "OrderStudentRecords",
column: "StudentId",
principalTable: "Students",
principalColumn: "Id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_OrderStudentRecords_StudentGroups_StudentGroupToId",
table: "OrderStudentRecords");
migrationBuilder.DropForeignKey(
name: "FK_OrderStudentRecords_Students_StudentId",
table: "OrderStudentRecords");
migrationBuilder.DropTable(
name: "OrderSyncHistoryRecords");
migrationBuilder.DropTable(
name: "OrderSyncHistories");
migrationBuilder.AddForeignKey(
name: "FK_OrderStudentRecords_StudentGroups_StudentGroupToId",
table: "OrderStudentRecords",
column: "StudentGroupToId",
principalTable: "StudentGroups",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_OrderStudentRecords_Students_StudentId",
table: "OrderStudentRecords",
column: "StudentId",
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class ChangeStudentGroups : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_StudentGroups_AcademicPlans_AcademicPlanId",
table: "StudentGroups");
migrationBuilder.RenameColumn(
name: "EnrollmentYear",
table: "StudentGroups",
newName: "AcademicCourse");
migrationBuilder.RenameColumn(
name: "AcademicPlanId",
table: "StudentGroups",
newName: "EducationDirectionId");
migrationBuilder.RenameIndex(
name: "IX_StudentGroups_AcademicPlanId_EnrollmentYear_GroupNumber",
table: "StudentGroups",
newName: "IX_StudentGroups_EducationDirectionId_AcademicCourse_GroupNumber");
migrationBuilder.AddForeignKey(
name: "FK_StudentGroups_EducationDirections_EducationDirectionId",
table: "StudentGroups",
column: "EducationDirectionId",
principalTable: "EducationDirections",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_StudentGroups_EducationDirections_EducationDirectionId",
table: "StudentGroups");
migrationBuilder.RenameColumn(
name: "EducationDirectionId",
table: "StudentGroups",
newName: "AcademicPlanId");
migrationBuilder.RenameColumn(
name: "AcademicCourse",
table: "StudentGroups",
newName: "EnrollmentYear");
migrationBuilder.RenameIndex(
name: "IX_StudentGroups_EducationDirectionId_AcademicCourse_GroupNumber",
table: "StudentGroups",
newName: "IX_StudentGroups_AcademicPlanId_EnrollmentYear_GroupNumber");
migrationBuilder.AddForeignKey(
name: "FK_StudentGroups_AcademicPlans_AcademicPlanId",
table: "StudentGroups",
column: "AcademicPlanId",
principalTable: "AcademicPlans",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class UpdateStudnet : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Iduniv",
table: "Students",
type: "nvarchar(max)",
nullable: false,
defaultValue: "");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Iduniv",
table: "Students");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class UpdateStudnet2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Students",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Students",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,56 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class UpdateStudnet3 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Students_StudentGroups_StudentGroupId",
table: "Students");
migrationBuilder.AlterColumn<Guid>(
name: "StudentGroupId",
table: "Students",
type: "uniqueidentifier",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uniqueidentifier");
migrationBuilder.AddForeignKey(
name: "FK_Students_StudentGroups_StudentGroupId",
table: "Students",
column: "StudentGroupId",
principalTable: "StudentGroups",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Students_StudentGroups_StudentGroupId",
table: "Students");
migrationBuilder.AlterColumn<Guid>(
name: "StudentGroupId",
table: "Students",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uniqueidentifier",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Students_StudentGroups_StudentGroupId",
table: "Students",
column: "StudentGroupId",
principalTable: "StudentGroups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
using System;
using System.Runtime.Serialization;
namespace CoreDatabase.Models
{
/// <summary>
/// Базовый набор для сущности
/// </summary>
[DataContract]
public class BaseEntity : IdEntity
{
[DataMember]
public DateTime DateCreate { get; set; }
[DataMember]
public DateTime? DateDelete { get; set; }
[DataMember]
public bool IsDeleted { get; set; }
public BaseEntity() : base()
{
DateCreate = DateTime.Now;
DateDelete = null;
IsDeleted = false;
}
}
}

View File

@ -0,0 +1,40 @@
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class AcademicPlan : BaseEntity, IEntitySecurityExtenstion<AcademicPlan>, IAcademicPlanModel
{
[DataMember]
public Guid? EducationDirectionId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public int YearEntrance { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public int YearFinish { get; set; }
//-------------------------------------------------------------------------
public virtual EducationDirection EducationDirection { get; set; }
//-------------------------------------------------------------------------
[ForeignKey("AcademicPlanId")]
public virtual List<AcademicPlanRecord> AcademicPlanRecords { get; set; }
//-------------------------------------------------------------------------
public AcademicPlan SecurityCheck(AcademicPlan entity, bool allowFullData) => entity;
public override string ToString() => $"{EducationDirection?.ShortName}({EducationDirection?.Profile}): {YearEntrance}-{YearFinish}";
}
}

View File

@ -0,0 +1,61 @@
using CoreModels.Enums.Department;
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class AcademicPlanRecord : BaseEntity, IEntitySecurityExtenstion<AcademicPlanRecord>, IAcademicPlanRecordModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public Guid AcademicPlanId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public Guid DisciplineId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public bool InDepartment { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public Semester Semester { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public int Zet { get; set; }
[DataMember]
public Guid? AcademicPlanRecordParentId { get; set; }
[DataMember]
public bool IsParent { get; set; }
[DataMember]
public bool IsFacultative { get; set; }
//-------------------------------------------------------------------------
public virtual AcademicPlan AcademicPlan { get; set; }
public virtual Discipline Discipline { get; set; }
//-------------------------------------------------------------------------
[ForeignKey("AcademicPlanRecordId")]
public virtual List<AcademicPlanRecordTimeNormHour> AcademicPlanRecordTimeNormHours { get; set; }
//-------------------------------------------------------------------------
public AcademicPlanRecord SecurityCheck(AcademicPlanRecord entity, bool allowFullData) => entity;
public override string ToString() => $"{Discipline} - {Semester + 1} семестр";
}
}

View File

@ -0,0 +1,38 @@
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class AcademicPlanRecordTimeNormHour : BaseEntity, IEntitySecurityExtenstion<AcademicPlanRecordTimeNormHour>, IAcademicPlanRecordTimeNormHourModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public Guid AcademicPlanRecordId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public Guid TimeNormId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public decimal PlanHours { get; set; }
//-------------------------------------------------------------------------
public virtual AcademicPlanRecord AcademicPlanRecord { get; set; }
public virtual TimeNorm TimeNorm { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
public AcademicPlanRecordTimeNormHour SecurityCheck(AcademicPlanRecordTimeNormHour entity, bool allowFullData) => entity;
public override string ToString() => $"{AcademicPlanRecord.Discipline}({(AcademicPlanRecord.Semester + 1)}) - {TimeNorm}";
}
}

View File

@ -0,0 +1,68 @@
using CoreModels.Enums.Department;
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class Classroom : BaseEntity, IEntitySecurityExtenstion<Classroom>, IClassroomModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public string Number { get; set; }
[DataMember]
public string Title { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public Guid EmployeeId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public ClassroomType ClassroomType { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public decimal Square { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public int Capacity { get; set; }
[DataMember]
public string SecurityCode { get; set; }
[DataMember]
public bool HaveProjector { get; set; }
[DataMember]
public string Description { get; set; }
[DataMember]
public byte[] Photo { get; set; }
//-------------------------------------------------------------------------
public virtual Employee Employee { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
public Classroom SecurityCheck(Classroom entity, bool allowFullData)
{
if (!allowFullData)
{
entity.SecurityCode = "скрыто";
}
return entity;
}
public override string ToString() => Number;
}
}

View File

@ -0,0 +1,48 @@
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
/// <summary>
/// Класс, описывающий дисципилну кафедры
/// </summary>
[DataContract]
public class Discipline : BaseEntity, IEntitySecurityExtenstion<Discipline>, IDisciplineModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public Guid DisciplineBlockId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public string DisciplineName { get; set; }
[DataMember]
public string DisciplineShortName { get; set; }
[DataMember]
public string Description { get; set; }
public string DisciplineBlueAsteriskName { get; set; }
//-------------------------------------------------------------------------
public virtual DisciplineBlock DisciplineBlock { get; set; }
//-------------------------------------------------------------------------
[ForeignKey("DisciplineId")]
public virtual List<AcademicPlanRecord> AcademicPlanRecords { get; set; }
//-------------------------------------------------------------------------
public Discipline SecurityCheck(Discipline entity, bool allowFullData) => entity;
public override string ToString() => DisciplineName;
}
}

View File

@ -0,0 +1,42 @@
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class DisciplineBlock : BaseEntity, IEntitySecurityExtenstion<DisciplineBlock>, IDisciplineBlockModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public string Title { get; set; }
[DataMember]
public bool DisciplineBlockUseForGrouping { get; set; }
[DataMember]
public int DisciplineBlockOrder { get; set; }
[DataMember]
public string DisciplineBlockBlueAsteriskName { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
[ForeignKey("DisciplineBlockId")]
public virtual List<Discipline> Disciplines { get; set; }
[ForeignKey("DisciplineBlockId")]
public virtual List<TimeNorm> TimeNorms { get; set; }
//-------------------------------------------------------------------------
public DisciplineBlock SecurityCheck(DisciplineBlock entity, bool allowFullData) => entity;
public override string ToString() => Title;
}
}

View File

@ -0,0 +1,60 @@
using CoreModels.Enums.Department;
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
/// <summary>
/// Класс, описывающий направление обучения кафедры
/// </summary>
[DataContract]
public class EducationDirection : BaseEntity, IEntitySecurityExtenstion<EducationDirection>, IEducationDirectionModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public string Cipher { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public string ShortName { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public string Title { get; set; }
public string Profile { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public EducationDirectionQualification Qualification { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public Guid LecturerId { get; set; }
public string Description { get; set; }
//-------------------------------------------------------------------------
public virtual Lecturer Lecturer { get; set; }
//-------------------------------------------------------------------------
[ForeignKey("EducationDirectionId")]
public virtual List<AcademicPlan> AcademicPlans { get; set; }
[ForeignKey("EducationDirectionId")]
public virtual List<StudentGroup> StudentGroups { get; set; }
//-------------------------------------------------------------------------
public EducationDirection SecurityCheck(EducationDirection entity, bool allowFullData) => entity;
public override string ToString() => $"{Cipher} {ShortName}({Profile})";
}
}

View File

@ -0,0 +1,83 @@
using CoreModels.ModelsDepartment;
using CoreDatabase.Models.Security;
using ToolsModule.Extensions;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class Employee : BaseEntity, IEntitySecurityExtenstion<Employee>, IEmployeeModel
{
[DataMember]
public Guid UserId { get; set; }
[DataMember]
public string FirstName { get; set; }
[DataMember]
public string LastName { get; set; }
[DataMember]
public string Patronymic { get; set; }
[DataMember]
public DateTime DateBirth { get; set; }
[DataMember]
public string Address { get; set; }
[DataMember]
public string Email { get; set; }
[DataMember]
public string MobileNumber { get; set; }
[DataMember]
public string HomeNumber { get; set; }
[DataMember]
public string Description { get; set; }
[DataMember]
public byte[] Photo { get; set; }
[DataMember]
public string GroupElectricalSafety { get; set; }
//-------------------------------------------------------------------------
public virtual User User { get; set; }
//-------------------------------------------------------------------------
[ForeignKey("EmployeeId")]
public virtual List<EmployeePost> EmployeePosts { get; set; }
[ForeignKey("EmployeeId")]
public virtual List<Classroom> Classrooms { 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;
}
public override string ToString() =>
$"{LastName}{(FirstName.IsNotEmpty() ? $" {FirstName[0]}." : string.Empty)}{(Patronymic.IsNotEmpty() ? $"{Patronymic[0]}." : string.Empty)}";
}
}

View File

@ -0,0 +1,40 @@
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class EmployeePost : BaseEntity, IEntitySecurityExtenstion<EmployeePost>, IEmployeePostModel
{
[DataMember]
public Guid EmployeeId { get; set; }
[DataMember]
public Guid PostId { get; set; }
[DataMember]
public decimal Rate { get; set; }
[DataMember]
public bool IsInternalCombination { get; set; }
[DataMember]
public bool IsExternalCombination { get; set; }
//-------------------------------------------------------------------------
public virtual Post Post { get; set; }
public virtual Employee Employee { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
public EmployeePost SecurityCheck(EmployeePost entity, bool allowFullData) => entity;
public override string ToString() => $"{Post}-{Employee}";
}
}

View File

@ -0,0 +1,110 @@
using CoreModels.ModelsDepartment;
using CoreDatabase.Models.Security;
using ToolsModule.Extensions;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class Lecturer : BaseEntity, IEntitySecurityExtenstion<Lecturer>, ILecturerModel
{
[DataMember]
[Required]
public Guid UserId { get; set; }
[DataMember]
public Guid? LecturerAcademicRankId { get; set; }
[DataMember]
public Guid? LecturerAcademicDegreeId { get; set; }
[DataMember]
[Required]
public string LastName { get; set; }
[DataMember]
[Required]
public string FirstName { get; set; }
[DataMember]
public string Patronymic { get; set; }
[DataMember]
public string Abbreviation { get; set; }
[DataMember]
[Required]
public DateTime DateBirth { get; set; }
[DataMember]
[Required]
public string Address { get; set; }
[DataMember]
[Required]
public string Email { get; set; }
[DataMember]
[Required]
public string MobileNumber { get; set; }
[DataMember]
public string HomeNumber { get; set; }
[DataMember]
public string Description { get; set; }
[DataMember]
public byte[] Photo { get; set; }
[DataMember]
public bool OnlyForPrivate { get; set; }
[DataMember]
public string GroupElectricalSafety { get; set; }
//-------------------------------------------------------------------------
public virtual User User { get; set; }
public virtual LecturerAcademicRank LecturerAcademicRank { get; set; }
public virtual LecturerAcademicDegree LecturerAcademicDegree { get; set; }
//-------------------------------------------------------------------------
[ForeignKey("LecturerId")]
public virtual List<LecturerPost> LecturerPosts { get; set; }
[ForeignKey("LecturerId")]
public virtual List<EducationDirection> EducationDirections { get; set; }
[ForeignKey("LecturerId")]
public virtual List<StudentGroup> StudentGroups { get; set; }
//-------------------------------------------------------------------------
public Lecturer SecurityCheck(Lecturer entity, bool allowFullData)
{
if (!allowFullData)
{
entity.DateBirth = DateTime.Now;
entity.Address = "скрыто";
entity.Email = "скрыто";
entity.MobileNumber = "скрыто";
entity.HomeNumber = "скрыто";
entity.Photo = null;
}
return entity;
}
public override string ToString() =>
$"{LastName}{(FirstName.IsNotEmpty() ? $" {FirstName[0]}." : string.Empty)}{(Patronymic.IsNotEmpty() ? $"{Patronymic[0]}." : string.Empty)}";
}
}

View File

@ -0,0 +1,36 @@
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class LecturerAcademicDegree : BaseEntity, IEntitySecurityExtenstion<LecturerAcademicDegree>, ILecturerAcademicDegreeModel
{
[DataMember]
[Required]
public string LecturerAcademicDegreeName { get; set; }
[DataMember]
public string Description { get; set; }
[DataMember]
public int Order { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
[ForeignKey("LecturerAcademicDegreeId")]
public virtual List<Lecturer> Lecturers { get; set; }
//-------------------------------------------------------------------------
public LecturerAcademicDegree SecurityCheck(LecturerAcademicDegree entity, bool allowFullData) => entity;
public override string ToString() => LecturerAcademicDegreeName;
}
}

View File

@ -0,0 +1,33 @@
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class LecturerAcademicRank : BaseEntity, IEntitySecurityExtenstion<LecturerAcademicRank>, ILecturerAcademicRankModel
{
[DataMember]
[Required]
public string LecturerAcademicRankName { get; set; }
[DataMember]
public int Order { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
[ForeignKey("LecturerAcademicRankId")]
public virtual List<Lecturer> Lecturers { get; set; }
//-------------------------------------------------------------------------
public LecturerAcademicRank SecurityCheck(LecturerAcademicRank entity, bool allowFullData) => entity;
public override string ToString() => LecturerAcademicRankName;
}
}

View File

@ -0,0 +1,44 @@
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class LecturerPost : BaseEntity, IEntitySecurityExtenstion<LecturerPost>, ILecturerPostModel
{
[DataMember]
[Required]
public Guid LecturerId { get; set; }
[DataMember]
[Required]
public Guid PostId { get; set; }
[DataMember]
[Required]
public decimal Rate { get; set; }
[DataMember]
public bool IsInternalCombination { get; set; }
[DataMember]
public bool IsExternalCombination { get; set; }
//-------------------------------------------------------------------------
public virtual Post Post { get; set; }
public virtual Lecturer Lecturer { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
public LecturerPost SecurityCheck(LecturerPost entity, bool allowFullData) => entity;
public override string ToString() => $"{Lecturer}-{Post}";
}
}

View File

@ -0,0 +1,40 @@
using CoreModels.Enums.Department;
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class Order : BaseEntity, IEntitySecurityExtenstion<Order>, IOrderModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public string OrderNumber { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public DateTime OrderDate { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public OrderType OrderType { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
[ForeignKey("OrderId")]
public virtual List<OrderStudentRecord> OrderStudentRecords { get; set; }
//-------------------------------------------------------------------------
public Order SecurityCheck(Order entity, bool allowFullData) => entity;
public override string ToString() => $"№{OrderNumber} от {OrderDate.ToShortDateString()}";
}
}

View File

@ -0,0 +1,61 @@
using CoreModels.Enums.Department;
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class OrderStudentRecord : BaseEntity, IEntitySecurityExtenstion<OrderStudentRecord>, IOrderStudentRecordModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public Guid OrderId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public Guid StudentId { get; set; }
[DataMember]
public Guid? StudentGroupFromId { get; set; }
[DataMember]
public Guid? StudentGroupToId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public OrderStudentMoveType OrderStudentMoveType { get; set; }
[DataMember]
public string Info { get; set; }
//-------------------------------------------------------------------------
public virtual Order Order { get; set; }
public virtual Student Student { get; set; }
public virtual StudentGroup StudentGroupFrom { get; set; }
public virtual StudentGroup StudentGroupTo { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
public OrderStudentRecord SecurityCheck(OrderStudentRecord entity, bool allowFullData)
{
if (!allowFullData)
{
entity.Info = string.Empty;
entity.OrderStudentMoveType = 0;
}
return entity;
}
public override string ToString() => $"{Student} {OrderStudentMoveType}";
}
}

View File

@ -0,0 +1,31 @@
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class OrderSyncHistory : IdEntity, IEntitySecurityExtenstion<OrderSyncHistory>, IOrderSyncHistoryModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public DateTime SyncDate { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
[ForeignKey("OrderSyncHistoryId")]
public virtual List<OrderSyncHistoryRecord> OrderSyncHistoryRecords { get; set; }
//-------------------------------------------------------------------------
public OrderSyncHistory SecurityCheck(OrderSyncHistory entity, bool allowFullData) => entity;
public override string ToString() => SyncDate.ToShortDateString();
}
}

View File

@ -0,0 +1,40 @@
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class OrderSyncHistoryRecord : IdEntity, IEntitySecurityExtenstion<OrderSyncHistoryRecord>, IOrderSyncHistoryRecordModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public Guid OrderSyncHistoryId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public string Information { get; set; }
//-------------------------------------------------------------------------
public virtual OrderSyncHistory OrderSyncHistory { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
public OrderSyncHistoryRecord SecurityCheck(OrderSyncHistoryRecord entity, bool allowFullData)
{
if (!allowFullData)
{
entity.Information = "скрыто";
}
return entity;
}
public override string ToString() => Information;
}
}

View File

@ -0,0 +1,37 @@
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class Post : BaseEntity, IEntitySecurityExtenstion<Post>, IPostModel
{
[DataMember]
public string PostName { get; set; }
[DataMember]
public int? Hours { get; set; }
[DataMember]
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;
public override string ToString() => PostName;
}
}

View File

@ -0,0 +1,86 @@
using CoreModels.Enums.Department;
using CoreModels.ModelsDepartment;
using CoreDatabase.Models.Security;
using ToolsModule.Extensions;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class Student : BaseEntity, IEntitySecurityExtenstion<Student>, IStudentModel
{
[DataMember]
[Required]
public Guid UserId { get; set; }
[DataMember]
public Guid? StudentGroupId { get; set; }
[DataMember]
[Required]
public string Iduniv { get; set; }
[DataMember]
[Required]
public string NumberOfBook { get; set; }
[DataMember]
[Required]
public string LastName { get; set; }
[DataMember]
[Required]
public string FirstName { get; set; }
[DataMember]
public string Patronymic { get; set; }
[DataMember]
public string Email { get; set; }
[DataMember]
public string Description { get; set; }
[Required(ErrorMessage = "required")]
public StudentState StudentState { get; set; }
[DataMember]
public byte[] Photo { get; set; }
[DataMember]
public bool IsSteward { get; set; }
//-------------------------------------------------------------------------
public virtual User User { get; set; }
public virtual StudentGroup StudentGroup { get; set; }
//-------------------------------------------------------------------------
[ForeignKey("StudentId")]
public virtual List<OrderStudentRecord> OrderStudentRecords { get; set; }
//-------------------------------------------------------------------------
public Student SecurityCheck(Student entity, bool allowFullData)
{
if (!allowFullData)
{
entity.NumberOfBook = Guid.NewGuid().ToString();
entity.Email = "скрыто";
entity.Photo = null;
}
return entity;
}
public override string ToString() =>
$"{LastName}{(FirstName.IsNotEmpty() ? $" {FirstName[0]}." : string.Empty)}{(Patronymic.IsNotEmpty() ? $"{Patronymic[0]}." : string.Empty)}";
}
}

View File

@ -0,0 +1,59 @@
using CoreModels.Enums.Department;
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class StudentGroup : BaseEntity, IEntitySecurityExtenstion<StudentGroup>, IStudentGroupModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public Guid EducationDirectionId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public int GroupNumber { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public AcademicCourse AcademicCourse { get; set; }
[DataMember]
public Guid? LecturerId { get; set; }
//-------------------------------------------------------------------------
public virtual EducationDirection EducationDirection { get; set; }
public virtual Lecturer Lecturer { get; set; }
//-------------------------------------------------------------------------
[ForeignKey("StudentGroupId")]
public virtual List<Student> Students { get; set; }
[ForeignKey("StudentGroupFromId")]
public virtual List<OrderStudentRecord> OrderStudentRecordFroms { get; set; }
[ForeignKey("StudentGroupToId")]
public virtual List<OrderStudentRecord> OrderStudentRecordTos { get; set; }
//-------------------------------------------------------------------------
public StudentGroup SecurityCheck(StudentGroup entity, bool allowFullData) => entity;
public override string ToString() => $"{EducationDirection?.ShortName}-{AcademicCourse}{GroupNumber}";
public int GetStudnetsByState(StudentState state)
{
return Students?.Where(x => x.StudentState == state)?.Count() ?? 0;
}
}
}

View File

@ -0,0 +1,71 @@
using CoreModels.Enums.Department;
using CoreModels.ModelsDepartment;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class TimeNorm : BaseEntity, IEntitySecurityExtenstion<TimeNorm>, ITimeNormModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public Guid DisciplineBlockId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public string TimeNormName { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public string TimeNormShortName { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public int TimeNormOrder { get; set; }
[DataMember]
public EducationDirectionQualification? TimeNormEducationDirectionQualification { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public string KindOfLoadName { get; set; }
[DataMember]
public string KindOfLoadAttributeName { get; set; }
[DataMember]
public string KindOfLoadBlueAsteriskName { get; set; }
[DataMember]
public string KindOfLoadBlueAsteriskAttributeName { get; set; }
[DataMember]
public string KindOfLoadBlueAsteriskPracticName { get; set; }
[DataMember]
public bool UseInLearningProgress { get; set; }
[DataMember]
public bool UseInSite { get; set; }
//-------------------------------------------------------------------------
public virtual DisciplineBlock DisciplineBlock { get; set; }
//-------------------------------------------------------------------------
[ForeignKey("TimeNormId")]
public virtual List<AcademicPlanRecordTimeNormHour> AcademicPlanRecordTimeNormHours { get; set; }
//-------------------------------------------------------------------------
public TimeNorm SecurityCheck(TimeNorm entity, bool allowFullData) => entity;
public override string ToString() => TimeNormName;
}
}

View File

@ -0,0 +1,24 @@
using ToolsModule.Attributes;
using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models
{
/// <summary>
/// Тип Id для всеъ сущностей
/// </summary>
[DataContract]
public class IdEntity
{
[DataMember]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[MapConfiguration("Id")]
public Guid Id { get; set; }
public IdEntity() : base()
{
Id = Guid.NewGuid();
}
}
}

View File

@ -0,0 +1,44 @@
using CoreModels.ModelsSecurity;
using ToolsModule.Enums;
using ToolsModule.Interfaces;
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Security
{
[DataContract]
public class Access : BaseEntity, IEntitySecurityExtenstion<Access>, IAccessModel
{
[DataMember]
[Required]
public Guid RoleId { get; set; }
[DataMember]
[Required]
public AccessOperation AccessOperation { get; set; }
[DataMember]
[Required]
public AccessType AccessType { get; set; }
//-------------------------------------------------------------------------
public virtual Role Role { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
public Access SecurityCheck(Access entity, bool allowFullData)
{
if (!allowFullData)
{
entity.AccessType = AccessType.View;
}
return entity;
}
public override string ToString() => $"{Role.RoleName}-{AccessOperation:G}({AccessType:G})";
}
}

View File

@ -0,0 +1,39 @@
using CoreModels.ModelsSecurity;
using ToolsModule.Interfaces;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Security
{
[DataContract]
public class EnviromentSetting : BaseEntity, IEntitySecurityExtenstion<EnviromentSetting>, IEnviromentSettingModel
{
[DataMember]
[Required]
public string Key { get; set; }
[DataMember]
[Required]
public string Value { get; set; }
[DataMember]
public string Description { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
public EnviromentSetting SecurityCheck(EnviromentSetting entity, bool allowFullData)
{
if (!allowFullData)
{
entity.Value = "скрыто";
}
return entity;
}
public override string ToString() => Key;
}
}

View File

@ -0,0 +1,37 @@
using CoreModels.ModelsSecurity;
using ToolsModule.Interfaces;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Security
{
[DataContract]
public class Role : BaseEntity, IEntitySecurityExtenstion<Role>, IRoleModel
{
[DataMember]
[Required]
public string RoleName { get; set; }
[DataMember]
public int RolePriority { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
[ForeignKey("RoleId")]
public virtual List<Access> Access { get; set; }
[ForeignKey("RoleId")]
public virtual List<UserRole> UserRoles { get; set; }
//-------------------------------------------------------------------------
public Role SecurityCheck(Role entity, bool allowFullData) => entity;
public override string ToString() => RoleName;
}
}

View File

@ -0,0 +1,74 @@
using CoreModels.ModelsSecurity;
using CoreDatabase.Models.Department;
using ToolsModule.Attributes;
using ToolsModule.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Security
{
[DataContract]
public class User : BaseEntity, IEntitySecurityExtenstion<User>, IUserModel
{
[DataMember]
[Required]
public string UserName { get; set; }
[DataMember]
[Required]
public string PasswordHash { get; set; }
[DataMember]
public byte[] Avatar { get; set; }
[DataMember]
public DateTime? DateLastVisit { get; set; }
[DataMember]
public bool IsBanned { get; set; }
[DataMember]
public DateTime? DateBanned { get; set; }
[DataMember]
public int CountAttempt { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
[ForeignKey("UserId")]
public virtual List<UserRole> UserRoles { get; set; }
[ForeignKey("UserId")]
public virtual List<Employee> Employees { get; set; }
[ForeignKey("UserId")]
public virtual List<Lecturer> Lecturers { get; set; }
[ForeignKey("UserId")]
public virtual List<Student> Students { get; set; }
//-------------------------------------------------------------------------
public User SecurityCheck(User entity, bool allowFullData)
{
if (!allowFullData)
{
entity.PasswordHash = SecurityManager.GetPasswordHash("qwerty");
entity.Avatar = null;
entity.IsBanned = false;
entity.DateBanned = null;
entity.CountAttempt = 0;
entity.DateLastVisit = null;
}
return entity;
}
public override string ToString() => UserName;
}
}

View File

@ -0,0 +1,31 @@
using CoreModels.ModelsSecurity;
using ToolsModule.Interfaces;
using System;
using System.Runtime.Serialization;
namespace CoreDatabase.Models.Security
{
[DataContract]
public class UserRole : BaseEntity, IEntitySecurityExtenstion<UserRole>, IUserRoleModel
{
[DataMember]
public Guid RoleId { get; set; }
[DataMember]
public Guid UserId { get; set; }
//-------------------------------------------------------------------------
public virtual Role Role { get; set; }
public virtual User User { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
public UserRole SecurityCheck(UserRole entity, bool allowFullData) => entity;
public override string ToString() => $"{Role.RoleName}-{User.UserName}";
}
}

View File

@ -0,0 +1,129 @@
using Microsoft.EntityFrameworkCore;
namespace CoreDatabase.Scripts
{
/// <summary>
/// Скрипты для миграции данных по кафедре
/// </summary>
public static class DepartmentMigrationScript
{
private static readonly string clearMigration =
@"DELETE FROM [DepartmentDatabasePortal].[dbo].[Classrooms];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[DisciplineBlocks];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[Disciplines];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[Posts];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[Lecturers];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[TimeNorms];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[AcademicPlans];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[AcademicPlanRecords];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[AcademicPlanRecordTimeNormHours];
GO";
private static readonly string classroomsMigration =
@"DECLARE @employeeId uniqueidentifier;
SELECT @employeeId = emp.[Id] FROM [DepartmentDatabasePortal].[dbo].[Employees] emp
INSERT INTO [DepartmentDatabasePortal].[dbo].[Classrooms]([Id],[Number],[EmployeeId],[ClassroomType],[Square],[Capacity],[HaveProjector],[SecurityCode],
[DateCreate],[DateDelete],[IsDeleted])
SELECT [Id],[Number],@employeeId,[ClassroomType],1,[Capacity],0,'-',[DateCreate],[DateDelete],[IsDeleted] FROM [DepartmentDatabaseContext].[dbo].[Classrooms]";
private static readonly string disciplineBlockMigration =
@"INSERT INTO [DepartmentDatabasePortal].[dbo].[DisciplineBlocks]([Id],[Title],[DisciplineBlockUseForGrouping],[DisciplineBlockOrder],
[DisciplineBlockBlueAsteriskName],[DateCreate],[DateDelete],[IsDeleted])
SELECT [Id],[Title],[DisciplineBlockUseForGrouping],[DisciplineBlockOrder],[DisciplineBlockBlueAsteriskName],[DateCreate],[DateDelete],[IsDeleted] FROM
[DepartmentDatabaseContext].[dbo].[DisciplineBlocks]";
private static readonly string disciplineMigration =
@"DELETE FROM [DepartmentDatabaseContext].[dbo].[Disciplines] WHERE [Id]='6CC684D5-900C-4278-AA43-0B83D0711C55' OR [Id]='A6598227-8449-4884-8290-13EABEC26924'
OR [Id]='4581ADC8-5A15-4F95-A40D-1607856ACB5C' OR [Id]='9DA4D810-025A-4A03-81FD-293DEF52FA4B' -- дублт в дисципдинах
INSERT INTO [DepartmentDatabasePortal].[dbo].[Disciplines]([Id],[DisciplineBlockId],[DisciplineName],[DisciplineShortName],[Description],
[DisciplineBlueAsteriskName],[DateCreate],[DateDelete],[IsDeleted])
SELECT [Id],[DisciplineBlockId],[DisciplineName],[DisciplineShortName],[DisciplineDescription],[DisciplineBlueAsteriskName],[DateCreate],[DateDelete],[IsDeleted]
FROM [DepartmentDatabaseContext].[dbo].[Disciplines]";
private static readonly string postMigration =
@"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 =
@"DECLARE @userId uniqueidentifier;
SELECT @userId = u.[Id] FROM [DepartmentDatabasePortal].[dbo].[Users] u WHERE u.[UserName]='admin'
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]";
private static readonly string educationdirectionrMigration =
@"DECLARE @lecturerId uniqueidentifier;
SELECT @lecturerId = l.[Id] FROM [DepartmentDatabasePortal].[dbo].[Lecturers] l
INSERT INTO [DepartmentDatabasePortal].[dbo].[EducationDirections]([Id],[Cipher],[ShortName],[Title],[Profile],[Qualification],[LecturerId],[Description],
[DateCreate],[DateDelete],[IsDeleted])
SELECT [Id],[Cipher],[ShortName],[Title],[Profile],[Qualification],@lecturerId,[Description],[DateCreate],[DateDelete],[IsDeleted] FROM
[DepartmentDatabaseContext].[dbo].[EducationDirections]";
private static readonly string timeNormMigration =
@"INSERT INTO [DepartmentDatabasePortal].[dbo].[TimeNorms]([Id],[DisciplineBlockId],[TimeNormName],[TimeNormShortName]
,[TimeNormOrder],[TimeNormEducationDirectionQualification],[KindOfLoadName],[KindOfLoadAttributeName],[KindOfLoadBlueAsteriskName]
,[KindOfLoadBlueAsteriskAttributeName],[KindOfLoadBlueAsteriskPracticName],[UseInLearningProgress],[UseInSite],[DateCreate],[DateDelete],[IsDeleted])
SELECT [Id],[DisciplineBlockId],[TimeNormName],[TimeNormShortName],[TimeNormOrder],[TimeNormEducationDirectionQualification],[KindOfLoadName]
,[KindOfLoadAttributeName],[KindOfLoadBlueAsteriskName],[KindOfLoadBlueAsteriskAttributeName],[KindOfLoadBlueAsteriskPracticName]
,[UseInLearningProgress],[UseInSite],[DateCreate],[DateDelete],[IsDeleted] FROM [DepartmentDatabaseContext].[dbo].[TimeNorms] WHERE
[AcademicYearId]='4FFC16B7-C1A5-47B1-B780-821ED70793DC'";
private static readonly string academicplanMigration =
@"INSERT INTO [DepartmentDatabasePortal].[dbo].[AcademicPlans]([Id],[EducationDirectionId],[YearEntrance],[YearFinish],[DateCreate],[DateDelete],[IsDeleted])
SELECT [Id],[EducationDirectionId],2020 + ABS(CHECKSUM(NEWID()) % 100),2024,[DateCreate],[DateDelete],[IsDeleted] FROM [DepartmentDatabaseContext].[dbo].[AcademicPlans] WHERE
[AcademicYearId]='4FFC16B7-C1A5-47B1-B780-821ED70793DC'";
private static readonly string academicplanrecordsMigration =
@"INSERT INTO [DepartmentDatabasePortal].[dbo].[AcademicPlanRecords]([Id],[AcademicPlanId],[DisciplineId],[InDepartment],[Semester],[Zet]
,[AcademicPlanRecordParentId],[IsParent],[IsFacultative],[DateCreate],[DateDelete],[IsDeleted])
SELECT apr.[Id],apr.[AcademicPlanId],apr.[DisciplineId],apr.[InDepartment],apr.[Semester],apr.[Zet],apr.[AcademicPlanRecordParentId],apr.[IsParent],apr.[IsFacultative]
,apr.[DateCreate],apr.[DateDelete],apr.[IsDeleted] FROM [DepartmentDatabaseContext].[dbo].[AcademicPlanRecords] apr
JOIN [DepartmentDatabaseContext].[dbo].[AcademicPlans] ap on apr.[AcademicPlanId]=ap.[Id] WHERE
ap.[AcademicYearId]='4FFC16B7-C1A5-47B1-B780-821ED70793DC'";
private static readonly string academicplanrecordhoursMigration =
@"INSERT INTO [DepartmentDatabasePortal].[dbo].[AcademicPlanRecordTimeNormHours]([Id],[AcademicPlanRecordId],[TimeNormId],[PlanHours],[DateCreate],[DateDelete],
[IsDeleted])
SELECT apre.[Id],apre.[AcademicPlanRecordId],apre.[TimeNormId],apre.[PlanHours],apre.[DateCreate],apre.[DateDelete],apre.[IsDeleted]
FROM [DepartmentDatabaseContext].[dbo].[AcademicPlanRecordElements] apre
JOIN [DepartmentDatabaseContext].[dbo].[AcademicPlanRecords] apr on apre.[AcademicPlanRecordId]=apr.[Id]
JOIN [DepartmentDatabaseContext].[dbo].[AcademicPlans] ap on apr.[AcademicPlanId]=ap.[Id] WHERE
ap.[AcademicYearId]='4FFC16B7-C1A5-47B1-B780-821ED70793DC'";
/// <summary>
/// Перенос данных по безопасности
/// </summary>
/// <param name="context"></param>
public static void RunScript(DbContext context)
{
context.Database.ExecuteSqlRaw(clearMigration, null);
context.Database.ExecuteSqlRaw(classroomsMigration, null);
context.Database.ExecuteSqlRaw(disciplineBlockMigration, null);
context.Database.ExecuteSqlRaw(disciplineMigration, null);
context.Database.ExecuteSqlRaw(postMigration, null);
context.Database.ExecuteSqlRaw(lecturerMigration, null);
context.Database.ExecuteSqlRaw(educationdirectionrMigration, null);
context.Database.ExecuteSqlRaw(timeNormMigration, null);
context.Database.ExecuteSqlRaw(academicplanMigration, null);
context.Database.ExecuteSqlRaw(academicplanrecordsMigration, null);
context.Database.ExecuteSqlRaw(academicplanrecordhoursMigration, null);
}
}
}

View File

@ -0,0 +1,57 @@
using Microsoft.EntityFrameworkCore;
namespace CoreDatabase.Scripts
{
/// <summary>
/// Скрипты для миграции данных по безопасности
/// </summary>
public static class SecureMigrationScript
{
private static readonly string clearMigration =
@"DELETE FROM [DepartmentDatabasePortal].[dbo].[EnviromentSettings];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[Accesses];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[UserRoles];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[Users];
GO
DELETE FROM [DepartmentDatabasePortal].[dbo].[Roles];
GO";
private static readonly string roleMigration =
@"INSERT INTO DepartmentDatabasePortal.dbo.Roles(Id, RoleName, RolePriority, DateCreate, DateDelete, IsDeleted)
SELECT Id, RoleName, RolePriority, DateCreate, DateDelete, IsDeleted FROM DepartmentDatabaseContext.dbo.DepartmentRoles";
private static readonly string userMigration =
@"INSERT INTO DepartmentDatabasePortal.dbo.Users(Id, UserName, PasswordHash, Avatar, DateLastVisit, IsBanned, DateBanned, CountAttempt, DateCreate, DateDelete, IsDeleted)
SELECT Id, UserName, PasswordHash, Avatar, DateLastVisit, IsLocked, DateBanned, CountAttempt, DateCreate, DateDelete, IsDeleted FROM DepartmentDatabaseContext.dbo.DepartmentUsers";
private static readonly string userroleMigration =
@"INSERT INTO DepartmentDatabasePortal.dbo.UserRoles(Id, UserId, RoleId, DateCreate, DateDelete, IsDeleted)
SELECT Id, UserId, RoleId, DateCreate, DateDelete, IsDeleted FROM DepartmentDatabaseContext.dbo.DepartmentUserRoles";
private static readonly string accessMigration =
@"INSERT INTO DepartmentDatabasePortal.dbo.Accesses(Id, Operation, AccessType, RoleId, DateCreate, DateDelete, IsDeleted)
SELECT Id, Operation, AccessType, RoleId, DateCreate, DateDelete, IsDeleted FROM DepartmentDatabaseContext.dbo.DepartmentAccesses";
private static readonly string enviromentsettingMigration =
@"INSERT INTO DepartmentDatabasePortal.dbo.EnviromentSettings(Id, [Key], [Value])
SELECT NEWID(), [Key], [Value] FROM DepartmentDatabaseContext.dbo.CurrentSettings";
/// <summary>
/// Перенос данных по безопасности
/// </summary>
/// <param name="context"></param>
public static void RunScript(DbContext context)
{
context.Database.ExecuteSqlRaw(clearMigration, null);
context.Database.ExecuteSqlRaw(roleMigration, null);
context.Database.ExecuteSqlRaw(userMigration, null);
context.Database.ExecuteSqlRaw(userroleMigration, null);
context.Database.ExecuteSqlRaw(accessMigration, null);
context.Database.ExecuteSqlRaw(enviromentsettingMigration, null);
}
}
}

View File

@ -0,0 +1,237 @@
using CoreDatabase.Models.Security;
using ToolsModule.Enums;
using ToolsModule.Interfaces;
using ToolsModule.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace CoreDatabase
{
public class SecurityManager : ISecurityManager
{
private readonly int _countDayToBanned = 3;
private readonly int _countMaxAttempt = 3;
public Guid? User { get; set; }
public List<Guid> Roles { get; set; }
public string ErrorMessage { get; set; }
public bool IsAuth => User != null;
public bool CheckAccess(SecurityManagerCheckAccessModel model)
{
using var context = DatabaseManager.GetContext;
Access access = null;
if (model.Model != null)
{
// если не указан идентификатор пользователя, то смотрим, может он авторизован
if (!model.Model.UserIdForAccess.HasValue && User.HasValue)
{
model.Model.UserIdForAccess = User.Value;
}
var roles = context.UserRoles.Where(x => x.UserId == model.Model.UserIdForAccess && !x.IsDeleted).Select(x => x.Role).OrderByDescending(x => x.RolePriority).ToList();
if (roles == null)
{
ErrorMessage = $"Не верный пользователь";
return false;
}
access = context.Accesses.FirstOrDefault(a => a.AccessOperation == model.Operation && roles.Contains(a.Role));
}
else if (Roles != null)
{
access = context.Accesses.FirstOrDefault(a => a.AccessOperation == model.Operation && Roles.Contains(a.RoleId));
}
if (access != null)
{
if (access.AccessType >= model.Type) return true;
}
switch (model.Type)
{
case AccessType.View:
ErrorMessage = $"Нет доступа на чтение данных по сущности '{model.Entity}'";
return false;
case AccessType.Change:
ErrorMessage = $"Нет доступа на изменение данных по сущности '{model.Entity}'";
return false;
case AccessType.Delete:
ErrorMessage = $"Нет доступа на удаление данных по сущности '{model.Entity}'";
return false;
default:
ErrorMessage = $"Нет доступа по сущности '{model.Entity}'";
return false;
}
}
public void CheckStartDataSource()
{
using var context = DatabaseManager.GetContext;
using var transaction = context.Database.BeginTransaction();
var role = context.Roles.FirstOrDefault(x => x.RoleName == "Администратор");
if (role == null)
{
role = new Role
{
RoleName = "Администратор",
RolePriority = 100
};
context.Roles.Add(role);
context.SaveChanges();
}
var accesses = context.Accesses.Where(x => x.RoleId == role.Id);
foreach (AccessOperation operation in Enum.GetValues(typeof(AccessOperation)))
{
if (!accesses.Any(x => x.AccessOperation == operation && x.AccessType == AccessType.Delete))
{
context.Accesses.Add(new Access
{
AccessOperation = operation,
AccessType = AccessType.Delete,
RoleId = role.Id
});
}
}
context.SaveChanges();
var md5 = new MD5CryptoServiceProvider();
var user = context.Users.FirstOrDefault(x => x.UserName == "admin");
if (user == null)
{
user = new User
{
UserName = "admin",
PasswordHash = Encoding.ASCII.GetString(md5.ComputeHash(Encoding.ASCII.GetBytes("qwerty"))),
CountAttempt = 0
};
context.Users.Add(user);
context.SaveChanges();
}
var link = context.UserRoles.FirstOrDefault(x => x.RoleId == role.Id && x.UserId == user.Id);
if (link == null)
{
context.UserRoles.Add(new UserRole
{
RoleId = role.Id,
UserId = user.Id
});
context.SaveChanges();
}
List<string> enviromentKeys = new()
{
"Практика",
"Учебный год",
"Даты семестра",
"Дисциплины (модули)",
"Кафедра",
"ГИА",
"SyncStudentOrderIpAddress",
"SyncStudentOrderUserName",
"SyncStudentOrderPassword"
};
foreach(var key in enviromentKeys)
{
var es = context.EnviromentSettings.FirstOrDefault(x => x.Key == key);
if(es == null)
{
context.EnviromentSettings.Add(new EnviromentSetting
{
Key = key,
Value = "Прописать значение!"
});
}
}
context.SaveChanges();
transaction.Commit();
}
public async Task LoginAsync(string login, string password)
{
var passwordHash = GetPasswordHash(password);
using var context = DatabaseManager.GetContext;
var user = context.Users.FirstOrDefault(x => x.UserName == login && x.PasswordHash == passwordHash && !x.IsDeleted);
await CheckUserAsync(login, user, context);
user.DateLastVisit = DateTime.Now;
user.CountAttempt = 0;
await context.SaveChangesAsync();
User = user.Id;
Roles = context.UserRoles.Where(x => x.UserId == user.Id && !x.IsDeleted).Select(x => x.RoleId).ToList();
}
public async Task LogoutAsync()
{
await Task.Run(() =>
{
User = null;
Roles = null;
});
}
public async Task ChangePassword(string login, string oldPassword, string newPassword)
{
using var context = DatabaseManager.GetContext;
var user = context.Users.FirstOrDefault(x => x.UserName == login && x.PasswordHash == GetPasswordHash(oldPassword) && !x.IsDeleted);
await CheckUserAsync(login, user, context);
user.PasswordHash = GetPasswordHash(newPassword);
await context.SaveChangesAsync();
}
/// <summary>
/// Получение хеша пароля
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
public static string GetPasswordHash(string password) => Encoding.ASCII.GetString((new MD5CryptoServiceProvider()).ComputeHash(Encoding.ASCII.GetBytes(password)));
/// <summary>
/// Проверка пользователя при авторизации и при смене пароля
/// </summary>
/// <param name="login"></param>
/// <param name="user"></param>
/// <param name="context"></param>
/// <returns></returns>
private async Task CheckUserAsync(string login, User user, DatabaseContext context)
{
if (user == null)
{
user = context.Users.FirstOrDefault(x => x.UserName == login && !x.IsDeleted);
if (user != null)
{
user.CountAttempt++;
if (user.CountAttempt > _countMaxAttempt)
{
user.IsBanned = true;
user.DateBanned = DateTime.Now;
await context.SaveChangesAsync();
throw new Exception($"Введен неверный логин/пароль? учетная запись заблоикрована на {_countDayToBanned} дней(я)");
}
}
throw new Exception("Введен неверный логин/пароль");
}
if (user.IsBanned)
{
if (user.DateBanned.Value.AddDays(_countDayToBanned) > DateTime.Now)
{
user.IsBanned = false;
await context.SaveChangesAsync();
}
else
{
throw new Exception("Пользователь заблокирован");
}
}
}
}
}

View File

@ -1,4 +1,4 @@
using DatabaseCore.Models;
using CoreDatabase.Models;
using Microsoft.EntityFrameworkCore;
using ToolsModule.BindingModels;
using ToolsModule.BusinessLogics;
@ -9,7 +9,7 @@ using ToolsModule.ViewModels;
using System;
using System.Linq;
namespace DatabaseCore
namespace CoreDatabase
{
public abstract class AbstractGenerticEntityService<G, S, T, L, E> : IGenerticEntityService<G, S>
where G : GetBindingModel

View File

@ -1,8 +1,8 @@
using DatabaseCore.Models.Department;
using DatabaseCore.Models.Security;
using CoreDatabase.Models.Department;
using CoreDatabase.Models.Security;
using Microsoft.EntityFrameworkCore;
namespace DatabaseCore
namespace CoreDatabase
{
public class DatabaseContext : DbContext
{

Some files were not shown because too many files have changed in this diff Show More