Bazunov A.I. Lab Work #2 #6

Closed
viltskaa wants to merge 4 commits from LabWork_2 into LabWork_1
Showing only changes of commit 0851de65f5 - Show all commits

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;