Добавление модели и таблицы БД

This commit is contained in:
kotcheshir73 2022-12-20 22:28:40 +04:00
parent 92f9e9f8e9
commit be261d84d4
10 changed files with 1862 additions and 0 deletions

View File

@ -90,6 +90,7 @@ namespace CoreDatabase
.WithMany(x => x.OrderStudentRecords)
.OnDelete(DeleteBehavior.NoAction);
modelBuilder.Entity<StudentMarkPassedDiscipline>().HasIndex(d => new { d.StudentId, d.DisciplineId, d.Semester, d.Mark }).IsUnique();
}
#region Security
@ -122,6 +123,7 @@ namespace CoreDatabase
public virtual DbSet<OrderStudentRecord> OrderStudentRecords { set; get; }
public virtual DbSet<OrderSyncHistory> OrderSyncHistories { set; get; }
public virtual DbSet<OrderSyncHistoryRecord> OrderSyncHistoryRecords { set; get; }
public virtual DbSet<StudentMarkPassedDiscipline> StudentMarkPassedDisciplines { set; get; }
#endregion
}
}

View File

@ -0,0 +1,61 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace CoreDatabase.Migrations
{
public partial class AddStudentMarkPassedDiscipline : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "StudentMarkPassedDisciplines",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
StudentId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
DisciplineId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Semester = table.Column<int>(type: "int", nullable: false),
Mark = table.Column<int>(type: "int", nullable: false),
DateAffixing = table.Column<DateTime>(type: "datetime2", nullable: false),
IsIncreaseMark = table.Column<bool>(type: "bit", nullable: false),
IsDirection = 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_StudentMarkPassedDisciplines", x => x.Id);
table.ForeignKey(
name: "FK_StudentMarkPassedDisciplines_Disciplines_DisciplineId",
column: x => x.DisciplineId,
principalTable: "Disciplines",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StudentMarkPassedDisciplines_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_StudentMarkPassedDisciplines_DisciplineId",
table: "StudentMarkPassedDisciplines",
column: "DisciplineId");
migrationBuilder.CreateIndex(
name: "IX_StudentMarkPassedDisciplines_StudentId_DisciplineId_Semester_Mark",
table: "StudentMarkPassedDisciplines",
columns: new[] { "StudentId", "DisciplineId", "Semester", "Mark" },
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "StudentMarkPassedDisciplines");
}
}
}

View File

