Подменил OrderLogic
This commit is contained in:
parent
19415b5c7b
commit
d19523fddb
1
.gitignore
vendored
1
.gitignore
vendored
@ -398,3 +398,4 @@ FodyWeavers.xsd
|
|||||||
# JetBrains Rider
|
# JetBrains Rider
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
|
|
||||||
|
ImplementationExtensions/
|
@ -13,12 +13,14 @@ namespace SecuritySystemBusinessLogic.BusinessLogics
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
private readonly IShopLogic _shopLogic;
|
private readonly IShopLogic _shopLogic;
|
||||||
|
private readonly ISecureStorage _secureStorage;
|
||||||
|
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic)
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic, ISecureStorage secureStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
_shopLogic = shopLogic;
|
_shopLogic = shopLogic;
|
||||||
|
_secureStorage = secureStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
@ -56,14 +58,18 @@ namespace SecuritySystemBusinessLogic.BusinessLogics
|
|||||||
_logger.LogWarning("Read operation failed");
|
_logger.LogWarning("Read operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
model.SecureId = element.SecureId;
|
||||||
|
model.Count = element.Count;
|
||||||
|
model.Sum = element.Sum;
|
||||||
if (element.Status != targetStatus - 1)
|
if (element.Status != targetStatus - 1)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Status change operation failed");
|
_logger.LogWarning("Status change operation failed");
|
||||||
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
||||||
}
|
}
|
||||||
|
var secure = _secureStorage.GetElement(new SecureSearchModel { Id = model.SecureId });
|
||||||
if (targetStatus == OrderStatus.Выдан)
|
if (targetStatus == OrderStatus.Выдан)
|
||||||
{
|
{
|
||||||
_shopLogic.SupplySecures();
|
_shopLogic.SupplySecures(secure, model.Count);
|
||||||
}
|
}
|
||||||
model.Status = targetStatus;
|
model.Status = targetStatus;
|
||||||
if (model.Status == OrderStatus.Выдан)
|
if (model.Status == OrderStatus.Выдан)
|
||||||
|
Loading…
Reference in New Issue
Block a user