This commit is contained in:
dex_moth 2024-05-01 19:43:56 +04:00
parent dadaf9c744
commit b8753069d7
33 changed files with 963 additions and 0 deletions

View File

@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreDataba
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreREST", "ComputerHardwareStoreREST\ComputerHardwareStoreREST.csproj", "{20E4D287-C0F4-4DAB-B338-349F8B6EA22B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreREST", "ComputerHardwareStoreREST\ComputerHardwareStoreREST.csproj", "{20E4D287-C0F4-4DAB-B338-349F8B6EA22B}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StoreKeeperClient", "ComputerHardwareStoreStoreKeeperApp\StoreKeeperClient.csproj", "{0FF8FE3D-A38E-40AF-9286-4D7B11ADA785}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -45,6 +47,10 @@ Global
{20E4D287-C0F4-4DAB-B338-349F8B6EA22B}.Debug|Any CPU.Build.0 = Debug|Any CPU {20E4D287-C0F4-4DAB-B338-349F8B6EA22B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20E4D287-C0F4-4DAB-B338-349F8B6EA22B}.Release|Any CPU.ActiveCfg = Release|Any CPU {20E4D287-C0F4-4DAB-B338-349F8B6EA22B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20E4D287-C0F4-4DAB-B338-349F8B6EA22B}.Release|Any CPU.Build.0 = Release|Any CPU {20E4D287-C0F4-4DAB-B338-349F8B6EA22B}.Release|Any CPU.Build.0 = Release|Any CPU
{0FF8FE3D-A38E-40AF-9286-4D7B11ADA785}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0FF8FE3D-A38E-40AF-9286-4D7B11ADA785}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0FF8FE3D-A38E-40AF-9286-4D7B11ADA785}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0FF8FE3D-A38E-40AF-9286-4D7B11ADA785}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -0,0 +1,6 @@
@ComputerHardwareStoreStoreKeeperApp_HostAddress = http://localhost:5062
GET {{ComputerHardwareStoreStoreKeeperApp_HostAddress}}/weatherforecast/
Accept: application/json
###

View File

@ -0,0 +1,49 @@
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
using ComputerHardwareStoreContracts.StorageContracts;
using ComputerHardwareStoreDatabaseImplement.Implements;
using ComputerHardwareStoreBusinessLogic.BusinessLogic;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Services.AddTransient<IVendorStorage, VendorStorage>();
builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>();
builder.Services.AddTransient<IBuildStorage, BuildStorage>();
builder.Services.AddTransient<ICommentStorage, CommentStorage>();
builder.Services.AddTransient<IProductStorage, ProductStorage>();
builder.Services.AddTransient<IComponentStorage, ComponentStorage>();
builder.Services.AddTransient<IStoreKeeperStorage, StoreKeeperStorage>();
builder.Services.AddTransient<IVendorLogic, VendorLogic>();
builder.Services.AddTransient<IPurchaseLogic, PurchaseLogic>();
builder.Services.AddTransient<IBuildLogic, BuildLogic>();
builder.Services.AddTransient<ICommentLogic, CommentLogic>();
builder.Services.AddTransient<IProductLogic, ProductLogic>();
builder.Services.AddTransient<IComponentLogic, ComponentLogic>();
builder.Services.AddTransient<IStoreKeeperLogic, StoreKeeperLogic>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();

View File

