diff --git a/CarService/CarServiceWebApp/Controllers/HomeController.cs b/CarService/CarServiceWebApp/Controllers/HomeController.cs index db8e0bb..5c3f2f6 100644 --- a/CarService/CarServiceWebApp/Controllers/HomeController.cs +++ b/CarService/CarServiceWebApp/Controllers/HomeController.cs @@ -38,9 +38,7 @@ namespace CarServiceWebApp.Controllers /// [HttpGet] public IActionResult Enter() - { - return View(); - } + => View(); /// /// Ввод данных в форму для входа /// @@ -94,10 +92,7 @@ namespace CarServiceWebApp.Controllers /// /// [HttpGet] - public IActionResult Register() - { - return View(); - } + public IActionResult Register() => View(); /// /// Ввод данных при регистрации пользователя /// @@ -116,31 +111,64 @@ namespace CarServiceWebApp.Controllers } return Redirect("~/Home/Enter"); } + /// + /// Отображение формы CRUD работы + /// + /// + /// [HttpGet] public IActionResult Work(int Id) { ViewBag.Work = _workLogic.ReadElement(new() { Id = Id }); return View(); } + /// + /// Обновление работы + /// + /// + /// [HttpPost] - public IActionResult UpdateWork(Work work) + public IActionResult UpdateWork(WorkBindingModel model) { - //ViewBag.Work = _workLogic.ReadElement(new() { Id = Id }); - return View(); + _workLogic.Update(model); + return Redirect("~/Home/Works"); } + /// + /// Удаление работы + /// + /// + /// [HttpPost] - public IActionResult DeleteWork(int Id) + public IActionResult DeleteWork(WorkBindingModel model) { - ViewBag.Work = _workLogic.ReadElement(new() { Id = Id }); - return View(); + _workLogic.Delete(model); + return Redirect("~/Home/Works"); + } + /// + /// Отображение формы добавления работы + /// + /// + //[HttpGet] + public IActionResult CreateWork() => View(); + /// + /// Добавление работы + /// + /// + /// + [HttpPost] + public IActionResult CreateWork(WorkBindingModel model) + { + try + { + _workLogic.Create(model); + } + catch (Exception ex) + { + ViewBag.Exception = ex.Message; + return View(); + } + return Redirect("~/Home/Works"); } - - - - - - - /// /// Вывод ошибок /// diff --git a/CarService/CarServiceWebApp/Views/Home/CreateWork.cshtml b/CarService/CarServiceWebApp/Views/Home/CreateWork.cshtml new file mode 100644 index 0000000..7b30578 --- /dev/null +++ b/CarService/CarServiceWebApp/Views/Home/CreateWork.cshtml @@ -0,0 +1,20 @@ +
+ + +
+
Название:
+
+
+
+
Цена:
+
+
+
+
Длительность:
+
+
+
+
+
+
+
@ViewBag.Exception
\ No newline at end of file diff --git a/CarService/CarServiceWebApp/Views/Home/Enter.cshtml b/CarService/CarServiceWebApp/Views/Home/Enter.cshtml index 77a8f67..463ef5b 100644 --- a/CarService/CarServiceWebApp/Views/Home/Enter.cshtml +++ b/CarService/CarServiceWebApp/Views/Home/Enter.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["Title"] = "Enter"; + ViewData["Title"] = "Вход"; }
diff --git a/CarService/CarServiceWebApp/Views/Home/Work.cshtml b/CarService/CarServiceWebApp/Views/Home/Work.cshtml index 5661d93..4973cf6 100644 --- a/CarService/CarServiceWebApp/Views/Home/Work.cshtml +++ b/CarService/CarServiceWebApp/Views/Home/Work.cshtml @@ -1,5 +1,6 @@ 
+
Название:
@@ -13,10 +14,10 @@
-
+
-
+
diff --git a/CarService/CarServiceWebApp/Views/Home/Works.cshtml b/CarService/CarServiceWebApp/Views/Home/Works.cshtml index 10a5d13..20d02d1 100644 --- a/CarService/CarServiceWebApp/Views/Home/Works.cshtml +++ b/CarService/CarServiceWebApp/Views/Home/Works.cshtml @@ -6,26 +6,29 @@

Работы

@if (ViewBag.Works.Count != 0) { - - - - - - - - - - @foreach (var work in ViewBag.Works) - { +
+
НазваниеЦена (в рублях)Длительность (в часах)
+ - - - - + + + - } - -
@work.Name@work.Price@work.DurationИзменитьНазваниеЦена (в рублях)Длительность (в часах)
+ + + @foreach (var work in ViewBag.Works) + { + + @work.Name + @work.Price + @work.Duration + Изменить + + } + + + } +
Добавить
@ViewBag.Exception
\ No newline at end of file