merge
This commit is contained in:
commit
a2b22658c3
@ -1,5 +1,6 @@
|
|||||||
using HardwareShopContracts.BindingModels;
|
using HardwareShopContracts.BindingModels;
|
||||||
using HardwareShopContracts.ViewModels;
|
using HardwareShopContracts.ViewModels;
|
||||||
|
using HardwareShopDatabaseImplement.Models;
|
||||||
using HardwareShopDataModels.Enums;
|
using HardwareShopDataModels.Enums;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@ -52,7 +53,6 @@ namespace HardwareShopStorekeeperApp.Controllers
|
|||||||
Response.Redirect("Orders");
|
Response.Redirect("Orders");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void DeleteOrder(int Id)
|
public void DeleteOrder(int Id)
|
||||||
{
|
{
|
||||||
@ -189,6 +189,52 @@ namespace HardwareShopStorekeeperApp.Controllers
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void UpdateComponent(string name, string cost, DateTime date, int component)
|
||||||
|
{
|
||||||
|
if (APIClient.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||||
|
}
|
||||||
|
if (component <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception($"Идентификтаор комплектующего не может быть меньше или равен 0");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
throw new Exception($"Имя комплектующего не должно быть пустым");
|
||||||
|
}
|
||||||
|
if (Convert.ToDouble(cost.Replace('.', ',')) <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception($"Цена комплектующего не может быть меньше или равна 0");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/component/updatedata", new ComponentBindingModel
|
||||||
|
{
|
||||||
|
Id = component,
|
||||||
|
ComponentName = name,
|
||||||
|
Cost = Convert.ToDouble(cost.Replace('.', ',')),
|
||||||
|
UserId = APIClient.User.Id,
|
||||||
|
});
|
||||||
|
Response.Redirect("Components");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void DeleteComponent(int component)
|
||||||
|
{
|
||||||
|
if (APIClient.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||||
|
}
|
||||||
|
if (component <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception($"Идентификтаор комплектующего не может быть меньше или равен 0");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/component/deletecomponent", new ComponentBindingModel
|
||||||
|
{
|
||||||
|
Id = component
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public IActionResult MainStorekeeper()
|
public IActionResult MainStorekeeper()
|
||||||
{
|
{
|
||||||
if (APIClient.User == null)
|
if (APIClient.User == null)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||||
<link rel="stylesheet" href="~/HardwareShopStorekeeperApp.styles.css" asp-append-version="true" />
|
<link rel="stylesheet" href="~/HardwareShopStorekeeperApp.styles.css" asp-append-version="true" />
|
||||||
|
<link rel="stylesheet" href="~/lib/font-awesome-4.7.0/css/font-awesome.min.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@RenderSection("Header")
|
@RenderSection("Header")
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||||
<link rel="stylesheet" href="~/HardwareShopStorekeeperApp.styles.css" asp-append-version="true" />
|
<link rel="stylesheet" href="~/HardwareShopStorekeeperApp.styles.css" asp-append-version="true" />
|
||||||
|
<link rel="stylesheet" href="~/lib/font-awesome-4.7.0/css/font-awesome.min.css">
|
||||||
@await RenderSectionAsync("Styles", required: false)
|
@await RenderSectionAsync("Styles", required: false)
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
@{
|
@{
|
||||||
<p>
|
<p>
|
||||||
<a asp-action="CreateComponent" class="btn btn-primary mx-2">Создать комплектующее</a>
|
<a asp-action="CreateComponent" class="btn btn-primary mx-2">Создать комплектующее</a>
|
||||||
<button type="button" class="btn btn-primary mx-2" data-bs-toggle="modal" data-bs-target="#exampleModal">Изменить комплектующее</button>
|
|
||||||
<button type="button" class="btn btn-primary mx-2">Удалить комплектующее</button>
|
|
||||||
<a asp-action="LinkBuilds" class="btn btn-primary mx-2">Привязка сборок</a>
|
<a asp-action="LinkBuilds" class="btn btn-primary mx-2">Привязка сборок</a>
|
||||||
</p>
|
</p>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
@ -32,6 +30,9 @@
|
|||||||
<th>
|
<th>
|
||||||
Дата приобретения
|
Дата приобретения
|
||||||
</th>
|
</th>
|
||||||
|
<th>
|
||||||
|
Действия
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -47,6 +48,16 @@
|
|||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.DateCreate)
|
@Html.DisplayFor(modelItem => item.DateCreate)
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>
|
||||||
|
<button onclick="getComponent(@item.Id)" type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#updateModal">
|
||||||
|
<i class="fa fa-pencil" aria-hidden="true"></i>
|
||||||
|
</button>
|
||||||
|
<button onclick="deleteComponent(@item.Id)" type="button" class="btn btn-danger">
|
||||||
|
<i class="fa fa-trash" aria-hidden="true"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -54,33 +65,58 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="post" class="d-flex flex-column align-items-center">
|
<form method="post" asp-controller="Storekeeper" asp-action="UpdateComponent">
|
||||||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
<div class="modal fade" id="updateModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title" id="exampleModalLabel">Изменение комплектующего</h5>
|
<h5 class="modal-title" id="exampleModalLabel">Комплектующая</h5>
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<label class="form-label">Название</label>
|
<label class="form-label">Название</label>
|
||||||
<input type="text" class="form-control" name="email">
|
<input type="text" class="form-control" name="name" id="name" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<label class="form-label">Стоимость</label>
|
<label class="form-label">Стоимость</label>
|
||||||
<input type="number" step="0.01" class="form-control" name="cost" min="0.01">
|
<input type="number" step="0.01" class="form-control" name="cost" id="cost" min="0.01" required>
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<label class="form-label">Дата приобретения</label>
|
|
||||||
<input type="date" class="form-control" name="date">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<input type="hidden" id="component" name="component" />
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
|
<input type="submit" class="btn btn-primary" value="Сохранить">
|
||||||
<button type="submit" class="btn btn-primary">Сохранить</button>
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@section Scripts
|
||||||
|
{
|
||||||
|
<script>
|
||||||
|
function getComponent(componentId) {
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: "/Storekeeper/GetComponent",
|
||||||
|
data: { Id: componentId },
|
||||||
|
success: function (result) {
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
$('#name').val(result.componentName);
|
||||||
|
$('#cost').val(result.cost);
|
||||||
|
$('#component').val(result.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function deleteComponent(componentId) {
|
||||||
|
$.ajax({
|
||||||
|
method: "POST",
|
||||||
|
url: "/Storekeeper/DeleteComponent",
|
||||||
|
data: { component: componentId }
|
||||||
|
}).done(() => window.location.href = "/Storekeeper/Components");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
}
|
@ -18,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<label class="form-label">Дата приобретения</label>
|
<label class="form-label">Дата приобретения</label>
|
||||||
<input type="date" class="form-control" name="date">
|
<input type="datetime-local" class="form-control" name="date">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
|
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
|
||||||
<button type="submit" class="btn btn-primary mt-3 px-4">Сохранить</button>
|
<button type="submit" class="btn btn-primary mt-3 px-4">Сохранить</button>
|
||||||
|
@ -95,7 +95,6 @@
|
|||||||
var inwork = document.getElementById("inwork");
|
var inwork = document.getElementById("inwork");
|
||||||
var ready = document.getElementById("ready");
|
var ready = document.getElementById("ready");
|
||||||
var done = document.getElementById("done");
|
var done = document.getElementById("done");
|
||||||
var order = 0;
|
|
||||||
for(var i = 1; i < table.rows.length; i++)
|
for(var i = 1; i < table.rows.length; i++)
|
||||||
{
|
{
|
||||||
table.rows[i].onclick = function()
|
table.rows[i].onclick = function()
|
||||||
@ -108,7 +107,8 @@
|
|||||||
index = this.rowIndex;
|
index = this.rowIndex;
|
||||||
// add class selected to the row
|
// add class selected to the row
|
||||||
this.classList.toggle("selected");
|
this.classList.toggle("selected");
|
||||||
order = parseInt(this.cells[0].innerText);
|
|
||||||
|
var order = parseInt(this.cells[0].innerText)
|
||||||
remove.addEventListener("click", () => {
|
remove.addEventListener("click", () => {
|
||||||
console.log('try to delete order')
|
console.log('try to delete order')
|
||||||
$.ajax(
|
$.ajax(
|
||||||
@ -117,7 +117,7 @@
|
|||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: { id: order }
|
data: { id: order }
|
||||||
}
|
}
|
||||||
)
|
).done(() => window.location.href='/Storekeeper/Orders')
|
||||||
})
|
})
|
||||||
inwork.addEventListener("click", () => {
|
inwork.addEventListener("click", () => {
|
||||||
console.log('try to delete order')
|
console.log('try to delete order')
|
||||||
@ -127,7 +127,7 @@
|
|||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: { id : order, status : 1 }
|
data: { id : order, status : 1 }
|
||||||
}
|
}
|
||||||
)
|
).done(() => window.location.href='/Storekeeper/Orders')
|
||||||
})
|
})
|
||||||
ready.addEventListener("click", () => {
|
ready.addEventListener("click", () => {
|
||||||
console.log('try to delete order')
|
console.log('try to delete order')
|
||||||
@ -137,7 +137,7 @@
|
|||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: { id : order, status : 2 }
|
data: { id : order, status : 2 }
|
||||||
}
|
}
|
||||||
)
|
).done(() => window.location.href='/Storekeeper/Orders')
|
||||||
})
|
})
|
||||||
done.addEventListener("click", () => {
|
done.addEventListener("click", () => {
|
||||||
console.log('try to delete order')
|
console.log('try to delete order')
|
||||||
@ -147,7 +147,7 @@
|
|||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: { id : order, status : 3 }
|
data: { id : order, status : 3 }
|
||||||
}
|
}
|
||||||
)
|
).done(() => window.location.href='/Storekeeper/Orders')
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
2337
HardwareShop/HardwareShopClientApp/wwwroot/lib/font-awesome-4.7.0/css/font-awesome.css
vendored
Normal file
2337
HardwareShop/HardwareShopClientApp/wwwroot/lib/font-awesome-4.7.0/css/font-awesome.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
HardwareShop/HardwareShopClientApp/wwwroot/lib/font-awesome-4.7.0/css/font-awesome.min.css
vendored
Normal file
4
HardwareShop/HardwareShopClientApp/wwwroot/lib/font-awesome-4.7.0/css/font-awesome.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -18,13 +18,10 @@ namespace HardwareShopRestApi.Controllers
|
|||||||
|
|
||||||
private readonly IPurchaseLogic _purchaseLogic;
|
private readonly IPurchaseLogic _purchaseLogic;
|
||||||
|
|
||||||
private readonly IGoodLogic _goodLogic;
|
public PurchaseController(IPurchaseLogic purchaseLogic, ILogger<UserController> logger)
|
||||||
|
|
||||||
public PurchaseController(IPurchaseLogic purchaseLogic, IGoodLogic goodLogic, ILogger<UserController> logger)
|
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_purchaseLogic = purchaseLogic;
|
_purchaseLogic = purchaseLogic;
|
||||||
_goodLogic = goodLogic;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -100,8 +97,8 @@ namespace HardwareShopRestApi.Controllers
|
|||||||
_logger.LogError(ex, "Ошибка удаления товара");
|
_logger.LogError(ex, "Ошибка удаления товара");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user