Compare commits
3 Commits
adea6c7922
...
a41f1a5638
Author | SHA1 | Date | |
---|---|---|---|
a41f1a5638 | |||
fe90954785 | |||
53817233dc |
1
.gitignore
vendored
1
.gitignore
vendored
@ -398,3 +398,4 @@ FodyWeavers.xsd
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
/AutomobilePlant/ImplementationExtensions
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using AutomobilePlantContracts.ViewModels;
|
||||
using AutomobilePlantShopApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutomobilePlantShopApp.Controllers
|
||||
{
|
||||
@ -105,7 +106,7 @@ namespace AutomobilePlantShopApp.Controllers
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Update(int shop, string shopName, string address, DateTime dateOpening, int count)
|
||||
public void Update(int shop, string name, string address, DateTime openingDate, int count)
|
||||
{
|
||||
if (!APIClient.isAuth)
|
||||
{
|
||||
@ -115,17 +116,41 @@ namespace AutomobilePlantShopApp.Controllers
|
||||
APIClient.PostRequest($"api/shop/updateshop", new ShopBindingModel
|
||||
{
|
||||
Id = shop,
|
||||
Name = shopName,
|
||||
Name = name,
|
||||
Address = address,
|
||||
OpeningDate = dateOpening,
|
||||
OpeningDate = openingDate,
|
||||
MaxCountCars = count
|
||||
}
|
||||
);
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ShopViewModel? GetShop(int shopId)
|
||||
{
|
||||
return APIClient.GetRequest<ShopViewModel>($"api/shop/getshop?shopId={shopId}");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
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()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
|
@ -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())
|
||||
|
@ -10,48 +10,48 @@
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p >
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="Create">Создать магазин</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="Update">Изменить магазин</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="Supply">Пополнить магазин</a>
|
||||
<a class="text-decoration-none text-black h5" asp-action="Delete">Удалить магазин</a>
|
||||
</p>
|
||||
<p >
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="Create">Создать магазин</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="Update">Изменить магазин</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="Supply">Пополнить магазин</a>
|
||||
<a class="text-decoration-none text-black h5" asp-action="Delete">Удалить магазин</a>
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Номер</th>
|
||||
<th>Название</th>
|
||||
<th>Адрес</th>
|
||||
<th>Дата открытия</th>
|
||||
<th>Макс. авто</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Номер</th>
|
||||
<th>Название</th>
|
||||
<th>Адрес</th>
|
||||
<th>Дата открытия</th>
|
||||
<th>Макс. авто</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var shop in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => shop.Id)
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => shop.Name)
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => shop.Address)
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => shop.OpeningDate)
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => shop.MaxCountCars)
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -13,7 +13,7 @@
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" /></div>
|
||||
<div class="col-8"><input type="text" id="name" name="name" /></div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Адрес:</div>
|
||||
@ -22,34 +22,33 @@
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Дата открытия:</div>
|
||||
<div class="col-8">
|
||||
<input type="datetime-local" id="openingDate" name="openingDate" />
|
||||
<input type="date" id="openingDate" name="openingDate" /></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Макс. авто:</div>
|
||||
<div class="col-8"><input type="number" id="count" name="count" /></div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Авто в магазине:</div>
|
||||
<div class="col-8">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Автомобиль</th>
|
||||
<th>Количество</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="carcount">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center ">
|
||||
<input type="submit" value="Принять" class="btn btn-success ps-5 pe-5" />
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Авто в магазине:</div>
|
||||
<div class="col-8">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Автомобиль</th>
|
||||
<th>Количество</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="carCount">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center ">
|
||||
<input type="submit" value="Принять" class="btn btn-success ps-5 pe-5" />
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
function getData() {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
@ -66,11 +65,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
function fillTable(carcount) {
|
||||
$("#carcount").empty();
|
||||
function fillTable(carCount) {
|
||||
$("#carCount").empty();
|
||||
|
||||
for (var i = 0; i < carcount.length; i++)
|
||||
$("#carcount").append('<tr><td>' + carcount[i].item1 +
|
||||
'</td><td>' + carcount[i].item2 + '</td></tr>');
|
||||
for (var i = 0; i < carCount.length; i++)
|
||||
$("#carCount").append('<tr><td>' + carCount[i].item1 + '</td><td>' + carCount[i].item2 + '</td></tr>');
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user