Compare commits
3 Commits
933a3bf3ea
...
eeec81593b
Author | SHA1 | Date | |
---|---|---|---|
eeec81593b | |||
e1673bca2c | |||
bca6631aab |
@ -23,7 +23,7 @@ namespace BusinessLogic.BusinessLogic
|
||||
private readonly IPurchaseStorage _purchaseStorage;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public PurchaseLogic(IPurchaseStorage purchaseStorage, ILogger logger)
|
||||
public PurchaseLogic(IPurchaseStorage purchaseStorage, ILogger<PurchaseLogic> logger)
|
||||
{
|
||||
_purchaseStorage = purchaseStorage;
|
||||
_logger = logger;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicContracts;
|
||||
using Contracts.Converters;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
@ -13,12 +14,12 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BusinessLogic.BusinessLogic
|
||||
{
|
||||
public class SellLogic
|
||||
public class SellLogic : ISellLogic
|
||||
{
|
||||
private readonly ISellStorage _sellStorage;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public SellLogic(ISellStorage sellStorage, ILogger logger)
|
||||
public SellLogic(ISellStorage sellStorage, ILogger<SellLogic> logger)
|
||||
{
|
||||
_sellStorage = sellStorage;
|
||||
_logger = logger;
|
||||
@ -33,7 +34,7 @@ namespace BusinessLogic.BusinessLogic
|
||||
}
|
||||
return sell;
|
||||
}
|
||||
public SellViewModel GetElement(SellSearchModel model)
|
||||
public SellViewModel ReadElement(SellSearchModel model)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(model);
|
||||
var sell = _sellStorage.GetElement(model);
|
||||
@ -44,7 +45,7 @@ namespace BusinessLogic.BusinessLogic
|
||||
return sell;
|
||||
}
|
||||
|
||||
public IEnumerable<SellViewModel> GetElements(SellSearchModel? model)
|
||||
public IEnumerable<SellViewModel> ReadElements(SellSearchModel? model)
|
||||
{
|
||||
var sell_list = _sellStorage.GetFullList(model);
|
||||
if (sell_list is null || sell_list.Count() == 0)
|
||||
@ -54,6 +55,7 @@ namespace BusinessLogic.BusinessLogic
|
||||
}
|
||||
return sell_list;
|
||||
}
|
||||
|
||||
public SellViewModel Update(SellSearchModel model)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(model);
|
||||
|
@ -13,7 +13,7 @@ namespace Contracts.BusinessLogicContracts
|
||||
{
|
||||
SellViewModel Create(SellBindingModel model);
|
||||
|
||||
SellViewModel Update(SellBindingModel model);
|
||||
SellViewModel Update(SellSearchModel model);
|
||||
|
||||
SellViewModel ReadElement(SellSearchModel model);
|
||||
|
||||
|
@ -1,30 +1,29 @@
|
||||
using Contracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace WebApp.Controllers
|
||||
namespace RestAPI.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
public class CartController : Controller
|
||||
{
|
||||
// GET: HomeController
|
||||
// GET: CartController
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View(APIClient.GetRequest<List<ProductViewModel>>($"api/main/getfullproductslist"));
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: HomeController/Details/5
|
||||
// GET: CartController/Details/5
|
||||
public ActionResult Details(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: HomeController/Create
|
||||
// GET: CartController/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: HomeController/Create
|
||||
// POST: CartController/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Create(IFormCollection collection)
|
||||
@ -39,13 +38,13 @@ namespace WebApp.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
// GET: HomeController/Edit/5
|
||||
// GET: CartController/Edit/5
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: HomeController/Edit/5
|
||||
// POST: CartController/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Edit(int id, IFormCollection collection)
|
||||
@ -60,13 +59,13 @@ namespace WebApp.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
// GET: HomeController/Delete/5
|
||||
// GET: CartController/Delete/5
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: HomeController/Delete/5
|
||||
// POST: CartController/Delete/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Delete(int id, IFormCollection collection)
|
@ -11,32 +11,18 @@ namespace RestAPI.Controllers
|
||||
{
|
||||
[Route("[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class MainController
|
||||
public class ProductController
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProductLogic _product;
|
||||
|
||||
public MainController(ILogger<MainController> logger, IProductLogic productLogic)
|
||||
public ProductController(ILogger<ProductController> logger, IProductLogic productLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_product = productLogic;
|
||||
}
|
||||
[HttpGet]
|
||||
public List<ProductViewModel>? GetFullProductList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _product.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка продуктов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ProductViewModel>? GetFilteredProductList()
|
||||
public List<ProductViewModel>? GetFullList()
|
||||
{
|
||||
try
|
||||
{
|
83
RestAPI/Controllers/PurchaseController.cs
Normal file
83
RestAPI/Controllers/PurchaseController.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace RestAPI.Controllers
|
||||
{
|
||||
public class PurchaseController : Controller
|
||||
{
|
||||
// GET: PurchaseController
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: PurchaseController/Details/5
|
||||
public ActionResult Details(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: PurchaseController/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: PurchaseController/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Create(IFormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
// GET: PurchaseController/Edit/5
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: PurchaseController/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Edit(int id, IFormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
// GET: PurchaseController/Delete/5
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: PurchaseController/Delete/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Delete(int id, IFormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -20,10 +20,17 @@ builder.Logging.AddLog4Net("log4net.config");
|
||||
|
||||
builder.Services.AddTransient<IRoleLogic, RoleLogic>();
|
||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||
builder.Services.AddTransient<IProductLogic, ProductLogic>();
|
||||
builder.Services.AddTransient<ISellLogic, SellLogic>();
|
||||
builder.Services.AddTransient<IPurchaseLogic, PurchaseLogic>();
|
||||
|
||||
builder.Services.AddSingleton<ITwoFactorAuthService, TwoFactorAuthService>();
|
||||
|
||||
builder.Services.AddTransient<IRoleStorage, RoleStorage>();
|
||||
builder.Services.AddTransient<IUserStorage, UserStorage>();
|
||||
builder.Services.AddTransient<IProductStorage, ProductStorage>();
|
||||
builder.Services.AddTransient<ISellStorage, SellStorage>();
|
||||
builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>();
|
||||
|
||||
builder.Services.AddSingleton<JwtProvider>();
|
||||
builder.Services.AddSingleton<MailSender>();
|
||||
|
@ -1,81 +1,74 @@
|
||||
@using Contracts.ViewModels
|
||||
|
||||
@model List<ProductViewModel>
|
||||
@page
|
||||
@model WebApp.Pages.IndexModel
|
||||
@{
|
||||
ViewData["Title"] = "Home page";
|
||||
ViewData["Title"] = "Catalog Page";
|
||||
}
|
||||
|
||||
<!-- Шапка -->
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="#">Catalog</a>
|
||||
<div class="collapse navbar-collapse">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<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 class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" 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>
|
||||
@* МОЖНО РЕАЛИЗОВАТЬ ПОЗЖЕ *@
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
||||
<li><a class="dropdown-item" href="#">Пистолеты</a></li>
|
||||
<li><a class="dropdown-item" href="#">Револьверы</a></li>
|
||||
<li><a class="dropdown-item" href="#">Винтовки</a></li>
|
||||
</ul>
|
||||
</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="">
|
||||
<form class="d-flex" method="get">
|
||||
<input class="form-control me-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">
|
||||
<div class="form-group ms-3">
|
||||
<div class="d-flex align-items-center">
|
||||
<input type="range" step="1000" min="0" max="10000" value="50000" class="custom-range me-2" 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">
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<input type="range" step="1000" min="0" max="100000" value="50000" class="custom-range me-2" id="priceTo">
|
||||
<label for="priceTo">До: <span id="priceLabelTo">50 000</span> руб.</label>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</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)
|
||||
@* КАРТОЧКИ ТОВАРОВ *@
|
||||
<div class="row row-cols-1 row-cols-md-3 g-6">
|
||||
@foreach (var weapon in @Model.ProductsModel)
|
||||
{
|
||||
<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>
|
||||
<div class="card">
|
||||
<img src="#" class="card-img-top" alt="@weapon.Name">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">@weapon.Name</h5>
|
||||
<p class="card-text">Цена: >@weapon.Price руб.</p>
|
||||
<a href="#" class="btn btn-primary">В корзину</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
// СЛАЙДЕРЫ
|
||||
document.getElementById("priceFrom").addEventListener("input", function () {
|
||||
var price = this.value;
|
||||
document.getElementById("priceLabelFrom").textContent = price + " руб.";
|
||||
// Здесь должен быть код для фильтрации товаров по цене
|
||||
document.getElementById("priceLabelFrom").textContent = price + " р.";
|
||||
});
|
||||
|
||||
document.getElementById("priceTo").addEventListener("input", function () {
|
||||
var price = this.value;
|
||||
document.getElementById("priceLabelTo").textContent = price + " руб.";
|
||||
// Здесь должен быть код для фильтрации товаров по цене
|
||||
document.getElementById("priceLabelTo").textContent = price + " р.";
|
||||
});
|
||||
</script>
|
||||
}
|
@ -1,20 +1,18 @@
|
||||
using Contracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
[AllowAnonymous]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
|
||||
public IndexModel(ILogger<IndexModel> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
public List<ProductViewModel> ProductsModel { get; set; }
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
|
||||
ProductsModel = APIClient.GetRequest<List<ProductViewModel>>($"Product/GetFullList");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user