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 @@
+
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 @@