776 lines
25 KiB
C#
776 lines
25 KiB
C#
using ComputerShopImplementerApp.Models;
|
||
using ComputerShopContracts.BindingModels;
|
||
using ComputerShopContracts.ViewModels;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using System.Diagnostics;
|
||
using ComputerShopDataModels.Enums;
|
||
using ComputerShopDataModels.Models;
|
||
using ComputerShopContracts.SearchModels;
|
||
using ComputerShopContracts.BusinessLogicContracts;
|
||
using DocumentFormat.OpenXml.Bibliography;
|
||
using Microsoft.AspNetCore.DataProtection.Repositories;
|
||
|
||
namespace ComputerShopImplementerApp.Controllers
|
||
{
|
||
public class HomeController : Controller
|
||
{
|
||
private readonly ILogger<HomeController> _logger;
|
||
private readonly IReportImplementerLogic _logic;
|
||
|
||
public HomeController(ILogger<HomeController> logger, IReportImplementerLogic logic)
|
||
{
|
||
_logger = logger;
|
||
_logic = logic;
|
||
}
|
||
|
||
public IActionResult Index()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
return View();
|
||
}
|
||
|
||
// ЗАКАЗЫ ЗАКАЗЫ ЗАКАЗЫ ЗАКАЗЫ ЗАКАЗЫ
|
||
|
||
public IActionResult Orders()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
return View(APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}"));
|
||
}
|
||
|
||
[HttpGet]
|
||
public OrderViewModel GetOrder(int orderId)
|
||
{
|
||
|
||
|
||
if (APIUser.User == null)
|
||
{
|
||
Response.Redirect("Enter");
|
||
}
|
||
var result = APIUser.GetRequest<OrderViewModel>($"api/order/getorder?id={orderId}");
|
||
if (result == null)
|
||
{
|
||
return default;
|
||
}
|
||
return result;
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
[HttpGet]
|
||
public IActionResult CreateOrder()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
|
||
[HttpPost]
|
||
public void CreateOrder(OrderStatus status, DateTime date)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
throw new Exception("Вход только авторизованным");
|
||
}
|
||
if (date != DateTime.MinValue)
|
||
{
|
||
APIUser.PostRequest("api/order/createorder", new OrderBindingModel
|
||
{
|
||
UserId = APIUser.User.Id,
|
||
Status = status,
|
||
DateCreate = date,
|
||
Sum = 0
|
||
});
|
||
}
|
||
Response.Redirect("Orders");
|
||
}
|
||
|
||
|
||
|
||
[HttpGet]
|
||
public IActionResult UpdateOrder()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||
//ViewBag.Statuses =
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public void UpdateOrder(int order, OrderStatus status, DateTime date, double sum)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
Response.Redirect("~/Home/Entry");
|
||
}
|
||
if (order > 0 && date != DateTime.MinValue)
|
||
{
|
||
APIUser.PostRequest("api/order/updateorder", new OrderBindingModel
|
||
{
|
||
Id = order,
|
||
UserId = APIUser.User.Id,
|
||
Status = status,
|
||
DateCreate = date,
|
||
Sum = sum
|
||
});
|
||
}
|
||
Response.Redirect("Orders");
|
||
}
|
||
|
||
|
||
[HttpGet]
|
||
public IActionResult DeleteOrder()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public void DeleteOrder(int order)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
Redirect("~/Home/Enter");
|
||
}
|
||
|
||
if (order > 0)
|
||
{
|
||
APIUser.PostRequest("api/order/deleteorder", new OrderBindingModel
|
||
{
|
||
Id = order
|
||
});
|
||
}
|
||
Response.Redirect("Orders");
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
// ПАРТИИ ТОВАРОВ ПАРТИИ ТОВАРОВ ПАРТИИ ТОВАРОВ ПАРТИИ ТОВАРОВ ПАРТИИ ТОВАРОВ
|
||
|
||
public async Task<IActionResult> Shipments()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
var shipments = await APIUser.GetRequestShipmentAsync<List<ShipmentViewModel>>($"api/shipment/getshipments?userId={APIUser.User.Id}");
|
||
|
||
return View(shipments);
|
||
}
|
||
|
||
[HttpGet]
|
||
public async Task<ShipmentViewModel> GetShipment(int shipmentId)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
Redirect("~/Home/Enter");
|
||
}
|
||
var result = await APIUser.GetRequestShipmentAsync<ShipmentViewModel>($"api/shipment/getshipment?id={shipmentId}");
|
||
if (result == null)
|
||
{
|
||
return default;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
[HttpGet]
|
||
public IActionResult CreateShipment()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||
return View();
|
||
}
|
||
|
||
|
||
[HttpPost]
|
||
public void CreateShipment(string providerName, DateTime date, int[] orders)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
Redirect("~/Home/Enter");
|
||
}
|
||
// Создаем словарь из выбранных заказов
|
||
var selectedOrders = new Dictionary<int, IOrderModel>();
|
||
foreach (var orderId in orders)
|
||
{
|
||
selectedOrders.Add(orderId, new OrderSearchModel { Id = orderId } as IOrderModel);
|
||
}
|
||
if (!string.IsNullOrEmpty(providerName) && date != DateTime.MinValue && APIUser.User != null)
|
||
{
|
||
APIUser.PostRequest("api/shipment/createshipment", new ShipmentBindingModel
|
||
{
|
||
UserId = APIUser.User.Id,
|
||
ProviderName = providerName,
|
||
DateShipment = date,
|
||
ShipmentOrders = selectedOrders
|
||
});
|
||
}
|
||
Response.Redirect("Shipments");
|
||
}
|
||
|
||
|
||
[HttpGet]
|
||
public async Task<IActionResult> UpdateShipment()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Shipments = await APIUser.GetRequestShipmentAsync<List<ShipmentViewModel>>($"api/shipment/getshipments?userId={APIUser.User.Id}");
|
||
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public void UpdateShipment(int shipment, string providerName, DateTime date, int[] orders)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
Redirect("~/Home/Enter");
|
||
}
|
||
var selectedOrders = new Dictionary<int, IOrderModel>();
|
||
foreach (var orderId in orders)
|
||
{
|
||
selectedOrders.Add(orderId, new OrderSearchModel { Id = orderId } as IOrderModel);
|
||
}
|
||
if (shipment > 0 && !string.IsNullOrEmpty(providerName) && date != DateTime.MinValue && APIUser.User != null)
|
||
{
|
||
APIUser.PostRequest("api/shipment/updateshipment", new ShipmentBindingModel
|
||
{
|
||
Id = shipment,
|
||
UserId = APIUser.User.Id,
|
||
ProviderName = providerName,
|
||
DateShipment = date,
|
||
ShipmentOrders = selectedOrders
|
||
});
|
||
}
|
||
Response.Redirect("Shipments");
|
||
}
|
||
|
||
[HttpGet]
|
||
public async Task<IActionResult> DeleteShipment()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Shipments = await APIUser.GetRequestShipmentAsync<List<ShipmentViewModel>>($"api/shipment/getshipments?userId={APIUser.User.Id}");
|
||
return View();
|
||
}
|
||
|
||
|
||
[HttpPost]
|
||
public async Task<IActionResult> DeleteShipment(int shipment)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
if (shipment > 0)
|
||
{
|
||
await APIUser.PostRequestAsync("api/shipment/deleteshipment", new ShipmentBindingModel
|
||
{
|
||
Id = shipment
|
||
});
|
||
}
|
||
return Redirect("Shipments");
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
// ЗАЯВКИ НА СБОРКИ ЗАЯВКИ НА СБОРКИ ЗАЯВКИ НА СБОРКИ ЗАЯВКИ НА СБОРКИ ЗАЯВКИ НА СБОРКИ
|
||
|
||
public async Task<IActionResult> Requests()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
var requests = await APIUser.GetRequestRequestAsync<List<RequestViewModel>>($"api/request/getrequests?userId={APIUser.User.Id}");
|
||
return View(requests);
|
||
}
|
||
|
||
|
||
[HttpGet]
|
||
public async Task<RequestViewModel> GetRequest(int requestId)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
Response.Redirect("~/Home/Enter");
|
||
}
|
||
var result = await APIUser.GetRequestRequestAsync<RequestViewModel>($"api/request/getrequest?id={requestId}");
|
||
if (result == null)
|
||
{
|
||
return default;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
|
||
[HttpGet]
|
||
public IActionResult CreateRequest()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||
return View();
|
||
}
|
||
|
||
|
||
[HttpPost]
|
||
public void CreateRequest(string clientFIO, DateTime date, int[] orders)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
Redirect("~/Home/Enter");
|
||
}
|
||
// Создаем словарь из выбранных заказов
|
||
var selectedOrders = new Dictionary<int, IOrderModel>();
|
||
foreach (var orderId in orders)
|
||
{
|
||
selectedOrders.Add(orderId, new OrderSearchModel { Id = orderId } as IOrderModel);
|
||
}
|
||
if (!string.IsNullOrEmpty(clientFIO) && date != DateTime.MinValue)
|
||
{
|
||
APIUser.PostRequest("api/request/createrequest", new RequestBindingModel
|
||
{
|
||
UserId = APIUser.User.Id,
|
||
ClientFIO = clientFIO,
|
||
DateRequest = date,
|
||
RequestOrders = selectedOrders
|
||
});
|
||
}
|
||
Response.Redirect("Requests");
|
||
}
|
||
|
||
|
||
[HttpGet]
|
||
public async Task<IActionResult> UpdateRequest()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Requests = await APIUser.GetRequestRequestAsync<List<RequestViewModel>>($"api/request/getrequests?userId={APIUser.User.Id}");
|
||
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public void UpdateRequest(int request, string clientFIO, DateTime date, int[] orders)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
Response.Redirect("~/Home/Enter");
|
||
}
|
||
|
||
var selectedOrders = new Dictionary<int, IOrderModel>();
|
||
foreach (var orderId in orders)
|
||
{
|
||
selectedOrders.Add(orderId, new OrderSearchModel { Id = orderId } as IOrderModel);
|
||
}
|
||
if (request > 0 && !string.IsNullOrEmpty(clientFIO) && date != DateTime.MinValue)
|
||
{
|
||
APIUser.PostRequest("api/request/updaterequest", new RequestBindingModel
|
||
{
|
||
Id = request,
|
||
UserId = APIUser.User.Id,
|
||
ClientFIO = clientFIO,
|
||
DateRequest = date,
|
||
RequestOrders = selectedOrders
|
||
});
|
||
}
|
||
Response.Redirect("Requests");
|
||
}
|
||
|
||
|
||
[HttpGet]
|
||
public async Task<IActionResult> ConnectRequestAssembly()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Requests = await APIUser.GetRequestRequestAsync<List<RequestViewModel>>($"api/request/getrequests?userId={APIUser.User.Id}");
|
||
ViewBag.Assemblies = APIUser.GetRequest<List<AssemblyViewModel>>($"api/assembly/getassemblies");
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public void ConnectRequestAssembly(int request, int assembly)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
Redirect("~/Home/Enter");
|
||
}
|
||
if (request > 0 && assembly > 0)
|
||
{
|
||
APIUser.PostRequest("api/request/connectRequestAssembly", new RequestBindingModel
|
||
{
|
||
Id = request,
|
||
AssemblyId = assembly
|
||
});
|
||
}
|
||
Response.Redirect("Requests");
|
||
}
|
||
|
||
|
||
|
||
|
||
[HttpGet]
|
||
public async Task<IActionResult> DeleteRequest()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
throw new Exception("Вход только авторизованным");
|
||
}
|
||
ViewBag.Requests = await APIUser.GetRequestRequestAsync<List<RequestViewModel>>($"api/request/getrequests?userId={APIUser.User.Id}");
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public async Task<IActionResult> DeleteRequest(int request)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
throw new Exception("Вход только авторизованным");
|
||
}
|
||
if (request > 0)
|
||
{
|
||
await APIUser.PostRequestAsync("api/request/deleterequest", new RequestBindingModel
|
||
{
|
||
Id = request
|
||
});
|
||
}
|
||
return RedirectToAction("Requests");
|
||
}
|
||
|
||
|
||
//ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ
|
||
|
||
[HttpGet]
|
||
public IActionResult ReportOrdersAssembliesToFile()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||
return View();
|
||
}
|
||
|
||
[HttpGet]
|
||
public IActionResult GetWordFile()
|
||
{
|
||
return PhysicalFile("C:\\!КУРСОВАЯ\\Сборки по выбранным заказам.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Сборки по выбранным заказам.docx");
|
||
}
|
||
|
||
public IActionResult GetExcelFile()
|
||
{
|
||
return PhysicalFile("C:\\!КУРСОВАЯ\\Сборки по выбранным заказам.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Сборки по выбранным заказам.xlsx");
|
||
}
|
||
|
||
[HttpPost]
|
||
public IActionResult ReportOrdersAssembliesToFile(int[] orders, string type)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
Redirect("Index");
|
||
}
|
||
if (orders.Length > 0 && !string.IsNullOrEmpty(type))
|
||
{
|
||
//Преобразование массива в список
|
||
List<int> ids = new List<int>();
|
||
foreach (var item in orders)
|
||
{
|
||
ids.Add(item);
|
||
}
|
||
|
||
if (type == "docx")
|
||
{
|
||
APIUser.PostRequest("api/order/createreporttowordfile", new ReportBindingModel
|
||
{
|
||
Ids = ids,
|
||
FileName = "C:\\!КУРСОВАЯ\\Сборки по выбранным заказам.docx"
|
||
});
|
||
return GetWordFile();
|
||
}
|
||
|
||
if (type == "xlsx")
|
||
{
|
||
APIUser.PostRequest("api/order/createreporttoexcelfile", new ReportBindingModel
|
||
{
|
||
Ids = ids,
|
||
FileName = "C:\\!КУРСОВАЯ\\Сборки по выбранным заказам.xlsx"
|
||
});
|
||
return GetExcelFile();
|
||
}
|
||
}
|
||
return Redirect("Index");
|
||
}
|
||
|
||
|
||
[HttpGet]
|
||
public IActionResult ReportOrdersByDates()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
return View();
|
||
}
|
||
|
||
[HttpGet]
|
||
public string GetOrdersReportByDates(DateTime dateFrom, DateTime dateTo)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
throw new Exception("Вход только авторизованным");
|
||
}
|
||
if (dateFrom != DateTime.MinValue && dateTo != DateTime.MinValue)
|
||
{
|
||
List<ReportOrdersViewModel> result;
|
||
result = _logic.GetReportOrdersByDates(new ReportBindingModel
|
||
{
|
||
UserId = APIUser.User.Id,
|
||
DateFrom = dateFrom,
|
||
DateTo = dateTo
|
||
});
|
||
string table = "";
|
||
table += $"<table class=\"u-table-entity\">";
|
||
table += "<colgroup>";
|
||
//ID заказа
|
||
table += "<col width=\"5%\" />";
|
||
//Дата заказа
|
||
table += "<col width=\"10%\" />";
|
||
//Стоимость заказа
|
||
table += "<col width=\"10%\" />";
|
||
//Статус заказа
|
||
table += "<col width=\"10%\" />";
|
||
//ID заявки
|
||
table += "<col width=\"5%\" />";
|
||
//ФИО клиента
|
||
table += "<col width=\"15%\" />";
|
||
//Дата заявки
|
||
table += "<col width=\"10%\" />";
|
||
//Название сборки
|
||
table += "<col width=\"15%\" />";
|
||
//Категория сборки
|
||
table += "<col width=\"10%\" />";
|
||
//Цена сборки
|
||
table += "<col width=\"10%\" />";
|
||
table += "</colgroup>";
|
||
table += "<thead class=\"u-custom-color-1 u-table-header u-table-header-1\">";
|
||
table += "<tr style=\"height: 31px\">";
|
||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">ID заказа</th>";
|
||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Дата заказа</th>";
|
||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Стоимость заказа</th>";
|
||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Статус заказа</th>";
|
||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">ID заявки</th>";
|
||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">ФИО клиента</th>";
|
||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Дата заявки</th>";
|
||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Название сборки</th>";
|
||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Категория сборки</th>";
|
||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Цена сборки</th>";
|
||
table += "</tr>";
|
||
table += "</thead>";
|
||
table += "<tbody class=\"u-table-body\">";
|
||
foreach (var order in result)
|
||
{
|
||
if (order.RequestsAssemblies.Count < 1)
|
||
{
|
||
table += "<tr style=\"height: 75px\">";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{order.OrderId.ToString()}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{order.DateCreateOrder.ToShortDateString()}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{order.OrderSum.ToString()}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{order.OrderStatus.ToString()}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{"Заказ без заявок"}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{"Неизвестно"}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{"Неизвестно"}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{"Неизвестно"}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{"Неизвестно"}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{"Неизвестно"}</td>";
|
||
table += "</tr>";
|
||
}
|
||
foreach (var request in order.RequestsAssemblies)
|
||
{
|
||
table += "<tr style=\"height: 75px\">";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{order.OrderId.ToString()}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{order.DateCreateOrder.ToShortDateString()}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{order.OrderSum.ToString()}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{order.OrderStatus.ToString()}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{request.RequestId.ToString()}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{request.ClientFIO.ToString()}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{request.DateRequest.ToShortDateString()}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{(string.IsNullOrEmpty(request.AssemblyName) ? "Сборка не привязана" : request.AssemblyName)}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{(string.IsNullOrEmpty(request.AssemblyCategory) ? "Неизвестная категория" : request.AssemblyCategory)}</td>";
|
||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{request.AssemblyPrice.ToString()}</td>";
|
||
table += "</tr>";
|
||
}
|
||
}
|
||
table += "</table>";
|
||
return table;
|
||
}
|
||
return "";
|
||
}
|
||
|
||
[HttpPost]
|
||
public void ReportOrdersByDates(DateTime dateFrom, DateTime dateTo)
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
throw new Exception("Вход только авторизованным");
|
||
}
|
||
if (dateFrom != DateTime.MinValue && dateTo != DateTime.MinValue)
|
||
{
|
||
APIUser.PostRequest("api/order/CreateReportToPDFFile", new ReportBindingModel
|
||
{
|
||
FileName = "C:\\!КУРСОВАЯ\\Отчёт за период.pdf",
|
||
DateFrom = dateFrom,
|
||
DateTo = dateTo,
|
||
UserId = APIUser.User.Id
|
||
});
|
||
APIUser.PostRequest("api/order/SendPDFToMail", new MailSendInfoBindingModel
|
||
{
|
||
MailAddress = APIUser.User.Email,
|
||
Subject = "Отчет за период",
|
||
Text = "Отчет по заказам с " + dateFrom.ToShortDateString() + " по " + dateTo.ToShortDateString()
|
||
});
|
||
}
|
||
Response.Redirect("Index");
|
||
}
|
||
|
||
|
||
// ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ
|
||
|
||
[HttpGet]
|
||
public IActionResult Privacy()
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
return Redirect("~/Home/Enter");
|
||
}
|
||
return View(APIUser.User);
|
||
}
|
||
|
||
[HttpPost]
|
||
public void Privacy(string login, string password, string email)
|
||
{
|
||
try
|
||
{
|
||
if (APIUser.User == null)
|
||
{
|
||
throw new Exception("Вход только авторизованным");
|
||
}
|
||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email))
|
||
{
|
||
throw new Exception("Введите логин, пароль и почту");
|
||
}
|
||
APIUser.PostRequest("api/user/updatedata", new UserBindingModel
|
||
{
|
||
Id = APIUser.User.Id,
|
||
Login = login,
|
||
Password = password,
|
||
Email = email
|
||
});
|
||
|
||
APIUser.User.Login = login;
|
||
APIUser.User.Password = password;
|
||
APIUser.User.Email = email;
|
||
Response.Redirect("Index");
|
||
}
|
||
catch (Exception)
|
||
{
|
||
Response.Redirect("Index");
|
||
}
|
||
}
|
||
|
||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||
public IActionResult Error()
|
||
{
|
||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||
}
|
||
|
||
[HttpGet]
|
||
public IActionResult Enter()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public void Enter(string login, string password)
|
||
{
|
||
try
|
||
{
|
||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||
{
|
||
throw new Exception("Введите логин и пароль");
|
||
}
|
||
APIUser.User = APIUser.GetRequest<UserViewModel>($"api/user/loginimplementer?login={login}&password={password}");
|
||
if (APIUser.User == null)
|
||
{
|
||
throw new Exception("Неверный логин/пароль");
|
||
}
|
||
Response.Redirect("Index");
|
||
}
|
||
catch (Exception)
|
||
{
|
||
Response.Redirect("Enter");
|
||
}
|
||
}
|
||
|
||
[HttpGet]
|
||
public IActionResult Register()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public void Register(string login, string password, string email)
|
||
{
|
||
try
|
||
{
|
||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email))
|
||
{
|
||
throw new Exception("Введите логин, пароль и почту");
|
||
}
|
||
APIUser.PostRequest("api/user/registerimplementer", new UserBindingModel
|
||
{
|
||
Login = login,
|
||
Password = password,
|
||
Email = email
|
||
});
|
||
Response.Redirect("Enter");
|
||
return;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
Response.Redirect("Register");
|
||
}
|
||
}
|
||
}
|
||
} |