Compare commits
No commits in common. "main" and "Worker_Raspaev" have entirely different histories.
main
...
Worker_Ras
@ -129,6 +129,7 @@ namespace HardwareShopBusinessLogic.OfficePackage
|
||||
}
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(info);
|
||||
|
@ -264,7 +264,7 @@ namespace HardwareShopStorekeeperApp.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateComponent(string name, string cost)
|
||||
public void CreateComponent(string name, string cost, DateTime date)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
@ -282,7 +282,8 @@ namespace HardwareShopStorekeeperApp.Controllers
|
||||
{
|
||||
UserId = APIClient.User.Id,
|
||||
ComponentName = name,
|
||||
Cost = Convert.ToDouble(cost.Replace('.', ','))
|
||||
Cost = Convert.ToDouble(cost.Replace('.', ',')),
|
||||
DateCreate = date
|
||||
});
|
||||
Response.Redirect("Components");
|
||||
}
|
||||
@ -442,15 +443,5 @@ 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}")!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,10 @@
|
||||
<label class="form-label">Стоимость</label>
|
||||
<input type="number" step="0.01" class="form-control" name="cost" min="0.01" required>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Дата приобретения</label>
|
||||
<input type="datetime-local" class="form-control" name="date" required>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
|
@ -41,9 +41,6 @@
|
||||
<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>
|
||||
@ -65,21 +62,6 @@
|
||||
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')
|
||||
@ -139,19 +121,13 @@
|
||||
})
|
||||
}
|
||||
|
||||
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",
|
||||
@ -166,6 +142,7 @@
|
||||
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 })
|
||||
@ -177,7 +154,6 @@
|
||||
};
|
||||
}
|
||||
getComponentBuilds();
|
||||
getCommentsOnBuild();
|
||||
|
||||
</script>
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using HardwareShopDataModels.Models;
|
||||
|
||||
namespace HardwareShopContracts.BindingModels
|
||||
{
|
||||
public class MessageInfoBindingModel : IMessageInfoModel
|
||||
{
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
|
||||
public int? UserId { get; set; }
|
||||
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateDelivery { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
namespace HardwareShopDataModels.Models
|
||||
{
|
||||
public interface IMessageInfoModel
|
||||
{
|
||||
string MessageId { get; }
|
||||
|
||||
int? UserId { get; }
|
||||
|
||||
string SenderName { get; }
|
||||
|
||||
DateTime DateDelivery { get; }
|
||||
|
||||
string Subject { get; }
|
||||
|
||||
string Body { get; }
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ using HardwareShopDatabaseImplement.Models.ManyToMany;
|
||||
using HardwareShopDatabaseImplement.Models.Storekeeper;
|
||||
using HardwareShopDatabaseImplement.Models.Worker;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace HardwareShopDatabaseImplement
|
||||
{
|
||||
@ -11,7 +10,7 @@ namespace HardwareShopDatabaseImplement
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=Computer_Hardware_Store5;Username=postgres;Password=1234");
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=Computer_Hardware_Store4;Username=postgres;Password=1234");
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,8 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
||||
var build = context.Builds
|
||||
.Include(x => x.Purchases)
|
||||
.ThenInclude(x => x.Purchase)
|
||||
.FirstOrDefault(x => x.Id == model.Id && x.UserId == model.UserId);
|
||||
if (build == null)
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (build == null || build.UserId != build.UserId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
||||
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model)
|
||||
{
|
||||
using var context = new HardwareShopDatabase();
|
||||
if (model.UserId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
if (model.UserId.HasValue && !model.PurchaseStatus.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
return context.Purchases
|
||||
.Include(x => x.Builds)
|
||||
@ -36,28 +36,21 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
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)
|
||||
.Where(x => x.PurchaseStatus == model.PurchaseStatus)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
.Include(x => x.Goods)
|
||||
.ThenInclude(x => x.Good)
|
||||
.Where(x => x.PurchaseStatus == model.PurchaseStatus)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<PurchaseViewModel> GetReportFilteredList(PurchaseSearchModel model)
|
||||
@ -124,8 +117,8 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
||||
var purchase = context.Purchases
|
||||
.Include(x => x.Goods)
|
||||
.ThenInclude(x => x.Good)
|
||||
.FirstOrDefault(x => x.Id == model.Id && x.UserId == model.UserId);
|
||||
if (purchase == null)
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (purchase == null || purchase.UserId != model.UserId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -202,7 +202,6 @@ namespace HardwareShopRestApi.Controllers
|
||||
PurchaseStatus = purchase.PurchaseStatus,
|
||||
DatePurchase = purchase.DatePurchase,
|
||||
PurchaseGoods = purchase.PurchaseGoods,
|
||||
UserId = purchase.UserId
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -37,24 +37,7 @@ 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]
|
||||
[HttpGet]
|
||||
public CommentViewModel? GetComment(int commentId)
|
||||
{
|
||||
try
|
||||
|
@ -49,12 +49,12 @@ namespace HardwareShopRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public List<PurchaseViewModel>? GetPurchases(PurchaseSearchModel model)
|
||||
[HttpGet]
|
||||
public List<PurchaseViewModel>? GetPurchases(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _purchaseLogic.ReadList(model);
|
||||
return _purchaseLogic.ReadList(new() { UserId = userId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -63,21 +63,7 @@ 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]
|
||||
[HttpGet]
|
||||
public PurchaseViewModel? GetPurchase(int purchaseId)
|
||||
{
|
||||
try
|
||||
|
@ -327,7 +327,7 @@ namespace HardwareShopWorkerApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.PostRequestWithResult<PurchaseSearchModel, List<PurchaseViewModel>>($"api/purchase/getpurchases", new() { UserId = APIClient.User.Id }));
|
||||
return View(APIClient.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchases?userId={APIClient.User.Id}"));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -358,8 +358,7 @@ namespace HardwareShopWorkerApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Purchases = APIClient.PostRequestWithResult<PurchaseSearchModel, List<PurchaseViewModel>> ($"api/purchase/getpurchases", new() {UserId = APIClient.User.Id });
|
||||
ViewBag.Purchases = APIClient.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchases?userId={APIClient.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -439,8 +438,7 @@ namespace HardwareShopWorkerApp.Controllers
|
||||
APIClient.PostRequest("api/purchase/UpdateStatusPurchase", new PurchaseBindingModel
|
||||
{
|
||||
Id = id,
|
||||
PurchaseStatus = (PurchaseStatus)status,
|
||||
UserId = APIClient.User.Id
|
||||
PurchaseStatus = (PurchaseStatus)status
|
||||
});
|
||||
}
|
||||
|
||||
@ -522,8 +520,8 @@ namespace HardwareShopWorkerApp.Controllers
|
||||
if (buildId <= 0)
|
||||
{
|
||||
throw new Exception($"Идентификтаор сборки не может быть ниже или равен 0");
|
||||
}
|
||||
ViewBag.Purchases = APIClient.PostRequestWithResult<PurchaseSearchModel, List<PurchaseViewModel>>($"api/purchase/getpurchases", new() { UserId = APIClient.User.Id, PurchaseStatus = PurchaseStatus.Выполняется });
|
||||
}
|
||||
ViewBag.Purchase = APIClient.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchases?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,6 +101,10 @@
|
||||
<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"] = "Link purchase";
|
||||
ViewData["Title"] = "Привязка сборок";
|
||||
Layout = "~/Views/Shared/_LayoutWorker.cshtml";
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<label class="form-label">Покупка</label>
|
||||
<select id="purchaseId" name="purchaseId" class="form-control" asp-items="@(new SelectList(@ViewBag.Purchases, "Id","Id"))"></select>
|
||||
<select id="purchaseId" name="purchaseId" class="form-control" asp-items="@(new SelectList(@ViewBag.Purchase, "Id","Id"))"></select>
|
||||
<div class="form-group">
|
||||
<label>Количество</label>
|
||||
<input type="number" class="form-control" required="required" name="count" />
|
||||
|
@ -1,6 +1,6 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "List components";
|
||||
ViewData["Title"] = "Получение списка";
|
||||
Layout = "~/Views/Shared/_LayoutWorker.cshtml";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user