сделали 13 этап
This commit is contained in:
parent
f07b35cd87
commit
e4e9447a0b
@ -129,7 +129,6 @@ namespace HardwareShopBusinessLogic.OfficePackage
|
||||
}
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(info);
|
||||
|
@ -443,5 +443,15 @@ namespace HardwareShopStorekeeperApp.Controllers
|
||||
reportModel.UserEmail = APIClient.User.Email;
|
||||
APIClient.PostRequest("api/report/componentsreportsendonmail", reportModel);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CommentViewModel> GetCommentsOnBuild(int buildId)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
return APIClient.GetRequest<List<CommentViewModel>>($"api/comment/GetCommentsOnBuild?buildId={buildId}")!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,9 @@
|
||||
<div class="modal-body">
|
||||
<label class="form-label">Сборка</label>
|
||||
<select id="build" name="build" class="form-control" asp-items="@(new SelectList(@ViewBag.Builds, "Id", "BuildName"))" required></select>
|
||||
<table class="table table-hover">
|
||||
<thead><tr><th scope="col">Комментарии</th></tr></thead>
|
||||
<tbody id="comments"></tbody>
|
||||
<label class="form-label">Количество</label>
|
||||
<input type="number" class="form-control" name="count" id="count" min="1" value="1" required>
|
||||
</div>
|
||||
@ -62,6 +65,21 @@
|
||||
const saveBtn = document.getElementById("linkbuilds");
|
||||
const countElem = document.getElementById("count");
|
||||
const resultTable = document.getElementById("result");
|
||||
const selectBuilds = document.getElementById("build");
|
||||
const comments = document.getElementById("comments");
|
||||
|
||||
selectBuilds.addEventListener('change', function() { getCommentsOnBuild() });
|
||||
|
||||
function getCommentsOnBuild() {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Storekeeper/GetCommentsOnBuild`,
|
||||
data: { buildId: selectBuilds.value },
|
||||
success: function (result) {
|
||||
reloadCommentsTable(result)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
submitBuildBtn.addEventListener("click", () => {
|
||||
console.log('try to add build')
|
||||
@ -121,13 +139,19 @@
|
||||
})
|
||||
}
|
||||
|
||||
function reloadCommentsTable(result) {
|
||||
comments.innerHTML = ''
|
||||
result.forEach((elem) => {
|
||||
comments.innerHTML += `<tr><td>${elem.text}</td></tr>`
|
||||
})
|
||||
}
|
||||
|
||||
function deleteBuild(id) {
|
||||
list = list.filter(value => value.build.buildName != resultTable.rows[id].cells[0].innerText)
|
||||
reloadTable()
|
||||
}
|
||||
|
||||
function getComponentBuilds() {
|
||||
console.log(componentid)
|
||||
if (componentid) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
@ -142,7 +166,6 @@
|
||||
url: "/Storekeeper/GetComponentBuilds",
|
||||
data: { componentid: componentid },
|
||||
success: function (result) {
|
||||
console.log(result)
|
||||
if (result) {
|
||||
result.forEach(elem => {
|
||||
list.push({ build: elem.item1, count: elem.item2 })
|
||||
@ -154,6 +177,7 @@
|
||||
};
|
||||
}
|
||||
getComponentBuilds();
|
||||
getCommentsOnBuild();
|
||||
|
||||
</script>
|
||||
}
|
@ -10,7 +10,7 @@ namespace HardwareShopDatabaseImplement
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=Computer_Hardware_Store4;Username=postgres;Password=1234");
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=Computer_Hardware_Store1;Username=user;Password=12345");
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
||||
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model)
|
||||
{
|
||||
using var context = new HardwareShopDatabase();
|
||||
if (model.UserId.HasValue && !model.PurchaseStatus.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
if (model.UserId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
return context.Purchases
|
||||
.Include(x => x.Builds)
|
||||
@ -36,15 +36,22 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.UserId.HasValue)
|
||||
if (model.UserId.HasValue && model.PurchaseStatus.HasValue)
|
||||
{
|
||||
return context.Purchases
|
||||
.Include(x => x.Goods)
|
||||
.ThenInclude(x => x.Good)
|
||||
.Where(x => x.PurchaseStatus == model.PurchaseStatus && x.UserId == model.UserId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.UserId.HasValue)
|
||||
return context.Purchases
|
||||
.Include(x => x.Goods)
|
||||
.ThenInclude(x => x.Good)
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return context.Purchases
|
||||
.Include(x => x.Goods)
|
||||
.ThenInclude(x => x.Good)
|
||||
|
@ -202,6 +202,7 @@ namespace HardwareShopRestApi.Controllers
|
||||
PurchaseStatus = purchase.PurchaseStatus,
|
||||
DatePurchase = purchase.DatePurchase,
|
||||
PurchaseGoods = purchase.PurchaseGoods,
|
||||
UserId = purchase.UserId
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -37,6 +37,23 @@ namespace HardwareShopRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CommentViewModel>? GetCommentsOnBuild(int buildId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _commentLogic.ReadList(new CommentSearchModel
|
||||
{
|
||||
BuildId = buildId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка комментариев пользоватля");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public CommentViewModel? GetComment(int commentId)
|
||||
{
|
||||
|
@ -63,6 +63,20 @@ namespace HardwareShopRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<PurchaseViewModel>? GetPurchasesNotDelivery(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _purchaseLogic.ReadList(new() { UserId = userId, PurchaseStatus = PurchaseStatus.Выполняется });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка товаров");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public PurchaseViewModel? GetPurchase(int purchaseId)
|
||||
{
|
||||
|
@ -438,7 +438,8 @@ namespace HardwareShopWorkerApp.Controllers
|
||||
APIClient.PostRequest("api/purchase/UpdateStatusPurchase", new PurchaseBindingModel
|
||||
{
|
||||
Id = id,
|
||||
PurchaseStatus = (PurchaseStatus)status
|
||||
PurchaseStatus = (PurchaseStatus)status,
|
||||
UserId = APIClient.User.Id
|
||||
});
|
||||
}
|
||||
|
||||
@ -521,7 +522,7 @@ namespace HardwareShopWorkerApp.Controllers
|
||||
{
|
||||
throw new Exception($"Идентификтаор сборки не может быть ниже или равен 0");
|
||||
}
|
||||
ViewBag.Purchase = APIClient.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchases?userId={APIClient.User.Id}");
|
||||
ViewBag.Purchase = APIClient.GetRequest<List<PurchaseViewModel>>($"api/purchase/GetPurchasesNotDelivery?userId={APIClient.User.Id}");
|
||||
return View(APIClient.GetRequest<List<Tuple<PurchaseViewModel, int>>>($"api/build/GetBuildPurchase?buildId={buildId}"));
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
Текст
|
||||
</th>
|
||||
<th>
|
||||
Название сборки к которой относится комментарий
|
||||
Сборка
|
||||
</th>
|
||||
<th>
|
||||
Действия
|
||||
@ -101,10 +101,6 @@
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div>
|
||||
<label class="form-label">Сборка</label>
|
||||
<select id="buildId" name="buildId" class="form-control" asp-items="@(new SelectList(@ViewBag.Builds,"Id", "BuildName"))"></select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label">Текст</label>
|
||||
<input type="text" class="form-control" required="required" id="text" name="text" />
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
@model List<Tuple<PurchaseViewModel, int>>
|
||||
@{
|
||||
ViewData["Title"] = "Привязка сборок";
|
||||
ViewData["Title"] = "Link purchase";
|
||||
Layout = "~/Views/Shared/_LayoutWorker.cshtml";
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Получение списка";
|
||||
ViewData["Title"] = "List components";
|
||||
Layout = "~/Views/Shared/_LayoutWorker.cshtml";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user