From 7da42c3539ab43867492ff242e8c93de93af60cc Mon Sep 17 00:00:00 2001 From: "ityurner02@mail.ru" Date: Thu, 18 May 2023 20:00:05 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D0=B5=20CRUD-=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=BE=D0=B4=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 20 ++++-- SchoolAgainStudy/TeacherWebClient/Program.cs | 50 +++++++++++--- .../Views/Home/CreateLesson.cshtml | 34 +++++++++ .../Views/Home/CreateMaterial.cshtml | 22 ++++++ .../Views/Home/CreateTask.cshtml | 32 +++++++++ .../TeacherWebClient/Views/Home/Enter.cshtml | 21 ++++++ .../Views/Home/LessonSetting.cshtml | 37 ++++++++++ .../Views/Home/Lessons.cshtml | 69 +++++++++++++++++++ .../Views/Home/MaterialSetting.cshtml | 24 +++++++ .../Views/Home/Materials.cshtml | 51 ++++++++++++++ .../Views/Home/Register.cshtml | 34 +++++++++ .../Views/Home/TaskSetting.cshtml | 35 ++++++++++ .../TeacherWebClient/Views/Home/Tasks.cshtml | 68 ++++++++++++++++++ .../Views/Shared/_Layout.cshtml | 19 ++++- 14 files changed, 497 insertions(+), 19 deletions(-) create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/CreateLesson.cshtml create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/CreateMaterial.cshtml create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/CreateTask.cshtml create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/Enter.cshtml create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/LessonSetting.cshtml create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/Lessons.cshtml create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/MaterialSetting.cshtml create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/Materials.cshtml create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/Register.cshtml create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/TaskSetting.cshtml create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/Tasks.cshtml diff --git a/SchoolAgainStudy/TeacherWebClient/Controllers/HomeController.cs b/SchoolAgainStudy/TeacherWebClient/Controllers/HomeController.cs index 6743f59..a238d93 100644 --- a/SchoolAgainStudy/TeacherWebClient/Controllers/HomeController.cs +++ b/SchoolAgainStudy/TeacherWebClient/Controllers/HomeController.cs @@ -68,7 +68,7 @@ namespace TeacherWebClient.Controllers { Id = APIClient.Teacher.Id, Name = name, - Email = login, + Email = email, Password = password, Login = login, Post = post @@ -117,7 +117,7 @@ namespace TeacherWebClient.Controllers _teacher.Create(new TeacherBindingModel { Name = name, - Email = login, + Email = email, Password = password, Login = login, Post = post @@ -212,7 +212,7 @@ namespace TeacherWebClient.Controllers ViewBag.Products = _product.ReadList(null); var list = _material.ReadList(new MaterialSearchModel { TeacherId = APIClient.Teacher.Id }); var simpMaterial = list.Select(x => new { MaterialId = x.Id, MaterialName = x.Title }); - ViewBag.Interests = new MultiSelectList(simpMaterial, "MaterialId", "MaterialName"); + ViewBag.Materials = new MultiSelectList(simpMaterial, "MaterialId", "MaterialName"); return View(); } [HttpPost] @@ -255,7 +255,7 @@ namespace TeacherWebClient.Controllers return View(lesson); } [HttpPost] - public void UpdateDiy(int idLesson, string title, string dateEvent, int product, int[] materials) + public void UpdateLesson(int idLesson, string title, string dateEvent, int product, int[] materials) { @@ -289,7 +289,7 @@ namespace TeacherWebClient.Controllers Title = title, DateEvent = DateTime.SpecifyKind(DateTime.Parse(dateEvent), DateTimeKind.Utc), ProductId = product, - ProductName = _task.ReadElement(new TaskSearchModel { Id = product }).Title, + ProductName = _product.ReadElement(new ProductSearchModel { Id = product }).Title, LessonMaterials = lessonMaterials }); @@ -319,7 +319,7 @@ namespace TeacherWebClient.Controllers { var list = _material.ReadList(new MaterialSearchModel { TeacherId = APIClient.Teacher.Id }); var simpMaterial = list.Select(x => new { MaterialId = x.Id, MaterialName = x.Title }); - ViewBag.Interests = new MultiSelectList(simpMaterial, "MaterialId", "MaterialName"); + ViewBag.Materials = new MultiSelectList(simpMaterial, "MaterialId", "MaterialName"); return View(); } [HttpPost] @@ -333,6 +333,10 @@ namespace TeacherWebClient.Controllers { throw new Exception("Введите название и даты"); } + if(DateTime.SpecifyKind(DateTime.Parse(dateIssue), DateTimeKind.Utc) >= DateTime.SpecifyKind(DateTime.Parse(dateDelivery), DateTimeKind.Utc)) + { + throw new Exception("Дата выдачи должна быть раньше срока сдачи"); + } Dictionary taskMaterials = new Dictionary(); foreach (int id in materials) { @@ -380,6 +384,10 @@ namespace TeacherWebClient.Controllers { throw new Exception("Нет материалов"); } + if (DateTime.SpecifyKind(DateTime.Parse(dateIssue), DateTimeKind.Utc) >= DateTime.SpecifyKind(DateTime.Parse(dateDelivery), DateTimeKind.Utc)) + { + throw new Exception("Дата выдачи должна быть раньше срока сдачи"); + } Dictionary taskMaterials = new Dictionary(); foreach (int id in materials) diff --git a/SchoolAgainStudy/TeacherWebClient/Program.cs b/SchoolAgainStudy/TeacherWebClient/Program.cs index 559dd3a..dae0433 100644 --- a/SchoolAgainStudy/TeacherWebClient/Program.cs +++ b/SchoolAgainStudy/TeacherWebClient/Program.cs @@ -1,27 +1,55 @@ -var builder = WebApplication.CreateBuilder(args); +using SchoolAgainStudyBusinessLogic.BusinessLogic; +using SchoolAgainStudyBusinessLogic.OfficePackage.Implements; +using SchoolAgainStudyBusinessLogic.OfficePackage; +using SchoolAgainStudyBusinessLogic._; +using SchoolAgainStudyContracts.BusinessLogicContracts; +using SchoolAgainStudyContracts.StorageContracts; +using SchoolAgainStudyDataBaseImplements.Implements; +using TeacherWebClient; +var builder = WebApplication.CreateBuilder(args); +builder.Logging.SetMinimumLevel(LogLevel.Trace); +builder.Logging.AddLog4Net("log4net.config"); +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(); + +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); // Add services to the container. builder.Services.AddControllersWithViews(); - var app = builder.Build(); - // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } - app.UseHttpsRedirection(); app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthorization(); - app.MapControllerRoute( - name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); - + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); app.Run(); diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/CreateLesson.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/CreateLesson.cshtml new file mode 100644 index 0000000..f7daf85 --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/CreateLesson.cshtml @@ -0,0 +1,34 @@ +@{ + ViewData["Title"] = "CreateLesson"; +} +
+

