diff --git a/RestAPI/Controllers/MainController.cs b/RestAPI/Controllers/MainController.cs index 6afdc21..5f23fd4 100644 --- a/RestAPI/Controllers/MainController.cs +++ b/RestAPI/Controllers/MainController.cs @@ -22,7 +22,7 @@ namespace RestAPI.Controllers _product = productLogic; } [HttpGet] - public List? GetProductList() + public List? GetFullProductList() { try { @@ -30,7 +30,21 @@ namespace RestAPI.Controllers } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения списка пакетов"); + _logger.LogError(ex, "Ошибка получения списка продуктов"); + throw; + } + } + + [HttpGet] + public List? GetFilteredProductList() + { + try + { + return _product.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка продуктов"); throw; } } diff --git a/WebApp/Controllers/HomeController.cs b/WebApp/Controllers/HomeController.cs new file mode 100644 index 0000000..2d4fc77 --- /dev/null +++ b/WebApp/Controllers/HomeController.cs @@ -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>($"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/Catalog.cshtml b/WebApp/Pages/Catalog.cshtml deleted file mode 100644 index e548507..0000000 --- a/WebApp/Pages/Catalog.cshtml +++ /dev/null @@ -1,56 +0,0 @@ -@page -@model WebApp.Pages.CatalogModel -@{ - ViewData["Title"] = "Каталог оружия"; -} - - - -@section Scripts { - -} \ No newline at end of file diff --git a/WebApp/Pages/Catalog.cshtml.cs b/WebApp/Pages/Catalog.cshtml.cs deleted file mode 100644 index 23f920a..0000000 --- a/WebApp/Pages/Catalog.cshtml.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace WebApp.Pages -{ - public class CatalogModel : PageModel - { - public void OnGet() - { - } - } -} diff --git a/WebApp/Pages/Index.cshtml b/WebApp/Pages/Index.cshtml index f9ff8d4..6fdbf65 100644 --- a/WebApp/Pages/Index.cshtml +++ b/WebApp/Pages/Index.cshtml @@ -1,10 +1,81 @@ -@page -@model IndexModel +@using Contracts.ViewModels + +@model List @{ ViewData["Title"] = "Home page"; } -
-

Welcome

-

Learn about building Web apps with ASP.NET Core.

-
+ + + + + + + + + + + + + + + @foreach (var weapon in Model) + { + + + + + + + } + +
#НазваниеЦенаИзображение
@Model.IndexOf(weapon)@weapon.Name@weapon.Price руб.@weapon.Name
+ +@section Scripts { + +} \ No newline at end of file diff --git a/WebApp/Pages/Shared/_Layout.cshtml b/WebApp/Pages/Shared/_Layout.cshtml index 24afbbf..420ed43 100644 --- a/WebApp/Pages/Shared/_Layout.cshtml +++ b/WebApp/Pages/Shared/_Layout.cshtml @@ -24,10 +24,7 @@