тварь ли я дрожащая или право имею
This commit is contained in:
parent
8706337153
commit
98de25531e
@ -22,7 +22,7 @@ namespace RestAPI.Controllers
|
||||
_product = productLogic;
|
||||
}
|
||||
[HttpGet]
|
||||
public List<ProductViewModel>? GetProductList()
|
||||
public List<ProductViewModel>? GetFullProductList()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -30,7 +30,21 @@ namespace RestAPI.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка пакетов");
|
||||
_logger.LogError(ex, "Ошибка получения списка продуктов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ProductViewModel>? GetFilteredProductList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _product.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка продуктов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
84
WebApp/Controllers/HomeController.cs
Normal file
84
WebApp/Controllers/HomeController.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using Contracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace WebApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
// GET: HomeController
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View(APIClient.GetRequest<List<ProductViewModel>>($"api/main/getfullproductslist"));
|
||||
}
|
||||
|
||||
// GET: HomeController/Details/5
|
||||
public ActionResult Details(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: HomeController/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: HomeController/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Create(IFormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
// GET: HomeController/Edit/5
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: HomeController/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Edit(int id, IFormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
// GET: HomeController/Delete/5
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: HomeController/Delete/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Delete(int id, IFormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
@page
|
||||
@model WebApp.Pages.CatalogModel
|
||||
@{
|
||||
ViewData["Title"] = "Каталог оружия";
|
||||
}
|
||||
<!-- Шапка -->
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<a class="navbar-brand" href="#">Catalog</a>
|
||||
<div class="collapse navbar-collapse">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Категории
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
||||
<a class="dropdown-item" href="#">Пистолеты</a>
|
||||
<a class="dropdown-item" href="#">Револьверы</a>
|
||||
<a class="dropdown-item" href="#">Винтовки</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<form method="get">
|
||||
<div class="form-inline col-lg-12">
|
||||
<input class="form-control mr-sm-2" type="search" placeholder="Поиск" name="search" value="">
|
||||
<button class="btn btn-outline-success" type="submit"><i class="fas fa-search"></i></button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="form-group">
|
||||
<form method="get" m>
|
||||
<input type="range" step="100" min="0" max="10000" value="50000" class="custom-range" id="priceFrom">
|
||||
<label for="priceFrom">От: <span id="priceLabelFrom">50 000</span> руб.</label>
|
||||
</form>
|
||||
|
||||
<form method="get">
|
||||
<input type="range" step="100" min="0" max="100000" value="50000" class="custom-range" id="priceTo">
|
||||
<label for="priceTo">До: <span id="priceLabelTo">50 000</span> руб.</label>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
document.getElementById("priceFrom").addEventListener("input", function () {
|
||||
var price = this.value;
|
||||
document.getElementById("priceLabelFrom").textContent = price + " руб.";
|
||||
// Здесь должен быть код для фильтрации товаров по цене
|
||||
});
|
||||
|
||||
document.getElementById("priceTo").addEventListener("input", function () {
|
||||
var price = this.value;
|
||||
document.getElementById("priceLabelTo").textContent = price + " руб.";
|
||||
// Здесь должен быть код для фильтрации товаров по цене
|
||||
});
|
||||
</script>
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
public class CatalogModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,81 @@
|
||||
@page
|
||||
@model IndexModel
|
||||
@using Contracts.ViewModels
|
||||
|
||||
@model List<ProductViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Home page";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Welcome</h1>
|
||||
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
|
||||
</div>
|
||||
<!-- Шапка -->
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<a class="navbar-brand" href="#">Catalog</a>
|
||||
<div class="collapse navbar-collapse">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Категории
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
||||
<a class="dropdown-item" href="#">Пистолеты</a>
|
||||
<a class="dropdown-item" href="#">Револьверы</a>
|
||||
<a class="dropdown-item" href="#">Винтовки</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<form method="get">
|
||||
<div class="form-inline col-lg-12">
|
||||
<input class="form-control mr-sm-2" type="search" placeholder="Поиск" name="search" value="">
|
||||
<button class="btn btn-outline-success" type="submit"><i class="fas fa-search"></i></button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="form-group">
|
||||
<form method="get" m>
|
||||
<input type="range" step="100" min="0" max="10000" value="50000" class="custom-range" id="priceFrom">
|
||||
<label for="priceFrom">От: <span id="priceLabelFrom">50 000</span> руб.</label>
|
||||
</form>
|
||||
|
||||
<form method="get">
|
||||
<input type="range" step="100" min="0" max="100000" value="50000" class="custom-range" id="priceTo">
|
||||
<label for="priceTo">До: <span id="priceLabelTo">50 000</span> руб.</label>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Таблица товаров -->
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">Название</th>
|
||||
<th scope="col">Цена</th>
|
||||
<th scope="col">Изображение</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var weapon in Model)
|
||||
{
|
||||
<tr>
|
||||
<th scope="row">@Model.IndexOf(weapon)</th>
|
||||
<td>@weapon.Name</td>
|
||||
<td>@weapon.Price руб.</td>
|
||||
<td><img src="@weapon" alt="@weapon.Name" style="width:100px;height:100px;"></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
document.getElementById("priceFrom").addEventListener("input", function () {
|
||||
var price = this.value;
|
||||
document.getElementById("priceLabelFrom").textContent = price + " руб.";
|
||||
// Здесь должен быть код для фильтрации товаров по цене
|
||||
});
|
||||
|
||||
document.getElementById("priceTo").addEventListener("input", function () {
|
||||
var price = this.value;
|
||||
document.getElementById("priceLabelTo").textContent = price + " руб.";
|
||||
// Здесь должен быть код для фильтрации товаров по цене
|
||||
});
|
||||
</script>
|
||||
}
|
@ -24,10 +24,7 @@
|
||||
<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-page="/Index">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Catalog">Catalog</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Catalog</a>
|
||||
</li>
|
||||
@* <li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
|
||||
|
Loading…
Reference in New Issue
Block a user