From d707ffd472f0b4e4eafd8927274c02fdef7fe880 Mon Sep 17 00:00:00 2001 From: ker73rus Date: Sat, 20 May 2023 05:46:02 +0400 Subject: [PATCH] ccc --- .../ViewModels/StreamViewModel.cs | 6 +- .../Controllers/DisciplineController.cs | 8 +- .../Controllers/EducationGroupController.cs | 41 +- .../Controllers/StreamController.cs | 2 +- .../Views/Discipline/Update.cshtml | 49 ++ UniversityCustomer/Views/Stream/Update.cshtml | 37 +- .../js/discipline/disciplines-update.js | 120 ++++ .../js/educationgroup/educationgroups.js | 2 +- .../wwwroot/js/stream/stream-update.js | 92 ++- UniversityDataBaseImplemet/Database.cs | 2 +- .../Implements/DisciplineStorage.cs | 5 +- .../Implements/StreamStorage.cs | 4 +- .../Migrations/20230520013404_ccc.Designer.cs | 525 ++++++++++++++++++ .../Migrations/20230520013404_ccc.cs | 22 + UniversityDataBaseImplemet/Models/Stream.cs | 4 +- 15 files changed, 877 insertions(+), 42 deletions(-) create mode 100644 UniversityCustomer/Views/Discipline/Update.cshtml create mode 100644 UniversityCustomer/wwwroot/js/discipline/disciplines-update.js create mode 100644 UniversityDataBaseImplemet/Migrations/20230520013404_ccc.Designer.cs create mode 100644 UniversityDataBaseImplemet/Migrations/20230520013404_ccc.cs diff --git a/UniversityContracts/ViewModels/StreamViewModel.cs b/UniversityContracts/ViewModels/StreamViewModel.cs index 1485817..d32e9e0 100644 --- a/UniversityContracts/ViewModels/StreamViewModel.cs +++ b/UniversityContracts/ViewModels/StreamViewModel.cs @@ -8,7 +8,7 @@ using UniversityModels.Models; namespace UniversityContracts.ViewModels { - public class StreamViewModel + public class StreamViewModel : IStreamModel { public int Id { get; set; } public int UserId { get; set; } @@ -16,7 +16,7 @@ namespace UniversityContracts.ViewModels public string Name { get; set; } = string.Empty; [DisplayName("Номер курса")] public int Course { get; set; } - public List StudentStream = new(); - public List StreamEdGroups = new(); + public List StudentStream { get; set; } = new(); + public List StreamEdGroups { get; set; } = new(); } } diff --git a/UniversityCustomer/Controllers/DisciplineController.cs b/UniversityCustomer/Controllers/DisciplineController.cs index 403942f..c9cc6ad 100644 --- a/UniversityCustomer/Controllers/DisciplineController.cs +++ b/UniversityCustomer/Controllers/DisciplineController.cs @@ -33,19 +33,19 @@ namespace UniversityCustomer.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Document = APIClient.GetRequest($"api/discipline/get?id={id}"); + ViewBag.Discipline = APIClient.GetRequest($"api/discipline/get?id={id}"); return View(); } [HttpPost] - public void Update([FromBody] DisciplineBindingModel streamModel) + public void Update([FromBody] DisciplineBindingModel disciplineModel) { if (APIClient.User == null) { throw new Exception("403"); } - streamModel.UserId = APIClient.User.Id; - APIClient.PostRequest("api/discipline/update", streamModel); + disciplineModel.UserId = APIClient.User.Id; + APIClient.PostRequest("api/discipline/update", disciplineModel); Response.Redirect("/Home/Disciplines"); } diff --git a/UniversityCustomer/Controllers/EducationGroupController.cs b/UniversityCustomer/Controllers/EducationGroupController.cs index f459eac..33b5835 100644 --- a/UniversityCustomer/Controllers/EducationGroupController.cs +++ b/UniversityCustomer/Controllers/EducationGroupController.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Mvc; using UniversityContracts.BindingModels; using UniversityContracts.ViewModels; +using UniversityModels.Models; namespace UniversityCustomer.Controllers { @@ -33,20 +34,20 @@ namespace UniversityCustomer.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Student = APIClient.GetRequest($"api/student/get?id={id}"); + ViewBag.EducationGroup = APIClient.GetRequest($"api/educationgroup/get?id={id}"); return View(); } [HttpPost] - public void Update([FromBody] StudentBindingModel studentModel) + public void Update([FromBody] EducationGroupBindingModel egsModel) { if (APIClient.User == null) { throw new Exception("403"); } - studentModel.UserId = APIClient.User.Id; - APIClient.PostRequest("api/student/update", studentModel); - Response.Redirect("/Home/Students"); + egsModel.UserId = APIClient.User.Id; + APIClient.PostRequest("api/educationgroup/update", egsModel); + Response.Redirect("/Home/EducationGroups"); } [HttpPost] @@ -56,38 +57,28 @@ namespace UniversityCustomer.Controllers { throw new Exception("403"); } - APIClient.PostRequest($"api/student/delete", new StudentBindingModel() { Id = id }); - Response.Redirect("/Home/Students"); + APIClient.PostRequest($"api/educationgroup/delete", new EducationGroupBindingModel() { Id = id }); + Response.Redirect("/Home/EducationGroups"); } - public List GetAllByUser() + public List GetAllByUser() { if (APIClient.User == null) { return new(); } - List? students = APIClient.GetRequest>($"api/student/getallbyuser?userId={APIClient.User.Id}"); - return students ?? new(); + List? egs = APIClient.GetRequest>($"api/educationgroup/getallbyuser?userId={APIClient.User.Id}"); + return egs ?? new(); } - public List GetAllByUserAndEducationStatus(int educationstatus) + public EducationGroupViewModel? Get(int id) { if (APIClient.User == null) - { - return new(); + { + return new(); } - List? students = APIClient.GetRequest>($"api/student/getallbyuserandeducationstatus?userId={APIClient.User.Id}&educationstatus={educationstatus}"); - return students ?? new(); - } - - public StudentViewModel? Get(int id) - { - if (APIClient.User == null) - { - return new(); - } - StudentViewModel? student = APIClient.GetRequest($"api/student/get?id={id}"); - return student; + EducationGroupViewModel? eg = APIClient.GetRequest($"api/educationgroup/get?id={id}"); + return eg; } } } diff --git a/UniversityCustomer/Controllers/StreamController.cs b/UniversityCustomer/Controllers/StreamController.cs index d874f75..5608071 100644 --- a/UniversityCustomer/Controllers/StreamController.cs +++ b/UniversityCustomer/Controllers/StreamController.cs @@ -33,7 +33,7 @@ namespace UniversityCustomer.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Document = APIClient.GetRequest($"api/stream/get?id={id}"); + ViewBag.Stream = APIClient.GetRequest($"api/stream/get?id={id}"); return View(); } diff --git a/UniversityCustomer/Views/Discipline/Update.cshtml b/UniversityCustomer/Views/Discipline/Update.cshtml new file mode 100644 index 0000000..e208436 --- /dev/null +++ b/UniversityCustomer/Views/Discipline/Update.cshtml @@ -0,0 +1,49 @@ +@using UniversityContracts.ViewModels + +@{ + ViewData["Title"] = "Дисциплина"; +} + +@{ + +

Обновление приказа

+ + if (ViewBag.Discipline == null) + { +

Войдите в аккаунт

+ return; + } +
+
+

+
+
+ +

Имя:

+ +

Часы:

+ +
+
+ + +
+
+
+
+ + +
+
+ + + +} + + \ No newline at end of file diff --git a/UniversityCustomer/Views/Stream/Update.cshtml b/UniversityCustomer/Views/Stream/Update.cshtml index 5f28270..10d927c 100644 --- a/UniversityCustomer/Views/Stream/Update.cshtml +++ b/UniversityCustomer/Views/Stream/Update.cshtml @@ -1 +1,36 @@ - \ No newline at end of file +@{ + ViewData["Title"] = "Поток"; +} + +@{ +

Обновление потока

+ +
+
+

+
+
+ +

Название:

+ + + + +
+
+ + + + + + + + + +
НазваниеКоличество студентов
+
+
+} + \ No newline at end of file diff --git a/UniversityCustomer/wwwroot/js/discipline/disciplines-update.js b/UniversityCustomer/wwwroot/js/discipline/disciplines-update.js new file mode 100644 index 0000000..4c72866 --- /dev/null +++ b/UniversityCustomer/wwwroot/js/discipline/disciplines-update.js @@ -0,0 +1,120 @@ +const createBtn = document.getElementById("update-button"); +const tbody = document.getElementById("scrollable-table__tbody"); +const currentDisciplineId = document.getElementById("discipline-data").dataset.id; + +const nameInput = document.getElementById("name-input"); +const hoursInput = document.getElementById("hours-input"); +const select = document.getElementById("streamsSelect"); +const markTypeSelect = document.getElementById("markTypeSelect"); +var streams = []; +var dataArray = []; +var currentDiscipline = null; +var currentStream = null; + +const correctData = () => { + + return true; +}; + +const validate = () => { + + return true; +}; + +window.addEventListener('load', async () => { + await $.ajax({ + url: `/discipline/get?id=${currentDisciplineId}`, + type: "GET", + contentType: "json" + }).done((result) => { + currentDiscipline = result; + }); + const streamsResponse = await $.ajax({ + url: `/stream/getallbyuser`, + type: "GET", + contentType: "json" + }); + streams = streamsResponse; + + if (currentDiscipline.markType) { + markTypeSelect.selectedIndex = 1; + } + else + markTypeSelect.selectedIndex = 0; + + streams.forEach((stream) => { + createStreamOption(stream); + }); + select.selectedIndex = currentDiscipline.StreamId - 1; + +}) + +const createStreamOption = (stream) => { + const option = document.createElement("option"); + option.value = stream.id; + option.innerHTML = stream.name; + select.appendChild(option); + select.selectedIndex = -1; +} + + +createBtn.addEventListener('click',() => { + if (!correctData()) { + return; + } + if (!validate()) { + return; + } + const stream = streams.find(x => x.id === parseInt(select.value)); + var markType = true; + if (markTypeSelect.value === "false") { + markType = false + } + var disciplinetUpdate = { + "Id": currentDiscipline.id, + "Name": nameInput.value, + "Hours": hoursInput.value, + "Marktype": markType, + "StreamId": stream.id + } + $.ajax({ + url: "/discipline/update", + type: "POST", + contentType: "application/json", + data: JSON.stringify(disciplinetUpdate) + }).done(() => { + window.location.href = "/Home/Disciplines"; + }); +}) + +const createRowForStudentsTable = (student) => { + const { id, name, surname, dateOfBirth, studentCard, educationStatusName } = student; + const row = tbody.insertRow(); + row.setAttribute("data-id", id); + + const cells = [name, surname, formatDate(dateOfBirth), studentCard, educationStatusName]; + cells.forEach((value) => { + const cell = row.insertCell(); + cell.textContent = value; + }); + + if (currentDiscipline.documentStudents.find(x => parseInt(x.id) === parseInt(student.id))) { + row.classList.add("bg-success"); + dataArray.push(student); + } + + row.addEventListener('click', () => addAndRemoveFromList(row)); +}; + + +const addAndRemoveFromList = (row) => { + var id = parseInt(row.dataset.id); + var index = dataArray.indexOf(students.find(x => x.id === id)); + if (index === -1) { + dataArray.push(students.find(x => x.id === id)); + row.classList.add("bg-success"); + } else { + dataArray.splice(index, 1); + row.classList.remove("bg-success"); + } +} \ No newline at end of file diff --git a/UniversityCustomer/wwwroot/js/educationgroup/educationgroups.js b/UniversityCustomer/wwwroot/js/educationgroup/educationgroups.js index 8a9866b..b2dc195 100644 --- a/UniversityCustomer/wwwroot/js/educationgroup/educationgroups.js +++ b/UniversityCustomer/wwwroot/js/educationgroup/educationgroups.js @@ -21,5 +21,5 @@ removeButtons.forEach(function (button) { pageInput.addEventListener("input", () => { const pageNumber = parseInt(pageInput.value); - goToPageBtn.href = `/Home/Students?page=${pageNumber}`; + goToPageBtn.href = `/Home/EducationGroup?page=${pageNumber}`; }); diff --git a/UniversityCustomer/wwwroot/js/stream/stream-update.js b/UniversityCustomer/wwwroot/js/stream/stream-update.js index 5f28270..b78bd63 100644 --- a/UniversityCustomer/wwwroot/js/stream/stream-update.js +++ b/UniversityCustomer/wwwroot/js/stream/stream-update.js @@ -1 +1,91 @@ - \ No newline at end of file +const createBtn = document.getElementById("create-button"); +const tbody = document.getElementById("scrollable-table__tbody"); +const nameInput = document.getElementById("name-input"); +const currentStreamId = document.getElementById("stream-data").dataset.id; +var groups = []; +var dataArray = []; +var currentStream = null; + +const correctData = () => { + + return true; +}; + +const validate = () => { + + return true; +}; + +window.addEventListener('load', async () => { + await $.ajax({ + url: "/educationgroup/getallbyuser", + type: "GET", + contentType: "json" + }).done((result) => { + groups = result; + }); + await $.ajax({ + url: `/stream/get?id=${currentStreamId}`, + type: "GET", + contentType: "json" + }).done((result) => { + currentStream = result; + }); + groups.forEach((group) => createRowForGroupTable(group)); +}) + +createBtn.addEventListener('click', () => { + if (!correctData()) { + return; + } + if (!validate()) { + return; + } + var streamGroupsUpdate = { + "Id": currentStream.id, + "Name": nameInput.value, + "EducationGroupStream": dataArray, + "StreamStudents": currentStream.StreamStudents, + } + $.ajax({ + url: "/stream/update", + type: "POST", + contentType: "application/json", + data: JSON.stringify(streamGroupsUpdate) + }).done(() => { + window.location.href = "/Home/Streams"; + }); +}) + +const createRowForGroupTable = (group) => { + const { id, name, numberOfStudents } = group; + const row = tbody.insertRow(); + row.setAttribute("data-id", id); + + const cells = [name, numberOfStudents]; + cells.forEach((value) => { + const cell = row.insertCell(); + cell.textContent = value; + }); + + if (currentStream.StreamEdGroups.find(x => parseInt(x.id) === parseInt(groups.id))) { + row.classList.add("bg-success"); + dataArray.push(student); + } + + + row.addEventListener('click', () => addAndRemoveFromList(row)); +}; + + +const addAndRemoveFromList = (row) => { + var id = parseInt(row.dataset.id); + var index = dataArray.indexOf(groups.find(x => x.id === id)); + if (index === -1) { + dataArray.push(groups.find(x => x.id === id)); + row.classList.add("bg-success"); + } else { + dataArray.splice(index, 1); + row.classList.remove("bg-success"); + } +} \ No newline at end of file diff --git a/UniversityDataBaseImplemet/Database.cs b/UniversityDataBaseImplemet/Database.cs index 72262d9..843e4f7 100644 --- a/UniversityDataBaseImplemet/Database.cs +++ b/UniversityDataBaseImplemet/Database.cs @@ -10,7 +10,7 @@ namespace UniversityDataBaseImplemet { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=UniversityCourseWork;Username=postgres;Password=123"); + optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=UniversityCourseWork;Username=postgres;Password=0000"); } base.OnConfiguring(optionsBuilder); } diff --git a/UniversityDataBaseImplemet/Implements/DisciplineStorage.cs b/UniversityDataBaseImplemet/Implements/DisciplineStorage.cs index 5d47398..13cacc3 100644 --- a/UniversityDataBaseImplemet/Implements/DisciplineStorage.cs +++ b/UniversityDataBaseImplemet/Implements/DisciplineStorage.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.EntityFrameworkCore; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -93,6 +94,8 @@ namespace UniversityDataBaseImplemet.Implements { using var context = new Database(); var stream = context.Discipline + .Include(record => record.User) + .Include(record => record.Stream) .FirstOrDefault(record => record.Id.Equals(model.Id)); if (stream == null) { diff --git a/UniversityDataBaseImplemet/Implements/StreamStorage.cs b/UniversityDataBaseImplemet/Implements/StreamStorage.cs index 94e4aae..61a89ad 100644 --- a/UniversityDataBaseImplemet/Implements/StreamStorage.cs +++ b/UniversityDataBaseImplemet/Implements/StreamStorage.cs @@ -106,8 +106,8 @@ namespace UniversityDataBaseImplemet.Implements { using var context = new Database(); var stream = context.Streams - .Include(record => record.User) - .Include(record => record.StreamStudents) + .Include(record => record.User) + .Include(record => record.EducationGroupStream) .FirstOrDefault(record => record.Id.Equals(model.Id)); if (stream == null) { diff --git a/UniversityDataBaseImplemet/Migrations/20230520013404_ccc.Designer.cs b/UniversityDataBaseImplemet/Migrations/20230520013404_ccc.Designer.cs new file mode 100644 index 0000000..2dc82db --- /dev/null +++ b/UniversityDataBaseImplemet/Migrations/20230520013404_ccc.Designer.cs @@ -0,0 +1,525 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using UniversityDataBaseImplemet; + +#nullable disable + +namespace UniversityDataBaseImplemet.Migrations +{ + [DbContext(typeof(Database))] + [Migration("20230520013404_ccc")] + partial class ccc + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("UniversityContracts.ViewModels.EducationGroupViewModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NumberOfStudent") + .HasColumnType("integer"); + + b.Property("StreamId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("StreamId"); + + b.ToTable("EducationGroupViewModel"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.Discipline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Hours") + .HasColumnType("integer"); + + b.Property("MarkType") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("StreamId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("StreamId"); + + b.HasIndex("UserId"); + + b.ToTable("Discipline"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Documents"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NumberOfStudent") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("EducationGroups"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupDocument", b => + { + b.Property("EducationGroupId") + .HasColumnType("integer"); + + b.Property("DocumentId") + .HasColumnType("integer"); + + b.HasKey("EducationGroupId", "DocumentId"); + + b.HasIndex("DocumentId"); + + b.ToTable("EducationGroupsDocuments"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupStream", b => + { + b.Property("EducationGroupId") + .HasColumnType("integer"); + + b.Property("StreamId") + .HasColumnType("integer"); + + b.HasKey("EducationGroupId", "StreamId"); + + b.HasIndex("StreamId"); + + b.ToTable("EducationGroupsStreams"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("EducationStatuses"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Course") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Streams"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.Student", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateOfAddmission") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfBirth") + .HasColumnType("timestamp with time zone"); + + b.Property("EducationStatusId") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("StudentCard") + .HasColumnType("integer"); + + b.Property("Surname") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("EducationStatusId"); + + b.HasIndex("UserId"); + + b.ToTable("Students"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentDocument", b => + { + b.Property("StudentId") + .HasColumnType("integer"); + + b.Property("DocumentId") + .HasColumnType("integer"); + + b.HasKey("StudentId", "DocumentId"); + + b.HasIndex("DocumentId"); + + b.ToTable("StudentDocuments"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentStream", b => + { + b.Property("StudentId") + .HasColumnType("integer"); + + b.Property("StreamId") + .HasColumnType("integer"); + + b.HasKey("StudentId", "StreamId"); + + b.HasIndex("StreamId"); + + b.ToTable("StudentStreams"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Login") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Role") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("User"); + }); + + modelBuilder.Entity("UniversityContracts.ViewModels.EducationGroupViewModel", b => + { + b.HasOne("UniversityDataBaseImplemet.Models.Stream", null) + .WithMany("StreamEdGroups") + .HasForeignKey("StreamId"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.Discipline", b => + { + b.HasOne("UniversityDataBaseImplemet.Models.Stream", "Stream") + .WithMany() + .HasForeignKey("StreamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("UniversityDataBaseImplemet.Models.User", "User") + .WithMany("Disciplines") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("Stream"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.Document", b => + { + b.HasOne("UniversityDataBaseImplemet.Models.User", "User") + .WithMany("Documents") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b => + { + b.HasOne("UniversityDataBaseImplemet.Models.User", "User") + .WithMany("EducationGroups") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupDocument", b => + { + b.HasOne("UniversityDataBaseImplemet.Models.Document", "Document") + .WithMany("EducationGroupDocument") + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("UniversityDataBaseImplemet.Models.EducationGroup", "EducationGroup") + .WithMany("EducationGroupDocument") + .HasForeignKey("EducationGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("EducationGroup"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupStream", b => + { + b.HasOne("UniversityDataBaseImplemet.Models.EducationGroup", "EducationGroup") + .WithMany("EducationGroupStream") + .HasForeignKey("EducationGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("UniversityDataBaseImplemet.Models.Stream", "Stream") + .WithMany("EducationGroupStream") + .HasForeignKey("StreamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EducationGroup"); + + b.Navigation("Stream"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationStatus", b => + { + b.HasOne("UniversityDataBaseImplemet.Models.User", "User") + .WithMany("EducationStatuses") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b => + { + b.HasOne("UniversityDataBaseImplemet.Models.User", "User") + .WithMany("Streams") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.Student", b => + { + b.HasOne("UniversityDataBaseImplemet.Models.EducationStatus", "EducationStatus") + .WithMany("Students") + .HasForeignKey("EducationStatusId"); + + b.HasOne("UniversityDataBaseImplemet.Models.User", "User") + .WithMany("Students") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("EducationStatus"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentDocument", b => + { + b.HasOne("UniversityDataBaseImplemet.Models.Document", "Document") + .WithMany("Students") + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("UniversityDataBaseImplemet.Models.Student", "Student") + .WithMany("DocumentStudents") + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentStream", b => + { + b.HasOne("UniversityDataBaseImplemet.Models.Stream", "Stream") + .WithMany("StreamStudents") + .HasForeignKey("StreamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("UniversityDataBaseImplemet.Models.Student", "Student") + .WithMany("StudentStream") + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Stream"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.Document", b => + { + b.Navigation("EducationGroupDocument"); + + b.Navigation("Students"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b => + { + b.Navigation("EducationGroupDocument"); + + b.Navigation("EducationGroupStream"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationStatus", b => + { + b.Navigation("Students"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b => + { + b.Navigation("EducationGroupStream"); + + b.Navigation("StreamEdGroups"); + + b.Navigation("StreamStudents"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.Student", b => + { + b.Navigation("DocumentStudents"); + + b.Navigation("StudentStream"); + }); + + modelBuilder.Entity("UniversityDataBaseImplemet.Models.User", b => + { + b.Navigation("Disciplines"); + + b.Navigation("Documents"); + + b.Navigation("EducationGroups"); + + b.Navigation("EducationStatuses"); + + b.Navigation("Streams"); + + b.Navigation("Students"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/UniversityDataBaseImplemet/Migrations/20230520013404_ccc.cs b/UniversityDataBaseImplemet/Migrations/20230520013404_ccc.cs new file mode 100644 index 0000000..bd3252a --- /dev/null +++ b/UniversityDataBaseImplemet/Migrations/20230520013404_ccc.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace UniversityDataBaseImplemet.Migrations +{ + /// + public partial class ccc : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/UniversityDataBaseImplemet/Models/Stream.cs b/UniversityDataBaseImplemet/Models/Stream.cs index 507f2d9..1078099 100644 --- a/UniversityDataBaseImplemet/Models/Stream.cs +++ b/UniversityDataBaseImplemet/Models/Stream.cs @@ -114,14 +114,14 @@ namespace UniversityDataBaseImplemet.Models } _educationGroupStream = null; } - public StreamViewModel GetViewModel => new() + public StreamViewModel GetViewModel => new StreamViewModel() { Id = Id, Name = Name, UserId = UserId, Course= Course, StudentStream = StudentStream, - StreamEdGroups = StreamEdGroups, + StreamEdGroups = StreamEdGroups }; } }