так
This commit is contained in:
parent
17c52d0eba
commit
aef701ae24
@ -18,13 +18,11 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly IAssemblyStorage _assemblyStorage;
|
||||
private readonly ISupplyStorage _supplyStorage;
|
||||
public OrderLogic(ILogger<ComponentLogic> logger, IOrderStorage orderStorage, IAssemblyStorage assemblyStorage, ISupplyStorage supplyStorage)
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IAssemblyStorage assemblyStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_assemblyStorage = assemblyStorage;
|
||||
_supplyStorage = supplyStorage;
|
||||
}
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
|
@ -18,14 +18,12 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
||||
private readonly ILogger _logger;
|
||||
private readonly ISupplyStorage _supplyStorage;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly IComponentStorage _componentStorage;
|
||||
|
||||
public SupplyLogic(ILogger logger, ISupplyStorage supplyStorage, IOrderStorage orderStorage, IComponentStorage componentStorage)
|
||||
public SupplyLogic(ILogger<SupplyLogic> logger, ISupplyStorage supplyStorage, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_supplyStorage = supplyStorage;
|
||||
_orderStorage = orderStorage;
|
||||
_componentStorage = componentStorage;
|
||||
}
|
||||
public bool Create(SupplyBindingModel model)
|
||||
{
|
||||
@ -142,31 +140,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
public bool AddComponent(SupplySearchModel supplymodel, ComponentSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
var component = _componentStorage.GetElement(model);
|
||||
var supply = _supplyStorage.GetElement(supplymodel);
|
||||
|
||||
if (component == null || supply == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
supply.SupplyComponents[supply.Id] = component;
|
||||
|
||||
_supplyStorage.Update(new()
|
||||
{
|
||||
Id = supply.Id,
|
||||
SupplyOrders = supply.SupplyOrders,
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,9 +29,11 @@ builder.Services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
builder.Services.AddTransient<IAssemblyLogic, AssemblyLogic>();
|
||||
builder.Services.AddTransient<IEquipmentReceivingLogic, EquipmentReceivingLogic>();
|
||||
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||
builder.Services.AddTransient<ISupplyLogic, SupplyLogic>();
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
|
||||
|
||||
|
||||
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using ComputerShopContracts.BindingModels;
|
||||
using ComputerShopContracts.SearchModels;
|
||||
using ComputerShopContracts.ViewModels;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -30,9 +31,9 @@ namespace OrdererClientApp.Controllers
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
return Redirect("~/Order/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<OrderViewModel>>($"api/component/order"));
|
||||
return View(APIClient.GetRequest<List<OrderViewModel>>($"api/order/getorderlist?clientId={APIClient.Client.Id}"));
|
||||
}
|
||||
public IActionResult Supply()
|
||||
{
|
||||
@ -128,8 +129,8 @@ namespace OrdererClientApp.Controllers
|
||||
return;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateReceiving()
|
||||
[HttpPost]
|
||||
public void CreateReceiving()
|
||||
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
@ -142,7 +143,6 @@ namespace OrdererClientApp.Controllers
|
||||
ClientId = APIClient.Client.Id
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -208,42 +208,37 @@ namespace OrdererClientApp.Controllers
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateAssembly()
|
||||
public IActionResult AddAssemblyToOrder()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Assemblies = APIClient.GetRequest<List<OrderViewModel>>($"api/order/getorderlist?clientId={APIClient.Client.Id}");
|
||||
ViewBag.Components = APIClient.GetRequest<List<AssemblyViewModel>>($"api/assembly/getassemblylist?clientId={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void AddAssemblyToOrder(int order, int assembly, int amount)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Необходима авторизация");
|
||||
}
|
||||
APIClient.PostRequest("api/order/AddAssemblyToOrder", Tuple.Create(
|
||||
new AssemblySearchModel() { Id = assembly },
|
||||
new OrderSearchModel() { Id = order },
|
||||
|
||||
amount
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public double Calc(int count, int assembly)
|
||||
{
|
||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/component/getcomponentlist");
|
||||
ViewBag.CurrentComponents = new List<ComponentViewModel>();
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateAssembly(string name, int sum)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (sum <= 0)
|
||||
{
|
||||
throw new Exception("Сумма должна быть больше 0");
|
||||
}
|
||||
APIClient.PostRequest("api/assembly/createassembly", new AssemblyBindingModel
|
||||
{
|
||||
ClientId = APIClient.Client.Id,
|
||||
AssemblyName = name,
|
||||
Price = 0,
|
||||
AssemblyComponents = new()
|
||||
});
|
||||
System.Diagnostics.Debug.WriteLine("it might work");
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public double Calc(int count, int order)
|
||||
{
|
||||
var or = APIClient.GetRequest<OrderViewModel>($"api/main/getcomponent?componentId={order}");
|
||||
var or = APIClient.GetRequest<OrderViewModel>($"api/main/getassembly?assemblyId={assembly}");
|
||||
return count * (or?.Sum ?? 1);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
g ComputerShopContracts.ViewModels;
|
||||
@using ComputerShopDataModels.Models;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Add Assembly To Order";
|
||||
}
|
||||
|
||||
@model Dictionary<int, IAssemblyModel>
|
||||
|
||||
<form method="post">
|
||||
|
||||
<div class="u-form-group u-form-name u-label-top">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Заказ: </label>
|
||||
<div class="u-input u-input-rectangle">
|
||||
<select id="order" name="order" class="form-control" asp-items="@(new SelectList(@ViewBag.Orders, "Id", "DateCreate"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-form-group u-form-name u-label-top">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Сборка: </label>
|
||||
<div class="u-input u-input-rectangle">
|
||||
<select id="assembly" name="assembly" class="form-control" asp-items="@(new SelectList(@ViewBag.Assemblies, "Id", "AssemblyName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-align-right u-form-group u-form-submit u-label-top">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Добавить заказ" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
|
||||
</div>
|
||||
</form>
|
@ -1,17 +1,24 @@
|
||||
@{
|
||||
@using ComputerShopContracts.ViewModels;
|
||||
@using ComputerShopDataModels.Models;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "CreateOrder";
|
||||
}
|
||||
@model Dictionary<int, IAssemblyModel>
|
||||
|
||||
<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="sum" id="sum" /></div>
|
||||
<div class="u-form-group u-form-name u-label-top">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">Выберете сборки для заказа: </label>
|
||||
<div class="u-input u-input-rectangle">
|
||||
<select id="assembly" name="assembly" class="form-control" asp-items="@(new SelectList(@ViewBag.Assemblies, "Id", "AssemblyName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="text" name="status" id="status" /></div>
|
||||
<div class="u-align-right u-form-group u-form-submit u-label-top">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Добавить заказ" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
|
@ -1,5 +0,0 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
@ -20,7 +20,9 @@
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateReceiving" class="btn btn-primary">Создать новое получение</a>
|
||||
<form action="CreateReceiving" method="post">
|
||||
<button type="submit" class="btn btn-primary">Создать новое получение</button>
|
||||
</form>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -20,14 +20,12 @@
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateComponent">Создать заказ</a>
|
||||
<a asp-action="CreateOrder">Создать заказ</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="EditComponent">Изменить заказ</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="DeleteComponent">Удалить заказ</a>
|
||||
<a asp-action="AddAssemblyToOrder">Добавить сборки к заказу</a>
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -60,10 +58,10 @@
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
</td
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateCreate)
|
||||
</td
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateImplement)
|
||||
</td>
|
||||
|
Loading…
Reference in New Issue
Block a user