diff --git a/UniversityContracts/BusinessLogicContracts/IReportCustomerLogic.cs b/UniversityContracts/BusinessLogicContracts/IReportCustomerLogic.cs index f331890..f245f0f 100644 --- a/UniversityContracts/BusinessLogicContracts/IReportCustomerLogic.cs +++ b/UniversityContracts/BusinessLogicContracts/IReportCustomerLogic.cs @@ -13,10 +13,7 @@ namespace UniversityContracts.BusinessLogicContracts List GetDiscipline(ReportBindingModel model); List StreamEducationStatus(List streams); - void SaveBlanksToWordFile(ReportBindingModel model); - - void SaveDocumentBlankToExcelFile(ReportBindingModel model); - - void SaveOrdersToPdfFile(ReportBindingModel model); + byte[] SaveListFile(StreamStudentBindingModel model); + void SendByMailStatusReport(ReportBindingModel reportModel); } } diff --git a/UniversityCustomer/Controllers/HomeController.cs b/UniversityCustomer/Controllers/HomeController.cs index 75ba5c3..5331b4f 100644 --- a/UniversityCustomer/Controllers/HomeController.cs +++ b/UniversityCustomer/Controllers/HomeController.cs @@ -129,7 +129,7 @@ namespace UniversityProvider.Controllers return Array.Empty(); } byte[]? file = APIClient.PostRequestWithResult - ("api/reportprovider/streamstudentlist", listModel); + ("api/reportcustomer/streamstudentlist", listModel); return file!.Select(b => (int)b).ToArray(); } diff --git a/UniversityCustomer/Controllers/ReportCustomerController.cs b/UniversityCustomer/Controllers/ReportCustomerController.cs new file mode 100644 index 0000000..619ebb9 --- /dev/null +++ b/UniversityCustomer/Controllers/ReportCustomerController.cs @@ -0,0 +1,39 @@ +using Microsoft.AspNetCore.Mvc; +using UniversityContracts.BindingModels; +using UniversityContracts.BusinessLogicContracts; +using UniversityContracts.ViewModels; + +namespace UniversityRestAPI.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ReportCustomerController : Controller + { + private readonly IReportCustomerLogic reportLogic; + + public ReportCustomerController(IReportCustomerLogic reportLogic) + { + this.reportLogic = reportLogic; + } + + [HttpPost] + public byte[] StreamStudentList(StreamStudentBindingModel listModel) + { + byte[] file = reportLogic.SaveListFile(listModel); + return file; + } + + [HttpPost] + public List GetReportData(ReportBindingModel reportModel) + { + var list = reportLogic.GetDiscipline(reportModel); + return list; + } + + [HttpPost] + public void SendByMailStatusReport(ReportBindingModel reportModel) + { + reportLogic.SendByMailStatusReport(reportModel); + } + } +} diff --git a/UniversityCustomer/UniversityCustomer.csproj b/UniversityCustomer/UniversityCustomer.csproj index 2a03491..6cc5a3c 100644 --- a/UniversityCustomer/UniversityCustomer.csproj +++ b/UniversityCustomer/UniversityCustomer.csproj @@ -14,4 +14,11 @@ + + + true + PreserveNewest + + + diff --git a/UniversityCustomer/Views/EducationGroup/Update.cshtml b/UniversityCustomer/Views/EducationGroup/Update.cshtml index 5f28270..70d989d 100644 --- a/UniversityCustomer/Views/EducationGroup/Update.cshtml +++ b/UniversityCustomer/Views/EducationGroup/Update.cshtml @@ -1 +1,41 @@ - \ No newline at end of file +@{ + ViewData["Title"] = "Группа обучения"; +} + +@{ +
+

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

+
+ +
+
+

+
+
+ +

Название:

+ + + + +
+
+ + + + + + + + + + + + +
ИмяФамилияДата рожденияНомер студ. билетаСтатус обучения
+
+
+} + \ No newline at end of file diff --git a/UniversityCustomer/Views/Home/StreamStudentList.cshtml b/UniversityCustomer/Views/Home/StreamStudentList.cshtml index 895d5cc..456925b 100644 --- a/UniversityCustomer/Views/Home/StreamStudentList.cshtml +++ b/UniversityCustomer/Views/Home/StreamStudentList.cshtml @@ -17,7 +17,14 @@ - + +
+
+ + +
+
diff --git a/UniversityCustomer/wwwroot/js/educationgroup/educationgroup-update.js b/UniversityCustomer/wwwroot/js/educationgroup/educationgroup-update.js index 5f28270..5cb362e 100644 --- a/UniversityCustomer/wwwroot/js/educationgroup/educationgroup-update.js +++ b/UniversityCustomer/wwwroot/js/educationgroup/educationgroup-update.js @@ -1 +1,109 @@ - \ 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 currentDocumentId = document.getElementById("document-data").dataset.id; +var students = []; +var dataArray = []; +var currentDocument = null; +const errorP = document.getElementById("error-p"); +const errorDivShell = document.getElementById("error-div-shell"); + +const correctData = () => { + + return true; +}; + +const validate = () => { + if (nameInput.value === "") { + errorDivShell.style.gridTemplateRows = "1fr"; + errorP.innerHTML = "Заполните поле 'Название'"; + return false; + } + if (dataArray.length === 0) { + errorDivShell.style.gridTemplateRows = "1fr"; + errorP.innerHTML = "Заполните список 'Студенты'"; + return false; + } + return true; +}; + +window.addEventListener('load', async () => { + await $.ajax({ + url: "/student/getallbyuser", + type: "GET", + contentType: "json" + }).done((result) => { + students = result; + }); + await $.ajax({ + url: `/document/get?id=${currentDocumentId}`, + type: "GET", + contentType: "json" + }).done((result) => { + currentDocument = result; + }); + students.forEach((student) => createRowForStudentsTable(student)); +}) + +createBtn.addEventListener('click', () => { + if (!correctData()) { + return; + } + if (!validate()) { + return; + } + var documentGroupsUpdate = { + "Id": currentDocument.id, + "Name": nameInput.value, + "Date": currentDocument.date, + "StreamStudents": dataArray, + "DocumentGroups": currentDocument.documentEdGroups, + } + $.ajax({ + url: "/document/update", + type: "POST", + contentType: "application/json", + data: JSON.stringify(documentGroupsUpdate) + }).done(() => { + window.location.href = "/Home/Documents"; + }); +}) + +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 (currentDocument.documentStudents.find(x => parseInt(x.id) === parseInt(student.id))) { + row.classList.add("bg-success"); + dataArray.push(student); + } + + row.addEventListener('click', () => addAndRemoveFromList(row)); +}; + +const formatDate = (dateString) => { + const date = new Date(dateString); + const year = date.getFullYear(); + const month = ('0' + (date.getMonth() + 1)).slice(-2); + const day = ('0' + date.getDate()).slice(-2); + return `${year}-${month}-${day}`; +}; + +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/report/reportlist.js b/UniversityCustomer/wwwroot/js/report/reportlist.js index 339c297..4ef4ee7 100644 --- a/UniversityCustomer/wwwroot/js/report/reportlist.js +++ b/UniversityCustomer/wwwroot/js/report/reportlist.js @@ -2,23 +2,42 @@ const tbody = document.getElementById("scrollable-table__tbody") const nameInput = document.getElementById("name-input") var fileType = document.getElementById("file-type") +const select = document.getElementById("streamsSelect") var students = [] +var streams = [] var dataArray = []; const wordMIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; const excelMIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; -window.addEventListener('load', () => { - $.ajax({ - url: "/student/getallbyuser", +window.addEventListener('load', async() => { + const streamsResponse = await $.ajax({ + url: `/stream/getallbyuser`, type: "GET", contentType: "json" - }).done((result) => { - students = result; - students.forEach((student) => createRowForStudentsTable(student)); + }); + streams = streamsResponse; + streams.forEach((stream) => { + createStreamOption(stream); }); }) -createBtn.addEventListener('click', () => { +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', async () => { + const st = await $.ajax({ + url: `/stream/get?id=${parseInt(select.value)}`, + type: "GET", + contentType: "json" + }); + students = st.studentStream; + students.forEach((student) => { + createRowForStudentsTable(student); + }) let listModel = { "Students": Array.from(dataArray), "FileType": fileType.value diff --git a/UniversityDataBaseImplemet/Database.cs b/UniversityDataBaseImplemet/Database.cs index 72262d9..7613a90 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=4757"); } base.OnConfiguring(optionsBuilder); } diff --git a/UniversityDataBaseImplemet/Migrations/20230520013404_ccc.cs b/UniversityDataBaseImplemet/Migrations/20230520013404_ccc.cs deleted file mode 100644 index bd3252a..0000000 --- a/UniversityDataBaseImplemet/Migrations/20230520013404_ccc.cs +++ /dev/null @@ -1,22 +0,0 @@ -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/Migrations/20230520013404_ccc.Designer.cs b/UniversityDataBaseImplemet/Migrations/20230520061807_init.Designer.cs similarity index 99% rename from UniversityDataBaseImplemet/Migrations/20230520013404_ccc.Designer.cs rename to UniversityDataBaseImplemet/Migrations/20230520061807_init.Designer.cs index 2dc82db..0da9026 100644 --- a/UniversityDataBaseImplemet/Migrations/20230520013404_ccc.Designer.cs +++ b/UniversityDataBaseImplemet/Migrations/20230520061807_init.Designer.cs @@ -12,8 +12,8 @@ using UniversityDataBaseImplemet; namespace UniversityDataBaseImplemet.Migrations { [DbContext(typeof(Database))] - [Migration("20230520013404_ccc")] - partial class ccc + [Migration("20230520061807_init")] + partial class init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/UniversityDataBaseImplemet/Migrations/20230520061807_init.cs b/UniversityDataBaseImplemet/Migrations/20230520061807_init.cs new file mode 100644 index 0000000..b8ac262 --- /dev/null +++ b/UniversityDataBaseImplemet/Migrations/20230520061807_init.cs @@ -0,0 +1,389 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace UniversityDataBaseImplemet.Migrations +{ + /// + public partial class init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "User", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Login = table.Column(type: "text", nullable: false), + Password = table.Column(type: "text", nullable: false), + Role = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_User", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Documents", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Date = table.Column(type: "timestamp with time zone", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Documents", x => x.Id); + table.ForeignKey( + name: "FK_Documents_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "EducationGroups", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + NumberOfStudent = table.Column(type: "integer", nullable: false), + Name = table.Column(type: "text", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EducationGroups", x => x.Id); + table.ForeignKey( + name: "FK_EducationGroups_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "EducationStatuses", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EducationStatuses", x => x.Id); + table.ForeignKey( + name: "FK_EducationStatuses_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Streams", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Course = table.Column(type: "integer", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Streams", x => x.Id); + table.ForeignKey( + name: "FK_Streams_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "EducationGroupsDocuments", + columns: table => new + { + EducationGroupId = table.Column(type: "integer", nullable: false), + DocumentId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EducationGroupsDocuments", x => new { x.EducationGroupId, x.DocumentId }); + table.ForeignKey( + name: "FK_EducationGroupsDocuments_Documents_DocumentId", + column: x => x.DocumentId, + principalTable: "Documents", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_EducationGroupsDocuments_EducationGroups_EducationGroupId", + column: x => x.EducationGroupId, + principalTable: "EducationGroups", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Students", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Surname = table.Column(type: "text", nullable: false), + DateOfBirth = table.Column(type: "timestamp with time zone", nullable: false), + DateOfAddmission = table.Column(type: "timestamp with time zone", nullable: false), + StudentCard = table.Column(type: "integer", nullable: false), + EducationStatusId = table.Column(type: "integer", nullable: true), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Students", x => x.Id); + table.ForeignKey( + name: "FK_Students_EducationStatuses_EducationStatusId", + column: x => x.EducationStatusId, + principalTable: "EducationStatuses", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Students_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Discipline", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + UserId = table.Column(type: "integer", nullable: false), + StreamId = table.Column(type: "integer", nullable: false), + Hours = table.Column(type: "integer", nullable: false), + MarkType = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Discipline", x => x.Id); + table.ForeignKey( + name: "FK_Discipline_Streams_StreamId", + column: x => x.StreamId, + principalTable: "Streams", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Discipline_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "EducationGroupsStreams", + columns: table => new + { + EducationGroupId = table.Column(type: "integer", nullable: false), + StreamId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EducationGroupsStreams", x => new { x.EducationGroupId, x.StreamId }); + table.ForeignKey( + name: "FK_EducationGroupsStreams_EducationGroups_EducationGroupId", + column: x => x.EducationGroupId, + principalTable: "EducationGroups", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_EducationGroupsStreams_Streams_StreamId", + column: x => x.StreamId, + principalTable: "Streams", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "EducationGroupViewModel", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + NumberOfStudent = table.Column(type: "integer", nullable: false), + UserId = table.Column(type: "integer", nullable: false), + StreamId = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_EducationGroupViewModel", x => x.Id); + table.ForeignKey( + name: "FK_EducationGroupViewModel_Streams_StreamId", + column: x => x.StreamId, + principalTable: "Streams", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "StudentDocuments", + columns: table => new + { + StudentId = table.Column(type: "integer", nullable: false), + DocumentId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_StudentDocuments", x => new { x.StudentId, x.DocumentId }); + table.ForeignKey( + name: "FK_StudentDocuments_Documents_DocumentId", + column: x => x.DocumentId, + principalTable: "Documents", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_StudentDocuments_Students_StudentId", + column: x => x.StudentId, + principalTable: "Students", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "StudentStreams", + columns: table => new + { + StudentId = table.Column(type: "integer", nullable: false), + StreamId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_StudentStreams", x => new { x.StudentId, x.StreamId }); + table.ForeignKey( + name: "FK_StudentStreams_Streams_StreamId", + column: x => x.StreamId, + principalTable: "Streams", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_StudentStreams_Students_StudentId", + column: x => x.StudentId, + principalTable: "Students", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Discipline_StreamId", + table: "Discipline", + column: "StreamId"); + + migrationBuilder.CreateIndex( + name: "IX_Discipline_UserId", + table: "Discipline", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Documents_UserId", + table: "Documents", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_EducationGroups_UserId", + table: "EducationGroups", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_EducationGroupsDocuments_DocumentId", + table: "EducationGroupsDocuments", + column: "DocumentId"); + + migrationBuilder.CreateIndex( + name: "IX_EducationGroupsStreams_StreamId", + table: "EducationGroupsStreams", + column: "StreamId"); + + migrationBuilder.CreateIndex( + name: "IX_EducationGroupViewModel_StreamId", + table: "EducationGroupViewModel", + column: "StreamId"); + + migrationBuilder.CreateIndex( + name: "IX_EducationStatuses_UserId", + table: "EducationStatuses", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Streams_UserId", + table: "Streams", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_StudentDocuments_DocumentId", + table: "StudentDocuments", + column: "DocumentId"); + + migrationBuilder.CreateIndex( + name: "IX_Students_EducationStatusId", + table: "Students", + column: "EducationStatusId"); + + migrationBuilder.CreateIndex( + name: "IX_Students_UserId", + table: "Students", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_StudentStreams_StreamId", + table: "StudentStreams", + column: "StreamId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Discipline"); + + migrationBuilder.DropTable( + name: "EducationGroupsDocuments"); + + migrationBuilder.DropTable( + name: "EducationGroupsStreams"); + + migrationBuilder.DropTable( + name: "EducationGroupViewModel"); + + migrationBuilder.DropTable( + name: "StudentDocuments"); + + migrationBuilder.DropTable( + name: "StudentStreams"); + + migrationBuilder.DropTable( + name: "EducationGroups"); + + migrationBuilder.DropTable( + name: "Documents"); + + migrationBuilder.DropTable( + name: "Streams"); + + migrationBuilder.DropTable( + name: "Students"); + + migrationBuilder.DropTable( + name: "EducationStatuses"); + + migrationBuilder.DropTable( + name: "User"); + } + } +} diff --git a/UniversityProvider/Controllers/ReportProviderController.cs b/UniversityProvider/Controllers/ReportProviderController.cs new file mode 100644 index 0000000..619b178 --- /dev/null +++ b/UniversityProvider/Controllers/ReportProviderController.cs @@ -0,0 +1,39 @@ +using Microsoft.AspNetCore.Mvc; +using UniversityContracts.BindingModels; +using UniversityContracts.BusinessLogicContracts; +using UniversityContracts.ViewModels; + +namespace UniversityRestAPI.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ReportProviderController : Controller + { + private readonly IReportProviderLogic reportLogic; + + public ReportProviderController(IReportProviderLogic reportLogic) + { + this.reportLogic = reportLogic; + } + + [HttpPost] + public byte[] StudentDisciplineList(StudentDisciplineListBindingModel listModel) + { + byte[] file = reportLogic.SaveListFile(listModel); + return file; + } + + [HttpPost] + public List GetReportData(ReportBindingModel reportModel) + { + var list = reportLogic.GetStreamStudentEdStatPeriod(reportModel); + return list; + } + + [HttpPost] + public void SendByMailStatusReport(ReportBindingModel reportModel) + { + reportLogic.SendByMailStatusReport(reportModel); + } + } +} diff --git a/UniversityProvider/wwwroot/js/student/student-create.js b/UniversityProvider/wwwroot/js/student/student-create.js index 3d8fc09..9158ddb 100644 --- a/UniversityProvider/wwwroot/js/student/student-create.js +++ b/UniversityProvider/wwwroot/js/student/student-create.js @@ -58,12 +58,6 @@ const validate = () => { }; createBtn.addEventListener("click", () => { - if (!validate()) { - return; - } - if (!correctData()) { - return; - } let student = { "Name": nameInput.value, "Surname": surnameInput.value, diff --git a/UniversityRestAPI/Controllers/ReportCustomerController.cs b/UniversityRestAPI/Controllers/ReportCustomerController.cs new file mode 100644 index 0000000..619ebb9 --- /dev/null +++ b/UniversityRestAPI/Controllers/ReportCustomerController.cs @@ -0,0 +1,39 @@ +using Microsoft.AspNetCore.Mvc; +using UniversityContracts.BindingModels; +using UniversityContracts.BusinessLogicContracts; +using UniversityContracts.ViewModels; + +namespace UniversityRestAPI.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ReportCustomerController : Controller + { + private readonly IReportCustomerLogic reportLogic; + + public ReportCustomerController(IReportCustomerLogic reportLogic) + { + this.reportLogic = reportLogic; + } + + [HttpPost] + public byte[] StreamStudentList(StreamStudentBindingModel listModel) + { + byte[] file = reportLogic.SaveListFile(listModel); + return file; + } + + [HttpPost] + public List GetReportData(ReportBindingModel reportModel) + { + var list = reportLogic.GetDiscipline(reportModel); + return list; + } + + [HttpPost] + public void SendByMailStatusReport(ReportBindingModel reportModel) + { + reportLogic.SendByMailStatusReport(reportModel); + } + } +} diff --git a/UniversityRestAPI/Controllers/StudentController.cs b/UniversityRestAPI/Controllers/StudentController.cs index 8fbc3b0..8edb35a 100644 --- a/UniversityRestAPI/Controllers/StudentController.cs +++ b/UniversityRestAPI/Controllers/StudentController.cs @@ -68,6 +68,19 @@ namespace UniversityRestAPI.Controllers throw; } } + [HttpGet] + public List? GetAllByUserAndStream(int userId, int streamId) + { + try + { + + return _studentLogic.ReadList(new StudentSearchModel { UserId = userId}); + } + catch (Exception ex) + { + throw; + } + } [HttpGet] public List? GetMany(int userId, int page)