diff --git a/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs b/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs index 7bdafe2..a563f93 100644 --- a/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs +++ b/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs @@ -3,7 +3,6 @@ using HardwareShopContracts.BindingModels; using HardwareShopContracts.ViewModels; using HardwareShopDataModels.Enums; using Microsoft.AspNetCore.Mvc; -using System.Data; using System.Diagnostics; namespace HardwareShopClientApp.Controllers @@ -17,7 +16,6 @@ namespace HardwareShopClientApp.Controllers _logger = logger; } - [HttpGet] public IActionResult Register() { return View(); @@ -43,10 +41,6 @@ namespace HardwareShopClientApp.Controllers public IActionResult Index() { - if (APIClient.User == null) - { - return Redirect("~/Home/Enter"); - } return View(); } @@ -61,15 +55,13 @@ namespace HardwareShopClientApp.Controllers return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } - - [HttpGet] public IActionResult Enter() { return View(); } [HttpPost] - public IActionResult Enter(string email, string password) + public void Enter(string email, string password) { if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { @@ -82,21 +74,12 @@ namespace HardwareShopClientApp.Controllers } if ((int)APIClient.User.Role == 1) { - return RedirectToAction("MainWorker", "Worker"); - return RedirectToAction("WorkerReport", "Worker"); + RedirectToAction("MainWorker", "Worker"); } else { - return Redirect("Index"); + RedirectToAction("Goods", "Storekeeper"); } - } - - [HttpGet] - public IActionResult MainWorker() - { - return View(); - } - } } \ No newline at end of file diff --git a/HardwareShop/HardwareShopClientApp/Controllers/StorekeeperController.cs b/HardwareShop/HardwareShopClientApp/Controllers/StorekeeperController.cs new file mode 100644 index 0000000..abc7a40 --- /dev/null +++ b/HardwareShop/HardwareShopClientApp/Controllers/StorekeeperController.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Mvc; + +namespace HardwareShopClientApp.Controllers +{ + public class StorekeeperController : Controller + { + private readonly ILogger _logger; + + public StorekeeperController(ILogger logger) + { + _logger = logger; + } + + public IActionResult MainStorekeeper() + { + return View(); + } + + public IActionResult Components() + { + return View(); + } + + public IActionResult Goods() + { + return View(); + } + + public IActionResult Orders() + { + return View(); + } + + } +} diff --git a/HardwareShop/HardwareShopClientApp/Controllers/WorkerController.cs b/HardwareShop/HardwareShopClientApp/Controllers/WorkerController.cs index 9155dc8..75f367c 100644 --- a/HardwareShop/HardwareShopClientApp/Controllers/WorkerController.cs +++ b/HardwareShop/HardwareShopClientApp/Controllers/WorkerController.cs @@ -35,7 +35,7 @@ namespace HardwareShopClientApp.Controllers [HttpGet] public IActionResult Purchases() { - return View(APIClient.GetRequest>($"api/client/getpurchases?UserId={APIClient.User.Id}")); + return View(); } [HttpPost] diff --git a/HardwareShop/HardwareShopClientApp/Views/Home/Enter.cshtml b/HardwareShop/HardwareShopClientApp/Views/Home/Enter.cshtml index 5081bb7..f74aed5 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Home/Enter.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Home/Enter.cshtml @@ -1,7 +1,24 @@ @{ ViewData["Title"] = "Enter"; } -@section Header {} +@section Header { +
+ +
+}

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

@@ -14,10 +31,8 @@ -
+
- Регистрация -
- +
Регистрация diff --git a/HardwareShop/HardwareShopClientApp/Views/Home/Index.cshtml b/HardwareShop/HardwareShopClientApp/Views/Home/Index.cshtml index 805a4eb..84ed0d9 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Home/Index.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Home/Index.cshtml @@ -1,99 +1,34 @@ @{ - ViewData["Title"] = "Home Page"; + ViewData["Title"] = "Enter"; } - -@using HardwareShopContracts.ViewModels - -@model List - @section Header { -
- -
+
+ +
} - -
-

Регистрация

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

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

- return; - } - - - - - - - - - - - - - @foreach (var item in Model) - { - - - - - - - - } - -
- Номер - - Блюдо - - Дата создания - - Количество - - Сумма - - Статус -
- @Html.DisplayFor(modelItem => item.Id) - - @Html.DisplayFor(modelItem => item.DatePurchase) - - @Html.DisplayFor(modelItem => item.Sum) - - @Html.DisplayFor(modelItem => item.PurchaseStatus) - - @Html.DisplayFor(modelItem => item.UserLogin) -
- } +
+ Основная страница
diff --git a/HardwareShop/HardwareShopClientApp/Views/Home/Register.cshtml b/HardwareShop/HardwareShopClientApp/Views/Home/Register.cshtml index 4902b55..12f9ed9 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Home/Register.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Home/Register.cshtml @@ -1,7 +1,24 @@ @{ ViewData["Title"] = "Register"; } -@section Header {} +@section Header { +
+ +
+}

