Some seller app (full this time, i think)
This commit is contained in:
parent
fbe2269275
commit
d6c3358821
@ -35,7 +35,7 @@ namespace ComputerStoreDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Product)
|
||||
.Where(x =>
|
||||
(!model.ID.HasValue || x.ID == model.ID) &&
|
||||
(!model.OrderID.HasValue || x.OrderID == model.OrderID) &&
|
||||
(x.OrderID == model.OrderID) &&
|
||||
(!model.ProductID.HasValue || x.Products.FirstOrDefault(y => y.ProductID == model.ProductID) != null))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -78,7 +78,7 @@ namespace ComputerStoreDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
var consignment = context.Consignments.Include(x => x.Products).FirstOrDefault(x => x.ID == model.ID);
|
||||
var consignment = context.Consignments.Include(x => x.Products).ThenInclude(x => x.Product).FirstOrDefault(x => x.ID == model.ID);
|
||||
if (consignment == null)
|
||||
{
|
||||
return null;
|
||||
|
@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -19,7 +20,9 @@ namespace ComputerStoreDatabaseImplement.Implements
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Orders.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.Include(x => x._requests)
|
||||
.ThenInclude(x => x.Products)
|
||||
.Include(y => y._requests)
|
||||
.ThenInclude(y => y.PCs)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -30,7 +33,9 @@ namespace ComputerStoreDatabaseImplement.Implements
|
||||
return context.Orders
|
||||
.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.ThenInclude(x => x.Products)
|
||||
.Include(x => x._requests)
|
||||
.ThenInclude(x => x.PCs)
|
||||
.Where(x =>
|
||||
(!model.ID.HasValue ||
|
||||
x.ID == model.ID) &&
|
||||
@ -51,7 +56,9 @@ namespace ComputerStoreDatabaseImplement.Implements
|
||||
using var context = new ComputerStoreDatabase();
|
||||
return context.Orders.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.ThenInclude(x => x.Products)
|
||||
.Include(x => x._requests)
|
||||
.ThenInclude(x => x.PCs)
|
||||
.FirstOrDefault(x =>
|
||||
(!model.ID.HasValue ||
|
||||
x.ID == model.ID) &&
|
||||
@ -92,8 +99,11 @@ namespace ComputerStoreDatabaseImplement.Implements
|
||||
using var context = new ComputerStoreDatabase();
|
||||
|
||||
var order = context.Orders
|
||||
.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.ThenInclude(x => x.Products)
|
||||
.Include(x => x._requests)
|
||||
.ThenInclude(x => x.PCs)
|
||||
.FirstOrDefault(x => x.ID == model.ID);
|
||||
if (order == null)
|
||||
{
|
||||
@ -107,7 +117,9 @@ namespace ComputerStoreDatabaseImplement.Implements
|
||||
|
||||
return context.Orders.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.ThenInclude(x => x.Products)
|
||||
.Include(x => x._requests)
|
||||
.ThenInclude(x => x.PCs)
|
||||
.FirstOrDefault(x => x.ID == model.ID)?
|
||||
.GetViewModel;
|
||||
}
|
||||
@ -118,7 +130,9 @@ namespace ComputerStoreDatabaseImplement.Implements
|
||||
|
||||
var order = context.Orders.Include(x => x.Seller)
|
||||
.Include(x => x._consignments)
|
||||
.ThenInclude(x => x.Products)
|
||||
.Include(x => x._requests)
|
||||
.ThenInclude(x => x.PCs)
|
||||
.FirstOrDefault(x => x.ID == model.ID);
|
||||
if (order != null)
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ namespace ComputerStoreDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x =>
|
||||
(!model.ID.HasValue || x.ID == model.ID) &&
|
||||
(!model.OrderID.HasValue || x.OrderID == model.OrderID) &&
|
||||
(x.OrderID == model.OrderID) &&
|
||||
(!model.PCID.HasValue || x.PCID == model.PCID))
|
||||
.Select(y => y.GetViewModel)
|
||||
.ToList();
|
||||
|
@ -16,7 +16,7 @@ namespace ComputerStoreDatabaseImplement.Models
|
||||
{
|
||||
public int ID { get; private set; }
|
||||
|
||||
public int? OrderID { get; private set; }
|
||||
public int? OrderID { get; set; }
|
||||
public virtual Order? Order { get; set; }
|
||||
|
||||
[Required]
|
||||
@ -84,6 +84,7 @@ namespace ComputerStoreDatabaseImplement.Models
|
||||
{
|
||||
context.ConsignmentProducts.RemoveRange(consignmentProducts.Where(rec => !model.ConsignmentProducts.ContainsKey(rec.ProductID)));
|
||||
context.SaveChanges();
|
||||
consignmentProducts = context.ConsignmentProducts.Where(rec => rec.ConsignmentID == model.ID).ToList();
|
||||
foreach (var updateProduct in consignmentProducts)
|
||||
{
|
||||
updateProduct.Count = model.ConsignmentProducts[updateProduct.ProductID].Item2;
|
||||
|
@ -19,7 +19,7 @@ namespace ComputerStoreDatabaseImplement.Models
|
||||
{
|
||||
public int ID { get; private set; }
|
||||
|
||||
public int? OrderID { get; private set; }
|
||||
public int? OrderID { get; set; }
|
||||
public virtual Order? Order { get; set; }
|
||||
|
||||
public int? PCID { get; private set; }
|
||||
|
@ -21,8 +21,4 @@
|
||||
<ProjectReference Include="..\ComputerStoreDatabaseImplement\ComputerStoreDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Views\Order\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,6 +1,8 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreBusinessLogic.BusinessLogic;
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDatabaseImplement.Models;
|
||||
using ComputerStoreDataModels.Models;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
@ -145,6 +147,12 @@ namespace ComputerStoreSellerApp.Controllers
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
if (selectedProducts.Count == 0)
|
||||
{
|
||||
TempData.Add("error", "Партия должна содержать продукты");
|
||||
return RedirectToAction("CreatePage", "Consignment");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
double tmpPrice = 0;
|
||||
@ -178,6 +186,15 @@ namespace ComputerStoreSellerApp.Controllers
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
if (selectedProducts.Count == 0)
|
||||
{
|
||||
TempData.Add("error", "Партия должна содержать продукты");
|
||||
ViewData["currentConsignment"] = _consignmentLogic.ReadElement(new ConsignmentSearchModel() { ID = id });
|
||||
ViewData["products"] = _productLogic.ReadList(null);
|
||||
ViewData["selectedProducts"] = selectedProducts;
|
||||
return View("Views/Consignment/Create.cshtml");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
double tmpPrice = 0;
|
||||
@ -219,26 +236,26 @@ namespace ComputerStoreSellerApp.Controllers
|
||||
return RedirectToAction("List", "Consignment", null);
|
||||
}
|
||||
|
||||
//[HttpPost("[controller]/[action]/{selectedproductid}/{currentconsignmentid}")]
|
||||
//public IActionResult DeleteProduct(int selectedproductid, int currentconsignmentid)
|
||||
//{
|
||||
// if (!HttpContext.Session.Keys.Contains("login"))
|
||||
// {
|
||||
// return RedirectToAction("Login", "Auth");
|
||||
// }
|
||||
[HttpPost("[controller]/[action]/{selectedproductid}/{currentconsignmentid}")]
|
||||
public IActionResult DeleteProduct(int selectedproductid, int currentconsignmentid)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
// selectedProducts.Remove(selectedProducts.FirstOrDefault(x => x.productId == selectedproductid && x.count > 0));
|
||||
// if (currentconsignmentid > 0)
|
||||
// {
|
||||
// ViewData["currentConsignment"] = _consignmentLogic.ReadElement(new ConsignmentSearchModel() { ID = currentconsignmentid });
|
||||
// ViewData["products"] = _productLogic.ReadList(null);
|
||||
// ViewData["selectedProducts"] = selectedProducts;
|
||||
// return View("Views/Consignment/Create.cshtml");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return RedirectToAction("CreatePage", "Consignment");
|
||||
// }
|
||||
//}
|
||||
selectedProducts.Remove(selectedProducts.FirstOrDefault(x => x.productId == selectedproductid && x.count > 0));
|
||||
if (currentconsignmentid > 0)
|
||||
{
|
||||
ViewData["currentConsignment"] = _consignmentLogic.ReadElement(new ConsignmentSearchModel() { ID = currentconsignmentid });
|
||||
ViewData["products"] = _productLogic.ReadList(null);
|
||||
ViewData["selectedProducts"] = selectedProducts;
|
||||
return View("Views/Consignment/Create.cshtml");
|
||||
}
|
||||
else
|
||||
{
|
||||
return RedirectToAction("CreatePage", "Consignment");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
407
ComputerStoreSellerApp/Controllers/OrderController.cs
Normal file
407
ComputerStoreSellerApp/Controllers/OrderController.cs
Normal file
@ -0,0 +1,407 @@
|
||||
using ComputerStoreBusinessLogic.BusinessLogic;
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDataModels.Enums;
|
||||
using ComputerStoreDataModels.Models;
|
||||
using DocumentFormat.OpenXml.Office2013.Word;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ComputerStoreSellerApp.Controllers
|
||||
{
|
||||
public class OrderController : Controller
|
||||
{
|
||||
private IOrderLogic _orderLogic;
|
||||
private IConsignmentLogic _consignmentLogic;
|
||||
private IRequestLogic _requestLogic;
|
||||
private ISellerLogic _sellerLogic;
|
||||
|
||||
private static List<int> selectedConsignments = new();
|
||||
private static List<int> selectedRequests = new();
|
||||
|
||||
public OrderController(IOrderLogic orderLogic, IConsignmentLogic consignmentLogic, IRequestLogic requestLogic, ISellerLogic sellerLogic)
|
||||
{
|
||||
_orderLogic = orderLogic;
|
||||
_consignmentLogic = consignmentLogic;
|
||||
_requestLogic = requestLogic;
|
||||
_sellerLogic = sellerLogic;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("[controller]/[action]")]
|
||||
public IActionResult AddConsignment(int consignment)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
if (!selectedConsignments.Contains(consignment))
|
||||
{
|
||||
selectedConsignments.Add(consignment);
|
||||
}
|
||||
|
||||
return RedirectToAction("CreatePage", "Order");
|
||||
}
|
||||
|
||||
[HttpPost("[controller]/[action]")]
|
||||
public IActionResult UpdateConsignment(int consignment, int id)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
if (!selectedConsignments.Contains(consignment))
|
||||
{
|
||||
selectedConsignments.Add(consignment);
|
||||
}
|
||||
|
||||
ViewData["currentOrder"] = _orderLogic.ReadElement(new OrderSearchModel() { ID = id });
|
||||
var tmpconsignments = new List<ConsignmentViewModel>();
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = null })!);
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = id })!);
|
||||
ViewData["consignments"] = tmpconsignments;
|
||||
|
||||
var tmprequests = new List<RequestViewModel>();
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = null, PCID = null })!);
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = id, PCID = null })!);
|
||||
ViewData["requests"] = tmprequests;
|
||||
|
||||
ViewData["selectedConsignments"] = selectedConsignments;
|
||||
ViewData["selectedRequests"] = selectedRequests;
|
||||
|
||||
return View("Views/Order/Create.cshtml");
|
||||
}
|
||||
|
||||
[HttpPost("[controller]/[action]/{selectedconsignmentid}/{currentorderid}")]
|
||||
public IActionResult DeleteConsignment(int selectedconsignmentid, int currentorderid)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
selectedConsignments.Remove(selectedconsignmentid);
|
||||
if (currentorderid > 0)
|
||||
{
|
||||
ViewData["currentOrder"] = _orderLogic.ReadElement(new OrderSearchModel() { ID = currentorderid });
|
||||
|
||||
var tmpconsignments = new List<ConsignmentViewModel>();
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = null })!);
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = currentorderid })!);
|
||||
ViewData["consignments"] = tmpconsignments;
|
||||
|
||||
var tmprequests = new List<RequestViewModel>();
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = null, PCID = null })!);
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = currentorderid, PCID = null })!);
|
||||
ViewData["requests"] = tmprequests;
|
||||
|
||||
ViewData["selectedConsignments"] = selectedConsignments;
|
||||
ViewData["selectedRequests"] = selectedRequests;
|
||||
return View("Views/Order/Create.cshtml");
|
||||
}
|
||||
else
|
||||
{
|
||||
return RedirectToAction("CreatePage", "Order");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("[controller]/[action]")]
|
||||
public IActionResult AddRequest(int request)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
if (!selectedRequests.Contains(request))
|
||||
{
|
||||
selectedRequests.Add(request);
|
||||
}
|
||||
|
||||
return RedirectToAction("CreatePage", "Order");
|
||||
}
|
||||
|
||||
[HttpPost("[controller]/[action]")]
|
||||
public IActionResult UpdateRequest(int request, int id)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
if (!selectedRequests.Contains(request))
|
||||
{
|
||||
selectedRequests.Add(request);
|
||||
}
|
||||
|
||||
ViewData["currentOrder"] = _orderLogic.ReadElement(new OrderSearchModel() { ID = id });
|
||||
var tmpconsignments = new List<ConsignmentViewModel>();
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = null })!);
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = id })!);
|
||||
ViewData["consignments"] = tmpconsignments;
|
||||
|
||||
var tmprequests = new List<RequestViewModel>();
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = null, PCID = null })!);
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = id, PCID = null })!);
|
||||
ViewData["requests"] = tmprequests;
|
||||
|
||||
ViewData["selectedConsignments"] = selectedConsignments;
|
||||
ViewData["selectedRequests"] = selectedRequests;
|
||||
|
||||
return View("Views/Order/Create.cshtml");
|
||||
}
|
||||
|
||||
[HttpPost("[controller]/[action]/{selectedrequestid}/{currentorderid}")]
|
||||
public IActionResult DeleteRequest(int selectedrequestid, int currentorderid)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
selectedRequests.Remove(selectedrequestid);
|
||||
if (currentorderid > 0)
|
||||
{
|
||||
ViewData["currentOrder"] = _orderLogic.ReadElement(new OrderSearchModel() { ID = currentorderid });
|
||||
var tmpconsignments = new List<ConsignmentViewModel>();
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = null })!);
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = currentorderid })!);
|
||||
ViewData["consignments"] = tmpconsignments;
|
||||
|
||||
var tmprequests = new List<RequestViewModel>();
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = null, PCID = null })!);
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = currentorderid, PCID = null })!);
|
||||
ViewData["requests"] = tmprequests;
|
||||
ViewData["selectedConsignments"] = selectedConsignments;
|
||||
ViewData["selectedRequests"] = selectedRequests;
|
||||
return View("Views/Order/Create.cshtml");
|
||||
}
|
||||
else
|
||||
{
|
||||
return RedirectToAction("CreatePage", "Order");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("[controller]/[action]")]
|
||||
public IActionResult List()
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
selectedConsignments.Clear();
|
||||
selectedRequests.Clear();
|
||||
ViewData["orders"] = _orderLogic.ReadList(null);
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet("[controller]/[action]/{id}")]
|
||||
public IActionResult View(int id)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
var order = _orderLogic.ReadElement(new OrderSearchModel() { ID = id });
|
||||
|
||||
if (order is null)
|
||||
{
|
||||
TempData.Add("error", "Заказа с таким идентификатором не существует");
|
||||
return RedirectToAction("List", "Order", null);
|
||||
}
|
||||
|
||||
ViewData["currentOrder"] = order;
|
||||
var tmpconsignments = new List<ConsignmentViewModel>();
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = null })!);
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = id })!);
|
||||
ViewData["consignments"] = tmpconsignments;
|
||||
|
||||
var tmprequests = new List<RequestViewModel>();
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = null, PCID = null })!);
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = id, PCID = null })!);
|
||||
ViewData["requests"] = tmprequests;
|
||||
|
||||
if (order.OrderConsignments != null && order.OrderConsignments.Count > 0)
|
||||
{
|
||||
selectedConsignments.AddRange(order.OrderConsignments.Select(x => x.ID));
|
||||
}
|
||||
if (order.OrderRequests != null && order.OrderRequests.Count > 0)
|
||||
{
|
||||
selectedRequests.AddRange(order.OrderRequests.Select(x => x.ID));
|
||||
}
|
||||
|
||||
ViewData["selectedConsignments"] = selectedConsignments;
|
||||
ViewData["selectedRequests"] = selectedRequests;
|
||||
|
||||
return View("Views/Order/Create.cshtml");
|
||||
}
|
||||
|
||||
[HttpGet("[controller]/[action]")]
|
||||
public IActionResult CreatePage()
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
ViewData["selectedConsignments"] = selectedConsignments;
|
||||
ViewData["selectedRequests"] = selectedRequests;
|
||||
ViewData["consignments"] = _consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = null});
|
||||
ViewData["requests"] = _requestLogic.ReadList(new RequestSearchModel() { OrderID = null });
|
||||
|
||||
return View("Views/Order/Create.cshtml");
|
||||
}
|
||||
|
||||
[HttpPost("[controller]/[action]")]
|
||||
public IActionResult Create()
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
if (selectedConsignments.Count == 0 && selectedRequests.Count == 0)
|
||||
{
|
||||
TempData.Add("error", "Заказ должен содержать партию или заявку");
|
||||
return RedirectToAction("CreatePage", "Order");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
double tmpPrice = 0;
|
||||
foreach (var item in selectedConsignments)
|
||||
{
|
||||
tmpPrice += _consignmentLogic.ReadElement(new ConsignmentSearchModel() { ID = item })!.Price;
|
||||
}
|
||||
foreach (var item in selectedRequests)
|
||||
{
|
||||
tmpPrice += _requestLogic.ReadElement(new RequestSearchModel() { ID = item })!.Price;
|
||||
}
|
||||
|
||||
_orderLogic.CreateOrder(new OrderBindingModel()
|
||||
{
|
||||
Price = tmpPrice,
|
||||
OrderConsignments = selectedConsignments.Select(x => (IConsignmentModel)_consignmentLogic.ReadElement(new ConsignmentSearchModel() { ID = x })!).ToList(),
|
||||
OrderRequests = selectedRequests.Select(x => (IRequestModel)_requestLogic.ReadElement(new RequestSearchModel() { ID = x })!).ToList(),
|
||||
SellerID = _sellerLogic.ReadElement(new SellerSearchModel() { Username = HttpContext.Session.GetString("login")!.ToString() })!.ID,
|
||||
});
|
||||
selectedConsignments.Clear();
|
||||
selectedRequests.Clear();
|
||||
return RedirectToAction("List", "Order", null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TempData.Add("error", Regex.Replace(e.Message, "[a-zA-Z\\(\\)']", ""));
|
||||
selectedConsignments.Clear();
|
||||
selectedRequests.Clear();
|
||||
return RedirectToAction("List", "Order", null);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("[controller]/[action]/{id}")]
|
||||
public IActionResult Edit(int id)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
if (selectedConsignments.Count == 0 && selectedRequests.Count == 0)
|
||||
{
|
||||
TempData.Add("error", "Заказ должен содержать партию или заявку");
|
||||
ViewData["currentOrder"] = _orderLogic.ReadElement(new OrderSearchModel() { ID = id });
|
||||
var tmpconsignments = new List<ConsignmentViewModel>();
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = null })!);
|
||||
tmpconsignments.AddRange(_consignmentLogic.ReadList(new ConsignmentSearchModel() { OrderID = id })!);
|
||||
ViewData["consignments"] = tmpconsignments;
|
||||
|
||||
var tmprequests = new List<RequestViewModel>();
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = null, PCID = null })!);
|
||||
tmprequests.AddRange(_requestLogic.ReadList(new RequestSearchModel() { OrderID = id, PCID = null })!);
|
||||
ViewData["requests"] = tmprequests;
|
||||
|
||||
ViewData["selectedConsignments"] = selectedConsignments;
|
||||
ViewData["selectedRequests"] = selectedRequests;
|
||||
|
||||
return View("Views/Order/Create.cshtml");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
double tmpPrice = 0;
|
||||
foreach (var item in selectedConsignments)
|
||||
{
|
||||
tmpPrice += _consignmentLogic.ReadElement(new ConsignmentSearchModel() { ID = item })!.Price;
|
||||
}
|
||||
foreach (var item in selectedRequests)
|
||||
{
|
||||
tmpPrice += _requestLogic.ReadElement(new RequestSearchModel() { ID = item })!.Price;
|
||||
}
|
||||
|
||||
_orderLogic.UpdateOrder(new OrderBindingModel()
|
||||
{
|
||||
ID = id,
|
||||
Price = tmpPrice,
|
||||
Status = _orderLogic.ReadElement(new OrderSearchModel() { ID = id })!.Status,
|
||||
DateCreate = _orderLogic.ReadElement(new OrderSearchModel() { ID = id })!.DateCreate,
|
||||
DateImplement = _orderLogic.ReadElement(new OrderSearchModel() { ID = id })!.DateImplement,
|
||||
SellerID = _orderLogic.ReadElement(new OrderSearchModel() { ID= id })!.SellerID,
|
||||
OrderConsignments = selectedConsignments.Select(x => (IConsignmentModel)_consignmentLogic.ReadElement(new ConsignmentSearchModel() { ID = x })!).ToList(),
|
||||
OrderRequests = selectedRequests.Select(x => (IRequestModel)_requestLogic.ReadElement(new RequestSearchModel() { ID = x })!).ToList(),
|
||||
});
|
||||
selectedConsignments.Clear();
|
||||
selectedRequests.Clear();
|
||||
return RedirectToAction("List", "Order", null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TempData.Add("error", Regex.Replace(e.Message, "[a-zA-Z\\(\\)']", ""));
|
||||
return RedirectToAction("View", "Order", new { id = id });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("[controller]/[action]/{id}")]
|
||||
public IActionResult Delete(int id)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
_orderLogic.DeleteOrder(new OrderBindingModel() { ID = id });
|
||||
|
||||
return RedirectToAction("List", "Order", null);
|
||||
}
|
||||
|
||||
[HttpPost("[controller]/[action]/{id}")]
|
||||
public IActionResult UpdateStatus(int id)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
var curOrder = _orderLogic.ReadElement(new OrderSearchModel() { ID = id })!;
|
||||
if (curOrder.Status == OrderStatus.Accepted)
|
||||
{
|
||||
_orderLogic.TakeOrderInProcess(new OrderBindingModel() { ID = id });
|
||||
}
|
||||
if (curOrder.Status == OrderStatus.InProcess)
|
||||
{
|
||||
_orderLogic.TakeOrderReady(new OrderBindingModel() { ID = id });
|
||||
}
|
||||
if (curOrder.Status == OrderStatus.Ready)
|
||||
{
|
||||
_orderLogic.TakeOrderGiven(new OrderBindingModel() { ID = id });
|
||||
}
|
||||
|
||||
return RedirectToAction("List", "Order", null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreBusinessLogic.BusinessLogic;
|
||||
using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.BusinessLogicContracts;
|
||||
using ComputerStoreContracts.SearchModels;
|
||||
using ComputerStoreDataModels.Models;
|
||||
@ -142,6 +143,12 @@ namespace ComputerStoreSellerApp.Controllers
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
if (selectedComponents.Count == 0)
|
||||
{
|
||||
TempData.Add("error", "Заявка должна содержать компоненты");
|
||||
return RedirectToAction("CreatePage", "Request");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
double tmpPrice = 0;
|
||||
@ -176,6 +183,15 @@ namespace ComputerStoreSellerApp.Controllers
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
if (selectedComponents.Count == 0)
|
||||
{
|
||||
TempData.Add("error", "Заявка должна содержать компоненты");
|
||||
ViewData["currentRequest"] = _requestLogic.ReadElement(new RequestSearchModel() { ID = id });
|
||||
ViewData["components"] = _componentLogic.ReadList(null);
|
||||
ViewData["selectedComponents"] = selectedComponents;
|
||||
return View("Views/Request/Create.cshtml");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
double tmpPrice = 0;
|
||||
@ -218,5 +234,27 @@ namespace ComputerStoreSellerApp.Controllers
|
||||
|
||||
return RedirectToAction("List", "Request", null);
|
||||
}
|
||||
|
||||
[HttpPost("[controller]/[action]/{selectedcomponentid}/{currentrequestid}")]
|
||||
public IActionResult DeleteComponent(int selectedcomponentid, int currentrequestid)
|
||||
{
|
||||
if (!HttpContext.Session.Keys.Contains("login"))
|
||||
{
|
||||
return RedirectToAction("Login", "Auth");
|
||||
}
|
||||
|
||||
selectedComponents.Remove(selectedComponents.FirstOrDefault(x => x.componentId == selectedcomponentid && x.count > 0));
|
||||
if (currentrequestid > 0)
|
||||
{
|
||||
ViewData["currentRequest"] = _requestLogic.ReadElement(new RequestSearchModel() { ID = currentrequestid });
|
||||
ViewData["components"] = _componentLogic.ReadList(null);
|
||||
ViewData["selectedComponents"] = selectedComponents;
|
||||
return View("Views/Request/Create.cshtml");
|
||||
}
|
||||
else
|
||||
{
|
||||
return RedirectToAction("CreatePage", "Request");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,16 +4,16 @@
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Партия";
|
||||
//var currentConsignment = TempData["currentConsignment"] is null ? null : JsonConvert.DeserializeObject<ConsignmentViewModel>((string)TempData["currentConsignment"]!);
|
||||
var currentConsignment = ViewData["currentConsignment"] as ConsignmentViewModel;
|
||||
|
||||
//var products = JsonConvert.DeserializeObject<List<ProductViewModel>>((string)TempData["products"]!);
|
||||
var products = ViewData["products"] as List<ProductViewModel>;
|
||||
|
||||
//var selectedProducts = JsonConvert.DeserializeObject<List<(int productId, int count)>>((string)TempData["selectedProducts"]!);
|
||||
var selectedProducts = ViewData["selectedProducts"] as List<(int productId, int count)>;
|
||||
}
|
||||
<div class="row is-vertical-align">
|
||||
@{
|
||||
if (currentConsignment is null || currentConsignment.OrderID is null)
|
||||
{
|
||||
<div class="row is-vertical-align">
|
||||
<div class="col"></div>
|
||||
|
||||
<form method="post" action="@(currentConsignment is null ? Url.Action("AddProduct", "Consignment") : Url.Action("UpdateProduct", "Consignment", new { id = currentConsignment.ID }))">
|
||||
@ -57,8 +57,9 @@
|
||||
</form>
|
||||
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
}
|
||||
}
|
||||
<div class="row is-vertical-align mt-5">
|
||||
<div class="col"></div>
|
||||
<div class="card col-7 table table-striped">
|
||||
@ -76,6 +77,16 @@
|
||||
<td class="h4">@products.FirstOrDefault(x => x.ID == selectedprod.productId)?.Name</td>
|
||||
<td class="h4">@selectedprod.count</td>
|
||||
<td class="h4">@(products.FirstOrDefault(x => x.ID == selectedprod.productId)?.Price * selectedprod.count)</td>
|
||||
@{
|
||||
if (currentConsignment is null || currentConsignment.OrderID is null)
|
||||
{
|
||||
<td>
|
||||
<form class="h4" action="@Url.Action("DeleteProduct", "Consignment", new {selectedproductid = selectedprod.productId, currentconsignmentid = (currentConsignment is null ? -1 : currentConsignment.ID)})" method="POST">
|
||||
<button type="submit" class="button primary outline">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
}
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
|
@ -9,18 +9,18 @@
|
||||
|
||||
<div class="row is-vertical-align">
|
||||
<div class="col"></div>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Consignment" asp-action="CreatePage">Создать</a>
|
||||
<a class="nav-link text-dark is-center" asp-area="" asp-controller="Consignment" asp-action="CreatePage">Создать</a>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row is-vertical-align mt-5">
|
||||
<div class="col"></div>
|
||||
<div class="card col-10 table table-striped">
|
||||
<div class="card col-12 table table-striped">
|
||||
<h2 class="is-center mb-4">Все партии</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="h4">Номер</th>
|
||||
<th class="h4">Номер заказа</th>
|
||||
<th class="h4">№</th>
|
||||
<th class="h4">№ заказа</th>
|
||||
<th class="h4">Стоимость</th>
|
||||
<th class="h4">Товары</th>
|
||||
</tr>
|
||||
@ -32,9 +32,9 @@
|
||||
<td class="h4">@(consignment.OrderID == null ? "" : consignment.OrderID)</td>
|
||||
<td class="h4">@consignment.Price</td>
|
||||
@{
|
||||
var productsString = string.Join(", ", consignment.ConsignmentProducts.Select(m => m.Value.Item1.Name.ToLower()));
|
||||
var productsString = string.Join("<br/>", consignment.ConsignmentProducts.Select(m => (m.Value.Item1.Name.ToLower() + " " + m.Value.Item2.ToString())));
|
||||
}
|
||||
<td class="h4">@productsString</td>
|
||||
<td class="h4">@Html.Raw(productsString)</td>
|
||||
<td>
|
||||
<div class="row">
|
||||
<a class="button primary outline col" asp-area="" asp-controller="Consignment" asp-action="View" asp-route-id="@consignment.ID">Посмотреть</a>
|
||||
|
154
ComputerStoreSellerApp/Views/Order/Create.cshtml
Normal file
154
ComputerStoreSellerApp/Views/Order/Create.cshtml
Normal file
@ -0,0 +1,154 @@
|
||||
@using Newtonsoft.Json
|
||||
@using ComputerStoreContracts.ViewModels;
|
||||
@inject IHttpContextAccessor Accessor;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Заказ";
|
||||
var currentOrder = ViewData["currentOrder"] as OrderViewModel;
|
||||
|
||||
var consignments = ViewData["consignments"] as List<ConsignmentViewModel>;
|
||||
var requests = ViewData["requests"] as List<RequestViewModel>;
|
||||
|
||||
var selectedConsignments = ViewData["selectedConsignments"] as List<int>;
|
||||
var selectedRequests = ViewData["selectedRequests"] as List<int>;
|
||||
}
|
||||
@{
|
||||
if (currentOrder is null || currentOrder.Status == ComputerStoreDataModels.Enums.OrderStatus.Accepted)
|
||||
{
|
||||
<div class="row is-vertical-align">
|
||||
<h3 class="is-center mb-5">@(currentOrder is not null ? "Просмотр заказа" : "Создать заказ")</h3>
|
||||
@{
|
||||
if (TempData.Keys.Contains("error"))
|
||||
{
|
||||
<div class="alert alert-danger mb-3 h4" role="alert">
|
||||
@TempData["error"]
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
<form method="post" action="@(currentOrder is null ? Url.Action("AddConsignment", "Order") : Url.Action("UpdateConsignment", "Order", new { id = currentOrder.ID }))">
|
||||
<div class="row mb-3">
|
||||
<label class="h4">
|
||||
Партия:
|
||||
<select type="text" id="consignment" name="consignment">
|
||||
@{
|
||||
foreach (var consignment in consignments!)
|
||||
{
|
||||
var productsString = "№" + consignment.ID.ToString() + ": " + string.Join(", ", consignment.ConsignmentProducts.Select(m => (m.Value.Item1.Name.ToLower() + " " + m.Value.Item2.ToString())));
|
||||
<option value="@consignment.ID">@Html.Raw(productsString)</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="row mb-5">
|
||||
<button class="button primary is-center" type="submit">Добавить партию</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form method="post" action="@(currentOrder is null ? Url.Action("AddRequest", "Order") : Url.Action("UpdateRequest", "Order", new { id = currentOrder.ID }))">
|
||||
<div class="row mb-3">
|
||||
<label class="h4">
|
||||
Заявка:
|
||||
<select type="text" id="request" name="request">
|
||||
@{
|
||||
foreach (var request in requests!)
|
||||
{
|
||||
var componentsString = "№" + request.ID.ToString() + ": " + string.Join(", ", request.RequestComponents.Select(m => (m.Item1.Name.ToLower() + " " + m.Item2.ToString())));
|
||||
<option value="@request.ID">@Html.Raw(componentsString)</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="row mb-5">
|
||||
<button class="button primary is-center" type="submit">Добавить заявку</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form class="row" method="post" action="@(currentOrder is null ? Url.Action("Create", "Order") : Url.Action("Edit", "Order", new { id = currentOrder.ID }))">
|
||||
<div class="row mb-5">
|
||||
<button class="button primary is-center" type="submit">@((currentOrder is not null) ? "Изменить" : "Создать")</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
<div class="row is-vertical-align mt-5">
|
||||
<div class="card col-12 table table-striped">
|
||||
<h2 class="is-center mb-4">Партии заказа</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="h4 col-2">№</th>
|
||||
<th class="h4 col-2">Товары</th>
|
||||
<th class="h4 col-2">Цена</th>
|
||||
</tr>
|
||||
@{
|
||||
foreach (var selectedcons in selectedConsignments!)
|
||||
{
|
||||
<tr>
|
||||
<td class="h4">@selectedcons</td>
|
||||
@{
|
||||
var productsString = string.Join("<br/>", consignments.FirstOrDefault(x => x.ID == selectedcons)!.ConsignmentProducts.Select(m => (m.Value.Item1.Name.ToLower() + " " + m.Value.Item2.ToString())));
|
||||
}
|
||||
<td class="h4">@Html.Raw(productsString)</td>
|
||||
<td class="h4">@consignments.FirstOrDefault(x => x.ID == selectedcons)?.Price.ToString()</td>
|
||||
@{
|
||||
if (currentOrder is null || currentOrder.Status == ComputerStoreDataModels.Enums.OrderStatus.Accepted)
|
||||
{
|
||||
<td>
|
||||
<form class="h4" action="@Url.Action("DeleteConsignment", "Order", new {selectedconsignmentid = selectedcons, currentorderid = (currentOrder is null ? -1 : currentOrder.ID)})" method="POST">
|
||||
<button type="submit" class="button primary outline">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
}
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row is-vertical-align mt-5">
|
||||
<div class="card col-12 table table-striped">
|
||||
<h2 class="is-center mb-4">Заявки заказа</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="h4 col-2">№</th>
|
||||
<th class="h4 col-2">Компоненты</th>
|
||||
<th class="h4 col-2">Цена</th>
|
||||
</tr>
|
||||
@{
|
||||
foreach (var selectedreq in selectedRequests!)
|
||||
{
|
||||
<tr>
|
||||
<td class="h4">@selectedreq</td>
|
||||
@{
|
||||
var componentsString = string.Join("<br/>", requests.FirstOrDefault(x => x.ID == selectedreq)!.RequestComponents.Select(m => (m.Item1.Name.ToLower() + " " + m.Item2.ToString())));
|
||||
}
|
||||
<td class="h4">@Html.Raw(componentsString)</td>
|
||||
<td class="h4">@requests.FirstOrDefault(x => x.ID == selectedreq)?.Price.ToString()</td>
|
||||
@{
|
||||
if (currentOrder is null || currentOrder.Status == ComputerStoreDataModels.Enums.OrderStatus.Accepted)
|
||||
{
|
||||
<td>
|
||||
<form class="h4" action="@Url.Action("DeleteRequest", "Order", new {selectedrequestid = selectedreq, currentorderid = (currentOrder is null ? -1 : currentOrder.ID)})" method="POST">
|
||||
<button type="submit" class="button primary outline">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
}
|
||||
}
|
||||
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
</script>
|
110
ComputerStoreSellerApp/Views/Order/List.cshtml
Normal file
110
ComputerStoreSellerApp/Views/Order/List.cshtml
Normal file
@ -0,0 +1,110 @@
|
||||
@using Newtonsoft.Json
|
||||
@using ComputerStoreContracts.ViewModels;
|
||||
@inject IHttpContextAccessor Accessor;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Заказы";
|
||||
var orders = ViewData["orders"] as List<OrderViewModel>;
|
||||
}
|
||||
|
||||
<div class="row is-vertical-align">
|
||||
<div class="col"></div>
|
||||
<a class="nav-link text-dark is-center" asp-area="" asp-controller="Order" asp-action="CreatePage">Создать</a>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row is-vertical-align mt-5">
|
||||
<div class="card col-12 table table-striped">
|
||||
<h2 class="is-center mb-4">Все заказы</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="h4">№</th>
|
||||
<th class="h4">№ партий</th>
|
||||
<th class="h4">№ заявок</th>
|
||||
<th class="h4">Стоимость</th>
|
||||
<th class="h4">Статус</th>
|
||||
<th class="h4">Дата принятия</th>
|
||||
<th class="h4">Дата выдачи</th>
|
||||
<th class="h4">Продавец</th>
|
||||
</tr>
|
||||
@{
|
||||
foreach (var order in orders!)
|
||||
{
|
||||
<tr>
|
||||
<td class="h4">@order.ID</td>
|
||||
@{
|
||||
var consignmentsString = order.OrderConsignments is not null ? string.Join(", ", order.OrderConsignments.Select(m => m.ID)) : "";
|
||||
}
|
||||
<td class="h4">@Html.Raw(consignmentsString)</td>
|
||||
@{
|
||||
var requestsString = order.OrderRequests is not null ? string.Join(", ", order.OrderRequests.Select(m => m.ID)) : "";
|
||||
}
|
||||
<td class="h4">@Html.Raw(requestsString)</td>
|
||||
<td class="h4">@order.Price</td>
|
||||
@{
|
||||
if (order.Status == ComputerStoreDataModels.Enums.OrderStatus.Accepted)
|
||||
{
|
||||
<td class="h4">Принят</td>
|
||||
}
|
||||
if (order.Status == ComputerStoreDataModels.Enums.OrderStatus.InProcess)
|
||||
{
|
||||
<td class="h4">В работе</td>
|
||||
}
|
||||
if (order.Status == ComputerStoreDataModels.Enums.OrderStatus.Ready)
|
||||
{
|
||||
<td class="h4">Готов</td>
|
||||
}
|
||||
if (order.Status == ComputerStoreDataModels.Enums.OrderStatus.Given)
|
||||
{
|
||||
<td class="h4">Выдан</td>
|
||||
}
|
||||
}
|
||||
<td class="h4">@(order.DateCreate.ToShortDateString() + " " + order.DateCreate.ToLongTimeString())</td>
|
||||
<td class="h4">@(order.DateImplement is null ? "" : ((DateTime)order.DateImplement).ToShortDateString() + " " + ((DateTime)order.DateImplement).ToLongTimeString())</td>
|
||||
<td class="h4">@order.SellerUsername</td>
|
||||
|
||||
<td>
|
||||
<div class="row">
|
||||
<a class="button primary outline col" asp-area="" asp-controller="Order" asp-action="View" asp-route-id="@order.ID">Посмотреть</a>
|
||||
</div>
|
||||
</td>
|
||||
@{
|
||||
if (order.Status == ComputerStoreDataModels.Enums.OrderStatus.Accepted)
|
||||
{
|
||||
<td>
|
||||
<form class="col" action="@Url.Action("UpdateStatus", "Order", new {id = order.ID})" method="POST">
|
||||
<button type="submit" class="button primary outline">Передать в работу</button>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form class="col" action="@Url.Action("Delete", "Order", new {id = order.ID})" method="POST">
|
||||
<button type="submit" class="button primary outline">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
}
|
||||
if (order.Status == ComputerStoreDataModels.Enums.OrderStatus.InProcess)
|
||||
{
|
||||
<td>
|
||||
<form class="col" action="@Url.Action("UpdateStatus", "Order", new {id = order.ID})" method="POST">
|
||||
<button type="submit" class="button primary outline">Выполнить</button>
|
||||
</form>
|
||||
</td>
|
||||
}
|
||||
if (order.Status == ComputerStoreDataModels.Enums.OrderStatus.Ready)
|
||||
{
|
||||
<td>
|
||||
<form class="col" action="@Url.Action("UpdateStatus", "Order", new {id = order.ID})" method="POST">
|
||||
<button type="submit" class="button primary outline">Выдать</button>
|
||||
</form>
|
||||
</td>
|
||||
}
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
</script>
|
@ -10,7 +10,10 @@
|
||||
|
||||
var selectedComponents = ViewData["selectedComponents"] as List<(int componentId, int count)>;
|
||||
}
|
||||
<div class="row is-vertical-align">
|
||||
@{
|
||||
if (currentRequest is null || currentRequest.OrderID is null)
|
||||
{
|
||||
<div class="row is-vertical-align">
|
||||
<div class="col"></div>
|
||||
|
||||
<form method="post" action="@(currentRequest is null ? Url.Action("AddComponent", "Request") : Url.Action("UpdateComponent", "Request", new { id = currentRequest.ID }))">
|
||||
@ -54,8 +57,9 @@
|
||||
</form>
|
||||
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
}
|
||||
}
|
||||
<div class="row is-vertical-align mt-5">
|
||||
<div class="col"></div>
|
||||
<div class="card col-7 table table-striped">
|
||||
@ -73,6 +77,16 @@
|
||||
<td class="h4">@components.FirstOrDefault(x => x.ID == selectedcomp.componentId)?.Name</td>
|
||||
<td class="h4">@selectedcomp.count</td>
|
||||
<td class="h4">@(components.FirstOrDefault(x => x.ID == selectedcomp.componentId)?.Price * selectedcomp.count)</td>
|
||||
@{
|
||||
if (currentRequest is null || currentRequest.OrderID is null)
|
||||
{
|
||||
<td>
|
||||
<form class="h4" action="@Url.Action("DeleteComponent", "Request", new {selectedcomponentid = selectedcomp.componentId, currentrequestid = (currentRequest is null ? -1 : currentRequest.ID)})" method="POST">
|
||||
<button type="submit" class="button primary outline">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
}
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
|
@ -9,18 +9,18 @@
|
||||
|
||||
<div class="row is-vertical-align">
|
||||
<div class="col"></div>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Request" asp-action="CreatePage">Создать</a>
|
||||
<a class="nav-link text-dark is-center" asp-area="" asp-controller="Request" asp-action="CreatePage">Создать</a>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row is-vertical-align mt-5">
|
||||
<div class="col"></div>
|
||||
<div class="card col-10 table table-striped">
|
||||
<div class="card col-12 table table-striped">
|
||||
<h2 class="is-center mb-4">Все заявки</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="h4">Номер</th>
|
||||
<th class="h4">Номер заказа</th>
|
||||
<th class="h4">№</th>
|
||||
<th class="h4">№ заказа</th>
|
||||
<th class="h4">Название ПК</th>
|
||||
<th class="h4">Стоимость</th>
|
||||
<th class="h4">Компоненты</th>
|
||||
@ -34,9 +34,9 @@
|
||||
<td class="h4">@(request.PCID == null ? "" : request.PCID)</td>
|
||||
<td class="h4">@request.Price</td>
|
||||
@{
|
||||
var componentsString = string.Join(", ", request.RequestComponents.Select(m => m.Item1.Name.ToLower()));
|
||||
var componentsString = string.Join("<br/>", request.RequestComponents.Select(m => (m.Item1.Name.ToLower() + " " + m.Item2.ToString())));
|
||||
}
|
||||
<td class="h4">@componentsString</td>
|
||||
<td class="h4">@Html.Raw(componentsString)</td>
|
||||
<td>
|
||||
<div class="row">
|
||||
<a class="button primary outline col" asp-area="" asp-controller="Request" asp-action="View" asp-route-id="@request.ID">Посмотреть</a>
|
||||
|
@ -47,6 +47,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Consignment" asp-action="List">Партии</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Auth" asp-action="Logout">Выйти</a>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user