Подменил OrderLogic

This commit is contained in:
Никита Потапов 2024-05-20 11:29:34 +04:00
parent 19415b5c7b
commit d19523fddb
2 changed files with 9 additions and 2 deletions

1
.gitignore vendored
View File

@ -398,3 +398,4 @@ FodyWeavers.xsd
# JetBrains Rider # JetBrains Rider
*.sln.iml *.sln.iml
ImplementationExtensions/

View File

@ -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.Выдан)