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