В процессе
This commit is contained in:
parent
df209875aa
commit
32c42afffa
@ -2,6 +2,7 @@
|
||||
using JewelryStoreContracts.BusinessLogicsContracts;
|
||||
using JewelryStoreContracts.SearchModels;
|
||||
using JewelryStoreContracts.StoragesContracts;
|
||||
using JewelryStoreContracts.StoragesModels;
|
||||
using JewelryStoreContracts.ViewModels;
|
||||
using JewelryStoreDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -12,12 +13,14 @@ namespace JewelryStoreBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly IStoreStorage _shopStorage;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IStoreStorage shopStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
_shopStorage = shopStorage;
|
||||
}
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
@ -34,22 +37,24 @@ namespace JewelryStoreBusinessLogic.BusinessLogics
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel
|
||||
{
|
||||
Id = model.Id
|
||||
});
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("Read operation failed");
|
||||
return false;
|
||||
}
|
||||
if (element.Status != OrderStatus.Готов)
|
||||
{
|
||||
_logger.LogWarning("Status change operation failed");
|
||||
throw new InvalidOperationException("Заказ должен быть переведен в статус готовности перед выдачей!");
|
||||
}
|
||||
model.Status = OrderStatus.Выдан;
|
||||
var order = _orderStorage.GetElement(new OrderSearchModel
|
||||
{
|
||||
Id = model.Id,
|
||||
});
|
||||
if (order == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(order));
|
||||
}
|
||||
if (!_shopStorage.RestockingShops(new SupplyBindingModel
|
||||
{
|
||||
JewelId = order.JewelId,
|
||||
Count = order.Count
|
||||
}))
|
||||
{
|
||||
throw new ArgumentException("Недостаточно места");
|
||||
}
|
||||
|
||||
model.Status = OrderStatus.Выдан;
|
||||
model.DateImplement = DateTime.Now;
|
||||
_orderStorage.Update(model);
|
||||
return true;
|
||||
|
@ -7,8 +7,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace JewelryStoreBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfo
|
||||
{
|
||||
public class ExcelInfo : IDocument
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ReportJewelComponentViewModel> JewelComponents
|
||||
|
@ -7,8 +7,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace JewelryStoreBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfInfo
|
||||
{
|
||||
public class PdfInfo : IDocument
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public DateTime DateFrom { get; set; }
|
||||
|
@ -7,8 +7,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace JewelryStoreBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordInfo
|
||||
{
|
||||
public class WordInfo : IDocument
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<JewelViewModel> Jewels { get; set; } = new();
|
||||
|
@ -195,7 +195,7 @@ namespace JewelryStoreBusinessLogic.OfficePackage.Implements
|
||||
_ => 0U,
|
||||
};
|
||||
}
|
||||
protected override void CreateExcel(ExcelInfo info)
|
||||
protected override void CreateExcel(IDocument info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
|
||||
SpreadsheetDocumentType.Workbook);
|
||||
@ -327,7 +327,7 @@ namespace JewelryStoreBusinessLogic.OfficePackage.Implements
|
||||
};
|
||||
mergeCells.Append(mergeCell);
|
||||
}
|
||||
protected override void SaveExcel(ExcelInfo info)
|
||||
protected override void SaveExcel(IDocument info)
|
||||
{
|
||||
if (_spreadsheetDocument == null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user