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; + } + } } }