diff --git a/AutomobilePlant/AutomobilePlantContracts/BindingModels/ShopBindingModel.cs b/AutomobilePlant/AutomobilePlantContracts/BindingModels/ShopBindingModel.cs index 4b998dd..101dcc4 100644 --- a/AutomobilePlant/AutomobilePlantContracts/BindingModels/ShopBindingModel.cs +++ b/AutomobilePlant/AutomobilePlantContracts/BindingModels/ShopBindingModel.cs @@ -17,7 +17,7 @@ namespace AutomobilePlantContracts.BindingModels public DateTime OpeningDate { get; set; } - public Dictionary ShopCars { get; set; } + public Dictionary ShopCars { get; set; } = new(); public int MaxCountCars { get; set; } } } diff --git a/AutomobilePlant/AutomobilePlantRestApi/Controllers/ShopController.cs b/AutomobilePlant/AutomobilePlantRestApi/Controllers/ShopController.cs index de9ae6b..5a75afc 100644 --- a/AutomobilePlant/AutomobilePlantRestApi/Controllers/ShopController.cs +++ b/AutomobilePlant/AutomobilePlantRestApi/Controllers/ShopController.cs @@ -51,7 +51,7 @@ namespace AutomobilePlantRestApi.Controllers carCount.Add(new Tuple(car.Value.Item1.CarName, car.Value.Item2)); } - shop = new() + shop = new ShopViewModel() { Id = shop.Id, Name = shop.Name, diff --git a/AutomobilePlant/AutomobilePlantShopApp/Controllers/HomeController.cs b/AutomobilePlant/AutomobilePlantShopApp/Controllers/HomeController.cs index 8126665..b3b67e3 100644 --- a/AutomobilePlant/AutomobilePlantShopApp/Controllers/HomeController.cs +++ b/AutomobilePlant/AutomobilePlantShopApp/Controllers/HomeController.cs @@ -124,8 +124,32 @@ namespace AutomobilePlantShopApp.Controllers Response.Redirect("Index"); } + [HttpGet] + public ShopViewModel? GetShop(int shopId) + { + return APIClient.GetRequest($"api/shop/getshop?shopId={shopId}"); + } - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Supply() + { + + ViewBag.Shops = APIClient.GetRequest>("api/shop/getshoplist"); + ViewBag.Cars = APIClient.GetRequest>("api/main/getcarlist"); + return View(); + } + [HttpPost] + public void Supply(int shopId, int carId, int count) + { + if (!APIClient.isAuth) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.PostRequest($"api/shop/supplycarstoshop", (new ShopSearchModel { Id = shopId }, new CarBindingModel { Id = carId }, count)); + Response.Redirect("Index"); + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); diff --git a/AutomobilePlant/AutomobilePlantShopApp/Program.cs b/AutomobilePlant/AutomobilePlantShopApp/Program.cs index d35111d..11f7bf2 100644 --- a/AutomobilePlant/AutomobilePlantShopApp/Program.cs +++ b/AutomobilePlant/AutomobilePlantShopApp/Program.cs @@ -6,6 +6,7 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllersWithViews(); var app = builder.Build(); +APIClient.Connect(builder.Configuration); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) diff --git a/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Index.cshtml b/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Index.cshtml index 971c808..1a7a34e 100644 --- a/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Index.cshtml +++ b/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Index.cshtml @@ -10,48 +10,48 @@ @{ if (Model == null) { -

Авторизируйтесь

+

Авторизируйтесь

return; } -

- Создать магазин - Изменить магазин - Пополнить магазин - Удалить магазин -

+

+ Создать магазин + Изменить магазин + Пополнить магазин + Удалить магазин +

- - - - - - - - - - - +
НомерНазваниеАдресДата открытияМакс. авто
+ + + + + + + + + + @foreach (var shop in Model) { - - + - + - + - + - + - + + } - -
НомерНазваниеАдресДата открытияМакс. авто
+
@Html.DisplayFor(modelItem => shop.Id) - + @Html.DisplayFor(modelItem => shop.Name) - + @Html.DisplayFor(modelItem => shop.Address) - + @Html.DisplayFor(modelItem => shop.OpeningDate) - + @Html.DisplayFor(modelItem => shop.MaxCountCars) -
+ + } \ No newline at end of file diff --git a/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Update.cshtml b/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Update.cshtml index 1eb139c..cc84957 100644 --- a/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Update.cshtml +++ b/AutomobilePlant/AutomobilePlantShopApp/Views/Home/Update.cshtml @@ -29,24 +29,24 @@
Макс. авто:
-
-
Авто в магазине:
-
- - - - - - - - - -
АвтомобильКоличество
-
-
-
- +
+
Авто в магазине:
+
+ + + + + + + + + +
АвтомобильКоличество
+
+
+ +