From 75ead823e873731ec00dcd65ddb4e18e1883bee7 Mon Sep 17 00:00:00 2001 From: GokaPek Date: Mon, 27 May 2024 10:21:44 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A7=D0=B0=D1=81=D1=82=D0=B8=D1=87=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B=20=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BE=D1=81=D1=82=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 20 ++++++++++++++++++- .../Views/Home/Statements.cshtml | 6 +++--- .../BindingModels/StatementBindingModel.cs | 2 +- .../UniversityDatabase.cs | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/University/UniversityClientApp/Controllers/HomeController.cs b/University/UniversityClientApp/Controllers/HomeController.cs index e547801..f9cb7f2 100644 --- a/University/UniversityClientApp/Controllers/HomeController.cs +++ b/University/UniversityClientApp/Controllers/HomeController.cs @@ -80,14 +80,32 @@ namespace UniversityClientApp.Controllers return View(); } + [HttpGet] public IActionResult Statements() { if (APIStorekeeper.Client == null) { return Redirect("~/Home/Enter"); } + ViewBag.Teachers = APIStorekeeper.GetRequest>($"api/teacher/getteachers?userId={APIStorekeeper.Client.Id}"); return View(APIStorekeeper.GetRequest>($"api/statement/getstatements?teacherId={0}")); } + [HttpPost] + public void Statements(string name, DateTime date, int teacher) + { + if (APIStorekeeper.Client == null) + { + Redirect("~/Home/Enter"); + } + APIStorekeeper.PostRequest("api/statement/createstatement", new StatementBindingModel + { + UserId = APIStorekeeper.Client.Id, + Name = name, + Date = date, + TeacherId = teacher, + }); + Response.Redirect("Statements"); + } [HttpGet] public IActionResult Teachers() @@ -113,7 +131,7 @@ namespace UniversityClientApp.Controllers Position = position, AcademicDegree = academicDegree }); - Response.Redirect("Index"); + Response.Redirect("Teachers"); } public IActionResult Report() { diff --git a/University/UniversityClientApp/Views/Home/Statements.cshtml b/University/UniversityClientApp/Views/Home/Statements.cshtml index 7577237..9633069 100644 --- a/University/UniversityClientApp/Views/Home/Statements.cshtml +++ b/University/UniversityClientApp/Views/Home/Statements.cshtml @@ -14,19 +14,19 @@
Title:
- +
Date:
- +
Teacher:
- +
diff --git a/University/UniversityContracts/BindingModels/StatementBindingModel.cs b/University/UniversityContracts/BindingModels/StatementBindingModel.cs index 2c787e4..022296c 100644 --- a/University/UniversityContracts/BindingModels/StatementBindingModel.cs +++ b/University/UniversityContracts/BindingModels/StatementBindingModel.cs @@ -14,6 +14,6 @@ namespace UniversityContracts.BindingModels public int UserId { get; set; } public int TeacherId { get; set; } public string Name { get; set; } = string.Empty; - public DateTime Date { get; } + public DateTime Date { get; set; } } } 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); }