fix in controllers
This commit is contained in:
parent
68e542bce8
commit
ae16a70b32
@ -32,51 +32,20 @@ namespace FlowerShopRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public Tuple<ShopViewModel, List<FlowerViewModel>, List<int>>? GetShopFlowers(int shopId)
|
public ShopViewModel? GetShop(int shopId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var shop = _logic.ReadElement(new() { Id = shopId });
|
return _logic.ReadElement(new ShopSearchModel { Id = shopId });
|
||||||
if (shop == null)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
return null;
|
{
|
||||||
}
|
_logger.LogError(ex, "Ошибка получения списка магазинов");
|
||||||
var tuple = Tuple.Create(shop,
|
throw;
|
||||||
shop.ShopFlowers.Select(x => new FlowerViewModel()
|
}
|
||||||
{
|
}
|
||||||
Id = x.Value.Item1.Id,
|
[HttpPost]
|
||||||
Price = x.Value.Item1.Price,
|
|
||||||
FlowerName = x.Value.Item1.FlowerName,
|
|
||||||
}).ToList(),
|
|
||||||
shop.ShopFlowers.Select(x => x.Value.Item2).ToList());
|
|
||||||
return tuple;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка получения магазина с цветами");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public Dictionary<int, (IFlowerModel, int)>? GetListFlower(int shopId)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var shop = _logic.ReadElement(new() { Id = shopId });
|
|
||||||
if (shop == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return shop.ShopFlowers;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка получения цветов магазина");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public void CreateShop(ShopBindingModel model)
|
public void CreateShop(ShopBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -92,36 +92,13 @@ namespace FlowerShopShopApp.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public Tuple<ShopViewModel, string>? GetShopFlowers(int shopId)
|
public IActionResult Update(int Id)
|
||||||
{
|
|
||||||
var result = APIClient.GetRequest<Tuple<ShopViewModel, List<FlowerViewModel>, List<int>>>
|
|
||||||
($"api/shop/getshopflowers?shopId={shopId}");
|
|
||||||
if (result == null)
|
|
||||||
{
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
string flowerTable = "";
|
|
||||||
for (int i = 0; i < result.Item2.Count; i++)
|
|
||||||
{
|
|
||||||
var flower = result.Item2[i];
|
|
||||||
var count = result.Item3[i];
|
|
||||||
flowerTable += "<tr>";
|
|
||||||
flowerTable += $"<td>{flower.FlowerName}</td>";
|
|
||||||
flowerTable += $"<td>{flower.Price}</td>";
|
|
||||||
flowerTable += $"<td>{count}</td>";
|
|
||||||
flowerTable += "</tr>";
|
|
||||||
}
|
|
||||||
return Tuple.Create(result.Item1, flowerTable);
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Update()
|
|
||||||
{
|
{
|
||||||
if (!APIClient.AuthenticationDone)
|
if (!APIClient.AuthenticationDone)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>($"api/shop/getshoplist");
|
return View("Shop", APIClient.GetRequest<ShopViewModel>($"api/shop/getshop?shopId={Id}"));
|
||||||
return View("Shop");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@ -187,7 +164,7 @@ namespace FlowerShopShopApp.Controllers
|
|||||||
{
|
{
|
||||||
throw new Exception("Количество должно быть больше 0");
|
throw new Exception("Количество должно быть больше 0");
|
||||||
}
|
}
|
||||||
APIClient.PostRequest("api/shop/storereplenishment", Tuple.Create(
|
APIClient.PostRequest("api/shop/makesupply", Tuple.Create(
|
||||||
new ShopSearchModel() { Id = shop },
|
new ShopSearchModel() { Id = shop },
|
||||||
new FlowerViewModel() { Id = flower },
|
new FlowerViewModel() { Id = flower },
|
||||||
count
|
count
|
||||||
|
@ -64,8 +64,8 @@
|
|||||||
@foreach (var item in Model.ShopFlowers)
|
@foreach (var item in Model.ShopFlowers)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>@Html.DisplayFor(modelItem => item.Value.Item1.FlowerName)</td>
|
<td>@Html.DisplayFor(ShopItem => item.Value.Item1.FlowerName)</td>
|
||||||
<td>@Html.DisplayFor(modelItem => item.Value.Item2)</td>
|
<td>@Html.DisplayFor(ShopItem => item.Value.Item2)</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
<select class="form-select form-select-lg" id="shop" name="shop" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
|
<select class="form-select form-select-lg" id="shop" name="shop" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">Ремонт</label>
|
<label class="form-label">Цветок</label>
|
||||||
<select class="form-select form-select-lg" id="repair" name="repair" asp-items="@(new SelectList(@ViewBag.Repairs,"Id", "RepairName"))"></select>
|
<select class="form-select form-select-lg" id="flower" name="flower" asp-items="@(new SelectList(@ViewBag.Flowers,"Id", "FlowerName"))"></select>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">Количество</label>
|
<label class="form-label">Количество</label>
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
<div class="container">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" asp-area="" asp-page="/Index">FlowerShopShopApp</a>
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">FlowerShopShopApp</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
<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">
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
@ -20,10 +20,10 @@
|
|||||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||||
<ul class="navbar-nav flex-grow-1">
|
<ul class="navbar-nav flex-grow-1">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Главная</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Supply">Пополнение</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -38,14 +38,12 @@
|
|||||||
|
|
||||||
<footer class="border-top footer text-muted">
|
<footer class="border-top footer text-muted">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
© 2024 - FlowerShopShopApp - <a asp-area="" asp-page="/Privacy">Privacy</a>
|
© 2024 - FlowerShopShopApp - <a asp-area="" asp-controller="Home" asp-action="Index">Главная</a>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
|
||||||
@await RenderSectionAsync("Scripts", required: false)
|
@await RenderSectionAsync("Scripts", required: false)
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user