diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/WorkModeling.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/WorkModeling.cs index 3424475..16453bb 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/WorkModeling.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/WorkModeling.cs @@ -73,22 +73,25 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics try { _logger.LogDebug("DoWork. Worker {Id} try get order { Order}", implementer.Id, order.Id); - // пытаемся назначить заказ на исполнителя -_orderLogic.TakeOrderInWork(new OrderBindingModel -{ - Id = order.Id, - ImplementerId = implementer.Id -}); - - // делаем работу - Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, - 1000) * order.Count); - _logger.LogDebug("DoWork. Worker {Id} finish order { Order} ", implementer.Id, order.Id); - _orderLogic.FinishOrder(new OrderBindingModel - { - Id = order.Id, - ImplementerId = implementer.Id - }); + // пытаемся назначить заказ на исполнителя + if ( + _orderLogic.TakeOrderInWork(new OrderBindingModel + { + Id = order.Id, + ImplementerId = implementer.Id + })) + { + + // делаем работу + Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, + 1000) * order.Count); + _logger.LogDebug("DoWork. Worker {Id} finish order { Order} ", implementer.Id, order.Id); + _orderLogic.FinishOrder(new OrderBindingModel + { + Id = order.Id, + ImplementerId = implementer.Id + }); + } } // кто-то мог уже перехватить заказ, игнорируем ошибку catch (InvalidOperationException ex)