@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:34433",
"sslPort": 44361
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5062",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7291;http://localhost:5062",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ComputerHardwareStoreBusinessLogic\ComputerHardwareStoreBusinessLogic.csproj" />
<ProjectReference Include="..\ComputerHardwareStoreContracts\ComputerHardwareStoreContracts.csproj" />
<ProjectReference Include="..\ComputerHardwareStoreDatabaseImplement\ComputerHardwareStoreDatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,53 @@
@using ComputerHardwareStoreContracts.ViewModels
@model List<ProductViewModel>
@{
ViewData["Title"] = "BuildsByProductsReport";
}
<div class="text-center">
<h1 class="display-4">Сборки по товарам</h1>
</div>
<div class="text-center">
<form method="post">
@{
if (Model == null)
{
<h3 class="display-4">Войдите в профиль</h3>
return;
}
<div class="row mb-5">
<div class="col-4">Формат сохранения:</div>
<div class="col-8">
<input type="radio" id="xlc" name="saveFormat" value="xlc">
<label for="xlc">XLC</label>
<input type="radio" id="doc" name="saveFormat" value="doc">
<label for="doc">DOC</label>
</div>
</div>
<div class="row mb-5">
<div class="col-4">Выберите файл:</div>
<div class="col-8">
<input type="file" id="fileSave" name="fileSave" style="display:none">
<button type="button" onclick="document.getElementById('fileSave').click();">Выбрать файл</button>
</div>
</div>
<div class="row mb-5">
<div class="col-4">Выберите товары:</div>
<div class="col-8">
<select name="products" multiple>
@foreach (var product in Model)
{
<option value="@product.Id">@product.Name</option>
}
</select>
</div>
</div>
<div class="row mb-5">
<div class="col-8">
</div>
<div class="col-4">
<input type="submit" value="Сохранить список" class="btn btn-success" />
</div>
</div>
}
</form>
</div>

View File

@ -0,0 +1,29 @@
@{
ViewData["Title"] = "ComponentToBuild";
}
<div class="text-center mb-5">
<h2 class="display-4">Добавить комплектующие в сборку</h2>
</div>
<form method="post">
<div class="row mb-5">
<div class="col-4">Сборка:</div>
<div class="col-8 ">
<select id="buildId" name="buildId" class="form-control" asp-items="@(new SelectList(@ViewBag.Purchases,"Id", "BuildName"))"></select>
</div>
</div>
<div class="row mb-5">
<div class="col-4">Комплектующее:</div>
<div class="col-8">
<select id="componentId" name="componentId" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "ComponentName"))"></select>
</div>
</div>
<div class="row mb-5">
<div class="col-4">Количество:</div>
<div class="col-8">
<input type="text" name="count" id="count" />
</div>
</div>
<div class="col-4">
<input type="submit" value="Добавить" class="btn btn-success" />
</div>
</form>

View File

@ -0,0 +1,58 @@
@using ComputerHardwareStoreContracts.ViewModels
@model List<ComponentViewModel>
@{
ViewData["Title"] = "Components";
}
<div class="text-center">
<h1 class="display-4">Комплектующие</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Войдите в профиль!</h3>
return;
}
<p>
<a class="text-decoration-none me-3 text-black h5" asp-action="CreateComponent">Создать комплектующее</a>
<a class="text-decoration-none me-3 text-black h5" asp-action="UpdateComponent">Изменить комплектующее</a>
<a class="text-decoration-none me-3 text-black h5" asp-action="ComponentToBuild">Привязать комплектующее к сборке</a>
<a class="text-decoration-none text-black h5" asp-action="DeleteComponent">Удалить комплектующее</a>
</p>
<table class="componentTable">
<thead>
<tr>
<th>
Номер
</th>
<th>
Название
</th>
<th>
Цена
</th>
</tr>
</thead>
<tbody>
<tbody>
@foreach (var component in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => component.Id)
</td>
<td>
@Html.DisplayFor(modelItem => component.ComponentName)
</td>
<td>
@Html.DisplayFor(modelItem => component.ComponentPrice)
</td>
</tr>
}
</tbody>
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,58 @@
@using ComputerHardwareStoreContracts.ViewModels
@model List<ComponentViewModel>
@{
ViewData["Title"] = "ComponentsByPurchasesAndOrdersReport";
}
<div class="text-center">
<h1 class="display-4">Отчёт по комплектующим</h1>
</div>
<div class="text-center">
<form method="post">
@{
if (Model == null)
{
<h3 class="display-4">Войдите в профиль</h3>
return;
}
<div class="row mb-5">
<div class="col-4">Формат получения:</div>
<div class="col-8">
<input type="radio" id="email" name="saveFormat" value="email">
<label for="email">почта</label>
<input type="radio" id="site" name="saveFormat" value="site">
<label for="site">на сайте</label>
</div>
</div>
<div class="row mb-5">
<div class="col-4">Начальная дата:</div>
<div class="col-8">
<input type="date" id="startDate" name="startDate" class="form-control">
</div>
</div>
<div class="row mb-5">
<div class="col-4">Конечная дата:</div>
<div class="col-8">
<input type="date" id="endDate" name="endDate" class="form-control">
</div>
</div>
<div class="row mb-5">
<div class="col-4">Выберите комплектующие:</div>
<div class="col-8">
<select name="components" multiple>
@foreach (var component in Model)
{
<option value="@component.Id">@component.Id @component.Name</option>
}
</select>
</div>
</div>
<div class="row mb-5">
<div class="col-8">
</div>
<div class="col-4">
<input type="submit" value="получить отчёт" class="btn btn-success" />
</div>
</div>
}
</form>
</div>

