This commit is contained in:
Viltskaa 2023-02-14 10:17:42 +04:00
parent b7ccba8acc
commit 4b9f66ba35

View File

@ -46,14 +46,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
public bool FinishOrder(OrderBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_orderStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
return UpdateStatus(model, OrderStatus.Issued);
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
@ -77,12 +70,16 @@ namespace SushiBarBusinessLogic.BusinessLogics
private bool UpdateStatus(OrderBindingModel model, OrderStatus status)
{
CheckModel(model);
var order = _orderStorage.GetElement(new OrderSearchModel() { Id = model.Id });
if (model.Status + 1 != status)
{
_logger.LogWarning("Status update operation failed");
return false;
}
model.Status = status;
model.DateImplement = order?.DateImplement;
if (model.Status == OrderStatus.Issued)
{
model.DateImplement = DateTime.Now;