Регистрация

diff --git a/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Components.cshtml b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Components.cshtml index 125a5a8..5486c28 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Components.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Components.cshtml @@ -1,10 +1,32 @@ - - - - - - - +@using HardwareShopContracts.ViewModels +@{ + ViewData["Title"] = "Goods"; +} - - \ No newline at end of file +@model List + +@section Header { +
+ +
+} +
+ привет, мы в компонентах +
\ No newline at end of file diff --git a/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Goods.cshtml b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Goods.cshtml new file mode 100644 index 0000000..59fec69 --- /dev/null +++ b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Goods.cshtml @@ -0,0 +1,35 @@ +@using HardwareShopContracts.ViewModels +@{ + ViewData["Title"] = "Goods"; +} + +@model List + +@section Header { +
+ +
+} +
+ привет, мы в товарах +
\ No newline at end of file diff --git a/HardwareShop/HardwareShopClientApp/Views/Storekeeper/MainStorekeeper.cshtml b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/MainStorekeeper.cshtml new file mode 100644 index 0000000..d40ccd4 --- /dev/null +++ b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/MainStorekeeper.cshtml @@ -0,0 +1,29 @@ +@{ + ViewData["Title"] = "MainStorekeeper"; +} + +@section Header { +
+ +
+} \ No newline at end of file diff --git a/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Orders.cshtml b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Orders.cshtml new file mode 100644 index 0000000..c567d65 --- /dev/null +++ b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Orders.cshtml @@ -0,0 +1,35 @@ +@using HardwareShopContracts.ViewModels +@{ + ViewData["Title"] = "Goods"; +} + +@model List + +@section Header { +
+ +
+} +
+ привет, мы в заказах +
\ No newline at end of file diff --git a/HardwareShop/HardwareShopRestApi/Controllers/ClientController.cs b/HardwareShop/HardwareShopRestApi/Controllers/ClientController.cs index a3f1a9b..dff5017 100644 --- a/HardwareShop/HardwareShopRestApi/Controllers/ClientController.cs +++ b/HardwareShop/HardwareShopRestApi/Controllers/ClientController.cs @@ -15,13 +15,10 @@ namespace HardwareShopRestApi.Controllers private readonly IUserLogic _logic; - private readonly IPurchaseLogic _purchaseLogic; - - public ClientController(IUserLogic logic, IPurchaseLogic purchaseLogic, ILogger logger) + public ClientController(IUserLogic logic, ILogger logger) { _logger = logger; _logic = logic; - _purchaseLogic = purchaseLogic; } [HttpGet] @@ -55,20 +52,5 @@ namespace HardwareShopRestApi.Controllers throw; } } - - [HttpGet] - public List? GetPurchases(int userId) - { - try - { - return _purchaseLogic.ReadList(new PurchaseSearchModel { UserId = userId }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка заказов клиента id={Id}", userId); - throw; - } - } - } } \ No newline at end of file diff --git a/HardwareShop/HardwareShopRestApi/Controllers/MainController.cs b/HardwareShop/HardwareShopRestApi/Controllers/MainController.cs deleted file mode 100644 index 136cfc3..0000000 --- a/HardwareShop/HardwareShopRestApi/Controllers/MainController.cs +++ /dev/null @@ -1,66 +0,0 @@ -using HardwareShopContracts.BindingModels; -using HardwareShopContracts.BusinessLogicsContracts; -using Microsoft.AspNetCore.Mvc; - -namespace HardwareShopRestApi.Controllers -{ - [Route("api/[controller]/[action]")] - [ApiController] - public class MainController : Controller - { - private readonly ILogger _logger; - - private readonly IPurchaseLogic _purchase; - - private readonly IBuildLogic _build; - - public MainController(ILogger logger, IPurchaseLogic pur, IBuildLogic build) - { - _logger = logger; - _purchase = pur; - _build = build; - } - - [HttpPost] - public void CreateBuild(BuildBindingModel model) - { - try - { - _build.Create(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания"); - throw; - } - } - - [HttpPost] - public void CreatePurchase(PurchaseBindingModel model) - { - try - { - _purchase.Create(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания"); - throw; - } - } - - [HttpPut] - public void UpdateBuild(BuildBindingModel model) - { - try - { - _build.Update(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка обновления"); - throw; - } - } - } -}