1 задание
This commit is contained in:
parent
09fabc904e
commit
e017eb7709
@ -41,9 +41,9 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выполняется);
|
||||
public bool DeliveryOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выдан);
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
public OrderStatus? TakeOrderInWork(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выполняется);
|
||||
public OrderStatus? DeliveryOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выдан);
|
||||
public OrderStatus? FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
return SetOrderStatus(model, OrderStatus.Готов);
|
||||
@ -84,7 +84,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool SetOrderStatus(OrderBindingModel model, OrderStatus orderStatus)
|
||||
private OrderStatus? SetOrderStatus(OrderBindingModel model, OrderStatus orderStatus)
|
||||
{
|
||||
// Находим статус заказа по его айди
|
||||
var vmodel = _orderStorage.GetElement(new() { Id = model.Id });
|
||||
@ -125,9 +125,9 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
return true;
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||
|
@ -72,8 +72,12 @@ namespace ConfectioneryBusinessLogic
|
||||
}
|
||||
await RunOrderInWork(implementer);
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
await Task.Run(() => RunWorkToOrders(implementer, orders));
|
||||
|
||||
}
|
||||
|
||||
private void RunWorkToOrders(ImplementerViewModel implementer, List<OrderViewModel> orders)
|
||||
{
|
||||
foreach (var order in orders)
|
||||
{
|
||||
try
|
||||
@ -107,8 +111,7 @@ namespace ConfectioneryBusinessLogic
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
|
||||
|
@ -87,8 +87,8 @@ namespace ConfectioneryView
|
||||
_logger.LogInformation("Заказ No{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }) ;
|
||||
if (operationResult == null)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
@ -116,7 +116,7 @@ namespace ConfectioneryView
|
||||
Id = id,
|
||||
Status = orderStatus
|
||||
});
|
||||
if (!operationResult)
|
||||
if (operationResult == null)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
@ -141,7 +141,7 @@ namespace ConfectioneryView
|
||||
var operationResult = _orderLogic.DeliveryOrder(new
|
||||
OrderBindingModel
|
||||
{ Id = id });
|
||||
if (!operationResult)
|
||||
if (operationResult == null)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении.Дополнительная информация в логах.");
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using ConfectioneryContracts.BindingModels;
|
||||
using ConfectioneryContracts.SearchModels;
|
||||
using ConfectioneryContracts.ViewModels;
|
||||
using ConfectioneryDataModels.Enums;
|
||||
|
||||
namespace ConfectioneryContracts.BusinessLogicsContracts
|
||||
{
|
||||
@ -9,8 +10,8 @@ namespace ConfectioneryContracts.BusinessLogicsContracts
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
bool DeliveryOrder(OrderBindingModel model);
|
||||
OrderStatus? TakeOrderInWork(OrderBindingModel model);
|
||||
OrderStatus? FinishOrder(OrderBindingModel model);
|
||||
OrderStatus? DeliveryOrder(OrderBindingModel model);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user