пытаюсь пофиксить ведомости

This commit is contained in:
Arkadiy Radaev
2024-05-24 13:07:49 +04:00
parent 3f308271a4
commit 755b6fb81f
15 changed files with 155 additions and 425 deletions

View File

@@ -388,19 +388,21 @@ namespace UniversityAdminApp.Controllers
}
[HttpPost]
public void CreateStudyList(string name, DateTime date )
public void CreateStudyList(string name, DateTime date, int teacherId )
{
if (APIAdmin.Admin == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(name) || date == DateTime.MinValue)
if (string.IsNullOrEmpty(name) || date == DateTime.MinValue || teacherId < 0)
{
throw new Exception("Ошибка в введенных данных");
}
APIAdmin.PostRequest("api/studyList/createstudyList", new StudyListBindingModel
{
AdminId = APIAdmin.Admin.Id,
TeacherId = teacherId,
Name = name,
Date = date
});
@@ -443,13 +445,13 @@ namespace UniversityAdminApp.Controllers
}
[HttpPost]
public void UpdateStudyList(int studyListId, string name, DateTime date)
public void UpdateStudyList(int studyListId, string name, DateTime date, int teacherId)
{
if (APIAdmin.Admin == null)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(name) || date == DateTime.MinValue)
if (string.IsNullOrEmpty(name) || date == DateTime.MinValue || teacherId < 0)
{
throw new Exception("Ошибка в введенных данных");
}
@@ -457,8 +459,10 @@ namespace UniversityAdminApp.Controllers
APIAdmin.PostRequest("api/studyList/updatestudyList?isconnection=false", new StudyListBindingModel
{
Id = studyListId,
TeacherId = teacherId,
Name = name,
Date = date
Date = date,
AdminId = APIAdmin.Admin.Id
});
Response.Redirect("Index");
}

View File

@@ -8,6 +8,11 @@
<ItemGroup>
<PackageReference Include="MailKit" Version="4.6.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

View File

@@ -5,5 +5,6 @@
"Microsoft.AspNetCore": "Warning"
}
},
"IPAddress": "https://localhost:8080",
"AllowedHosts": "*"
}

View File

@@ -13,5 +13,6 @@ namespace UniversityContracts.BindingModels
public int AdminId { get; set; }
public string Name { get; set; } = string.Empty;
public DateTime Date { get; set; }
public int TeacherId { get; set; }
}
}

View File

@@ -10,6 +10,7 @@ namespace UniversityContracts.SearchModels
{
public int? Id { get; set; }
public int? AdminId { get; set; }
public int? TeacherId { get; set; }
public string? Name { get; set; }
public DateTime? Date { get; set; }
}

View File

