Доделана логика заказов

This commit is contained in:
Сергей Полевой 2023-02-12 18:21:48 +04:00
parent fa639ce8b4
commit 2093186453

View File

@ -57,16 +57,61 @@ namespace FlowerShopBusinessLogic.BusinessLogics
public bool TakeOrderInWork(OrderBindingModel model)
{
throw new NotImplementedException();
CheckModel(model, false);
if (model.Status != OrderStatus.Accepted)
{
_logger.LogWarning("Invalid order status");
return false;
}
model.Status = OrderStatus.Processing;
if (_orderStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
}
return true;
}
public bool FinishOrder(OrderBindingModel model)
{
throw new NotImplementedException();
CheckModel(model, false);
if (model.Status != OrderStatus.Processing)
{
_logger.LogWarning("Invalid order status");
return false;
}
model.Status = OrderStatus.Ready;
if (_orderStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
}
return true;
}
public bool DeliveryOrder(OrderBindingModel model)
{
throw new NotImplementedException();
CheckModel(model, false);
if (model.Status != OrderStatus.Ready)
{
_logger.LogWarning("Invalid order status");
return false;
}
model.Status = OrderStatus.Delivered;
if (_orderStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
}
return true;
}
private void CheckModel(OrderBindingModel model, bool withParams = true)