diff --git a/AutomobilePlant/AutomobilePlantContracts/ViewModels/ShopViewModel.cs b/AutomobilePlant/AutomobilePlantContracts/ViewModels/ShopViewModel.cs index 66472a4..dec4a2d 100644 --- a/AutomobilePlant/AutomobilePlantContracts/ViewModels/ShopViewModel.cs +++ b/AutomobilePlant/AutomobilePlantContracts/ViewModels/ShopViewModel.cs @@ -25,5 +25,7 @@ namespace AutomobilePlantContracts.ViewModels public DateTime OpeningDate { get; set; } public Dictionary ShopCars { get; set; } = new(); + + public List>? CarAndCount { get; set; } = new(); } } diff --git a/AutomobilePlant/AutomobilePlantRestApi/Controllers/ShopController.cs b/AutomobilePlant/AutomobilePlantRestApi/Controllers/ShopController.cs index 5e87c7a..d4f3000 100644 --- a/AutomobilePlant/AutomobilePlantRestApi/Controllers/ShopController.cs +++ b/AutomobilePlant/AutomobilePlantRestApi/Controllers/ShopController.cs @@ -25,7 +25,10 @@ namespace AutomobilePlantRestApi.Controllers { try { - return _shop.ReadList(null); + List shops = _shop.ReadList(null); + for (int i = 0; i < shops.Count; i++) + shops[i].CarAndCount = shops[i].ShopCars.Values.ToList().Select( x => (x.Item1.CarName, x.Item2).ToTuple() ).ToList(); + return shops; } catch (Exception ex) { diff --git a/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Update.cshtml b/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Update.cshtml index 0c12b14..537ca2d 100644 --- a/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Update.cshtml +++ b/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Update.cshtml @@ -65,7 +65,7 @@ $("#openingDate").val(new Date(selectedShop.openingDate).toISOString().substring(0, 16)); $("#address").val(selectedShop.address); $("#maxCountCars").val(selectedShop.maxCountCars); - fillTable(selectedShop.shopCars); + fillTable(selectedShop.carAndCount); } } @@ -73,6 +73,6 @@ $("#carTable").empty(); for (var car in shopCars) - $("#carTable").append('' + car.Value.Item1.CarName + '' + car.Value.Item2 + ''); + $("#carTable").append('' + shopCars[car].item1 + '' + shopCars[car].item2 + ''); } \ No newline at end of file diff --git a/AutomobilePlant/AutomobilePlantShopApp/Views/Home/_Layout.cshtml b/AutomobilePlant/AutomobilePlantShopApp/Views/Home/_Layout.cshtml index 9b2a5aa..b1dc757 100644 --- a/AutomobilePlant/AutomobilePlantShopApp/Views/Home/_Layout.cshtml +++ b/AutomobilePlant/AutomobilePlantShopApp/Views/Home/_Layout.cshtml @@ -40,7 +40,7 @@
- © 2023 - AutomobilePlantShopApp - Privacy + © 2024 - AutomobilePlantShopApp - Privacy