diff --git a/BusinessLogic/BusinessLogic/PurchaseLogic.cs b/BusinessLogic/BusinessLogic/PurchaseLogic.cs index 8e3724d..63edb55 100644 --- a/BusinessLogic/BusinessLogic/PurchaseLogic.cs +++ b/BusinessLogic/BusinessLogic/PurchaseLogic.cs @@ -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 logger) { _purchaseStorage = purchaseStorage; _logger = logger; diff --git a/BusinessLogic/BusinessLogic/SellLogic.cs b/BusinessLogic/BusinessLogic/SellLogic.cs index cc7f722..013cf26 100644 --- a/BusinessLogic/BusinessLogic/SellLogic.cs +++ b/BusinessLogic/BusinessLogic/SellLogic.cs @@ -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 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 GetElements(SellSearchModel? model) + public IEnumerable 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); diff --git a/Contracts/BusinessLogicContracts/ISellLogic.cs b/Contracts/BusinessLogicContracts/ISellLogic.cs index 471cfb2..2b32702 100644 --- a/Contracts/BusinessLogicContracts/ISellLogic.cs +++ b/Contracts/BusinessLogicContracts/ISellLogic.cs @@ -13,7 +13,7 @@ namespace Contracts.BusinessLogicContracts { SellViewModel Create(SellBindingModel model); - SellViewModel Update(SellBindingModel model); + SellViewModel Update(SellSearchModel model); SellViewModel ReadElement(SellSearchModel model); diff --git a/RestAPI/Controllers/MainController.cs b/RestAPI/Controllers/ProductController.cs similarity index 78% rename from RestAPI/Controllers/MainController.cs rename to RestAPI/Controllers/ProductController.cs index 5f23fd4..651adf7 100644 --- a/RestAPI/Controllers/MainController.cs +++ b/RestAPI/Controllers/ProductController.cs @@ -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 logger, IProductLogic productLogic) + public ProductController(ILogger logger, IProductLogic productLogic) { _logger = logger; _product = productLogic; } [HttpGet] - public List? GetFullProductList() - { - try - { - return _product.ReadList(null); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка продуктов"); - throw; - } - } - - [HttpGet] - public List? GetFilteredProductList() + public List? GetFullList() { try { diff --git a/RestAPI/Program.cs b/RestAPI/Program.cs index f71b32a..ea7534c 100644 --- a/RestAPI/Program.cs +++ b/RestAPI/Program.cs @@ -20,10 +20,17 @@ builder.Logging.AddLog4Net("log4net.config"); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + builder.Services.AddSingleton(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/WebApp/Controllers/HomeController.cs b/WebApp/Controllers/HomeController.cs deleted file mode 100644 index 50ed262..0000000 --- a/WebApp/Controllers/HomeController.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Contracts.ViewModels; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; - -namespace WebApp.Controllers -{ - public class HomeController : Controller - { - // GET: HomeController - public ActionResult Index() - { - return Redirect("~/Home/Enter"); - return View(APIClient.GetRequest>($"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(); - } - } - } -} diff --git a/WebApp/Pages/Index.cshtml b/WebApp/Pages/Index.cshtml index 6fdbf65..d4eec0d 100644 --- a/WebApp/Pages/Index.cshtml +++ b/WebApp/Pages/Index.cshtml @@ -1,81 +1,74 @@ -@using Contracts.ViewModels - -@model List +@page +@model WebApp.Pages.IndexModel @{ - ViewData["Title"] = "Home page"; + ViewData["Title"] = "Catalog Page"; } - - - - - - - - - - - - @foreach (var weapon in Model) - { - - - - - - - } - -
#НазваниеЦенаИзображение
@Model.IndexOf(weapon)@weapon.Name@weapon.Price руб.@weapon.Name
+@* КАРТОЧКИ ТОВАРОВ *@ +
+ @foreach (var weapon in @Model.ProductsModel) + { +
+ @weapon.Name +
+
@weapon.Name
+

Цена: >@weapon.Price руб.

+ В корзину +
+
+ } +
@section Scripts { } \ No newline at end of file diff --git a/WebApp/Pages/Index.cshtml.cs b/WebApp/Pages/Index.cshtml.cs index 9675588..0dadbf9 100644 --- a/WebApp/Pages/Index.cshtml.cs +++ b/WebApp/Pages/Index.cshtml.cs @@ -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 _logger; - - public IndexModel(ILogger logger) - { - _logger = logger; - } + public List ProductsModel { get; set; } public void OnGet() { - + ProductsModel = APIClient.GetRequest>($"Product/GetFullList"); } } }