ъуъ
This commit is contained in:
parent
6aa55f1c11
commit
8a7ccde75c
@ -76,7 +76,7 @@ namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
|
||||
throw new ArgumentNullException(nameof(element));
|
||||
}
|
||||
|
||||
model.OrderProducts = element.OrderProducts;
|
||||
model.ProductId = element.ProductId;
|
||||
model.DateCreate = element.DateCreate;
|
||||
model.Status = element.Status;
|
||||
|
||||
|
@ -7,6 +7,6 @@ namespace ComputerHardwareStoreContracts.BindingModels
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public IStoreKeeperModel StoreKeeper { get; set; }
|
||||
public int StoreKeeperId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ namespace ComputerHardwareStoreContracts.BindingModels
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; set; } = null;
|
||||
public Dictionary<int, (IProductModel, int)> OrderProducts { get; set; } = new();
|
||||
//public Dictionary<int, (IProductModel, int)> OrderProducts { get; set; } = new();
|
||||
public int ProductId { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,5 +5,7 @@
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string UserEmail { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ namespace ComputerHardwareStoreContracts.ViewModels
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Cost { get; set; }
|
||||
public IStoreKeeperModel StoreKeeper { get; set; }
|
||||
public int StoreKeeperId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
namespace ComputerHardwareStoreContracts.ViewModels.HelperModels
|
||||
{
|
||||
public class ComponentSelectionViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public bool IsSelected { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
@ -8,6 +8,11 @@ namespace ComputerHardwareStoreContracts.ViewModels
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
[DisplayName("Товар")]
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Статус")]
|
||||
@ -16,6 +21,6 @@ namespace ComputerHardwareStoreContracts.ViewModels
|
||||
public DateTime DateCreate { get; set; }
|
||||
[DisplayName("Дата выполнения")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
public Dictionary<int, (IProductModel, int)> OrderProducts { get; set; } = new();
|
||||
// public Dictionary<int, (IProductModel, int)> OrderProducts { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
namespace HardwareShopContracts.ViewModels
|
||||
{
|
||||
public class ReportComponentsViewModel
|
||||
{
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
public List<Tuple<string, int>> ProductOrBuilds { get; set; } = new();
|
||||
}
|
||||
}
|
@ -4,6 +4,6 @@
|
||||
{
|
||||
string Name { get; }
|
||||
double Cost { get; }
|
||||
IStoreKeeperModel StoreKeeper { get; }
|
||||
int StoreKeeperId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ namespace ComputerHardwareStoreDataModels.Models
|
||||
OrderStatus Status { get; }
|
||||
DateTime DateCreate { get; }
|
||||
DateTime? DateImplement { get; }
|
||||
public Dictionary<int, (IProductModel, int)> OrderProducts { get; }
|
||||
int ProductId { get; }
|
||||
int Count { get; }
|
||||
//public Dictionary<int, (IProductModel, int)> OrderProducts { get; }
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace ComputerHardwareStoreDatabaseImplement
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
//optionsBuilder.UseNpgsql("Host=192.168.1.61:5432;Database=computerhardwarestore;Username=compstore;Password=compstore");
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=ComputerHardwareStore;Username=postgres;Password=postgres");
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=ComputerHardwareStore2;Username=postgres;Password=postgres");
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
}
|
||||
public virtual DbSet<Component> Components { set; get; }
|
||||
@ -18,7 +18,6 @@ namespace ComputerHardwareStoreDatabaseImplement
|
||||
public virtual DbSet<StoreKeeper> StoreKeepers { set; get; }
|
||||
public virtual DbSet<Build> Builds { set; get; }
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<OrderProduct> OrderProducts { set; get; }
|
||||
public virtual DbSet<BuildComponent> BuildComponents { set; get; }
|
||||
public virtual DbSet<Comment> Comments { set; get; }
|
||||
public virtual DbSet<Vendor> Vendors { set; get; }
|
||||
|
@ -13,8 +13,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Orders
|
||||
.Include(o => o.Products)
|
||||
.ThenInclude(o => o.Product)
|
||||
.Include(o => o.Product)
|
||||
.Select(o => o.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -23,8 +22,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Orders
|
||||
.Include(o => o.Products)
|
||||
.ThenInclude(o => o.Product)
|
||||
.Include(o => o.Product)
|
||||
.Where(o =>
|
||||
(model.Id.HasValue && o.Id == model.Id) ||
|
||||
((model.DateFrom.HasValue && model.DateTo.HasValue) &&
|
||||
@ -43,8 +41,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Orders
|
||||
.Include(o => o.Products)
|
||||
.ThenInclude(o => o.Product)
|
||||
.Include(o => o.Product)
|
||||
.FirstOrDefault(o => o.Id == model.Id)?
|
||||
.GetViewModel;
|
||||
|
||||
@ -52,15 +49,18 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var newOrder = Order.Create(context, model);
|
||||
var newOrder = Order.Create(model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return newOrder.GetViewModel;
|
||||
return context.Orders
|
||||
.Include(x => x.Product)
|
||||
.FirstOrDefault(x => x.Id == newOrder.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
@ -70,8 +70,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
try
|
||||
{
|
||||
var order = context.Orders
|
||||
.Include(o => o.Products)
|
||||
.ThenInclude(o => o.Product)
|
||||
.Include(o => o.Product)
|
||||
.FirstOrDefault(o => o.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
@ -93,8 +92,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var element = context.Orders
|
||||
.Include(o => o.Products)
|
||||
.ThenInclude(o => o.Product)
|
||||
.Include(o => o.Product)
|
||||
.FirstOrDefault(o => o.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
|
@ -14,9 +14,9 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[Required]
|
||||
public virtual StoreKeeper? StoreKeeperЗЛ { get; set; }
|
||||
public virtual StoreKeeper? StoreKeeper { get; set; }
|
||||
[NotMapped]
|
||||
public IStoreKeeperModel? StoreKeeper { get; set; }
|
||||
public int StoreKeeperId { get; set; }
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<ProductComponent> ProductComponents { get; set; } = new();
|
||||
@ -33,7 +33,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Cost = model.Cost,
|
||||
StoreKeeper = model.StoreKeeper
|
||||
StoreKeeperId = model.StoreKeeperId
|
||||
};
|
||||
}
|
||||
public void Update (ComponentBindingModel model)
|
||||
|
@ -11,6 +11,9 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int ProductId { get; set; }
|
||||
public virtual Product Product { get; set; } = null!;
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
[Required]
|
||||
public double Sum { get; set; }
|
||||
@ -20,25 +23,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; set; }
|
||||
|
||||
private Dictionary<int, (IProductModel, int)>? _orderProducts = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IProductModel, int)> OrderProducts
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_orderProducts == null)
|
||||
{
|
||||
_orderProducts = Products
|
||||
.ToDictionary(
|
||||
op => op.ProductId,
|
||||
op => (op.Product as IProductModel, op.Count));
|
||||
}
|
||||
return _orderProducts;
|
||||
}
|
||||
}
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<OrderProduct> Products { get; set; } = new();
|
||||
public static Order? Create(ComputerHardwareStoreDBContext context, OrderBindingModel model)
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -47,23 +32,16 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
return new Order()
|
||||
{
|
||||
Id = model.Id,
|
||||
ProductId = model.ProductId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
Products = context.Products
|
||||
.Where(p => model.OrderProducts.ContainsKey(p.Id))
|
||||
.Select(p => new OrderProduct()
|
||||
{
|
||||
OrderId = model.Id,
|
||||
ProductId = p.Id,
|
||||
Product = p,
|
||||
Count = model.OrderProducts[p.Id].Item2
|
||||
})
|
||||
.ToList()
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel model)
|
||||
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -72,13 +50,17 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ProductId = ProductId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
ProductName = Product.Name
|
||||
};
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
{
|
||||
public class OrderProduct
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int OrderId { get; set; }
|
||||
[Required]
|
||||
public int ProductId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Product Product { get; set; } = new();
|
||||
public virtual Order Order { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
@{
|
||||
ViewData["Title"] = "Enter";
|
||||
}
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин компьютерной техники "Ты ж программист"</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Вход</h2>
|
||||
</div>
|
||||
<form method="post" class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Почта</label>
|
||||
<input type="text" class="form-control" name="email">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Пароль</label>
|
||||
<input type="password" class="form-control" name="password">
|
||||
</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><a asp-action="Register">Регистрация</a>
|
||||
</form>
|
||||
|
@ -0,0 +1,32 @@
|
||||
@{
|
||||
ViewData["Title"] = "Enter";
|
||||
}
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин компьютерной техники "Ты ж программист"</a>
|
||||
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="MainStorekeeper">Кладовщик</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
<div class="d-flex justify-content-center">
|
||||
Добро пожаловать
|
||||
</div>
|
@ -0,0 +1,29 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
|
||||
|
||||
@model StoreKeeperViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Личные данные</h2>
|
||||
</div>
|
||||
<form method="post" class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Почта:</label>
|
||||
<input type="text" class="form-control" name="name" value="@Model.Name">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Пароль:</label>
|
||||
<input type="text" class="form-control" name="password" value="@Model.Password">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Логин:</label>
|
||||
<input type="text" class="form-control" name="login" value="@Model.Login">
|
||||
</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>
|
||||
</form>
|
@ -0,0 +1,36 @@
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин компьютерной техники "Ты ж программист"</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
</div>
|
||||
<form method="post" class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Имя</label>
|
||||
<input type="text" class="form-control" name="name">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Логин</label>
|
||||
<input type="text" class="form-control" aria-describedby="emailHelp" name="login">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Пароль</label>
|
||||
<input type="password" class="form-control" name="password">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4">Подтвердить</button>
|
||||
<a asp-action="Enter">Вернуться на вход</a>
|
||||
|
||||
</form>
|
||||
|
@ -0,0 +1,127 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
|
||||
@model List<ComponentViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Комплектующие";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Комплектующие</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
<p>
|
||||
<a asp-action="CreateComponent" class="btn btn-primary mx-2">Создать комплектующее</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Цена
|
||||
</th>
|
||||
<th>
|
||||
Дата приобретения
|
||||
</th>
|
||||
<th>
|
||||
Действия
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Cost)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Cost)
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<a asp-controller="Storekeeper"
|
||||
asp-action="LinkBuilds"
|
||||
asp-route-componentid="@item.Id"
|
||||
class="btn btn-success">
|
||||
<i>Привязать</i>
|
||||
</a>
|
||||
<button onclick="getComponent(@item.Id)" type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#updateModal">
|
||||
<i>Изменить</i>
|
||||
</button>
|
||||
<button onclick="deleteComponent(@item.Id)" type="button" class="btn btn-danger">
|
||||
<i>Удалить</i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
<form method="post" asp-controller="Storekeeper" asp-action="UpdateComponent">
|
||||
<div class="modal fade" id="updateModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Комплектующая</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="col">
|
||||
<label class="form-label">Название</label>
|
||||
<input type="text" class="form-control" name="name" id="name" required>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label class="form-label">Стоимость</label>
|
||||
<input type="number" step="0.01" class="form-control" name="cost" id="cost" min="0.01" required>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="component" name="component" />
|
||||
<div class="modal-footer">
|
||||
<input type="submit" class="btn btn-primary" value="Сохранить">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
@{
|
||||
ViewData["Title"] = "Создание комплектующего";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание комплектующего</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Название</label>
|
||||
<input type="text" class="form-control" name="name" required>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<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-2 d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4">Сохранить</button>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,57 @@
|
||||
@{
|
||||
ViewData["Title"] = "Создание заказа";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание заказа</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Товар</label>
|
||||
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Количество</label>
|
||||
<input type="number" class="form-control" name="count" id="count" min="1" value="1" required>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Сумма</label>
|
||||
<input type="number" step="0.01" class="form-control" name="sum" id="sum" value="0" min="0,01" readonly 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>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
$('#product').on('change', function () {
|
||||
check();
|
||||
});
|
||||
$('#count').on('input', function () {
|
||||
check();
|
||||
});
|
||||
|
||||
function check() {
|
||||
var count = $('#count').val();
|
||||
var product = $('#product').val();
|
||||
if (count && product) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Storekeeper/Calc",
|
||||
data: { count: count, product: product },
|
||||
success: function (result) {
|
||||
$("#sum").val(result);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
});
|
||||
};
|
||||
}
|
||||
check()
|
||||
</script>
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Создание товара";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание товара</h2>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Название</label>
|
||||
<input type="text" class="form-control" name="name" id="name" >
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Цена</label>
|
||||
<input type="number" step="0.01" class="form-control" name="price" id="price" readonly min="0.01" value="0" >
|
||||
</div>
|
||||
<h1 class="display-6">Комплектующие</h1>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Комплектующее</th>
|
||||
<th scope="col">Стоимость</th>
|
||||
<th scope="col">Количество</th>
|
||||
<th scope="col">Сумма</th>
|
||||
<th scope="col">Действие</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="button" class="btn btn-primary mt-3 px-4" id="createproduct">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Комплектующее</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<label class="form-label">Комплектующее</label>
|
||||
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components, "Id", "ComponentName"))"></select>
|
||||
<label class="form-label">Количество</label>
|
||||
<input type="number" class="form-control" name="count" id="count" min="1" value="1" >
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="savecomponent">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
let list = [];
|
||||
const name = document.getElementById("name");
|
||||
const submitComponentBtn = document.getElementById("savecomponent");
|
||||
const saveBtn = document.getElementById("createproduct");
|
||||
const countElem = document.getElementById("count");
|
||||
const resultTable = document.getElementById("result");
|
||||
const totalPrice = document.getElementById("price");
|
||||
|
||||
submitComponentBtn.addEventListener("click", () => {
|
||||
console.log('try to add component')
|
||||
var count = $('#count').val();
|
||||
var component = $('#component').val();
|
||||
if (component && count && count > 0) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Storekeeper/GetComponent`,
|
||||
data: { Id: component },
|
||||
success: function (result) {
|
||||
let flag = false
|
||||
if (list.length > 0) {
|
||||
list.forEach((elem) => {
|
||||
if (elem.component.id === parseInt(result.id)) {
|
||||
console.log('component already added')
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!flag) list.push({ component: result, count: count })
|
||||
reloadTable()
|
||||
countElem.value = '1'
|
||||
}
|
||||
}).fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
saveBtn.addEventListener("click", () => {
|
||||
console.log('try to add product')
|
||||
if (list.length == 0) {
|
||||
alert('failed add product. components are empty')
|
||||
return
|
||||
}
|
||||
let components = []
|
||||
let counts = []
|
||||
list.forEach((x) => {
|
||||
components.push(x.component);
|
||||
counts.push(parseInt(x.count))
|
||||
})
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/CreateProduct`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({"ProductName": name.value,"Price": parseFloat(totalPrice.value),
|
||||
"ProductComponentsComponents": components, "ProductComponentsCounts": counts })
|
||||
}
|
||||
).done(() => window.location.href = '/Storekeeper/Products')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
|
||||
function reloadTable() {
|
||||
resultTable.innerHTML = ''
|
||||
let price = 0;
|
||||
let count = 0;
|
||||
list.forEach((elem) => {
|
||||
resultTable.innerHTML += `<tr><td>${elem.component.componentName}</td><td>${elem.component.cost}</td><td>${elem.count}</td><td>${Math.round(elem.component.cost * elem.count * 100) / 100}</td><td> \
|
||||
<div> \
|
||||
<button onclick="deleteComponent(${count})" type="button" class="btn btn-danger"> \
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> \
|
||||
</button> \
|
||||
</div><td/></tr>`
|
||||
count++;
|
||||
price += elem.component.cost * elem.count
|
||||
})
|
||||
totalPrice.value = Math.round(price * 100) / 100
|
||||
}
|
||||
|
||||
function deleteComponent(id) {
|
||||
list = list.filter(value => value.component.componentName != resultTable.rows[id].cells[0].innerText)
|
||||
reloadTable()
|
||||
}
|
||||
|
||||
</script>
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Привязка сборок";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Привязка сборок</h1>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Привязать</button>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="display-6">Привязанные сборки</h1>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Сборка</th>
|
||||
<th scope="col">Количество</th>
|
||||
<th scope="col">Действие</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="button" class="btn btn-primary mt-3 px-4" id="linkbuilds">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Привязка сборки</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||
</div>
|
||||
<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>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="savebuild">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
const componentid = @Model;
|
||||
let component;
|
||||
let list = [];
|
||||
const submitBuildBtn = document.getElementById("savebuild");
|
||||
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')
|
||||
var count = $('#count').val();
|
||||
var build = $('#build').val();
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Storekeeper/GetBuild`,
|
||||
data: { buildId: build },
|
||||
success: function (result) {
|
||||
let flag = false
|
||||
if (list.length > 0) {
|
||||
list.forEach((elem) => {
|
||||
if (elem.build.id === parseInt(result.id)) {
|
||||
console.log('build already added')
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!flag) list.push({ build: result, count: count })
|
||||
reloadTable()
|
||||
countElem.value = '1'
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
saveBtn.addEventListener("click", () => {
|
||||
console.log('try to link builds')
|
||||
let builds = []
|
||||
let counts = []
|
||||
list.forEach((x) => {
|
||||
builds.push(x.build);
|
||||
counts.push(parseInt(x.count))
|
||||
})
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/LinkBuilds`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ "Id": componentid, "ComponentName": component.componentName,
|
||||
"Cost": component.cost, "ComponentBuildsBuilds": builds, "ComponentBuildsCounts": counts })
|
||||
}
|
||||
).done(() => window.location.href = '/Storekeeper/Components')
|
||||
})
|
||||
|
||||
function reloadTable() {
|
||||
resultTable.innerHTML = ''
|
||||
let count = 0;
|
||||
list.forEach((elem) => {
|
||||
resultTable.innerHTML += `<tr><td>${elem.build.buildName}</td><td>${elem.count}</td><td> \
|
||||
<div> \
|
||||
<button onclick="deleteBuild(${count})" type="button" class="btn btn-danger"> \
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> \
|
||||
</button> \
|
||||
</div><td/></tr>`
|
||||
count++;
|
||||
})
|
||||
}
|
||||
|
||||
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() {
|
||||
if (componentid) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Storekeeper/GetComponent",
|
||||
data: { Id: componentid },
|
||||
success: function (result) {
|
||||
component = result
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Storekeeper/GetComponentBuilds",
|
||||
data: { componentid: componentid },
|
||||
success: function (result) {
|
||||
if (result) {
|
||||
result.forEach(elem => {
|
||||
list.push({ build: elem.item1, count: elem.item2 })
|
||||
})
|
||||
reloadTable()
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
getComponentBuilds();
|
||||
getCommentsOnBuild();
|
||||
|
||||
</script>
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Получение списка";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Получение списка сборок</h1>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<h1 class="display-6">Выбранные товары</h1>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить товар</button>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Товар</th>
|
||||
<th scope="col">Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="col d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="button" class="btn btn-primary m-2" id="savedoc">Сохранить в doc-формате</button>
|
||||
<button type="button" class="btn btn-primary m-2" id="saveexcel">Сохранить в xls-формате</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Товар</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<label class="form-label">Товар</label>
|
||||
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products, "Id", "ProductName"))"></select>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="saveproduct">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
let list = [];
|
||||
const submitProductBtn = document.getElementById("saveproduct");
|
||||
const resultTable = document.getElementById("result");
|
||||
const saveDocBtn = document.getElementById("savedoc");
|
||||
const saveExcelBtn = document.getElementById("saveexcel");
|
||||
|
||||
submitProductBtn.addEventListener("click", () => {
|
||||
console.log('try to add product')
|
||||
var product = $('#product').val();
|
||||
if (product)
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Storekeeper/GetProduct`,
|
||||
data: { Id: product },
|
||||
success: function (result) {
|
||||
let flag = false
|
||||
if (list.length > 0) {
|
||||
list.forEach((elem) => {
|
||||
if (elem.id === parseInt(result.id)) {
|
||||
console.log('product already added')
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!flag) list.push(result)
|
||||
reloadTable()
|
||||
}
|
||||
}).fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
|
||||
saveDocBtn.addEventListener("click", async () => {
|
||||
send('docx')
|
||||
})
|
||||
|
||||
saveExcelBtn.addEventListener("click", async () => {
|
||||
send('xlsx')
|
||||
})
|
||||
|
||||
function send(format) {
|
||||
console.log(`try to save in ${format} format`)
|
||||
if (list.length == 0) {
|
||||
alert('operation failed. products are empty')
|
||||
return
|
||||
}
|
||||
$.ajax({
|
||||
url: `/Storekeeper/ListBuilds?format=${format}`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ "Products" : list })
|
||||
}).done((file) => {
|
||||
let byteArray = new Uint8Array(file);
|
||||
saveFile(byteArray, format);
|
||||
})
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
}
|
||||
|
||||
async function saveFile(bytes, format) {
|
||||
if (window.showSaveFilePicker) {
|
||||
const opts = {
|
||||
suggestedName: `listbuilds.${format}`,
|
||||
types: [{
|
||||
description: `${format} file`,
|
||||
accept:
|
||||
{
|
||||
[`text/${format}`]: [`.${format}`]
|
||||
},
|
||||
}],
|
||||
};
|
||||
const handle = await showSaveFilePicker(opts);
|
||||
const writable = await handle.createWritable();
|
||||
await writable.write(bytes);
|
||||
writable.close();
|
||||
alert('done')
|
||||
}
|
||||
}
|
||||
|
||||
function reloadTable() {
|
||||
resultTable.innerHTML = ''
|
||||
let count = 0;
|
||||
list.forEach((elem) => {
|
||||
resultTable.innerHTML += `<tr><td>${elem.productName}</td><td> \
|
||||
<div> \
|
||||
<button onclick="deleteProduct(${count})" type="button" class="btn btn-danger"> \
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> \
|
||||
</button> \
|
||||
</div></td></tr>`
|
||||
count++;
|
||||
})
|
||||
}
|
||||
|
||||
function deleteProduct(id) {
|
||||
list = list.filter(value => value.productName != resultTable.rows[id].cells[0].innerText)
|
||||
reloadTable()
|
||||
}
|
||||
</script>
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
@{
|
||||
ViewData["Title"] = "Основная - Кладовщик";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-center">
|
||||
Добро пожаловать
|
||||
</div>
|
@ -0,0 +1,168 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
|
||||
@model List<OrderViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Заказы";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Заказы</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<p>
|
||||
<a asp-action="CreateOrder" class="btn btn-primary mx-2">Создать заказ</a>
|
||||
<button type="button" class="btn btn-primary mx-2" id="delete">Удалить заказ</button>
|
||||
<button type="button" class="btn btn-primary mx-2" id="inwork">Выполняется</button>
|
||||
<button type="button" class="btn btn-primary mx-2" id="ready">Готов</button>
|
||||
<button type="button" class="btn btn-primary mx-2" id="done">Выдан</button>
|
||||
</p>
|
||||
<table class="table" id="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Товар
|
||||
</th>
|
||||
<th>
|
||||
Количество
|
||||
</th>
|
||||
<th>
|
||||
Сумма
|
||||
</th>
|
||||
<th>
|
||||
Статус
|
||||
</th>
|
||||
<th>
|
||||
Дата создания
|
||||
</th>
|
||||
<th>
|
||||
Дата выполнения
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
@* <td>
|
||||
@Html.DisplayFor(modelItem => item.Pr)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Count)
|
||||
</td> *@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateCreate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateImplement)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@section Styles
|
||||
{
|
||||
<style>
|
||||
tr{cursor: pointer;}
|
||||
.selected{background-color: #0d6efd; color: white;}
|
||||
</style>
|
||||
}
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
// get selected row
|
||||
// display selected row data in text input
|
||||
|
||||
var table = document.getElementById("table");
|
||||
var remove = document.getElementById("delete");
|
||||
var inwork = document.getElementById("inwork");
|
||||
var ready = document.getElementById("ready");
|
||||
var done = document.getElementById("done");
|
||||
for(var i = 1; i < table.rows.length; i++)
|
||||
{
|
||||
table.rows[i].onclick = function()
|
||||
{
|
||||
// remove the background from the previous selected row
|
||||
if(typeof index !== "undefined") {
|
||||
table.rows[index].classList.toggle("selected");
|
||||
}
|
||||
// get the selected row index
|
||||
index = this.rowIndex;
|
||||
// add class selected to the row
|
||||
this.classList.toggle("selected");
|
||||
|
||||
var order = parseInt(this.cells[0].innerText)
|
||||
remove.addEventListener("click", () => {
|
||||
console.log('try to delete order')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/DeleteOrder`,
|
||||
type: 'POST',
|
||||
data: { id: order }
|
||||
}
|
||||
).done(() => window.location.href='/Storekeeper/Orders')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
inwork.addEventListener("click", () => {
|
||||
console.log('try to update order status')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/UpdateOrder`,
|
||||
type: 'POST',
|
||||
data: { id : order, status : 1 }
|
||||
}
|
||||
).done((result) => window.location.href='/Storekeeper/Orders')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
ready.addEventListener("click", () => {
|
||||
console.log('try to update order status')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/UpdateOrder`,
|
||||
type: 'POST',
|
||||
data: { id : order, status : 2 }
|
||||
}
|
||||
).done(() => window.location.href='/Storekeeper/Orders')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
done.addEventListener("click", () => {
|
||||
console.log('try to update order status')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/UpdateOrder`,
|
||||
type: 'POST',
|
||||
data: { id : order, status : 3 }
|
||||
}
|
||||
).done(() => window.location.href='/Storekeeper/Orders')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
</script>
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
|
||||
@model List<ProductViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Товары";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Товары</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<p>
|
||||
<a asp-action="CreateProduct" class="btn btn-primary mx-2">Создать товар</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Цена
|
||||
</th>
|
||||
<th>
|
||||
Действия
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Price)
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<a asp-controller="Storekeeper"
|
||||
asp-action="UpdateProduct"
|
||||
asp-route-productid="@item.Id"
|
||||
class="btn btn-primary">
|
||||
<i>Изменить</i>
|
||||
</a>
|
||||
<button onclick="deleteProduct(@item.Id)" type="button" class="btn btn-danger">
|
||||
<i>Удалить</i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function deleteProduct(productId) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Storekeeper/DeleteProduct",
|
||||
data: { product: productId }
|
||||
}).done(() => window.location.href = "/Storekeeper/Products");
|
||||
}
|
||||
</script>
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Отчет";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">С</label>
|
||||
<input type="date" class="form-control" name="dateFrom" id="dateFrom">
|
||||
<label class="form-label">По</label>
|
||||
<input type="date" class="form-control" name="dateTo" id="dateTo">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4" id="page">Вывод на страницу</button>
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4" id="mail">Отправить на почту</button>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Комплектующее</th>
|
||||
<th scope="col">Товар/Сборка</th>
|
||||
<th scope="col">Количество</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result">
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
let list = []
|
||||
const from = document.getElementById("dateFrom");
|
||||
const to = document.getElementById("dateTo");
|
||||
const onpage = document.getElementById("page");
|
||||
const onmail = document.getElementById("mail");
|
||||
const resultTable = document.getElementById("result");
|
||||
|
||||
onpage.addEventListener("click", () => {
|
||||
console.log('try to get report')
|
||||
if (from.value && to.value && from.value !== '' && to.value !== '') {
|
||||
const dateFrom = new Date(from.value);
|
||||
const dateTo = new Date(to.value);
|
||||
if (dateFrom.getTime() > dateTo.getTime())
|
||||
alert("Неправильные даты")
|
||||
const reportModel = { "DateFrom": dateFrom, "DateTo": dateTo }
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
contentType: "application/json",
|
||||
url: `/Storekeeper/Report`,
|
||||
data: JSON.stringify(reportModel),
|
||||
success: function (result) {
|
||||
list = result
|
||||
console.log(list)
|
||||
reloadTable()
|
||||
}
|
||||
}).fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
} else { alert("Пустые поля") }
|
||||
})
|
||||
onmail.addEventListener("click", () => {
|
||||
console.log('try to send email')
|
||||
if (from.value && to.value && from.value !== '' && to.value !== '') {
|
||||
const dateFrom = new Date(from.value);
|
||||
const dateTo = new Date(to.value);
|
||||
if (dateFrom.getTime() > dateTo.getTime())
|
||||
alert("Неправильные даты")
|
||||
const reportModel = { "DateFrom": dateFrom, "DateTo": dateTo }
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
contentType: "application/json",
|
||||
url: `/Storekeeper/ReportSendOnMail`,
|
||||
data: JSON.stringify(reportModel)
|
||||
}).fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
} else { alert("Пустые поля") }
|
||||
})
|
||||
|
||||
function reloadTable() {
|
||||
resultString = '';
|
||||
list.forEach((elem) => {
|
||||
resultString += `<tr><td>${elem.componentName}</td><td></td><td></td></tr>`;
|
||||
elem.productOrBuilds.forEach((productOrBuild) => {
|
||||
resultString += `<tr><td></td><td>${productOrBuild.item1}</td><td>${productOrBuild.item2}</td></tr>`;
|
||||
})
|
||||
resultString += `<tr><td>Итого</td><td></td><td>${elem.totalCount}</td></tr>`;
|
||||
})
|
||||
resultTable.innerHTML = resultString
|
||||
}
|
||||
</script>
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
|
||||
@model int
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Товар";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование товара</h2>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Название</label>
|
||||
<input type="text" class="form-control" name="name" id="name" required>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Цена</label>
|
||||
<input type="number" step="0.01" class="form-control" name="price" id="price" readonly min="0.01" value="0" required>
|
||||
</div>
|
||||
<h1 class="display-6">Комплектующие</h1>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Комплектующее</th>
|
||||
<th scope="col">Стоимость</th>
|
||||
<th scope="col">Количество</th>
|
||||
<th scope="col">Сумма</th>
|
||||
<th scope="col">Действие</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="button" class="btn btn-primary mt-3 px-4" id="editproduct">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Комплектующее</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<label class="form-label">Комплектующее</label>
|
||||
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components, "Id", "ComponentName"))"></select>
|
||||
<label class="form-label">Количество</label>
|
||||
<input type="number" class="form-control" name="count" id="count" min="1" value="1" required>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="savecomponent">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
const productid = @Model
|
||||
// components & counts
|
||||
let list = [];
|
||||
const name = document.getElementById("name");
|
||||
const submitComponentBtn = document.getElementById("savecomponent");
|
||||
const saveBtn = document.getElementById("editproduct");
|
||||
const countElem = document.getElementById("count");
|
||||
const resultTable = document.getElementById("result");
|
||||
const totalPrice = document.getElementById("price");
|
||||
|
||||
submitComponentBtn.addEventListener("click", () => {
|
||||
console.log('try to add component')
|
||||
var count = $('#count').val();
|
||||
var component = $('#component').val();
|
||||
if (component && count && count > 0)
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Storekeeper/GetComponent`,
|
||||
data: { Id: component },
|
||||
success: function (result) {
|
||||
let flag = false
|
||||
if (list.length > 0) {
|
||||
list.forEach((elem) => {
|
||||
if (elem.component.id === parseInt(result.id)) {
|
||||
console.log('component already added')
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!flag) list.push({ component: result, count: count })
|
||||
reloadTable()
|
||||
countElem.value = '1'
|
||||
}
|
||||
}).fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
});
|
||||
})
|
||||
|
||||
saveBtn.addEventListener("click", () => {
|
||||
console.log('try to update product')
|
||||
if (list.length == 0) {
|
||||
console.log('failed update product')
|
||||
return
|
||||
}
|
||||
let components = []
|
||||
let counts = []
|
||||
list.forEach((x) => {
|
||||
components.push(x.component);
|
||||
counts.push(parseInt(x.count))
|
||||
})
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/UpdateProduct`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ "Id": productid, "ProductName": name.value,"Price": parseFloat(totalPrice.value),
|
||||
"ProductComponentsComponents": components, "ProductComponentsCounts": counts })
|
||||
}
|
||||
).done(() => window.location.href = '/Storekeeper/Products')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
|
||||
function reloadTable() {
|
||||
resultTable.innerHTML = ''
|
||||
let price = 0;
|
||||
let count = 0;
|
||||
list.forEach((elem) => {
|
||||
resultTable.innerHTML += `<tr><td>${elem.component.componentName}</td><td>${elem.component.cost}</td><td>${elem.count}</td><td>${Math.round(elem.component.cost * elem.count * 100) / 100}</td><td> \
|
||||
<div> \
|
||||
<button onclick="deleteComponent(${count})" type="button" class="btn btn-danger"> \
|
||||
<i>Удалить</i> \
|
||||
</button> \
|
||||
</div><td/></tr>`
|
||||
count++;
|
||||
price += elem.component.cost * elem.count
|
||||
})
|
||||
totalPrice.value = Math.round(price * 100) / 100
|
||||
}
|
||||
|
||||
function deleteComponent(id) {
|
||||
list = list.filter(value => value.component.componentName != resultTable.rows[id].cells[0].innerText)
|
||||
reloadTable()
|
||||
}
|
||||
|
||||
function getProduct() {
|
||||
if (productid) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Storekeeper/GetProductUpdate",
|
||||
data: { productid: productid },
|
||||
success: function (result) {
|
||||
if (result) {
|
||||
name.value = result.item1.productName
|
||||
totalPrice.value = result.item1.price
|
||||
result.item2.forEach(elem => {
|
||||
list.push({ component: elem.item1, count: elem.item2 })
|
||||
})
|
||||
reloadTable()
|
||||
}
|
||||
else
|
||||
alert("Ошибка получения товара")
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
};
|
||||
}
|
||||
getProduct();
|
||||
</script>
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
@model ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<h1>Create</h1>
|
||||
|
||||
<h4>StoreKeeper</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Create">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Name" class="control-label"></label>
|
||||
<input asp-for="Name" class="form-control" />
|
||||
<span asp-validation-for="Name" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Login" class="control-label"></label>
|
||||
<input asp-for="Login" class="form-control" />
|
||||
<span asp-validation-for="Login" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Password" class="control-label"></label>
|
||||
<input asp-for="Password" class="form-control" />
|
||||
<span asp-validation-for="Password" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Create" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
@model ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>StoreKeeper</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Name)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Login)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Login)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Password)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Password)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form asp-action="Delete">
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</form>
|
||||
</div>
|
@ -1,36 +0,0 @@
|
||||
@model ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
}
|
||||
|
||||
<h1>Details</h1>
|
||||
|
||||
<div>
|
||||
<h4>StoreKeeper</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Name)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Login)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Login)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Password)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Password)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-action="Edit" asp-route-id="@Model?.Id">Edit</a> |
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
@ -1,44 +0,0 @@
|
||||
@model ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
}
|
||||
|
||||
<h1>Edit</h1>
|
||||
|
||||
<h4>StoreKeeper</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Edit">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Name" class="control-label"></label>
|
||||
<input asp-for="Name" class="form-control" />
|
||||
<span asp-validation-for="Name" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Login" class="control-label"></label>
|
||||
<input asp-for="Login" class="form-control" />
|
||||
<span asp-validation-for="Login" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Password" class="control-label"></label>
|
||||
<input asp-for="Password" class="form-control" />
|
||||
<span asp-validation-for="Password" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
@model IEnumerable<ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h1>Index</h1>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Login)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Password)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Login)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Password)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
||||
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
@ -8,7 +8,7 @@ namespace StoreKeeperClient
|
||||
public static class APIClient
|
||||
{
|
||||
private static readonly HttpClient _client = new();
|
||||
public static StoreKeeperViewModel? Client { get; set; } = null;
|
||||
public static StoreKeeperViewModel? User { get; set; } = null;
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
|
@ -1,10 +1,12 @@
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using StoreKeeperClient.Models;
|
||||
using StoreKeeperClient;
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using StoreKeeperClient.Models;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
|
||||
namespace StoreKeeperClient.Controllers
|
||||
namespace StorekeeperClient.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
@ -15,304 +17,67 @@ namespace StoreKeeperClient.Controllers
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Register(string login, string name, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите логин, email, пароль");
|
||||
}
|
||||
APIClient.PostRequest("api/storekeeper/register", new StoreKeeperBindingModel
|
||||
{
|
||||
Login = login,
|
||||
Name = name,
|
||||
Password = password
|
||||
});
|
||||
Response.Redirect("Enter");
|
||||
return;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.User);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Enter(string login, string password)
|
||||
public IActionResult Privacy(string login, string name, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Введите почту и пароль");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIClient.Client = APIClient.GetRequest<StoreKeeperViewModel>($"api/storekeeper/login?login={login}&password={password}");
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Неверные почта и/или пароль");
|
||||
}
|
||||
Response.Redirect("Home/Index");
|
||||
return;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Register(string name, string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите логин, name, пароль");
|
||||
throw new Exception("Введите логин, пароль и почту");
|
||||
}
|
||||
APIClient.PostRequest("api/storekeeper/register", new StoreKeeperBindingModel
|
||||
APIClient.PostRequest("api/user/updatedata", new StoreKeeperBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Id = APIClient.User.Id,
|
||||
Login = login,
|
||||
Password = password,
|
||||
Name = name,
|
||||
Password = password
|
||||
});
|
||||
Response.Redirect("Enter");
|
||||
return;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult AddBuildToPurchase()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
APIClient.User.Login = login;
|
||||
APIClient.User.Name = name;
|
||||
APIClient.User.Password = password;
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Builds()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View(new List<BuildViewModel>());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult BuildCreate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult BuildDelete()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult BuildUpdate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CommentCreate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CommentDelete()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CommentUpdate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Comments()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View(new List<CommentViewModel>());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Products()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View(new List<ProductViewModel>());
|
||||
}
|
||||
|
||||
public IActionResult CreateProduct()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponents?userId={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateProduct([FromBody] ProductBindingModel productModel)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(productModel.Name))
|
||||
{
|
||||
throw new Exception("Название не должно быть пустым");
|
||||
}
|
||||
if (productModel.Price <= 0)
|
||||
{
|
||||
throw new Exception("Цена должна быть больше 0");
|
||||
}
|
||||
productModel.StoreKeeperId = APIClient.Client.Id;
|
||||
APIClient.PostRequest("api/product/createproduct", productModel);
|
||||
}
|
||||
|
||||
public IActionResult UpdateProduct(int productid)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponents?userId={APIClient.Client.Id}");
|
||||
return View(productid);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateProduct([FromBody] ProductBindingModel productModel)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(productModel.Name))
|
||||
{
|
||||
throw new Exception("Название не должно быть пустым");
|
||||
}
|
||||
if (productModel.Price <= 0)
|
||||
{
|
||||
throw new Exception("Цена должна быть больше 0");
|
||||
}
|
||||
productModel.StoreKeeperId = APIClient.Client.Id;
|
||||
APIClient.PostRequest("api/product/updatedata", productModel);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteGood(int model)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (model <= 0)
|
||||
{
|
||||
throw new Exception($"Идентификатор товара не может быть меньше или равен 0");
|
||||
}
|
||||
APIClient.PostRequest("api/product/deleteproduct", new ProductBindingModel
|
||||
{
|
||||
Id = model
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ProductViewModel? GetProduct(int Id)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (Id <= 0)
|
||||
{
|
||||
throw new Exception($"Идентификатор товара не может быть меньше или равен 0");
|
||||
}
|
||||
var result = APIClient.GetRequest<ProductViewModel>($"api/product/getproduct?id={Id}");
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult PurchaseCreate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult PurchaseDelete()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Purchases()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View(new List<PurchaseViewModel>());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Report()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View(new List<PurchaseViewModel>());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Report(string password)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
Response.Redirect("ReportOnly");
|
||||
}
|
||||
|
||||
public IActionResult Mails()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<MessageInfoViewModel>>($"api/storekeeper/getmessages?storekeeperId={APIClient.Client.Id}"));
|
||||
return RedirectToAction("MainStorekeeper", "Storekeeper");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
@ -320,5 +85,25 @@ namespace StoreKeeperClient.Controllers
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Enter(string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите почту и пароль");
|
||||
}
|
||||
APIClient.User = APIClient.GetRequest<StoreKeeperViewModel>($"api/user/login?login={login}&password={password}");
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Неверные почта и/или пароль");
|
||||
}
|
||||
return RedirectToAction("MainStorekeeper", "Storekeeper");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,387 +1,456 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using ComputerHardwareStoreContracts.ViewModels.HelperModels;
|
||||
using ComputerHardwareStoreDataModels.Models;
|
||||
using ComputerHardwareStoreDataModels.Enums;
|
||||
using HardwareShopContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StoreKeeperClient;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace StoreKeeperClient.Controllers
|
||||
namespace StorekeeperClient.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class StoreKeeperController : Controller
|
||||
public class StorekeeperController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IStoreKeeperLogic _storeKeeperLogic;
|
||||
private readonly IComponentLogic _componentLogic;
|
||||
private readonly IBuildLogic _buildLogic;
|
||||
private readonly IProductLogic _productLogic;
|
||||
|
||||
public StoreKeeperController(ILogger<HomeController> logger, IComponentLogic componentLogic, IBuildLogic buildLogic, IProductLogic productLogic, IStoreKeeperLogic storeKeeperLogic)
|
||||
public StorekeeperController(ILogger<HomeController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_componentLogic = componentLogic;
|
||||
_buildLogic = buildLogic;
|
||||
_productLogic = productLogic;
|
||||
_storeKeeperLogic = storeKeeperLogic;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateComponent(string name, double price)
|
||||
public IActionResult CreateOrder()
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Enter name");
|
||||
}
|
||||
_componentLogic.Create(
|
||||
new ComponentBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Cost = price,
|
||||
StoreKeeper = APIClient.Client!
|
||||
}
|
||||
);
|
||||
Response.Redirect("Components");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult UpdateComponent()
|
||||
{
|
||||
ViewBag.Components = _componentLogic.ReadList(
|
||||
new ComponentSearchModel
|
||||
{
|
||||
StoreKeeperId = APIClient.Client.Id
|
||||
}
|
||||
);
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateComponent(int component, double price, string name)
|
||||
{
|
||||
if (component == 0)
|
||||
{
|
||||
throw new Exception("Chose component");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Enter name");
|
||||
}
|
||||
_componentLogic.Update(
|
||||
new ComponentBindingModel
|
||||
{
|
||||
Id = component,
|
||||
Name = name,
|
||||
Cost = price,
|
||||
StoreKeeper = APIClient.Client!
|
||||
}
|
||||
);
|
||||
Response.Redirect("Components");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult ComponentToBuild()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Assemblies = _buildLogic.ReadList(null);
|
||||
ViewBag.Components = _componentLogic.ReadList(
|
||||
new ComponentSearchModel
|
||||
{
|
||||
StoreKeeperId = APIClient.Client!.Id
|
||||
}
|
||||
);
|
||||
ViewBag.Products = APIClient.GetRequest<List<ProductViewModel>>($"api/product/getproducts?userId={APIClient.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void ComponentToBuild(int buildId, int componentId, int count)
|
||||
public void CreateOrder(int product, int count, string sum)
|
||||
{
|
||||
if (buildId == 0)
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("chose build");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (componentId == 0)
|
||||
if (product <= 0)
|
||||
{
|
||||
throw new Exception("chose component");
|
||||
throw new Exception("Некорректный идентификатор товара");
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new Exception("chose count");
|
||||
throw new Exception("Количество должно быть больше 0");
|
||||
}
|
||||
BuildViewModel build = _buildLogic.ReadElement(new BuildSearchModel { Id = buildId })!;
|
||||
ComponentViewModel component = _componentLogic.ReadElement(new ComponentSearchModel { Id = componentId })!;
|
||||
if (build.BuildComponents.ContainsKey(componentId))
|
||||
build.BuildComponents[componentId] = (component, build.BuildComponents[componentId].Item2 + count);
|
||||
else
|
||||
build.BuildComponents.Add(componentId, (component, count));
|
||||
build.Price += component.Cost * count;
|
||||
_buildLogic.Update(
|
||||
new BuildBindingModel
|
||||
if (Convert.ToDouble(sum.Replace('.', ',')) <= 0)
|
||||
{
|
||||
Id = buildId,
|
||||
Vendor = build.Vendor,
|
||||
Name = build.Name,
|
||||
Price = build.Price,
|
||||
BuildComponents = build.BuildComponents
|
||||
});
|
||||
Response.Redirect("Components");
|
||||
throw new Exception("Цена должна быть больше 0");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult RemoveComponentFromBuild()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Assemblies = _buildLogic.ReadList(null);
|
||||
ViewBag.Components = _componentLogic.ReadList(
|
||||
new ComponentSearchModel
|
||||
{
|
||||
StoreKeeperId = APIClient.Client!.Id
|
||||
}
|
||||
);
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void RemoveComponentFromBuild(int buildId, int componentId, int count)
|
||||
{
|
||||
if (buildId == 0)
|
||||
{
|
||||
throw new Exception("chose build");
|
||||
}
|
||||
if (componentId == 0)
|
||||
{
|
||||
throw new Exception("chose component");
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new Exception("chose count");
|
||||
}
|
||||
BuildViewModel build = _buildLogic.ReadElement(new BuildSearchModel { Id = buildId })!;
|
||||
ComponentViewModel component = _componentLogic.ReadElement(new ComponentSearchModel { Id = componentId })!;
|
||||
if (build.BuildComponents.ContainsKey(componentId))
|
||||
{
|
||||
if (build.BuildComponents[componentId].Item2 < count)
|
||||
throw new Exception("ther is not enough components in build");
|
||||
if (build.BuildComponents[componentId].Item2 == count)
|
||||
build.BuildComponents.Remove(componentId);
|
||||
else
|
||||
build.BuildComponents[componentId] = (component, build.BuildComponents[componentId].Item2 - count);
|
||||
}
|
||||
else
|
||||
throw new Exception("there is no that component in build");
|
||||
build.Price -= component.Cost * count;
|
||||
_buildLogic.Update(
|
||||
new BuildBindingModel
|
||||
{
|
||||
Id = buildId,
|
||||
Vendor = build.Vendor,
|
||||
Name = build.Name,
|
||||
Price = build.Price,
|
||||
BuildComponents = build.BuildComponents
|
||||
});
|
||||
Response.Redirect("Components");
|
||||
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult DeleteComponent()
|
||||
{
|
||||
ViewBag.Components = _componentLogic.ReadList(
|
||||
new ComponentSearchModel
|
||||
{
|
||||
StoreKeeperId = APIClient.Client.Id
|
||||
}
|
||||
);
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteComponent(int component)
|
||||
{
|
||||
if (component == 0)
|
||||
{
|
||||
throw new Exception("Chose component");
|
||||
}
|
||||
_componentLogic.Delete(
|
||||
new ComponentBindingModel { Id = component }
|
||||
);
|
||||
Response.Redirect("Components");
|
||||
//APIClient.PostRequest("api/order/createorder", new OrderBindingModel
|
||||
//{
|
||||
// //UserId = APIClient.User.Id,
|
||||
// ProductId = product,
|
||||
// Count = count,
|
||||
// Sum = Convert.ToDouble(sum.Replace('.', ','))
|
||||
//});
|
||||
Response.Redirect("Orders");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteOrder(int Id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (Id <= 0)
|
||||
{
|
||||
throw new Exception("Некорректный идентификатор");
|
||||
}
|
||||
APIClient.PostRequest("api/order/deleteorder", new OrderBindingModel
|
||||
{
|
||||
Id = Id
|
||||
});
|
||||
Response.Redirect("Orders");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateOrder(int id, int status)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (id <= 0)
|
||||
{
|
||||
throw new Exception("Некорректный идентификатор");
|
||||
}
|
||||
if (status <= 0)
|
||||
{
|
||||
throw new Exception("Некорректный статус");
|
||||
}
|
||||
APIClient.PostRequest("api/order/updatedata", new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Status = (OrderStatus)status
|
||||
});
|
||||
Response.Redirect("Orders");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public double Calc(int count, int product)
|
||||
{
|
||||
var prod = APIClient.GetRequest<ProductViewModel>($"api/product/getproduct?id={product}");
|
||||
double result = Math.Round(count * (prod?.Price ?? 1), 2);
|
||||
return result;
|
||||
}
|
||||
|
||||
// товары
|
||||
[HttpGet]
|
||||
public IActionResult CreateProduct()
|
||||
{
|
||||
return View(_componentLogic.ReadList(null));
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateProduct(double price, string name, List<ComponentSelectionViewModel> components)
|
||||
{
|
||||
var selectedComponents = components.Where(g => g.IsSelected && g.Quantity > 0).ToList();
|
||||
List<ComponentViewModel> componentsViewModels = _componentLogic.ReadList(null)!;
|
||||
Dictionary<int, (IComponentModel, int)> productComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||
price = 0;
|
||||
foreach (var component in selectedComponents)
|
||||
{
|
||||
productComponents.Add(component.Id, (
|
||||
componentsViewModels.FirstOrDefault(x => x.Id == component.Id)!,
|
||||
component.Quantity
|
||||
));
|
||||
price += component.Quantity * componentsViewModels.FirstOrDefault(x => x.Id == component.Id)!.Cost;
|
||||
|
||||
}
|
||||
_productLogic.Create(
|
||||
new ProductBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Price = price,
|
||||
StoreKeeper = APIClient.Client!,
|
||||
ProductComponents = productComponents,
|
||||
}
|
||||
);
|
||||
Response.Redirect("Products");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult UpdateProduct(int productId)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponents?clientId={APIClient.Client.Id}");
|
||||
return View(productId);
|
||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponents?userId={APIClient.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateProduct(double price, string name, List<ComponentSelectionViewModel> components, int product)
|
||||
public void CreateProduct([FromBody] ProductBindingModel productModel)
|
||||
{
|
||||
if (product == 0)
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("chose product");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var selectedComponents = components.Where(g => g.IsSelected && g.Quantity > 0).ToList();
|
||||
List<ComponentViewModel> componentsViewModels = _componentLogic.ReadList(null)!;
|
||||
Dictionary<int, (IComponentModel, int)> productComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||
price = 0;
|
||||
// добавляем в
|
||||
foreach (var component in selectedComponents)
|
||||
if (string.IsNullOrEmpty(productModel.Name))
|
||||
{
|
||||
productComponents.Add(component.Id, (
|
||||
componentsViewModels.FirstOrDefault(x => x.Id == component.Id)!,
|
||||
component.Quantity
|
||||
));
|
||||
price += component.Quantity * componentsViewModels.FirstOrDefault(x => x.Id == component.Id)!.Cost;
|
||||
throw new Exception("Название не должно быть пустым");
|
||||
}
|
||||
_productLogic.Update(
|
||||
new ProductBindingModel
|
||||
if (productModel.Price <= 0)
|
||||
{
|
||||
Id = product,
|
||||
StoreKeeper = APIClient.Client,
|
||||
Price = price,
|
||||
Name = name,
|
||||
ProductComponents = productComponents
|
||||
});
|
||||
Response.Redirect("Products");
|
||||
throw new Exception("Цена должна быть больше 0");
|
||||
}
|
||||
productModel.StoreKeeperId = APIClient.User.Id;
|
||||
APIClient.PostRequest("api/product/createproduct", productModel);
|
||||
}
|
||||
|
||||
public IActionResult UpdateProduct(int productid)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponents?userId={APIClient.User.Id}");
|
||||
return View(productid);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateProduct([FromBody] ProductBindingModel productModel)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(productModel.Name))
|
||||
{
|
||||
throw new Exception("Название не должно быть пустым");
|
||||
}
|
||||
if (productModel.Price <= 0)
|
||||
{
|
||||
throw new Exception("Цена должна быть больше 0");
|
||||
}
|
||||
productModel.StoreKeeperId = APIClient.User.Id;
|
||||
APIClient.PostRequest("api/product/updatedata", productModel);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult DeleteProduct()
|
||||
public ProductViewModel? GetProduct(int Id)
|
||||
{
|
||||
var products = _productLogic.ReadList(
|
||||
new ProductSearchModel
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
StoreKeeperId = APIClient.Client!.Id
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
);
|
||||
ViewBag.Products = products;
|
||||
return View();
|
||||
if (Id <= 0)
|
||||
{
|
||||
throw new Exception($"Идентификатор товара не может быть меньше или равен 0");
|
||||
}
|
||||
var result = APIClient.GetRequest<ProductViewModel>($"api/product/getproduct?id={Id}");
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<ProductViewModel, List<Tuple<ComponentViewModel?, int>>>? GetProductUpdate(int productid)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIClient.GetRequest<Tuple<ProductViewModel,
|
||||
List<Tuple<ComponentViewModel?, int>>>?>($"api/product/getproductupdate?id={productid}&userId={APIClient.User.Id}");
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteProduct(int product)
|
||||
{
|
||||
_productLogic.Delete(
|
||||
new ProductBindingModel { Id = product }
|
||||
);
|
||||
Response.Redirect("Products");
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (product <= 0)
|
||||
{
|
||||
throw new Exception($"Идентификатор товара не может быть меньше или равен 0");
|
||||
}
|
||||
APIClient.PostRequest("api/product/deleteproduct", new ProductBindingModel
|
||||
{
|
||||
Id = product
|
||||
});
|
||||
}
|
||||
|
||||
// заказы
|
||||
public IActionResult LinkBuilds(int componentid)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Builds = APIClient.GetRequest<List<BuildViewModel>>($"api/build/getbuilds");
|
||||
return View(componentid);
|
||||
}
|
||||
|
||||
//[HttpGet]
|
||||
//public IActionResult CreateOrder()
|
||||
//{
|
||||
// ViewBag.Products = _productLogic.ReadList(
|
||||
// new ProductSearchModel
|
||||
// {
|
||||
// StoreKeeperId = APIClient.Client!.Id
|
||||
// }
|
||||
// );
|
||||
// return View();
|
||||
//}
|
||||
//[HttpPost]
|
||||
//public void CreateOrder(DateTime date, string address, int product)
|
||||
//{
|
||||
// _orderForProductsLogic.Create(
|
||||
// new OrderForProductsBindingModel
|
||||
// {
|
||||
// OrderDate = date,
|
||||
// DeliveryAddres = address,
|
||||
// ProductId = product,
|
||||
// }
|
||||
// );
|
||||
// Response.Redirect("Orders");
|
||||
//}
|
||||
//[HttpGet]
|
||||
//public IActionResult UpdateOrder()
|
||||
//{
|
||||
// ViewBag.Products = _productLogic.ReadList(
|
||||
// new ProductSearchModel
|
||||
// {
|
||||
// StoreKeeperId = APIClient.Client!.Id
|
||||
// }
|
||||
// );
|
||||
// ViewBag.OrdersForProducts = _orderForProductsLogic.ReadList(
|
||||
// new OrderForProductsSearchModel
|
||||
// {
|
||||
// StoreKeeperId = APIClient.Client!.Id
|
||||
// }
|
||||
// );
|
||||
// return View();
|
||||
//}
|
||||
//[HttpPost]
|
||||
//public void UpdateOrder(DateTime date, string address, int product, int order)
|
||||
//{
|
||||
// _orderForProductsLogic.Update(
|
||||
// new OrderForProductsBindingModel
|
||||
// {
|
||||
// Id = order,
|
||||
// OrderDate = date,
|
||||
// DeliveryAddres = address,
|
||||
// ProductId = product
|
||||
// }
|
||||
// );
|
||||
// Response.Redirect("Orders");
|
||||
//}
|
||||
[HttpPost]
|
||||
public void LinkBuilds([FromBody] ComponentBindingModel componentModel)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
componentModel.StoreKeeperId = APIClient.User.Id;
|
||||
APIClient.PostRequest($"api/component/updatedata", componentModel);
|
||||
}
|
||||
|
||||
//[HttpGet]
|
||||
//public IActionResult DeleteOrder()
|
||||
//{
|
||||
// ViewBag.OrdersForProducts = _orderForProductsLogic.ReadList(
|
||||
// new OrderForProductsSearchModel
|
||||
// {
|
||||
// StoreKeeperId = APIClient.Client!.Id
|
||||
// }
|
||||
// );
|
||||
// return View();
|
||||
//}
|
||||
//[HttpPost]
|
||||
//public void DeleteOrder(int order)
|
||||
//{
|
||||
// _orderForProductsLogic.Delete(
|
||||
// new OrderForProductsBindingModel
|
||||
// {
|
||||
// Id = order,
|
||||
// }
|
||||
// );
|
||||
// Response.Redirect("Orders");
|
||||
//}
|
||||
[HttpGet]
|
||||
public BuildViewModel? GetBuild(int buildId)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (buildId <= 0)
|
||||
{
|
||||
throw new Exception($"Идентификатор сборки не может быть меньше или равен 0");
|
||||
}
|
||||
var result = APIClient.GetRequest<BuildViewModel>($"api/build/getbuild?buildId={buildId}");
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<Tuple<BuildViewModel, int>>? GetComponentBuilds(int componentid)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIClient.GetRequest<List<Tuple<BuildViewModel, int>>?>($"api/component/getcomponentbuilds?id={componentid}");
|
||||
return result;
|
||||
}
|
||||
|
||||
public IActionResult CreateComponent()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateComponent(string name, string cost)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Название не должно быть пустым");
|
||||
}
|
||||
if (string.IsNullOrEmpty(cost) || Convert.ToDouble(cost.Replace('.', ',')) <= 0)
|
||||
{
|
||||
throw new Exception("Цена должна быть больше 0");
|
||||
}
|
||||
APIClient.PostRequest("api/component/createcomponent", new ComponentBindingModel
|
||||
{
|
||||
StoreKeeperId = APIClient.User.Id,
|
||||
Name = name,
|
||||
Cost = Convert.ToDouble(cost.Replace('.', ','))
|
||||
});
|
||||
Response.Redirect("Components");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ComponentViewModel? GetComponent(int Id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIClient.GetRequest<ComponentViewModel?>($"api/component/getcomponent?id={Id}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
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/updatecomponent", new ComponentBindingModel
|
||||
{
|
||||
Id = component,
|
||||
Name = name,
|
||||
Cost = Convert.ToDouble(cost.Replace('.', ',')),
|
||||
StoreKeeperId = 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()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Components()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponents?userId={APIClient.User.Id}"));
|
||||
}
|
||||
|
||||
public IActionResult Products()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<ProductViewModel>>($"api/product/getproducts?userId={APIClient.User.Id}"));
|
||||
}
|
||||
|
||||
public IActionResult Orders()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIClient.User.Id}"));
|
||||
}
|
||||
|
||||
public IActionResult ListBuilds()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Products = APIClient.GetRequest<List<ProductViewModel>>($"api/product/getproducts?userId={APIClient.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public int[]? ListBuilds([FromBody] ProductBindingModel productModel, [FromQuery] string format)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(format))
|
||||
{
|
||||
throw new FormatException("Неправильный формат файла");
|
||||
}
|
||||
byte[]? file = APIClient.PostRequestWithResult<ProductBindingModel, byte[]>($"api/report/buildproductreport?format={format}", productModel);
|
||||
return file!.Select(b => (int)b).ToArray();
|
||||
}
|
||||
|
||||
public IActionResult Report()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public List<ReportComponentsViewModel> Report([FromBody] ReportBindingModel reportModel)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
//reportModel.UserId = APIClient.User.Id;
|
||||
List<ReportComponentsViewModel>? list = APIClient.PostRequestWithResult
|
||||
<ReportBindingModel, List<ReportComponentsViewModel>>("api/report/componentsreport", reportModel);
|
||||
return list!;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void ReportSendOnMail([FromBody] ReportBindingModel reportModel)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
reportModel.UserId = APIClient.User.Id;
|
||||
reportModel.UserEmail = APIClient.User.Login;
|
||||
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}")!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
|
||||
namespace StoreKeerepClient
|
||||
{
|
||||
public static class LoginedStoreKeeper
|
||||
{
|
||||
public static StoreKeeperViewModel? StoreKeeper { get; set; }
|
||||
}
|
||||
}
|
@ -7,10 +7,21 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Controllers\StoreKeeperController.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Views\Home\Enter.cshtml" />
|
||||
<None Include="Views\Home\Index.cshtml" />
|
||||
<None Include="Views\Home\Privacy.cshtml" />
|
||||
<None Include="Views\Home\Register.cshtml" />
|
||||
<None Include="Views\Storekeeper\Components.cshtml" />
|
||||
<None Include="Views\Storekeeper\CreateComponent.cshtml" />
|
||||
<None Include="Views\Storekeeper\CreateOrder.cshtml" />
|
||||
<None Include="Views\Storekeeper\CreateProduct.cshtml" />
|
||||
<None Include="Views\Storekeeper\LinkBuilds.cshtml" />
|
||||
<None Include="Views\Storekeeper\ListBuilds.cshtml" />
|
||||
<None Include="Views\Storekeeper\MainStorekeeper.cshtml" />
|
||||
<None Include="Views\Storekeeper\Orders.cshtml" />
|
||||
<None Include="Views\Storekeeper\Products.cshtml" />
|
||||
<None Include="Views\Storekeeper\Report.cshtml" />
|
||||
<None Include="Views\Storekeeper\UpdateProduct.cshtml" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-grid.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-grid.min.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-grid.rtl.css.map" />
|
||||
|
@ -1,53 +0,0 @@
|
||||
@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>
|
@ -1,29 +0,0 @@
|
||||
@{
|
||||
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>
|
@ -1,58 +0,0 @@
|
||||
@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.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => component.Cost)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -1,58 +0,0 @@
|
||||
@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>
|
@ -1,25 +0,0 @@
|
||||
@{
|
||||
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>
|
@ -1,29 +0,0 @@
|
||||
@{
|
||||
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>
|
@ -1,129 +0,0 @@
|
||||
@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>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
let list = [];
|
||||
const name = document.getElementById("name");
|
||||
const submitComponentBtn = document.getElementById("savecomponent");
|
||||
const saveBtn = document.getElementById("createproduct");
|
||||
const countElem = document.getElementById("count");
|
||||
const resultTable = document.getElementById("result");
|
||||
const totalPrice = document.getElementById("price");
|
||||
|
||||
submitComponentBtn.addEventListener("click", () => {
|
||||
console.log('try to add component')
|
||||
var count = $('#count').val();
|
||||
var component = $('#component').val();
|
||||
if (component && count && count > 0) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Storekeeper/GetComponent`,
|
||||
data: { Id: component },
|
||||
success: function (result) {
|
||||
let flag = false
|
||||
if (list.length > 0) {
|
||||
list.forEach((elem) => {
|
||||
if (elem.component.id === parseInt(result.id)) {
|
||||
console.log('component already added')
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!flag) list.push({ component: result, count: count })
|
||||
reloadTable()
|
||||
countElem.value = '1'
|
||||
}
|
||||
}).fail(function (xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
saveBtn.addEventListener("click", () => {
|
||||
console.log('try to add product')
|
||||
if (list.length == 0) {
|
||||
alert('failed add product. components are empty')
|
||||
return
|
||||
}
|
||||
let components = []
|
||||
let counts = []
|
||||
list.forEach((x) => {
|
||||
components.push(x.component);
|
||||
counts.push(parseInt(x.count))
|
||||
})
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/CreateProduct`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
"Name": name.value, "Price": parseFloat(totalPrice.value),
|
||||
"ProductComponentsComponents": components, "ProductComponentsCounts": counts
|
||||
})
|
||||
}
|
||||
).done(() => window.location.href = '/Storekeeper/Products')
|
||||
.fail(function (xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
|
||||
function reloadTable() {
|
||||
resultTable.innerHTML = ''
|
||||
let price = 0;
|
||||
let count = 0;
|
||||
list.forEach((elem) => {
|
||||
resultTable.innerHTML += `<tr><td>${elem.component.componentName}</td><td>${elem.component.cost}</td><td>${elem.count}</td><td>${Math.round(elem.component.cost * elem.count * 100) / 100}</td><td> \
|
||||
<div> \
|
||||
<button onclick="deleteComponent(${count})" type="button" class="btn btn-danger"> \
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> \
|
||||
</button> \
|
||||
</div><td/></tr>`
|
||||
count++;
|
||||
price += elem.component.cost * elem.count
|
||||
})
|
||||
totalPrice.value = Math.round(price * 100) / 100
|
||||
}
|
||||
|
||||
function deleteComponent(id) {
|
||||
list = list.filter(value => value.component.componentName != resultTable.rows[id].cells[0].innerText)
|
||||
reloadTable()
|
||||
}
|
||||
|
||||
</script>
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
@{
|
||||
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>
|
@ -1,17 +0,0 @@
|
||||
@{
|
||||
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>
|
@ -1,17 +0,0 @@
|
||||
@{
|
||||
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>
|
@ -1,20 +1,32 @@
|
||||
@{
|
||||
ViewData["Title"] = "Enter";
|
||||
}
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин компьютерной техники "Ты ж программист"</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
<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>
|
||||
<h2 class="display-4">Вход</h2>
|
||||
</div>
|
||||
<form method="post" class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Почта</label>
|
||||
<input type="text" class="form-control" name="email">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Пароль</label>
|
||||
<input type="password" class="form-control" name="password">
|
||||
</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><a asp-action="Register">Регистрация</a>
|
||||
</form>
|
||||
|
||||
|
@ -1,17 +1,32 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
@{
|
||||
ViewData["Title"] = "Enter";
|
||||
}
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин компьютерной техники "Ты ж программист"</a>
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Заказы</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Добро пожаловать</h3>
|
||||
return;
|
||||
}
|
||||
}
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Storekeeper" asp-action="MainStorekeeper">Кладовщик</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
<div class="d-flex justify-content-center">
|
||||
Добро пожаловать
|
||||
</div>
|
@ -1,48 +0,0 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@model List<MessageInfoViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Mails";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Заказы</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Дата письма
|
||||
</th>
|
||||
<th>
|
||||
Заголовок
|
||||
</th>
|
||||
<th>
|
||||
Текст
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateDelivery)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Subject)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Body)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -1,57 +0,0 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@model List<OrderViewModel>
|
||||
@{
|
||||
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.DateImplement)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -0,0 +1,29 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
|
||||
|
||||
@model StoreKeeperViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Личные данные</h2>
|
||||
</div>
|
||||
<form method="post" class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Почта:</label>
|
||||
<input type="text" class="form-control" name="name" value="@Model.Name">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Пароль:</label>
|
||||
<input type="text" class="form-control" name="password" value="@Model.Password">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Логин:</label>
|
||||
<input type="text" class="form-control" name="login" value="@Model.Login">
|
||||
</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>
|
||||
</form>
|
@ -1,59 +0,0 @@
|
||||
@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>
|
||||
|
@ -1,57 +0,0 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@model List<PurchaseViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Purchases";
|
||||
}
|
||||
<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="CreatePurchase">Создать покупку</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="UpdatePurchase">Изменить покупку</a>
|
||||
<a class="text-decoration-none text-black h5" asp-action="DeletePurchase">Удалить покупку</a>
|
||||
</p>
|
||||
|
||||
<table class="PurchaseTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Дата создания
|
||||
</th>
|
||||
<th>
|
||||
Дата выполнения
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody>
|
||||
@foreach (var purchase in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => purchase.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => purchase.DateCreate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => purchase.DateImplement)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -1,25 +1,36 @@
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
@section Header {
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин компьютерной техники "Ты ж программист"</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
}
|
||||
<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="name" /></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>
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
</div>
|
||||
<form method="post" class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Почта</label>
|
||||
<input type="text" class="form-control" name="email">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Логин</label>
|
||||
<input type="text" class="form-control" aria-describedby="emailHelp" name="login">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Пароль</label>
|
||||
<input type="password" class="form-control" name="password">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4">Подтвердить</button>
|
||||
<a asp-action="Enter">Вернуться на вход</a>
|
||||
|
||||
</form>
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
@{
|
||||
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>
|
@ -1,46 +0,0 @@
|
||||
@{
|
||||
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>
|
@ -1,69 +0,0 @@
|
||||
@{
|
||||
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>
|
@ -3,16 +3,16 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - ComputerStoreWorkerApp</title>
|
||||
<title>@ViewData["Title"] - ComputerHardwareStoreWorkerApp</title>
|
||||
<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="~/ComputerStoreWorkerApp.styles.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/ComputerHardwareStoreWorkerApp.styles.css" asp-append-version="true" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">ComputerStoreWorkerApp</a>
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">ComputerHardwareStoreWorkerApp</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@ -53,7 +53,7 @@
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - ComputerStoreWorkerApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
© 2024 - ComputerHardwareStoreWorkerApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
|
@ -0,0 +1,125 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@using HardwareShopContracts.ViewModels
|
||||
|
||||
@model List<ComponentViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Комплектующие";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Комплектующие</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
<p>
|
||||
<a asp-action="CreateComponent" class="btn btn-primary mx-2">Создать комплектующее</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Цена
|
||||
</th>
|
||||
<th>
|
||||
Дата приобретения
|
||||
</th>
|
||||
<th>
|
||||
Действия
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Cost)
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<a asp-controller="Storekeeper"
|
||||
asp-action="LinkBuilds"
|
||||
asp-route-componentid="@item.Id"
|
||||
class="btn btn-success">
|
||||
<i>Привязать</i>
|
||||
</a>
|
||||
<button onclick="getComponent(@item.Id)" type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#updateModal">
|
||||
<i>Изменить</i>
|
||||
</button>
|
||||
<button onclick="deleteComponent(@item.Id)" type="button" class="btn btn-danger">
|
||||
<i>Удалить</i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
<form method="post" asp-controller="Storekeeper" asp-action="UpdateComponent">
|
||||
<div class="modal fade" id="updateModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Комплектующая</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="col">
|
||||
<label class="form-label">Название</label>
|
||||
<input type="text" class="form-control" name="name" id="name" required>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label class="form-label">Стоимость</label>
|
||||
<input type="number" step="0.01" class="form-control" name="cost" id="cost" min="0.01" required>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="component" name="component" />
|
||||
<div class="modal-footer">
|
||||
<input type="submit" class="btn btn-primary" value="Сохранить">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
@{
|
||||
ViewData["Title"] = "Создание комплектующего";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание комплектующего</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Название</label>
|
||||
<input type="text" class="form-control" name="name" required>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<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-2 d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4">Сохранить</button>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,57 @@
|
||||
@{
|
||||
ViewData["Title"] = "Создание заказа";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание заказа</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Товар</label>
|
||||
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products, "Id", "ProductName"))" required></select>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Количество</label>
|
||||
<input type="number" class="form-control" name="count" id="count" min="1" value="1" required>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Сумма</label>
|
||||
<input type="number" step="0.01" class="form-control" name="sum" id="sum" value="0" min="0,01" readonly 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>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
$('#product').on('change', function () {
|
||||
check();
|
||||
});
|
||||
$('#count').on('input', function () {
|
||||
check();
|
||||
});
|
||||
|
||||
function check() {
|
||||
var count = $('#count').val();
|
||||
var product = $('#product').val();
|
||||
if (count && product) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Storekeeper/Calc",
|
||||
data: { count: count, product: product },
|
||||
success: function (result) {
|
||||
$("#sum").val(result);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
});
|
||||
};
|
||||
}
|
||||
check()
|
||||
</script>
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Создание товара";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание товара</h2>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Название</label>
|
||||
<input type="text" class="form-control" name="name" id="name" >
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Цена</label>
|
||||
<input type="number" step="0.01" class="form-control" name="price" id="price" readonly min="0.01" value="0" >
|
||||
</div>
|
||||
<h1 class="display-6">Комплектующие</h1>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Комплектующее</th>
|
||||
<th scope="col">Стоимость</th>
|
||||
<th scope="col">Количество</th>
|
||||
<th scope="col">Сумма</th>
|
||||
<th scope="col">Действие</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="button" class="btn btn-primary mt-3 px-4" id="createproduct">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Комплектующее</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<label class="form-label">Комплектующее</label>
|
||||
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components, "Id", "ComponentName"))"></select>
|
||||
<label class="form-label">Количество</label>
|
||||
<input type="number" class="form-control" name="count" id="count" min="1" value="1" >
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="savecomponent">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
let list = [];
|
||||
const name = document.getElementById("name");
|
||||
const submitComponentBtn = document.getElementById("savecomponent");
|
||||
const saveBtn = document.getElementById("createproduct");
|
||||
const countElem = document.getElementById("count");
|
||||
const resultTable = document.getElementById("result");
|
||||
const totalPrice = document.getElementById("price");
|
||||
|
||||
submitComponentBtn.addEventListener("click", () => {
|
||||
console.log('try to add component')
|
||||
var count = $('#count').val();
|
||||
var component = $('#component').val();
|
||||
if (component && count && count > 0) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Storekeeper/GetComponent`,
|
||||
data: { Id: component },
|
||||
success: function (result) {
|
||||
let flag = false
|
||||
if (list.length > 0) {
|
||||
list.forEach((elem) => {
|
||||
if (elem.component.id === parseInt(result.id)) {
|
||||
console.log('component already added')
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!flag) list.push({ component: result, count: count })
|
||||
reloadTable()
|
||||
countElem.value = '1'
|
||||
}
|
||||
}).fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
saveBtn.addEventListener("click", () => {
|
||||
console.log('try to add product')
|
||||
if (list.length == 0) {
|
||||
alert('failed add product. components are empty')
|
||||
return
|
||||
}
|
||||
let components = []
|
||||
let counts = []
|
||||
list.forEach((x) => {
|
||||
components.push(x.component);
|
||||
counts.push(parseInt(x.count))
|
||||
})
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/CreateProduct`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({"ProductName": name.value,"Price": parseFloat(totalPrice.value),
|
||||
"ProductComponentsComponents": components, "ProductComponentsCounts": counts })
|
||||
}
|
||||
).done(() => window.location.href = '/Storekeeper/Products')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
|
||||
function reloadTable() {
|
||||
resultTable.innerHTML = ''
|
||||
let price = 0;
|
||||
let count = 0;
|
||||
list.forEach((elem) => {
|
||||
resultTable.innerHTML += `<tr><td>${elem.component.componentName}</td><td>${elem.component.cost}</td><td>${elem.count}</td><td>${Math.round(elem.component.cost * elem.count * 100) / 100}</td><td> \
|
||||
<div> \
|
||||
<button onclick="deleteComponent(${count})" type="button" class="btn btn-danger"> \
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> \
|
||||
</button> \
|
||||
</div><td/></tr>`
|
||||
count++;
|
||||
price += elem.component.cost * elem.count
|
||||
})
|
||||
totalPrice.value = Math.round(price * 100) / 100
|
||||
}
|
||||
|
||||
function deleteComponent(id) {
|
||||
list = list.filter(value => value.component.componentName != resultTable.rows[id].cells[0].innerText)
|
||||
reloadTable()
|
||||
}
|
||||
|
||||
</script>
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Привязка сборок";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Привязка сборок</h1>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Привязать</button>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="display-6">Привязанные сборки</h1>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Сборка</th>
|
||||
<th scope="col">Количество</th>
|
||||
<th scope="col">Действие</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="button" class="btn btn-primary mt-3 px-4" id="linkbuilds">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Привязка сборки</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||
</div>
|
||||
<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>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="savebuild">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
const componentid = @Model;
|
||||
let component;
|
||||
let list = [];
|
||||
const submitBuildBtn = document.getElementById("savebuild");
|
||||
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')
|
||||
var count = $('#count').val();
|
||||
var build = $('#build').val();
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Storekeeper/GetBuild`,
|
||||
data: { buildId: build },
|
||||
success: function (result) {
|
||||
let flag = false
|
||||
if (list.length > 0) {
|
||||
list.forEach((elem) => {
|
||||
if (elem.build.id === parseInt(result.id)) {
|
||||
console.log('build already added')
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!flag) list.push({ build: result, count: count })
|
||||
reloadTable()
|
||||
countElem.value = '1'
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
saveBtn.addEventListener("click", () => {
|
||||
console.log('try to link builds')
|
||||
let builds = []
|
||||
let counts = []
|
||||
list.forEach((x) => {
|
||||
builds.push(x.build);
|
||||
counts.push(parseInt(x.count))
|
||||
})
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/LinkBuilds`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ "Id": componentid, "ComponentName": component.componentName,
|
||||
"Cost": component.cost, "ComponentBuildsBuilds": builds, "ComponentBuildsCounts": counts })
|
||||
}
|
||||
).done(() => window.location.href = '/Storekeeper/Components')
|
||||
})
|
||||
|
||||
function reloadTable() {
|
||||
resultTable.innerHTML = ''
|
||||
let count = 0;
|
||||
list.forEach((elem) => {
|
||||
resultTable.innerHTML += `<tr><td>${elem.build.buildName}</td><td>${elem.count}</td><td> \
|
||||
<div> \
|
||||
<button onclick="deleteBuild(${count})" type="button" class="btn btn-danger"> \
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> \
|
||||
</button> \
|
||||
</div><td/></tr>`
|
||||
count++;
|
||||
})
|
||||
}
|
||||
|
||||
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() {
|
||||
if (componentid) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Storekeeper/GetComponent",
|
||||
data: { Id: componentid },
|
||||
success: function (result) {
|
||||
component = result
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Storekeeper/GetComponentBuilds",
|
||||
data: { componentid: componentid },
|
||||
success: function (result) {
|
||||
if (result) {
|
||||
result.forEach(elem => {
|
||||
list.push({ build: elem.item1, count: elem.item2 })
|
||||
})
|
||||
reloadTable()
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
getComponentBuilds();
|
||||
getCommentsOnBuild();
|
||||
|
||||
</script>
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Получение списка";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Получение списка сборок</h1>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<h1 class="display-6">Выбранные товары</h1>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить товар</button>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Товар</th>
|
||||
<th scope="col">Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="col d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="button" class="btn btn-primary m-2" id="savedoc">Сохранить в doc-формате</button>
|
||||
<button type="button" class="btn btn-primary m-2" id="saveexcel">Сохранить в xls-формате</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Товар</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<label class="form-label">Товар</label>
|
||||
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products, "Id", "ProductName"))"></select>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="saveproduct">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
let list = [];
|
||||
const submitProductBtn = document.getElementById("saveproduct");
|
||||
const resultTable = document.getElementById("result");
|
||||
const saveDocBtn = document.getElementById("savedoc");
|
||||
const saveExcelBtn = document.getElementById("saveexcel");
|
||||
|
||||
submitProductBtn.addEventListener("click", () => {
|
||||
console.log('try to add product')
|
||||
var product = $('#product').val();
|
||||
if (product)
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Storekeeper/GetProduct`,
|
||||
data: { Id: product },
|
||||
success: function (result) {
|
||||
let flag = false
|
||||
if (list.length > 0) {
|
||||
list.forEach((elem) => {
|
||||
if (elem.id === parseInt(result.id)) {
|
||||
console.log('product already added')
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!flag) list.push(result)
|
||||
reloadTable()
|
||||
}
|
||||
}).fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
|
||||
saveDocBtn.addEventListener("click", async () => {
|
||||
send('docx')
|
||||
})
|
||||
|
||||
saveExcelBtn.addEventListener("click", async () => {
|
||||
send('xlsx')
|
||||
})
|
||||
|
||||
function send(format) {
|
||||
console.log(`try to save in ${format} format`)
|
||||
if (list.length == 0) {
|
||||
alert('operation failed. products are empty')
|
||||
return
|
||||
}
|
||||
$.ajax({
|
||||
url: `/Storekeeper/ListBuilds?format=${format}`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ "Products" : list })
|
||||
}).done((file) => {
|
||||
let byteArray = new Uint8Array(file);
|
||||
saveFile(byteArray, format);
|
||||
})
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
}
|
||||
|
||||
async function saveFile(bytes, format) {
|
||||
if (window.showSaveFilePicker) {
|
||||
const opts = {
|
||||
suggestedName: `listbuilds.${format}`,
|
||||
types: [{
|
||||
description: `${format} file`,
|
||||
accept:
|
||||
{
|
||||
[`text/${format}`]: [`.${format}`]
|
||||
},
|
||||
}],
|
||||
};
|
||||
const handle = await showSaveFilePicker(opts);
|
||||
const writable = await handle.createWritable();
|
||||
await writable.write(bytes);
|
||||
writable.close();
|
||||
alert('done')
|
||||
}
|
||||
}
|
||||
|
||||
function reloadTable() {
|
||||
resultTable.innerHTML = ''
|
||||
let count = 0;
|
||||
list.forEach((elem) => {
|
||||
resultTable.innerHTML += `<tr><td>${elem.productName}</td><td> \
|
||||
<div> \
|
||||
<button onclick="deleteProduct(${count})" type="button" class="btn btn-danger"> \
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> \
|
||||
</button> \
|
||||
</div></td></tr>`
|
||||
count++;
|
||||
})
|
||||
}
|
||||
|
||||
function deleteProduct(id) {
|
||||
list = list.filter(value => value.productName != resultTable.rows[id].cells[0].innerText)
|
||||
reloadTable()
|
||||
}
|
||||
</script>
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
@{
|
||||
ViewData["Title"] = "Основная - Кладовщик";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-center">
|
||||
Добро пожаловать
|
||||
</div>
|
@ -0,0 +1,168 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
|
||||
@model List<OrderViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Заказы";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Заказы</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<p>
|
||||
<a asp-action="CreateOrder" class="btn btn-primary mx-2">Создать заказ</a>
|
||||
<button type="button" class="btn btn-primary mx-2" id="delete">Удалить заказ</button>
|
||||
<button type="button" class="btn btn-primary mx-2" id="inwork">Выполняется</button>
|
||||
<button type="button" class="btn btn-primary mx-2" id="ready">Готов</button>
|
||||
<button type="button" class="btn btn-primary mx-2" id="done">Выдан</button>
|
||||
</p>
|
||||
<table class="table" id="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Товар
|
||||
</th>
|
||||
<th>
|
||||
Количество
|
||||
</th>
|
||||
<th>
|
||||
Сумма
|
||||
</th>
|
||||
<th>
|
||||
Статус
|
||||
</th>
|
||||
<th>
|
||||
Дата создания
|
||||
</th>
|
||||
<th>
|
||||
Дата выполнения
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ProductName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Count)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateCreate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateImplement)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@section Styles
|
||||
{
|
||||
<style>
|
||||
tr{cursor: pointer;}
|
||||
.selected{background-color: #0d6efd; color: white;}
|
||||
</style>
|
||||
}
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
// get selected row
|
||||
// display selected row data in text input
|
||||
|
||||
var table = document.getElementById("table");
|
||||
var remove = document.getElementById("delete");
|
||||
var inwork = document.getElementById("inwork");
|
||||
var ready = document.getElementById("ready");
|
||||
var done = document.getElementById("done");
|
||||
for(var i = 1; i < table.rows.length; i++)
|
||||
{
|
||||
table.rows[i].onclick = function()
|
||||
{
|
||||
// remove the background from the previous selected row
|
||||
if(typeof index !== "undefined") {
|
||||
table.rows[index].classList.toggle("selected");
|
||||
}
|
||||
// get the selected row index
|
||||
index = this.rowIndex;
|
||||
// add class selected to the row
|
||||
this.classList.toggle("selected");
|
||||
|
||||
var order = parseInt(this.cells[0].innerText)
|
||||
remove.addEventListener("click", () => {
|
||||
console.log('try to delete order')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/DeleteOrder`,
|
||||
type: 'POST',
|
||||
data: { id: order }
|
||||
}
|
||||
).done(() => window.location.href='/Storekeeper/Orders')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
inwork.addEventListener("click", () => {
|
||||
console.log('try to update order status')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/UpdateOrder`,
|
||||
type: 'POST',
|
||||
data: { id : order, status : 1 }
|
||||
}
|
||||
).done((result) => window.location.href='/Storekeeper/Orders')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
ready.addEventListener("click", () => {
|
||||
console.log('try to update order status')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/UpdateOrder`,
|
||||
type: 'POST',
|
||||
data: { id : order, status : 2 }
|
||||
}
|
||||
).done(() => window.location.href='/Storekeeper/Orders')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
done.addEventListener("click", () => {
|
||||
console.log('try to update order status')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/UpdateOrder`,
|
||||
type: 'POST',
|
||||
data: { id : order, status : 3 }
|
||||
}
|
||||
).done(() => window.location.href='/Storekeeper/Orders')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
</script>
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
|
||||
@model List<ProductViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Товары";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Товары</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<p>
|
||||
<a asp-action="CreateProduct" class="btn btn-primary mx-2">Создать товар</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Цена
|
||||
</th>
|
||||
<th>
|
||||
Действия
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Price)
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<a asp-controller="Storekeeper"
|
||||
asp-action="UpdateProduct"
|
||||
asp-route-productid="@item.Id"
|
||||
class="btn btn-primary">
|
||||
<i>Изменить</i>
|
||||
</a>
|
||||
<button onclick="deleteProduct(@item.Id)" type="button" class="btn btn-danger">
|
||||
<i>Удалить</i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function deleteProduct(productId) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Storekeeper/DeleteProduct",
|
||||
data: { product: productId }
|
||||
}).done(() => window.location.href = "/Storekeeper/Products");
|
||||
}
|
||||
</script>
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Отчет";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">С</label>
|
||||
<input type="date" class="form-control" name="dateFrom" id="dateFrom">
|
||||
<label class="form-label">По</label>
|
||||
<input type="date" class="form-control" name="dateTo" id="dateTo">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4" id="page">Вывод на страницу</button>
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4" id="mail">Отправить на почту</button>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Комплектующее</th>
|
||||
<th scope="col">Товар/Сборка</th>
|
||||
<th scope="col">Количество</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result">
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
let list = []
|
||||
const from = document.getElementById("dateFrom");
|
||||
const to = document.getElementById("dateTo");
|
||||
const onpage = document.getElementById("page");
|
||||
const onmail = document.getElementById("mail");
|
||||
const resultTable = document.getElementById("result");
|
||||
|
||||
onpage.addEventListener("click", () => {
|
||||
console.log('try to get report')
|
||||
if (from.value && to.value && from.value !== '' && to.value !== '') {
|
||||
const dateFrom = new Date(from.value);
|
||||
const dateTo = new Date(to.value);
|
||||
if (dateFrom.getTime() > dateTo.getTime())
|
||||
alert("Неправильные даты")
|
||||
const reportModel = { "DateFrom": dateFrom, "DateTo": dateTo }
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
contentType: "application/json",
|
||||
url: `/Storekeeper/Report`,
|
||||
data: JSON.stringify(reportModel),
|
||||
success: function (result) {
|
||||
list = result
|
||||
console.log(list)
|
||||
reloadTable()
|
||||
}
|
||||
}).fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
} else { alert("Пустые поля") }
|
||||
})
|
||||
onmail.addEventListener("click", () => {
|
||||
console.log('try to send email')
|
||||
if (from.value && to.value && from.value !== '' && to.value !== '') {
|
||||
const dateFrom = new Date(from.value);
|
||||
const dateTo = new Date(to.value);
|
||||
if (dateFrom.getTime() > dateTo.getTime())
|
||||
alert("Неправильные даты")
|
||||
const reportModel = { "DateFrom": dateFrom, "DateTo": dateTo }
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
contentType: "application/json",
|
||||
url: `/Storekeeper/ReportSendOnMail`,
|
||||
data: JSON.stringify(reportModel)
|
||||
}).fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
} else { alert("Пустые поля") }
|
||||
})
|
||||
|
||||
function reloadTable() {
|
||||
resultString = '';
|
||||
list.forEach((elem) => {
|
||||
resultString += `<tr><td>${elem.componentName}</td><td></td><td></td></tr>`;
|
||||
elem.productOrBuilds.forEach((productOrBuild) => {
|
||||
resultString += `<tr><td></td><td>${productOrBuild.item1}</td><td>${productOrBuild.item2}</td></tr>`;
|
||||
})
|
||||
resultString += `<tr><td>Итого</td><td></td><td>${elem.totalCount}</td></tr>`;
|
||||
})
|
||||
resultTable.innerHTML = resultString
|
||||
}
|
||||
</script>
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
@using HardwareShopContracts.ViewModels
|
||||
|
||||
@model int
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Товар";
|
||||
Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование товара</h2>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Название</label>
|
||||
<input type="text" class="form-control" name="name" id="name" required>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="form-label">Цена</label>
|
||||
<input type="number" step="0.01" class="form-control" name="price" id="price" readonly min="0.01" value="0" required>
|
||||
</div>
|
||||
<h1 class="display-6">Комплектующие</h1>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Комплектующее</th>
|
||||
<th scope="col">Стоимость</th>
|
||||
<th scope="col">Количество</th>
|
||||
<th scope="col">Сумма</th>
|
||||
<th scope="col">Действие</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="button" class="btn btn-primary mt-3 px-4" id="editproduct">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Комплектующее</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<label class="form-label">Комплектующее</label>
|
||||
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components, "Id", "ComponentName"))"></select>
|
||||
<label class="form-label">Количество</label>
|
||||
<input type="number" class="form-control" name="count" id="count" min="1" value="1" required>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="savecomponent">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
const productid = @Model
|
||||
// components & counts
|
||||
let list = [];
|
||||
const name = document.getElementById("name");
|
||||
const submitComponentBtn = document.getElementById("savecomponent");
|
||||
const saveBtn = document.getElementById("editproduct");
|
||||
const countElem = document.getElementById("count");
|
||||
const resultTable = document.getElementById("result");
|
||||
const totalPrice = document.getElementById("price");
|
||||
|
||||
submitComponentBtn.addEventListener("click", () => {
|
||||
console.log('try to add component')
|
||||
var count = $('#count').val();
|
||||
var component = $('#component').val();
|
||||
if (component && count && count > 0)
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `/Storekeeper/GetComponent`,
|
||||
data: { Id: component },
|
||||
success: function (result) {
|
||||
let flag = false
|
||||
if (list.length > 0) {
|
||||
list.forEach((elem) => {
|
||||
if (elem.component.id === parseInt(result.id)) {
|
||||
console.log('component already added')
|
||||
flag = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!flag) list.push({ component: result, count: count })
|
||||
reloadTable()
|
||||
countElem.value = '1'
|
||||
}
|
||||
}).fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
});
|
||||
})
|
||||
|
||||
saveBtn.addEventListener("click", () => {
|
||||
console.log('try to update product')
|
||||
if (list.length == 0) {
|
||||
console.log('failed update product')
|
||||
return
|
||||
}
|
||||
let components = []
|
||||
let counts = []
|
||||
list.forEach((x) => {
|
||||
components.push(x.component);
|
||||
counts.push(parseInt(x.count))
|
||||
})
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/UpdateProduct`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ "Id": productid, "ProductName": name.value,"Price": parseFloat(totalPrice.value),
|
||||
"ProductComponentsComponents": components, "ProductComponentsCounts": counts })
|
||||
}
|
||||
).done(() => window.location.href = '/Storekeeper/Products')
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
})
|
||||
|
||||
function reloadTable() {
|
||||
resultTable.innerHTML = ''
|
||||
let price = 0;
|
||||
let count = 0;
|
||||
list.forEach((elem) => {
|
||||
resultTable.innerHTML += `<tr><td>${elem.component.componentName}</td><td>${elem.component.cost}</td><td>${elem.count}</td><td>${Math.round(elem.component.cost * elem.count * 100) / 100}</td><td> \
|
||||
<div> \
|
||||
<button onclick="deleteComponent(${count})" type="button" class="btn btn-danger"> \
|
||||
<i>Удалить</i> \
|
||||
</button> \
|
||||
</div><td/></tr>`
|
||||
count++;
|
||||
price += elem.component.cost * elem.count
|
||||
})
|
||||
totalPrice.value = Math.round(price * 100) / 100
|
||||
}
|
||||
|
||||
function deleteComponent(id) {
|
||||
list = list.filter(value => value.component.componentName != resultTable.rows[id].cells[0].innerText)
|
||||
reloadTable()
|
||||
}
|
||||
|
||||
function getProduct() {
|
||||
if (productid) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Storekeeper/GetProductUpdate",
|
||||
data: { productid: productid },
|
||||
success: function (result) {
|
||||
if (result) {
|
||||
name.value = result.item1.productName
|
||||
totalPrice.value = result.item1.price
|
||||
result.item2.forEach(elem => {
|
||||
list.push({ component: elem.item1, count: elem.item2 })
|
||||
})
|
||||
reloadTable()
|
||||
}
|
||||
else
|
||||
alert("Ошибка получения товара")
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, textStatus, errorThrown) {
|
||||
alert(xhr.responseText);
|
||||
})
|
||||
};
|
||||
}
|
||||
getProduct();
|
||||
</script>
|
||||
}
|
@ -162,7 +162,7 @@ $.validator.addMethod( "bic", function( value, element ) {
|
||||
* B. LLCs
|
||||
* C. General partnerships
|
||||
* D. Companies limited partnerships
|
||||
* E. Communities of goods
|
||||
* E. Communities of products
|
||||
* F. Cooperative Societies
|
||||
* G. Associations
|
||||
* H. Communities of homeowners in horizontal property regime
|
||||
|
@ -3510,7 +3510,7 @@ jQuery.Callbacks = function( options ) {
|
||||
|
||||
firing = false;
|
||||
|
||||
// Clean up if we're done firing for good
|
||||
// Clean up if we're done firing for product
|
||||
if ( locked ) {
|
||||
|
||||
// Keep an empty list if we have data for future add calls
|
||||
|
Loading…
Reference in New Issue
Block a user