From 6a415df4d93a472cb0893568b6384d6ae5d70a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BE=D0=BB=D0=BE=D0=B4=D1=8F?= Date: Wed, 17 May 2023 18:16:54 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=85=D0=BE=D0=B4=20+=20=D0=A0=D0=B5?= =?UTF-8?q?=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8=D1=8F=20+=20CR?= =?UTF-8?q?UD=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D0=B5=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Properties/launchSettings.json | 12 + .../Properties/launchSettings.json | 12 + .../Controllers/HomeController.cs | 206 +++++++++++++++++- SchoolAgainStudy/StudentWebClient/Program.cs | 26 +-- .../Views/Home/CreateDiy.cshtml | 33 +++ .../Views/Home/CreateInterest.cshtml | 22 ++ .../StudentWebClient/Views/Home/Diyes.cshtml | 63 ++++++ .../Views/Home/InterestSetting.cshtml | 26 +++ .../Views/Home/Interests.cshtml | 51 +++++ .../Views/Home/Register.cshtml | 7 +- .../Views/Shared/_Layout.cshtml | 11 +- 11 files changed, 437 insertions(+), 32 deletions(-) create mode 100644 SchoolAgainStudy/SchoolAgainStudyBusinessLogic/Properties/launchSettings.json create mode 100644 SchoolAgainStudy/SchoolAgainStudyContracts/Properties/launchSettings.json create mode 100644 SchoolAgainStudy/StudentWebClient/Views/Home/CreateDiy.cshtml create mode 100644 SchoolAgainStudy/StudentWebClient/Views/Home/CreateInterest.cshtml create mode 100644 SchoolAgainStudy/StudentWebClient/Views/Home/Diyes.cshtml create mode 100644 SchoolAgainStudy/StudentWebClient/Views/Home/InterestSetting.cshtml create mode 100644 SchoolAgainStudy/StudentWebClient/Views/Home/Interests.cshtml diff --git a/SchoolAgainStudy/SchoolAgainStudyBusinessLogic/Properties/launchSettings.json b/SchoolAgainStudy/SchoolAgainStudyBusinessLogic/Properties/launchSettings.json new file mode 100644 index 0000000..89a7f60 --- /dev/null +++ b/SchoolAgainStudy/SchoolAgainStudyBusinessLogic/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "SchoolAgainStudyBusinessLogic": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:57331;http://localhost:57333" + } + } +} \ No newline at end of file diff --git a/SchoolAgainStudy/SchoolAgainStudyContracts/Properties/launchSettings.json b/SchoolAgainStudy/SchoolAgainStudyContracts/Properties/launchSettings.json new file mode 100644 index 0000000..b755ffe --- /dev/null +++ b/SchoolAgainStudy/SchoolAgainStudyContracts/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "SchoolAgainStudyContracts": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:57332;http://localhost:57334" + } + } +} \ No newline at end of file diff --git a/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs b/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs index 6e2c35c..26fc385 100644 --- a/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs +++ b/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using SchoolAgainStudyContracts.BindingModel; +using SchoolAgainStudyContracts.ViewModel; using StudentWebClient.Models; using System.Diagnostics; @@ -50,7 +51,7 @@ namespace StudentWebClient.Controllers { throw new Exception("Введите данные"); } - APIClient.PostRequest("api/client/updatedata", new StudentBindingModel + APIClient.PostRequest("api/student/updatedata", new StudentBindingModel { Id = APIClient.Student.Id, Name = name, @@ -67,5 +68,208 @@ namespace StudentWebClient.Controllers APIClient.Student.Class = scClass; Response.Redirect("Index"); } + [HttpGet] + public IActionResult Enter() + { + return View(); + } + + [HttpPost] + public void Enter(string login, string password) + { + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введите логин и пароль"); + } + APIClient.Student = APIClient.GetRequest($"api/student/login?login={login}&password={password}"); + if (APIClient.Student == null) + { + throw new Exception("Неверный логин/пароль"); + } + Response.Redirect("Index"); + } + [HttpGet] + public IActionResult Register() + { + return View(); + } + + [HttpPost] + public void Register(string name, string email, string login, string password, int scClass) + { + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(email) || scClass <= 0 || scClass > 11) + { + throw new Exception("Введите логин, пароль и ФИО, класс, почту"); + } + APIClient.PostRequest("api/student/register", new StudentBindingModel + { + Name = name, + Email = login, + Password = password, + Login = login, + Class = scClass + }); + Response.Redirect("Enter"); + return; + } + [HttpGet] + public IActionResult Interests() + { + if (APIClient.Student == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.GetRequest>($"api/main/getinterests?studentId={APIClient.Student.Id}")); + } + [HttpGet] + public IActionResult CreateInterest() + { + return View(); + } + [HttpPost] + public void CreateInterest(string title,string description) + { + if (APIClient.Student == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(title) && string.IsNullOrEmpty(description)) + { + throw new Exception("Введите название и описане"); + } + APIClient.PostRequest("api/main/createinterest", new InterestBindingModel + { + StudentId = APIClient.Student.Id, + Title = title, + Description = description + }); + Response.Redirect("Interests"); + } + [HttpGet] + public IActionResult InterestSetting(int id) + { + return View(APIClient.GetRequest($"api/main/getinterest?interestId={id}")); + } + [HttpPost] + public void UpdateInterest(int id,string name, string desc) + { + + + if (string.IsNullOrEmpty(name)) + { + throw new Exception("Нет названия"); + } + if (string.IsNullOrEmpty(desc)) + { + throw new Exception("Нет описания"); + } + + APIClient.PostRequest("api/main/UpdateInterest", new InterestBindingModel + { + Id = id, + Title = name, + Description = desc, + StudentId = APIClient.Student.Id, + + }); + Response.Redirect("/Home/Interests"); + } + + public void DeleteInterest(int id) + { + + APIClient.PostRequest("api/main/DeleteInterest", new InterestBindingModel + { + Id = id, + }); + Response.Redirect("/Home/Interests"); + } + + [HttpGet] + public IActionResult Diyes() + { + if (APIClient.Student == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.GetRequest>($"api/main/GetDiyes?studentId={APIClient.Student.Id}")); + } + [HttpGet] + public IActionResult CreateDiy() + { + ViewBag.Tasks = APIClient.GetRequest>("api/shop/GetTaskList"); + return View(); + } + [HttpPost] + public void CreateDiy(string title, string description, string dateCreate, int task, int[] interests ) + { + if (APIClient.Student == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(title) && string.IsNullOrEmpty(description) || string.IsNullOrEmpty(dateCreate) && task <=0 || interests.Length==0) + { + throw new Exception("Введите название и описане"); + } + APIClient.PostRequest("api/main/creatediy", new InterestBindingModel + { + StudentId = APIClient.Student.Id, + Title = title, + Description = description + }); + Response.Redirect("Interests"); + } + [HttpGet] + public IActionResult DiySetting(int id) + { + return View(APIClient.GetRequest($"api/main/getdiy?diyId={id}")); + } + [HttpPost] + public void UpdateDiy(int id, string name, string desc,string dateCreate, int task, int[] interests) + { + + + if (string.IsNullOrEmpty(name)) + { + throw new Exception("Нет названия"); + } + if (string.IsNullOrEmpty(desc)) + { + throw new Exception("Нет описания"); + } + if (string.IsNullOrEmpty(dateCreate)) + { + throw new Exception("Нет даты"); + } + if (task <= 0) + { + throw new Exception("Нет задания"); + } + if (interests.Length == 0) + { + throw new Exception("Нет интересов"); + } + + APIClient.PostRequest("api/main/UpdateDiy", new InterestBindingModel + { + Id = id, + Title = name, + Description = desc, + StudentId = APIClient.Student.Id, + + }); + Response.Redirect("/Home/Diyes"); + } + + public void DeleteDiy(int id) + { + + APIClient.PostRequest("api/main/DeletDiy", new DiyBindingModel + { + Id = id, + }); + Response.Redirect("/Home/Diyes"); + } + } } \ No newline at end of file diff --git a/SchoolAgainStudy/StudentWebClient/Program.cs b/SchoolAgainStudy/StudentWebClient/Program.cs index 44f1382..7ebc55a 100644 --- a/SchoolAgainStudy/StudentWebClient/Program.cs +++ b/SchoolAgainStudy/StudentWebClient/Program.cs @@ -1,33 +1,8 @@ -using SchoolAgainStudyBusinessLogic.BusinessLogic; -using SchoolAgainStudyBusinessLogic._; -using SchoolAgainStudyContracts.BusinessLogicContracts; -using SchoolAgainStudyContracts.StorageContracts; -using SchoolAgainStudyDataBaseImplements.Implements; using StudentWebClient; var builder = WebApplication.CreateBuilder(args); - // Add services to the container. builder.Services.AddControllersWithViews(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); - -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); - var app = builder.Build(); APIClient.Connect(builder.Configuration); // Configure the HTTP request pipeline. @@ -45,3 +20,4 @@ app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); app.Run(); + diff --git a/SchoolAgainStudy/StudentWebClient/Views/Home/CreateDiy.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Home/CreateDiy.cshtml new file mode 100644 index 0000000..e50fcaf --- /dev/null +++ b/SchoolAgainStudy/StudentWebClient/Views/Home/CreateDiy.cshtml @@ -0,0 +1,33 @@ +@{ + ViewData["Title"] = "CreateDiy"; +} +
+