Создание занятия

+
+
+ +
+
Название:
+
+
+
+
Дата проведения:
+
@Html.TextBox("dateEvent" ,"" ,new {type="Date"})
+
+
+
Изделие:
+
+ +
+
+
+
Материалы:
+
+ @Html.ListBox("materials", (MultiSelectList)ViewBag.Materials) +
+
+
+
+
+
+ +
diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/CreateMaterial.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/CreateMaterial.cshtml new file mode 100644 index 0000000..6ad3222 --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/CreateMaterial.cshtml @@ -0,0 +1,22 @@ +@{ + ViewData["Title"] = "CreateMaterial"; +} +
+

Создание материала

+
+
+ +
+
Название:
+
+
+
+
Сфера использования:
+
:
+
+
+
+
+
+ +
\ No newline at end of file diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/CreateTask.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/CreateTask.cshtml new file mode 100644 index 0000000..c81ae91 --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/CreateTask.cshtml @@ -0,0 +1,32 @@ +@{ + ViewData["Title"] = "CreateTask"; +} +
+

Создание задания

+
+
+ +
+
Название:
+
+
+
+
Дата выдачи:
+
@Html.TextBox("dateIssue" ,"" ,new {type="Date"})
+
+
+
Срок сдачи:
+
@Html.TextBox("dateDelivery" ,"" ,new {type="Date"})
+
+
+
Материалы:
+
+ @Html.ListBox("materials", (MultiSelectList)ViewBag.Materials) +
+
+
+
+
+
+ +
diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/Enter.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/Enter.cshtml new file mode 100644 index 0000000..bca6d69 --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/Enter.cshtml @@ -0,0 +1,21 @@ +@{ + ViewData["Title"] = "Enter"; +} + +
+