View File

@ -0,0 +1,25 @@
@{
ViewData["Title"] = "CreateComponent";
}
<div class="text-center">
<h2 class="display-4 mb-5">Создать комплектующее</h2>
</div>
<form method="post">
<div class="row mb-5">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" id="componentName" name="componentName" /></div>
</div>
<div class="row mb-5">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="number" id="componentPrice" name="componentPrice" /></div>
</div>
<div class="row mb-5">
<div class="col-8">
</div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-success" />
</div>
</div>
</form>

View File

@ -0,0 +1,29 @@
@{
ViewData["Title"] = "CreateOrder";
}
<div class="text-center">
<h2 class="display-4 mb-5">Создать заказ</h2>
</div>
<form method="post">
<div class="row mb-5">
<div class="col-4">Дата:</div>
<div class="col-8"><input type="number" id="date" name="date" /></div>
</div>
<div class="row mb-5">
<div class="col-4">Адрес доставки:</div>
<div class="col-8"><input type="text" id="address" name="address" /></div>
</div>
<div class="row mb-5">
<div class="col-4">Товар:</div>
<div class="col-8">
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "ProductName"))"></select>
</div>
</div>
<div class="row mb-5">
<div class="col-8">
</div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-success" />
</div>
</div>
</form>

View File

@ -0,0 +1,36 @@
@using ComputerHardwareStoreContracts.ViewModels
@model List<ComponentViewModel>
@{
ViewData["Title"] = "CreateProduct";
}
<div class="text-center">
<h2 class="display-4 mb-5">Создать товар</h2>
</div>
<form method="post">
<div class="row mb-5">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" id="productName" name="productName" /></div>
</div>
<div class="row mb-5">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="number" id="productPrice" name="productPrice" /></div>
</div>
<div class="row mb-5">
<div class="col-4">Комплектующие:</div>
<div class="col-8">
<select name="components" multiple>
@foreach (var component in Model)
{
<option value="@component.Id">@component.Name</option>
}
</select>
</div>
</div>
<div class="row mb-5">
<div class="col-8">
</div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-success" />
</div>
</div>
</form>

View File

@ -0,0 +1,17 @@
@{
ViewData["Title"] = "DeleteComponent";
}
<div class="text-center">
<h2 class="display-4">Удалить комплектующее</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8">
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components,"Id", "Name"))"></select>
</div>
</div>
<div class="col-4">
<input type="submit" value="Удалить" class="btn btn-danger" />
</div>
</form>

View File

@ -0,0 +1,17 @@
@{
ViewData["Title"] = "DeleteOrder";
}
<div class="text-center">
<h2 class="display-4">Удалить заказ</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Заказ:</div>
<div class="col-8">
<select id="order" name="order" class="form-control" asp-items="@(new SelectList(@ViewBag.Orders,"Id", "DateCreate"))"></select>
</div>
</div>
<div class="col-4">
<input type="submit" value="Удалить" class="btn btn-danger" />
</div>
</form>

View File

