LabWork05_Hard: Фиксы
This commit is contained in:
parent
adea6c7922
commit
53817233dc
@ -17,7 +17,7 @@ namespace AutomobilePlantContracts.BindingModels
|
|||||||
|
|
||||||
public DateTime OpeningDate { get; set; }
|
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; }
|
public int MaxCountCars { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace AutomobilePlantRestApi.Controllers
|
|||||||
carCount.Add(new Tuple<string, int>(car.Value.Item1.CarName, car.Value.Item2));
|
carCount.Add(new Tuple<string, int>(car.Value.Item1.CarName, car.Value.Item2));
|
||||||
}
|
}
|
||||||
|
|
||||||
shop = new()
|
shop = new ShopViewModel()
|
||||||
{
|
{
|
||||||
Id = shop.Id,
|
Id = shop.Id,
|
||||||
Name = shop.Name,
|
Name = shop.Name,
|
||||||
|
@ -124,6 +124,30 @@ namespace AutomobilePlantShopApp.Controllers
|
|||||||
Response.Redirect("Index");
|
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)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
public IActionResult Error()
|
public IActionResult Error()
|
||||||
|
@ -6,6 +6,7 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
APIClient.Connect(builder.Configuration);
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
<th>Количество</th>
|
<th>Количество</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="carcount">
|
<tbody id="carсount">
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -57,11 +57,11 @@
|
|||||||
data: { shopId: $('#shop').val()},
|
data: { shopId: $('#shop').val()},
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
console.log(result)
|
console.log(result)
|
||||||
$("#name").val(result.name);
|
$("#name").val(result.Name);
|
||||||
$("#openingDate").val(new Date(result.openingDate).toISOString().substring(0, 16));
|
$("#openingDate").val(new Date(result.OpeningDate).toISOString().substring(0, 16));
|
||||||
$("#address").val(result.address);
|
$("#address").val(result.Address);
|
||||||
$("#count").val(result.maxCountCars);
|
$("#count").val(result.MaxCountCars);
|
||||||
fillTable(result.carCount);
|
fillTable(result.CarCount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user