Создание поделки

+
+
+ +
+
Название:
+
+
+
+
Описание:
+
:
+
+
+
Дата создания:
+
@Html.TextBox("dateCreate" ,"" ,new {type="Date"})
+
+
+
Задание:
+
+ +
+
+ +
+
+
+
+ +
\ No newline at end of file diff --git a/SchoolAgainStudy/StudentWebClient/Views/Home/CreateInterest.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Home/CreateInterest.cshtml new file mode 100644 index 0000000..589103e --- /dev/null +++ b/SchoolAgainStudy/StudentWebClient/Views/Home/CreateInterest.cshtml @@ -0,0 +1,22 @@ +@{ + ViewData["Title"] = "CreateInterest"; +} +
+

Создание интереса

+
+
+ +
+
Название:
+
+
+
+
Описание:
+
:
+
+
+
+
+
+ +
\ No newline at end of file diff --git a/SchoolAgainStudy/StudentWebClient/Views/Home/Diyes.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Home/Diyes.cshtml new file mode 100644 index 0000000..e79a395 --- /dev/null +++ b/SchoolAgainStudy/StudentWebClient/Views/Home/Diyes.cshtml @@ -0,0 +1,63 @@ +@using SchoolAgainStudyContracts.ViewModel; + +@model List + +@{ + ViewData["Title"] = "Home Page"; +} + +
+