@ -0,0 +1,17 @@
@{
ViewData["Title"] = "DeleteProduct";
}
<div class="text-center">
<h2 class="display-4">Удалить комплектующее</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8">
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "Name"))"></select>
</div>
</div>
<div class="col-4">
<input type="submit" value="Удалить" class="btn btn-danger" />
</div>
</form>

View File

@ -0,0 +1,20 @@
@{
ViewData["Title"] = "Enter";
}
<div class="text-center">
<h2 class="display-4">Вход в приложение</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Вход" class="btn btnprimary" /></div>
</div>
</form>

View File

@ -0,0 +1,7 @@
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<img src="./Images/Logo.jpg" alt="logo" />
</div>

View File

@ -0,0 +1,57 @@
@using ComputerHardwareStoreContracts.ViewModels
@model List<OrderForProductsViewModel>
@{
ViewData["Title"] = "Orders";
}
<div class="text-center">
<h1 class="display-4">Заказы на товары</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Надо войти!</h3>
return;
}
<p>
<a class="text-decoration-none me-3 text-black h5" asp-action="CreateOrder">Создать заказ</a>
<a class="text-decoration-none me-3 text-black h5" asp-action="UpdateOrder">Изменить заказ</a>
<a class="text-decoration-none text-black h5" asp-action="DeleteOrder">Удалить заказе</a>
</p>
<table class="OrderTable">
<thead>
<tr>
<th>
Номер
</th>
<th>
Дата создания
</th>
<th>
Дата выполнения
</th>
</tr>
</thead>
<tbody>
<tbody>
@foreach (var order in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => order.Id)
</td>
<td>
@Html.DisplayFor(modelItem => order.DateCreate)
</td>
<td>
@Html.DisplayFor(modelItem => order.DateImplemet)
</td>
</tr>
}
</tbody>
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,58 @@
@using ComputerHardwareStoreContracts.ViewModels
@model List<ProductViewModel>
@{
ViewData["Title"] = "Products";
}
<div class="text-center">
<h1 class="display-4">Товары</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Надо войти!</h3>
return;
}
<p>
<a class="text-decoration-none me-3 text-black h5" asp-action="CreateProduct">Создать товар</a>
<a class="text-decoration-none me-3 text-black h5" asp-action="UpdateProduct">Изменить товар</a>
<a class="text-decoration-none text-black h5" asp-action="DeleteProduct">Удалить товар</a>
</p>
<table class="productTable">
<thead>
<tr>
<th>
Номер
</th>
<th>
Название
</th>
<th>
Цена
</th>
</tr>
</thead>
<tbody>
<tbody>
@foreach (var Product in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => Product.Id)
</td>
<td>
@Html.DisplayFor(modelItem => Product.Name)
</td>
<td>
@Html.DisplayFor(modelItem => Product.Price)
</td>
</tr>
}
</tbody>
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,25 @@
@{
ViewData["Title"] = "Register";
}
<div class="text-center">
<h2 class="display-4">Регистрация</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">ФИО:</div>
<div class="col-8"><input type="text" name="storeKeeperName" /></div>
</div>
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Регистрация"
class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,52 @@
@{
ViewData["Title"] = "UpdateComponent";
}
<div class="text-center">
<h2 class="display-4 mb-5">Изменить комплектующее</h2>
</div>
<form method="post">
<div class="row mb-3">
<div class="col-4">комплектующее:</div>
<div class="col-8">
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components,"Id", "ComponentName"))"></select>
</div>
</div>
<div class="row mb-3">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" id="componentName" name="componentName" /></div>
</div>
<div class="row mb-3">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="number" id="componentPrice" name="componentPrice" /></div>
</div>
<div class="text-center ">
<input type="submit" value="Обновить" class="btn btn-success ps-5 pe-5" />
</div>
</form>
<<script>
$('#component').on('change', function () {
getData();
});
function getData() {
var componentId = $('#component').val();
var componentData = @Html.Raw(Json.Serialize(ViewBag.Components));
var selectedComponent = componentData.find(function (component) {
return component.id == componentId;
});
if (selectedComponent) {
$("#componentName").val(selectedComponent.componentName);
$("#omponentPrice").val(selectedComponent.componentPrice);
fillTableBuilds(selectedComponent.buildsAndCounts);
}
function fillTableBuilds(componentBuilds) {
$("#componentTableBuilds").empty();
for (var build in componentBuilds)
$("#componentTableBuilds").append('<tr><td>' + componentBuilds[build].item1 + '</td><td>' + componentBuilds[build].item2 + '</td></tr>');
}
}
</script>