@@ -12,6 +12,7 @@ namespace UniversityContracts.ViewModels
{
public int Id { get; set; }
public int AdminId { get; set; }
public int TeacherId { get; set; }
[DisplayName("ФИО Преподователя")]
public string TeacherFIO { get; set; } = string.Empty;

View File

@@ -9,6 +9,7 @@ namespace UniversityDataModels.Models
public interface IStudyListModel: IId
{
int AdminId { get; }
int TeacherId { get; }
string Name { get; }
DateTime Date { get; }
}

View File

@@ -47,6 +47,7 @@ namespace UniversityDatabaseImplement.Implements
return context.StudyLists.Include(x => x.Teacher).Where(x => ((!model.Id.HasValue || x.Id == model.Id)
&& (!model.AdminId.HasValue || x.AdminId == model.AdminId)
&& (!model.TeacherId.HasValue || x.TeacherId == model.TeacherId)
&& (model.Date.HasValue || x.Date == model.Date)
&& (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name)))
.Select(x => x.GetViewModel).ToList();

View File

@@ -1,392 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace UniversityDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitMirgation : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Admins",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AdminFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Admins", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Disciplines",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
CountHours = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Disciplines", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Secretaries",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SecretaryFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Secretaries", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Teachers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TeacherFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
Position = table.Column<string>(type: "nvarchar(max)", nullable: false),
AcademicDegree = table.Column<string>(type: "nvarchar(max)", nullable: false),
AdminId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Teachers", x => x.Id);
table.ForeignKey(
name: "FK_Teachers_Admins_AdminId",
column: x => x.AdminId,
principalTable: "Admins",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "EducationPlans",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EducationPlanName = table.Column<string>(type: "nvarchar(max)", nullable: false),
SecretaryId = table.Column<int>(type: "int", nullable: false),
DateStart = table.Column<DateTime>(type: "datetime2", nullable: false),
DateEnd = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EducationPlans", x => x.Id);
table.ForeignKey(
name: "FK_EducationPlans_Secretaries_SecretaryId",
column: x => x.SecretaryId,
principalTable: "Secretaries",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Students",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
StudentFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
SecretaryId = table.Column<int>(type: "int", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Students", x => x.Id);
table.ForeignKey(
name: "FK_Students_Secretaries_SecretaryId",
column: x => x.SecretaryId,
principalTable: "Secretaries",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "StudyLists",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
TeacherId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_StudyLists", x => x.Id);
table.ForeignKey(
name: "FK_StudyLists_Teachers_TeacherId",
column: x => x.TeacherId,
principalTable: "Teachers",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "TeacherDisciplines",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TeacherId = table.Column<int>(type: "int", nullable: false),
DisciplineId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TeacherDisciplines", x => x.Id);
table.ForeignKey(
name: "FK_TeacherDisciplines_Disciplines_DisciplineId",
column: x => x.DisciplineId,
principalTable: "Disciplines",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TeacherDisciplines_Teachers_TeacherId",
column: x => x.TeacherId,
principalTable: "Teachers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "EducationPlanTeachers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EducationPlanId = table.Column<int>(type: "int", nullable: false),
TeacherId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EducationPlanTeachers", x => x.Id);
table.ForeignKey(
name: "FK_EducationPlanTeachers_EducationPlans_EducationPlanId",
column: x => x.EducationPlanId,
principalTable: "EducationPlans",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_EducationPlanTeachers_Teachers_TeacherId",
column: x => x.TeacherId,
principalTable: "Teachers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Certifications",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
StudentId = table.Column<int>(type: "int", nullable: false),
SecretaryId = table.Column<int>(type: "int", nullable: false),
Type = table.Column<int>(type: "int", nullable: false),
Mark = table.Column<int>(type: "int", nullable: false),
CertificationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Certifications", x => x.Id);
table.ForeignKey(
name: "FK_Certifications_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Certifications_Secretaries_SecretaryId",
column: x => x.SecretaryId,
principalTable: "Secretaries",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "DisciplineStudents",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DisciplineId = table.Column<int>(type: "int", nullable: false),
StudentId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DisciplineStudents", x => x.Id);
table.ForeignKey(
name: "FK_DisciplineStudents_Disciplines_DisciplineId",
column: x => x.DisciplineId,
principalTable: "Disciplines",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DisciplineStudents_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "StudentEducationPlans",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
StudentId = table.Column<int>(type: "int", nullable: false),
EducationPlanId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StudentEducationPlans", x => x.Id);
table.ForeignKey(
name: "FK_StudentEducationPlans_EducationPlans_EducationPlanId",
column: x => x.EducationPlanId,
principalTable: "EducationPlans",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StudentEducationPlans_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Certifications_SecretaryId",
table: "Certifications",
column: "SecretaryId");
migrationBuilder.CreateIndex(
name: "IX_Certifications_StudentId",
table: "Certifications",
column: "StudentId");
migrationBuilder.CreateIndex(
name: "IX_DisciplineStudents_DisciplineId",
table: "DisciplineStudents",
column: "DisciplineId");
migrationBuilder.CreateIndex(
name: "IX_DisciplineStudents_StudentId",
table: "DisciplineStudents",
column: "StudentId");
migrationBuilder.CreateIndex(
name: "IX_EducationPlans_SecretaryId",
table: "EducationPlans",
column: "SecretaryId");
migrationBuilder.CreateIndex(
name: "IX_EducationPlanTeachers_EducationPlanId",
table: "EducationPlanTeachers",
column: "EducationPlanId");
migrationBuilder.CreateIndex(
name: "IX_EducationPlanTeachers_TeacherId",
table: "EducationPlanTeachers",
column: "TeacherId");
migrationBuilder.CreateIndex(
name: "IX_StudentEducationPlans_EducationPlanId",
table: "StudentEducationPlans",
column: "EducationPlanId");
migrationBuilder.CreateIndex(
name: "IX_StudentEducationPlans_StudentId",
table: "StudentEducationPlans",
column: "StudentId");
migrationBuilder.CreateIndex(
name: "IX_Students_SecretaryId",
table: "Students",
column: "SecretaryId");
migrationBuilder.CreateIndex(
name: "IX_StudyLists_TeacherId",
table: "StudyLists",
column: "TeacherId");
migrationBuilder.CreateIndex(
name: "IX_TeacherDisciplines_DisciplineId",
table: "TeacherDisciplines",
column: "DisciplineId");
migrationBuilder.CreateIndex(
name: "IX_TeacherDisciplines_TeacherId",
table: "TeacherDisciplines",
column: "TeacherId");
migrationBuilder.CreateIndex(
name: "IX_Teachers_AdminId",
table: "Teachers",
column: "AdminId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Certifications");
migrationBuilder.DropTable(
name: "DisciplineStudents");
migrationBuilder.DropTable(
name: "EducationPlanTeachers");
migrationBuilder.DropTable(
name: "StudentEducationPlans");
migrationBuilder.DropTable(
name: "StudyLists");
migrationBuilder.DropTable(
name: "TeacherDisciplines");
migrationBuilder.DropTable(
name: "EducationPlans");
migrationBuilder.DropTable(
name: "Students");
migrationBuilder.DropTable(
name: "Disciplines");
migrationBuilder.DropTable(
name: "Teachers");
migrationBuilder.DropTable(
name: "Secretaries");
migrationBuilder.DropTable(
name: "Admins");
}
}
}

View File

@@ -12,7 +12,7 @@ using UniversityDatabaseImplement;
namespace UniversityDatabaseImplement.Migrations
{
[DbContext(typeof(UniversityDatabase))]
[Migration("20240523164132_InitialCreate")]
[Migration("20240524083513_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />

View File

@@ -12,8 +12,8 @@ using UniversityDatabaseImplement;
namespace UniversityDatabaseImplement.Migrations
{
[DbContext(typeof(UniversityDatabase))]
[Migration("20240501151724_InitMirgation")]
partial class InitMirgation
[Migration("20240524085350_UpdateDeleteBehavior")]
partial class UpdateDeleteBehavior
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -94,6 +94,9 @@ namespace UniversityDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AdminId")
.HasColumnType("int");
b.Property<int>("CountHours")
.HasColumnType("int");
@@ -107,6 +110,8 @@ namespace UniversityDatabaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("AdminId");
b.ToTable("Disciplines");
});
@@ -274,6 +279,9 @@ namespace UniversityDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AdminId")
.HasColumnType("int");
b.Property<DateTime>("Date")
.HasColumnType("datetime2");
@@ -281,11 +289,13 @@ namespace UniversityDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("TeacherId")
b.Property<int>("TeacherId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AdminId");
b.HasIndex("TeacherId");
b.ToTable("StudyLists");
@@ -303,7 +313,7 @@ namespace UniversityDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("AdminId")
b.Property<int>("AdminId")
.HasColumnType("int");
b.Property<string>("Email")
@@ -371,10 +381,21 @@ namespace UniversityDatabaseImplement.Migrations
b.Navigation("Student");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Admin", "Admin")
.WithMany("Disciplines")
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.DisciplineStudent", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Discipline", "Discipline")
.WithMany("DisciplineStudents")
.WithMany("Students")
.HasForeignKey("DisciplineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -452,28 +473,44 @@ namespace UniversityDatabaseImplement.Migrations
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudyList", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Teacher", null)
b.HasOne("UniversityDatabaseImplement.Models.Admin", "Admin")
.WithMany("StudyLists")
.HasForeignKey("TeacherId");
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
.WithMany("StudyLists")
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
b.Navigation("Teacher");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Admin", null)
b.HasOne("UniversityDatabaseImplement.Models.Admin", "Admin")
.WithMany("Teachers")
.HasForeignKey("AdminId");
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.TeacherDiscipline", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Discipline", "Discipline")
.WithMany("Teachers")
.WithMany()
.HasForeignKey("DisciplineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
.WithMany()
.WithMany("Disciplines")
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -485,14 +522,16 @@ namespace UniversityDatabaseImplement.Migrations
modelBuilder.Entity("UniversityDatabaseImplement.Models.Admin", b =>
{
b.Navigation("Disciplines");
b.Navigation("StudyLists");
b.Navigation("Teachers");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
{
b.Navigation("DisciplineStudents");
b.Navigation("Teachers");
b.Navigation("Students");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.EducationPlan", b =>
@@ -520,6 +559,8 @@ namespace UniversityDatabaseImplement.Migrations
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
{
b.Navigation("Disciplines");
b.Navigation("StudyLists");
});
#pragma warning restore 612, 618

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace UniversityDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class UpdateDeleteBehavior : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -91,6 +91,9 @@ namespace UniversityDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AdminId")
.HasColumnType("int");
b.Property<int>("CountHours")
.HasColumnType("int");
@@ -104,6 +107,8 @@ namespace UniversityDatabaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("AdminId");
b.ToTable("Disciplines");
});
@@ -271,6 +276,9 @@ namespace UniversityDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AdminId")
.HasColumnType("int");
b.Property<DateTime>("Date")
.HasColumnType("datetime2");
@@ -278,11 +286,13 @@ namespace UniversityDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("TeacherId")
b.Property<int>("TeacherId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AdminId");
b.HasIndex("TeacherId");
b.ToTable("StudyLists");
@@ -300,7 +310,7 @@ namespace UniversityDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("AdminId")
b.Property<int>("AdminId")
.HasColumnType("int");
b.Property<string>("Email")
@@ -368,10 +378,21 @@ namespace UniversityDatabaseImplement.Migrations
b.Navigation("Student");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Admin", "Admin")
.WithMany("Disciplines")
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.DisciplineStudent", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Discipline", "Discipline")
.WithMany("DisciplineStudents")
.WithMany("Students")
.HasForeignKey("DisciplineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -449,28 +470,44 @@ namespace UniversityDatabaseImplement.Migrations
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudyList", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Teacher", null)
b.HasOne("UniversityDatabaseImplement.Models.Admin", "Admin")
.WithMany("StudyLists")
.HasForeignKey("TeacherId");
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
.WithMany("StudyLists")
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
b.Navigation("Teacher");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Admin", null)
b.HasOne("UniversityDatabaseImplement.Models.Admin", "Admin")
.WithMany("Teachers")
.HasForeignKey("AdminId");
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.TeacherDiscipline", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Discipline", "Discipline")
.WithMany("Teachers")
.WithMany()
.HasForeignKey("DisciplineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
.WithMany()
.WithMany("Disciplines")
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -482,14 +519,16 @@ namespace UniversityDatabaseImplement.Migrations
modelBuilder.Entity("UniversityDatabaseImplement.Models.Admin", b =>
{
b.Navigation("Disciplines");
b.Navigation("StudyLists");
b.Navigation("Teachers");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
{
b.Navigation("DisciplineStudents");
b.Navigation("Teachers");
b.Navigation("Students");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.EducationPlan", b =>
@@ -517,6 +556,8 @@ namespace UniversityDatabaseImplement.Migrations
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
{
b.Navigation("Disciplines");
b.Navigation("StudyLists");
});
#pragma warning restore 612, 618

View File

@@ -35,10 +35,11 @@ namespace UniversityDatabaseImplement.Models
return null;
}
return new StudyList()
return new StudyList()
{
Id = model.Id,
AdminId = model.AdminId,
TeacherId = model.TeacherId,
Name = model.Name,
Date = model.Date,
Admin = context.Admins.First(x => x.Id == model.AdminId)
@@ -51,6 +52,7 @@ namespace UniversityDatabaseImplement.Models
return;
}
AdminId = model.AdminId;
TeacherId = model.TeacherId;
Name = model.Name;
Date = model.Date;
}
@@ -58,6 +60,7 @@ namespace UniversityDatabaseImplement.Models
{
Id = Id,
AdminId = AdminId,
TeacherId = TeacherId,
Name = Name,
Date = Date,
TeacherFIO = Teacher?.TeacherFIO ?? string.Empty