LabWork05_Hard: Фиксы

This commit is contained in:
Safgerd 2023-04-21 08:32:51 +04:00
parent adea6c7922
commit 53817233dc
6 changed files with 82 additions and 57 deletions

View File

@ -17,7 +17,7 @@ namespace AutomobilePlantContracts.BindingModels
public DateTime OpeningDate { get; set; }
public Dictionary<int, (ICarModel, int)> ShopCars { get; set; }
public Dictionary<int, (ICarModel, int)> ShopCars { get; set; } = new();
public int MaxCountCars { get; set; }
}
}

View File

@ -51,7 +51,7 @@ namespace AutomobilePlantRestApi.Controllers
carCount.Add(new Tuple<string, int>(car.Value.Item1.CarName, car.Value.Item2));
}
shop = new()
shop = new ShopViewModel()
{
Id = shop.Id,
Name = shop.Name,

View File

@ -124,6 +124,30 @@ namespace AutomobilePlantShopApp.Controllers
Response.Redirect("Index");
}
[HttpGet]
public ShopViewModel? GetShop(int shopId)
{
return APIClient.GetRequest<ShopViewModel>($"api/shop/getshop?shopId={shopId}");
}
public IActionResult Supply()
{
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>("api/shop/getshoplist");
ViewBag.Cars = APIClient.GetRequest<List<CarViewModel>>("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()

View File

@ -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())

View File

@ -39,7 +39,7 @@
<th>Количество</th>
</tr>
</thead>
<tbody id="carcount">
<tbody id="carсount">
</tbody>
</table>
</div>
@ -57,11 +57,11 @@
data: { shopId: $('#shop').val()},
success: function (result) {
console.log(result)
$("#name").val(result.name);
$("#openingDate").val(new Date(result.openingDate).toISOString().substring(0, 16));
$("#address").val(result.address);
$("#count").val(result.maxCountCars);
fillTable(result.carCount);
$("#name").val(result.Name);
$("#openingDate").val(new Date(result.OpeningDate).toISOString().substring(0, 16));
$("#address").val(result.Address);
$("#count").val(result.MaxCountCars);
fillTable(result.CarCount);
}
});
}