Compare commits

..

No commits in common. "a41f1a56380f169f1a2bbde39f9a24dcb47c28af" and "adea6c79224812838dfed7a3cd690f7ac0d1e05b" have entirely different histories.

6 changed files with 62 additions and 87 deletions

1
.gitignore vendored
View File

@ -398,4 +398,3 @@ FodyWeavers.xsd
# JetBrains Rider # JetBrains Rider
*.sln.iml *.sln.iml
/AutomobilePlant/ImplementationExtensions

View File

@ -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; } = new(); public Dictionary<int, (ICarModel, int)> ShopCars { get; set; }
public int MaxCountCars { get; set; } public int MaxCountCars { get; set; }
} }
} }

View File

@ -4,7 +4,6 @@ using AutomobilePlantContracts.ViewModels;
using AutomobilePlantShopApp.Models; using AutomobilePlantShopApp.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Diagnostics; using System.Diagnostics;
using System.Xml.Linq;
namespace AutomobilePlantShopApp.Controllers namespace AutomobilePlantShopApp.Controllers
{ {
@ -106,7 +105,7 @@ namespace AutomobilePlantShopApp.Controllers
return View(); return View();
} }
[HttpPost] [HttpPost]
public void Update(int shop, string name, string address, DateTime openingDate, int count) public void Update(int shop, string shopName, string address, DateTime dateOpening, int count)
{ {
if (!APIClient.isAuth) if (!APIClient.isAuth)
{ {
@ -116,41 +115,17 @@ namespace AutomobilePlantShopApp.Controllers
APIClient.PostRequest($"api/shop/updateshop", new ShopBindingModel APIClient.PostRequest($"api/shop/updateshop", new ShopBindingModel
{ {
Id = shop, Id = shop,
Name = name, Name = shopName,
Address = address, Address = address,
OpeningDate = openingDate, OpeningDate = dateOpening,
MaxCountCars = count MaxCountCars = count
} }
); );
Response.Redirect("Index"); Response.Redirect("Index");
} }
[HttpGet]
public ShopViewModel? GetShop(int shopId)
{
return APIClient.GetRequest<ShopViewModel>($"api/shop/getshop?shopId={shopId}");
}
public IActionResult Supply() [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
{
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() public IActionResult Error()
{ {
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });

View File

@ -6,7 +6,6 @@ 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())

View File

@ -10,48 +10,48 @@
@{ @{
if (Model == null) if (Model == null)
{ {
<h3 class="display-4">Авторизируйтесь</h3> <h3 class="display-4">Авторизируйтесь</h3>
return; return;
} }
<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="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="Update">Изменить магазин</a>
<a class="text-decoration-none me-3 text-black h5" asp-action="Supply">Пополнить магазин</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> <a class="text-decoration-none text-black h5" asp-action="Delete">Удалить магазин</a>
</p> </p>
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th>Номер</th> <th>Номер</th>
<th>Название</th> <th>Название</th>
<th>Адрес</th> <th>Адрес</th>
<th>Дата открытия</th> <th>Дата открытия</th>
<th>Макс. авто</th> <th>Макс. авто</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach (var shop in Model) @foreach (var shop in Model)
{ {
<tr> <tr>
<td> <td>
@Html.DisplayFor(modelItem => shop.Id) @Html.DisplayFor(modelItem => shop.Id)
</td> </td>
<td> <td>
@Html.DisplayFor(modelItem => shop.Name) @Html.DisplayFor(modelItem => shop.Name)
</td> </td>
<td> <td>
@Html.DisplayFor(modelItem => shop.Address) @Html.DisplayFor(modelItem => shop.Address)
</td> </td>
<td> <td>
@Html.DisplayFor(modelItem => shop.OpeningDate) @Html.DisplayFor(modelItem => shop.OpeningDate)
</td> </td>
<td> <td>
@Html.DisplayFor(modelItem => shop.MaxCountCars) @Html.DisplayFor(modelItem => shop.MaxCountCars)
</td> </td>
</tr> </tr>
} }
</tbody> </tbody>
</table> </table>
} }
</div> </div>

View File

@ -13,7 +13,7 @@
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-4">Название:</div> <div class="col-4">Название:</div>
<div class="col-8"><input type="text" id="name" name="name" /></div> <div class="col-8"><input type="text" name="name" id="name" /></div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-4">Адрес:</div> <div class="col-4">Адрес:</div>
@ -22,33 +22,34 @@
<div class="row mb-3"> <div class="row mb-3">
<div class="col-4">Дата открытия:</div> <div class="col-4">Дата открытия:</div>
<div class="col-8"> <div class="col-8">
<input type="date" id="openingDate" name="openingDate" /></div> <input type="datetime-local" id="openingDate" name="openingDate" />
</div> </div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-4">Макс. авто:</div> <div class="col-4">Макс. авто:</div>
<div class="col-8"><input type="number" id="count" name="count" /></div> <div class="col-8"><input type="number" id="count" name="count" /></div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-4">Авто в магазине:</div> <div class="col-4">Авто в магазине:</div>
<div class="col-8"> <div class="col-8">
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th>Автомобиль</th> <th>Автомобиль</th>
<th>Количество</th> <th>Количество</th>
</tr> </tr>
</thead> </thead>
<tbody id="carCount"> <tbody id="carcount">
</tbody> </tbody>
</table> </table>
</div>
</div>
<div class="text-center ">
<input type="submit" value="Принять" class="btn btn-success ps-5 pe-5" />
</div> </div>
</div>
<div class="text-center ">
<input type="submit" value="Принять" class="btn btn-success ps-5 pe-5" />
</div>
</form> </form>
<script> <script>
function getData() { function getData() {
$.ajax({ $.ajax({
method: "GET", method: "GET",
@ -65,10 +66,11 @@
}); });
} }
function fillTable(carCount) { function fillTable(carcount) {
$("#carCount").empty(); $("#carcount").empty();
for (var i = 0; i < carCount.length; i++) for (var i = 0; i < carcount.length; i++)
$("#carCount").append('<tr><td>' + carCount[i].item1 + '</td><td>' + carCount[i].item2 + '</td></tr>'); $("#carcount").append('<tr><td>' + carcount[i].item1 +
'</td><td>' + carcount[i].item2 + '</td></tr>');
} }
</script> </script>