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