From 0d6cafab672485e0fc2649a4a8723c400c92ce00 Mon Sep 17 00:00:00 2001 From: GokaPek Date: Tue, 28 May 2024 22:09:51 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A7=D0=B0=D1=81=D1=82=D0=B8=D1=87=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE=20=D0=95=D0=B3?= =?UTF-8?q?=D0=BE=D1=80=20=D0=92=D0=BE=D1=80=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ReportLogic.cs | 1 + .../UniversityDatabase.cs | 2 +- .../Controllers/TeacherController.cs | 20 ++++++++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/University/UniversityBusinessLogic/BusinessLogics/ReportLogic.cs b/University/UniversityBusinessLogic/BusinessLogics/ReportLogic.cs index c9fce5d..d970a4e 100644 --- a/University/UniversityBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/University/UniversityBusinessLogic/BusinessLogics/ReportLogic.cs @@ -86,6 +86,7 @@ public class ReportLogic : IReportLogic // Добавляем учителя и его студентов в результат result.Add(new ReportTeacherViewModel { + TeacherId = teacher.Id, TeacherName = teacher.Name, Students = students.Distinct().ToList() // Убираем дубликаты, если они есть }); diff --git a/University/UniversityDatabaseImplement/UniversityDatabase.cs b/University/UniversityDatabaseImplement/UniversityDatabase.cs index 2b73bad..07213d0 100644 --- a/University/UniversityDatabaseImplement/UniversityDatabase.cs +++ b/University/UniversityDatabaseImplement/UniversityDatabase.cs @@ -11,7 +11,7 @@ namespace UniversityDatabaseImplement if (optionsBuilder.IsConfigured == false) { //Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR - optionsBuilder.UseSqlServer(@"Data Source=DyCTaTOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-N8BRIPR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/University/UniversityRestApi/Controllers/TeacherController.cs b/University/UniversityRestApi/Controllers/TeacherController.cs index 0114e8a..3fe232c 100644 --- a/University/UniversityRestApi/Controllers/TeacherController.cs +++ b/University/UniversityRestApi/Controllers/TeacherController.cs @@ -1,5 +1,7 @@ using Microsoft.AspNetCore.Mvc; +using University.ViewModels; using UniversityContracts.BindingModels; +using UniversityContracts.BusinessLogicContracts; using UniversityContracts.BusinessLogicsContracts; using UniversityContracts.SearchModels; using UniversityContracts.ViewModels; @@ -12,10 +14,12 @@ namespace UniversityRestApi.Controllers { private readonly ILogger _logger; private readonly ITeacherLogic _logic; - public TeacherController(ITeacherLogic logic, ILogger logger) + private readonly IReportLogic _reportLogic; + public TeacherController(ITeacherLogic logic, ILogger logger, IReportLogic reportLogic) { _logic = logic; _logger = logger; + _reportLogic = reportLogic; } [HttpGet] public List? GetTeachers(int userId) @@ -82,5 +86,19 @@ namespace UniversityRestApi.Controllers throw; } } + + [HttpGet] + public List? GetDisciplinesReport() + { + try + { + return _reportLogic.GetTeachers(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка планов обучения"); + throw; + } + } } }