Переключение через header
This commit is contained in:
parent
3db96eaaa1
commit
88504d8bf1
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult MainWorker()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
RedirectToAction("Goods", "Storekeeper");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace HardwareShopClientApp.Controllers
|
||||
{
|
||||
public class StorekeeperController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
public StorekeeperController(ILogger<HomeController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IActionResult MainStorekeeper()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Components()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Goods()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Orders()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ namespace HardwareShopClientApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult Purchases()
|
||||
{
|
||||
return View(APIClient.GetRequest<List<PurchaseViewModel>>($"api/client/getpurchases?UserId={APIClient.User.Id}"));
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
@ -1,7 +1,24 @@
|
||||
@{
|
||||
ViewData["Title"] = "Enter";
|
||||
}
|
||||
@section Header {}
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Index</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Вход в приложение</h2>
|
||||
</div>
|
||||
@ -16,8 +33,6 @@
|
||||
</div>
|
||||
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4">Подтвердить</button>
|
||||
<a asp-action="Register">Регистрация</a>
|
||||
</div>
|
||||
|
||||
</div><a asp-action="Register">Регистрация</a>
|
||||
</form>
|
||||
|
||||
|
@ -1,35 +1,26 @@
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
ViewData["Title"] = "Enter";
|
||||
}
|
||||
|
||||
@using HardwareShopContracts.ViewModels
|
||||
|
||||
@model List<PurchaseViewModel>
|
||||
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Worker" asp-action="Purchases">Purchases</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Enter</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Worker" asp-action="Builds">Builds</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Register</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Worker" asp-action="Comments">Comments</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Worker" asp-action="MainWorker">MainWorker</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Worker" asp-action="listComponents">listComponents</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Worker" asp-action="WorkerReport">WorkerReport</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="MainStorekeeper">MainStorekeeper</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -37,63 +28,7 @@
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Блюдо
|
||||
</th>
|
||||
<th>
|
||||
Дата создания
|
||||
</th>
|
||||
<th>
|
||||
Количество
|
||||
</th>
|
||||
<th>
|
||||
Сумма
|
||||
</th>
|
||||
<th>
|
||||
Статус
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DatePurchase)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PurchaseStatus)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.UserLogin)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
<div>
|
||||
Основная страница
|
||||
</div>
|
||||
|
||||
|
@ -1,7 +1,24 @@
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
@section Header {}
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Index</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
</div>
|
||||
|
@ -1,10 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Goods";
|
||||
}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@model List<ComponentViewModel>
|
||||
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="Goods">Goods</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="Components">Components</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
<div>
|
||||
привет, мы в компонентах
|
||||
</div>
|
@ -0,0 +1,35 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Goods";
|
||||
}
|
||||
|
||||
@model List<GoodViewModel>
|
||||
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="Components">Components</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="Goods">Goods</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="Orders">Orders</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
<div>
|
||||
привет, мы в товарах
|
||||
</div>
|
@ -0,0 +1,29 @@
|
||||
@{
|
||||
ViewData["Title"] = "MainStorekeeper";
|
||||
}
|
||||
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="Components">Components</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="Goods">Goods</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="Orders">Orders</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Goods";
|
||||
}
|
||||
|
||||
@model List<OrderViewModel>
|
||||
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="Components">Components</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="Goods">Goods</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="Orders">Orders</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
<div>
|
||||
привет, мы в заказах
|
||||
</div>
|
@ -15,13 +15,10 @@ namespace HardwareShopRestApi.Controllers
|
||||
|
||||
private readonly IUserLogic _logic;
|
||||
|
||||
private readonly IPurchaseLogic _purchaseLogic;
|
||||
|
||||
public ClientController(IUserLogic logic, IPurchaseLogic purchaseLogic, ILogger<ClientController> logger)
|
||||
public ClientController(IUserLogic logic, ILogger<ClientController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_purchaseLogic = purchaseLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -55,20 +52,5 @@ namespace HardwareShopRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<PurchaseViewModel>? GetPurchases(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _purchaseLogic.ReadList(new PurchaseSearchModel { UserId = userId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка заказов клиента id={Id}", userId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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<MainController> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user