фикшу мелкие баги

This commit is contained in:
gg12 darfren 2024-04-14 16:46:26 +04:00
parent 8ee189b6c2
commit 7f84700e8e
3 changed files with 32 additions and 25 deletions

View File

@ -21,15 +21,18 @@ namespace IceCreamShopRestApi.Controllers
_logic = logic;
}
[HttpGet]
public ShopViewModel GetShop(ShopSearchModel model)
public Tuple<ShopViewModel, List<Tuple<string, int>>>? GetShop(int shopId)
{
try
{
return _logic.ReadElement(model);
var elem = _logic.ReadElement(new ShopSearchModel { Id = shopId });
if (elem == null)
return null;
return Tuple.Create(elem, elem.ShopIceCreams.Select(x => Tuple.Create(x.Value.Item1.IceCreamName, x.Value.Item2)).ToList());
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка магазинов");
_logger.LogError(ex, "Ошибка получения магазина по id={Id}", shopId);
throw;
}
}

View File

@ -134,7 +134,7 @@ namespace IceCreamShopsApp.Controllers
ShopName = name,
Address = address,
DateOpen = dateOpen,
MaxCapacity = maxCapacity
MaxCapacity = maxCapacity,
});
Response.Redirect("Index");
}

View File

@ -51,25 +51,29 @@
</div>
</form>
<script>
$('#shop').on('change', function () {
@section Scripts
{
<script>
function check() {
var shop = $('#shop').val();
if (shop) {
$.ajax({
method: "GET",
url: "/Home/GetShop",
data: { shopId: shop },
success: function (result) {
$('#name').val(result.item1.shopName);
$('#address').val(result.item1.address);
$('#dateopen').val(result.item1.dateOpen);
$('#maxcapacity').val(result.item1.maxCapacity);
$('#table-elements').html(result.item2);
}
});
};
}
check();
});
function check() {
var shop = $('#shop').val();
if (shop) {
$.ajax({
method: "GET",
url: "/Home/GetShop",
data: { shopId: shop },
success: function (result) {
$('#name').val(result.item1.shopName);
$('#address').val(result.item1.address);
$('#dateopen').val(result.item1.dateOpen);
$('#maxcapacity').val(result.item1.maxCapacity);
$('#table-elements').html(result.item2);
}
});
};
}
</script>
$('#shop').on('change', function () {
check();
});
</script>
}