Корректировка логики изменения статуса заказа

This commit is contained in:
Мк Игорь 2023-02-15 00:22:52 +04:00
parent 7db5841339
commit 46c1d78dd9
2 changed files with 20 additions and 9 deletions

View File

@ -32,7 +32,7 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
public bool CreateOrder(OrderBindingModel model)
{
CheckModel(model);
if ((int)model.Status > -2)
if (model.Status == OrderStatus.Неизвестен)
{
model.Status = OrderStatus.Принят;
}
@ -46,14 +46,16 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
_logger.LogWarning("Create order operation failed");
return false;
}
model.Status = OrderStatus.Принят;
return true;
}
public bool TakeOrderInWork(OrderBindingModel model)
{
OrderViewModel? vm = _orderStorage.GetElement(new() { Id = model.Id });
OrderViewModel? vm = _orderStorage.GetElement(new()
{
Id = model.Id
});
model.Status = vm?.Status ?? OrderStatus.Неизвестен;
if ((int)model.Status > -1)
if (model.Status == OrderStatus.Принят)
{
model.Status = OrderStatus.Выполняется;
}
@ -69,9 +71,12 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
}
public bool FinishOrder(OrderBindingModel model)
{
OrderViewModel? vm = _orderStorage.GetElement(new() { Id = model.Id });
OrderViewModel? vm = _orderStorage.GetElement(new()
{
Id = model.Id
});
model.Status = vm?.Status ?? OrderStatus.Неизвестен;
if ((int)model.Status > 0)
if (model.Status == OrderStatus.Выполняется)
{
model.Status = OrderStatus.Готов;
model.DateImplement = DateTime.Now;
@ -88,9 +93,12 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
}
public bool DeliveryOrder(OrderBindingModel model)
{
OrderViewModel? vm = _orderStorage.GetElement(new() { Id = model.Id });
OrderViewModel? vm = _orderStorage.GetElement(new()
{
Id = model.Id
});
model.Status = vm?.Status ?? OrderStatus.Неизвестен;
if ((int)model.Status > 1)
if (model.Status == OrderStatus.Готов)
{
model.Status = OrderStatus.Выдан;
}

View File

@ -52,7 +52,10 @@ namespace BlacksmithWorkshopListImplement.Models
return;
}
Status = model.Status;
DateImplement = model.DateImplement;
if (model.DateImplement != null)
{
DateImplement = model.DateImplement;
}
}
public OrderViewModel GetViewModel => new()
{