This commit is contained in:
Viltskaa 2023-02-14 09:35:24 +04:00
parent 9399daba9e
commit beffbdab69

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,13 +70,17 @@ 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;
if (model.Status == OrderStatus.Issued)
model.DateImplement = order?.DateImplement;
if (model.Status == OrderStatus.Ready)
{
model.DateImplement = DateTime.Now;
}