View File

@ -0,0 +1,46 @@
@{
ViewData["Title"] = "UpdateOrder";
}
<div class="text-center">
<h2 class="display-4 mb-5">Обновить заказ</h2>
</div>
<form method="post">
<div class="row mb-3">
<div class="col-4">Заказ:</div>
<div class="col-8">
<select id="order" name="order" class="form-control" asp-items="@(new SelectList(@ViewBag.OrdersForProducts,"Id", "OrderDate"))"></select>
</div>
</div>
<div class="row mb-3">
<div class="col-4">Дата:</div>
<div class="col-8"><input type="date" id="date" name="date" /></div>
</div>
<div class="row mb-3">
<div class="col-4">Товар:</div>
<div class="col-8">
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Orders,"Id", "OrderName"))"></select>
</div>
</div>
<div class="text-center ">
<input type="submit" value="Обновить" class="btn btn-success ps-5 pe-5" />
</div>
</form>
<<script>
$('#order').on('change', function () {
getData();
});
function getData() {
var orderId = $('#order').val();
var orderData = @Html.Raw(Json.Serialize(ViewBag.Orders));
var selectedOrder = orderData.find(function (order) {
return order.id == orderId;
});
if (selectedOrder) {
$("#date").val(selectedOrder.date);
$("#product").val(selectedOrder.orderId).change();
}
}
</script>

View File

@ -0,0 +1,69 @@
@{
ViewData["Title"] = "UpdateProduct";
}
<div class="text-center">
<h2 class="display-4 mb-5">Обновить покупку</h2>
</div>
<form method="post">
<div class="row mb-3">
<div class="col-4">Покупка:</div>
<div class="col-8">
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "ProductName"))"></select>
</div>
</div>
<div class="row mb-3">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" id="productName" name="productName" /></div>
</div>
<div class="row mb-3">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="number" id="productPrice" name="productPrice" /></div>
</div>
<div class="row mb-3">
<div class="col-4">Комплектующие в товаре:</div>
<div class="col-8">
<table class="tableComponents">
<thead>
<tr>
<th>Название</th>
<th>Количество</th>
</tr>
</thead>
<tbody id="productTableComponents">
</tbody>
</table>
</div>
</div>
<div class="text-center ">
<input type="submit" value="Обновить" class="btn btn-success ps-5 pe-5" />
</div>
</form>
<<script>
$('#product').on('change', function () {
getData();
});
function getData() {
var productId = $('#product').val();
var productData = @Html.Raw(Json.Serialize(ViewBag.Products));
var selectedProduct = productData.find(function (product) {
return product.id == productId;
});
if (selectedproduct) {
$("#productName").val(selectedProduct.productName);
$("#productPrice").val(selectedProduct.productPrice);
fillTableComponents(selectedProduct.componentsAndCounts);
}
}
function fillTableComponents(productComponents) {
$("#productTableComponents").empty();
for (var component in productComponents)
$("#productTableComponents").append('<tr><td>' + productComponents[component].item1 + '</td><td>' +productComponents[component].item2 + '</td></tr>');
}
</script>

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace WebApplication1.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

View File

@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:19732",
"sslPort": 44357
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5174",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7272;http://localhost:5174",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,13 @@
namespace WebApplication1
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,6 @@
@WebApplication1_HostAddress = http://localhost:5174
GET {{WebApplication1_HostAddress}}/weatherforecast/
Accept: application/json
###

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}