Вход в приложение

+
+
+
+
Логин:
+
+
+
+
Пароль:
+
+
+
+
+
+
+
diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/LessonSetting.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/LessonSetting.cshtml new file mode 100644 index 0000000..bab737f --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/LessonSetting.cshtml @@ -0,0 +1,37 @@ +@using SchoolAgainStudyContracts.ViewModel; +@model LessonViewModel +@{ + ViewData["Title"] = "Setting"; +} +
+

@Model.Title

+
+
+
+
+ + +
+
+
+
Название:
+
+
+
+
Дата проведения:
+
@Html.TextBox("dateEvent", Model.DateEvent.Date.ToString("yyyy-MM-dd"),new {type="Date"})
+
+
+
Изделие:
+
+ +
+
+
+
Материалы:
+
+ @Html.ListBox("materials", (MultiSelectList)ViewBag.Materials) +
+
+ +
diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/Lessons.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/Lessons.cshtml new file mode 100644 index 0000000..521c013 --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/Lessons.cshtml @@ -0,0 +1,69 @@ +@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.DateEvent) + + @Html.DisplayFor(modelItem => item.ProductName) + + + + U +
+ } +
diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/MaterialSetting.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/MaterialSetting.cshtml new file mode 100644 index 0000000..1ff8e40 --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/MaterialSetting.cshtml @@ -0,0 +1,24 @@ +@using SchoolAgainStudyContracts.ViewModel; +@model MaterialViewModel +@{ + ViewData["Title"] = "Setting"; +} +
+

@Model.Title

+
+
+
+
+ + +
+
+
+
Название:
+
+
+
+
Сфера использования:
+
:
+
+
\ No newline at end of file diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/Materials.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/Materials.cshtml new file mode 100644 index 0000000..7d98fb2 --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/Materials.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 +
+ } +
diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/Register.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/Register.cshtml new file mode 100644 index 0000000..ce6013e --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/Register.cshtml @@ -0,0 +1,34 @@ +@{ + ViewData["Title"] = "Register"; +} + +
+

Регистрация

+
+
+
+
ФИО:
+
+
+
+
Должность:
+
+
+
+
Почта:
+
+
+
+
Логин:
+
+
+
+
Пароль:
+
+
+ +
+
+
+
+
diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/TaskSetting.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/TaskSetting.cshtml new file mode 100644 index 0000000..f6028b5 --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/TaskSetting.cshtml @@ -0,0 +1,35 @@ +@using SchoolAgainStudyContracts.ViewModel; +@model TaskViewModel +@{ + ViewData["Title"] = "Setting"; +} +
+

@Model.Title

+
+
+
+
+ + +
+
+
+
Название:
+
+
+
+
Дата выдачи:
+
@Html.TextBox("dateIssue" ,Model.DateIssue.Date.ToString("yyyy-MM-dd") ,new {type="Date"})
+
+
+
Срок сдачи:
+
@Html.TextBox("dateDelivery" ,Model.DateDelivery.Date.ToString("yyyy-MM-dd") ,new {type="Date"})
+
+
+
Материалы:
+
+ @Html.ListBox("materials", (MultiSelectList)ViewBag.Materials) +
+
+ +
diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/Tasks.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/Tasks.cshtml new file mode 100644 index 0000000..3adbf2d --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/Tasks.cshtml @@ -0,0 +1,68 @@ +@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.DateIssue) + + @Html.DisplayFor(modelItem => item.DateDelivery) + + + + U +
+ } +
diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Shared/_Layout.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Shared/_Layout.cshtml index 3051cbd..ea4fdc7 100644 --- a/SchoolAgainStudy/TeacherWebClient/Views/Shared/_Layout.cshtml +++ b/SchoolAgainStudy/TeacherWebClient/Views/Shared/_Layout.cshtml @@ -20,10 +20,25 @@