Поделки

+
+ + +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } + +

+ Создать поделку +

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + } + +
+ Название + + Дата создания + + Задание +
+ @Html.DisplayFor(modelItem => item.Title) + + @Html.DisplayFor(modelItem => item.DateCreate) + + @Html.DisplayFor(modelItem => item.TaskName) + + U +
+ } +
diff --git a/SchoolAgainStudy/StudentWebClient/Views/Home/InterestSetting.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Home/InterestSetting.cshtml new file mode 100644 index 0000000..aad9f3d --- /dev/null +++ b/SchoolAgainStudy/StudentWebClient/Views/Home/InterestSetting.cshtml @@ -0,0 +1,26 @@ +@using SchoolAgainStudyContracts.ViewModel; +@model InterestViewModel +@{ + ViewData["Title"] = "Setting"; +} +
+

@Model.Title

+
+
+
+
+ + +
+
+
+
Название:
+
+
+
+
Описание:
+
:
+
+
+ + diff --git a/SchoolAgainStudy/StudentWebClient/Views/Home/Interests.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Home/Interests.cshtml new file mode 100644 index 0000000..98c4c62 --- /dev/null +++ b/SchoolAgainStudy/StudentWebClient/Views/Home/Interests.cshtml @@ -0,0 +1,51 @@ +@using SchoolAgainStudyContracts.ViewModel; + +@model List + +@{ + ViewData["Title"] = "Home Page"; +} + +
+

Интересы

+
+ + +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } + +

+ Создать интерес +

+ + + + + + + + + @foreach (var item in Model) + { + + + + + + } + +
+ Название +
+ @Html.DisplayFor(modelItem => item.Title) + + U +
+ } +
\ No newline at end of file diff --git a/SchoolAgainStudy/StudentWebClient/Views/Home/Register.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Home/Register.cshtml index 022ae21..d12dce9 100644 --- a/SchoolAgainStudy/StudentWebClient/Views/Home/Register.cshtml +++ b/SchoolAgainStudy/StudentWebClient/Views/Home/Register.cshtml @@ -16,7 +16,7 @@
Класс:
-
+
Логин:
@@ -26,10 +26,7 @@
Пароль:
-
-
ФИО:
-
-
+
diff --git a/SchoolAgainStudy/StudentWebClient/Views/Shared/_Layout.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Shared/_Layout.cshtml index 72a8dff..c1a9e92 100644 --- a/SchoolAgainStudy/StudentWebClient/Views/Shared/_Layout.cshtml +++ b/SchoolAgainStudy/StudentWebClient/Views/Shared/_Layout.cshtml @@ -24,7 +24,16 @@