@ -881,6 +881,51 @@ namespace CoreDatabase.Migrations
b.ToTable("StudentGroups");
});
modelBuilder.Entity("CoreDatabase.Models.Department.StudentMarkPassedDiscipline", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateAffixing")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<Guid>("DisciplineId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsDirection")
.HasColumnType("bit");
b.Property<bool>("IsIncreaseMark")
.HasColumnType("bit");
b.Property<int>("Mark")
.HasColumnType("int");
b.Property<int>("Semester")
.HasColumnType("int");
b.Property<Guid>("StudentId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("DisciplineId");
b.HasIndex("StudentId", "DisciplineId", "Semester", "Mark")
.IsUnique();
b.ToTable("StudentMarkPassedDisciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.TimeNorm", b =>
{
b.Property<Guid>("Id")
@ -1360,6 +1405,25 @@ namespace CoreDatabase.Migrations
b.Navigation("Lecturer");
});
modelBuilder.Entity("CoreDatabase.Models.Department.StudentMarkPassedDiscipline", b =>
{
b.HasOne("CoreDatabase.Models.Department.Discipline", "Discipline")
.WithMany("StudentMarkPassedDisciplines")
.HasForeignKey("DisciplineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CoreDatabase.Models.Department.Student", "Student")
.WithMany("StudentMarkPassedDisciplines")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Discipline");
b.Navigation("Student");
});
modelBuilder.Entity("CoreDatabase.Models.Department.TimeNorm", b =>
{
b.HasOne("CoreDatabase.Models.Department.DisciplineBlock", "DisciplineBlock")
@ -1423,6 +1487,8 @@ namespace CoreDatabase.Migrations
modelBuilder.Entity("CoreDatabase.Models.Department.Discipline", b =>
{
b.Navigation("AcademicPlanRecords");
b.Navigation("StudentMarkPassedDisciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.DisciplineBlock", b =>
@ -1485,6 +1551,8 @@ namespace CoreDatabase.Migrations
modelBuilder.Entity("CoreDatabase.Models.Department.Student", b =>
{
b.Navigation("OrderStudentRecords");
b.Navigation("StudentMarkPassedDisciplines");
});
modelBuilder.Entity("CoreDatabase.Models.Department.StudentGroup", b =>

View File

@ -44,6 +44,9 @@ namespace CoreDatabase.Models.Department
[ForeignKey("DisciplineId")]
public virtual List<AcademicPlanRecord> AcademicPlanRecords { get; set; }
[ForeignKey("DisciplineId")]
public virtual List<StudentMarkPassedDiscipline> StudentMarkPassedDisciplines { get; set; }
//-------------------------------------------------------------------------
public Discipline SecurityCheck(Discipline entity, bool allowFullData) => entity;

View File

@ -71,6 +71,9 @@ namespace CoreDatabase.Models.Department
[ForeignKey("StudentId")]
public virtual List<OrderStudentRecord> OrderStudentRecords { get; set; }
[ForeignKey("StudentId")]
public virtual List<StudentMarkPassedDiscipline> StudentMarkPassedDisciplines { get; set; }
//-------------------------------------------------------------------------
public Student SecurityCheck(Student entity, bool allowFullData)

View File

@ -0,0 +1,65 @@
using CoreModels.Enums.Department;
using CoreModels.ModelsDepartment;
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using ToolsModule.ManagmentSecurity;
namespace CoreDatabase.Models.Department
{
[DataContract]
public class StudentMarkPassedDiscipline : BaseEntity, IEntitySecurityExtenstion<StudentMarkPassedDiscipline>, IStudentMarkPassedDisciplineModel
{
[DataMember]
[Required(ErrorMessage = "required")]
public Guid StudentId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public Guid DisciplineId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public Semester Semester { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public MarkDisciplinePassedType Mark { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public DateTime DateAffixing { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public bool IsIncreaseMark { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
public bool IsDirection { get; set; }
//-------------------------------------------------------------------------
public virtual Discipline Discipline { get; set; }
public virtual Student Student { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
public StudentMarkPassedDiscipline SecurityCheck(StudentMarkPassedDiscipline entity, bool allowFullData)
{
if (!allowFullData)
{
entity.Mark = MarkDisciplinePassedType.НеСдано;
entity.DateAffixing = DateTime.Now;
entity.Semester = Semester.Нулевой;
}
return entity;
}
public override string ToString() => $"{Student} {Discipline} {Semester + 1} семестр {Mark}";
}
}

View File

@ -0,0 +1,22 @@
namespace CoreModels.Enums.Department
{
/// <summary>
/// Результат сдачи предмета в сессию
/// </summary>
public enum MarkDisciplinePassedType
{
НеСдано = -1,
НеЯвился = 0,
НеУдовлетворительно = 1,
Удовлетворительно = 2,
Хорошо = 3,
Отлично = 4,
Зачет = 10,
}
}

View File

@ -5,6 +5,8 @@
/// </summary>
public enum Semester
{
Нулевой = -1,
Первый = 1,
Второй = 2,

View File

@ -0,0 +1,42 @@
using CoreModels.Enums.Department;
using CoreModels.Tools;
using System;
using ToolsModule.ManagmentEntity;
namespace CoreModels.ModelsDepartment
{
[EntityDescription("StudentMarkPassedDiscipline", "Оценка студента по сданной дисципилне")]
[EntityDependency("Discipline", "DisciplineId", "Дисциплина, по которой выставлена оценка")]
[EntityDependency("Student", "StudentId", "Студент, сдающий дисциплину")]
public interface IStudentMarkPassedDisciplineModel : IId
{
Guid StudentId { get; }
Guid DisciplineId { get; }
/// <summary>
/// Семестр, в котором сдавался экзамен/зачет по дисциплине
/// </summary>
Semester Semester { get; }
/// <summary>
/// Результат сдачи
/// </summary>
MarkDisciplinePassedType Mark { get; }
/// <summary>
/// Дата сдачи
/// </summary>
DateTime DateAffixing { get; }
/// <summary>
/// Является повышением оценки
/// </summary>
bool IsIncreaseMark { get; }
/// <summary>
/// Является сдачей по направлению
/// </summary>
bool IsDirection { get; }
}
}