This commit is contained in:
Илья Федотов 2024-08-02 14:36:23 +04:00
parent 84442ed049
commit f04063b44d
15 changed files with 38 additions and 43 deletions

View File

@ -111,9 +111,9 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
var element = _storage.GetElement(new ClientSearchModel
{
Email= model.Email
Email = model.Email
});
if (element != null && element.Email == model.Email)
if (element != null && element.ID != model.ID)
{
throw new InvalidOperationException("Клиент с такой почтой уже есть");
}

View File

@ -93,7 +93,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic {
var element = _storage.GetElement(new EmployeeSearchModel {
Login = model.Login
});
if (element != null && element.Login == model.Login) {
if (element != null && element.ID != model.ID) {
throw new InvalidOperationException("Сотрудник с таким логином уже есть");
}
}

View File

@ -71,6 +71,9 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
{
throw new ArgumentNullException("Сумма оплаты должна быть больше 0", nameof(model.SumPayment));
}
if (string.IsNullOrEmpty(model.ClientID.ToString())) {
throw new ArgumentNullException("У оплаты должен быть клиент");
}
_logger.LogInformation($"Payment. ID:{model.ID}.Sum:{model.SumPayment}.OrderID:{model.OrderID}" +
$".PayOption{model.PayOption}");
}

View File

@ -93,9 +93,12 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
if (model.Price <= 0) {
throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.Price));
}
if (string.IsNullOrEmpty(model.CostItemID.ToString())) {
throw new ArgumentNullException("Нет номера статьи затрат");
}
_logger.LogInformation($"Product. ID:{model.ID}.ProductName:{model.ProductName}.Price:{model.Price}.CostItemID:{model.CostItemID}");
var element = _storage.GetElement(new ProductSearchModel { ProductName = model.ProductName });
if (element != null && element.ProductName == model.ProductName) {
if (element != null && element.ID != model.ID) {
throw new InvalidOperationException("Продукт с таким названием уже есть");
}
}

View File

@ -51,21 +51,32 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "C",
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "C",
RowIndex = rowIndex,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
MergeCells(new ExcelMergeParameters {
CellFromName = $"B{rowIndex}",
CellToName = $"C{rowIndex}"
});
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "D",
RowIndex = rowIndex,
Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "D",
ColumnName = "E",
RowIndex = rowIndex,
Text = CostItem,
StyleInfo = ExcelStyleInfoType.TextWithBroder,
});
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "E",
ColumnName = "F",
RowIndex = rowIndex,
Text = Price.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder,

View File

@ -38,24 +38,14 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (pre.OrderID.ToString(), new WordTextProperties { Size = "24", Bold=true})},
{ ($"Номер заказа: {pre.OrderID.ToString()}; Номер оплаты: {pre.ID.ToString()}; Статус оплаты: {pre.PayOption.ToString()}",
new WordTextProperties { Size = "24", Bold=false})},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{ (pre.PayOption.ToString(), new WordTextProperties { Size = "20", Bold=false})},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
var document = SaveWord(info);

View File

@ -71,10 +71,6 @@ namespace ElectronicsShopDataBaseImplement.Implements
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
{
if (string.IsNullOrEmpty(model.Email))
{
return new();
}
using var context = new Database();
return context.Clients.Where(x => !string.IsNullOrEmpty(model.ClientFIO) && x.ClientFIO
.Contains(model.ClientFIO)).Select(x => x.GetViewModel).ToList();

View File

@ -57,15 +57,13 @@ namespace ElectronicsShopDataBaseImplement.Implements
.FirstOrDefault(x => (x.Login == model.Login && x.Password == model.Password))
?.GetViewModel;
}
return new();
return context.Employees
.FirstOrDefault(x => (x.Login == model.Login))
?.GetViewModel;
}
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
{
if (string.IsNullOrEmpty(model.Login))
{
return new();
}
using var context = new Database();
return context.Employees.Where(x => x.Login
.Contains(model.Login))

View File

@ -88,11 +88,7 @@ namespace ElectronicsShopDataBaseImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
using var context = new Database();
if (!model.ID.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
return new();
}
else if (model.ClientID.HasValue) {
if (model.ClientID.HasValue) {
return context.Orders
.Include (x => x.Products)
.Where(x => x.ClientID == model.ClientID && x.Status == OrderStatus.Неоплачено)

View File

@ -77,7 +77,6 @@ namespace ElectronicsShopDataBaseImplement.Implements
public List<ProductViewModel>? GetFilteredList(ProductSearchModel model)
{
using var context = new Database();
if (model.CostItemID.HasValue && string.IsNullOrEmpty(model.ProductName)) {
return context.Products
.Where(x => x.CostItemID == model.CostItemID)

View File

@ -319,7 +319,7 @@ namespace ElectronicsShopEmployeeApp.Controllers {
[HttpGet]
public IActionResult Report() {
if (APIEmployee.Employee == null) {
return RedirectToAction("~/Home/Index");
return Redirect("/Home/Index");
}
return View();

View File

@ -220,7 +220,7 @@ namespace ElectronicsShopRestAPI.Controllers {
_mailWorker.MailSendAsync(new() {
MailAddress = model.ClientEmail,
Subject = "Отчет",
Text = $"Отчет оплаченных товаров с {model.DateFrom} по {model.DateTo}",
Text = $"Отчет оплаченных товаров с {model.DateFrom.ToShortDateString()} по {model.DateTo.ToShortDateString()}",
document = data
});

View File

@ -194,12 +194,10 @@ namespace ElectronicsShopUserApp.Controllers {
}
[HttpGet]
public IActionResult DeleteProductOrder(int id) {
var view = APIClient.GetRequset<OrderViewModel>($"api/main/getorder?_clientid={APIClient.Client?.ID}")
?? throw new Exception("Îøèáêà ïîëó÷åíèÿ ìîäåëè");
APIClient.PostRequestStr($"api/main/deleteproductorder", view.ID, id);
public IActionResult DeleteProductOrder(int orderID, int id) {
APIClient.PostRequestStr($"api/main/deleteproductorder", orderID, id);
return Redirect($"https://localhost:7219/Home/EditOrder/{view.ID}");
return Redirect($"https://localhost:7219/Home/EditOrder/{orderID}");
}
[HttpGet]

View File

@ -66,7 +66,8 @@
</th>
<td>
<a class="btn btn-primary btn-sm" asp-action="DeleteProductOrder" style="background-color:red;" asp-route-ID="@item.Key">Удалить</a>
<a class="btn btn-primary btn-sm" asp-action="DeleteProductOrder" style="background-color:red;" asp-route-orderID="@Model.Item1"
asp-route-ID="@item.Key">Удалить</a>
</td>
</tr>
}