From 5e53d3c1d5dcc4cb3e8a476e6b62cfddc2f88f72 Mon Sep 17 00:00:00 2001 From: GokaPek Date: Thu, 30 May 2024 01:50:55 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D0=B4=D0=B8=D1=81=D1=86?= =?UTF-8?q?=D0=B8=D0=BF=D0=BB=D0=B8=D0=BD=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 3 +-- .../Implements/DisciplineStorage.cs | 11 ++++++----- .../UniversityDatabase.cs | 2 +- .../Controllers/DisciplineController .cs | 19 ++++++++++++++++--- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/University/UniversityClientApp/Controllers/HomeController.cs b/University/UniversityClientApp/Controllers/HomeController.cs index 5aac7b6..a8742b6 100644 --- a/University/UniversityClientApp/Controllers/HomeController.cs +++ b/University/UniversityClientApp/Controllers/HomeController.cs @@ -90,7 +90,7 @@ namespace UniversityClientApp.Controllers ViewBag.Students = APIStorekeeper.GetRequest>($"api/student/getstudents?userId={APIStorekeeper.Client.Id}"); // - var disciplines = await APIStorekeeper.GetRequestDisciplineAsync>($"api/discipline/getdisciplines?teacherId={0}"); + var disciplines = await APIStorekeeper.GetRequestDisciplineAsync>($"api/discipline/getdisciplines"); // return View(disciplines); @@ -111,7 +111,6 @@ namespace UniversityClientApp.Controllers Date = date, TeacherId = teacher, StudentDisciplines = studentIds.ToDictionary(id => id, id => (IStudentModel)null) - // }; APIStorekeeper.PostRequest("api/discipline/creatediscipline", disciplineModel); diff --git a/University/UniversityDatabaseImplement/Implements/DisciplineStorage.cs b/University/UniversityDatabaseImplement/Implements/DisciplineStorage.cs index 0e6820e..fbbf708 100644 --- a/University/UniversityDatabaseImplement/Implements/DisciplineStorage.cs +++ b/University/UniversityDatabaseImplement/Implements/DisciplineStorage.cs @@ -96,10 +96,10 @@ namespace UniversityDatabaseImplement.Implements - /*if (model.DateFrom.HasValue && model.DateTo.HasValue) + if (model.DateFrom.HasValue && model.DateTo.HasValue) { query = query.Where(x => model.DateFrom.Value <= x.Date && x.Date <= model.DateTo.Value); - }*/ + var x = query.Select(x => x.GetViewModel).ToList(); var res = new List(); @@ -110,9 +110,9 @@ namespace UniversityDatabaseImplement.Implements res.Add(item); } } - - //return query.Select(x => x.GetViewModel).ToList(); return res; + } + return query.Select(x => x.GetViewModel).ToList(); } @@ -122,7 +122,8 @@ namespace UniversityDatabaseImplement.Implements return context.Disciplines .Include(x => x.Students) .ThenInclude(x => x.Student) - .ToList() + .Include(x => x.Teacher) + .ToList() .Select(x => x.GetViewModel) .ToList(); } diff --git a/University/UniversityDatabaseImplement/UniversityDatabase.cs b/University/UniversityDatabaseImplement/UniversityDatabase.cs index 3eebb86..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=LAPTOP-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/DisciplineController .cs b/University/UniversityRestApi/Controllers/DisciplineController .cs index 9c3ba42..0ad705c 100644 --- a/University/UniversityRestApi/Controllers/DisciplineController .cs +++ b/University/UniversityRestApi/Controllers/DisciplineController .cs @@ -23,7 +23,7 @@ namespace UniversityRestApi.Controllers _reportLogic = reportLogic; _mailWorker = mailWorker; } - [HttpGet] + /*[HttpGet] public List? GetDisciplines(int userId) { try @@ -35,8 +35,21 @@ namespace UniversityRestApi.Controllers _logger.LogError(ex, "Ошибка получения списка дисциплин"); throw; } - } - [HttpGet] + }*/ + [HttpGet] + public List? GetDisciplines() + { + try + { + return _logic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка дисциплин"); + throw; + } + } + [HttpGet] public List GetReportDisciplines(DateOnly dateFrom, DateOnly dateTo) { try