Ну вроде сделал
This commit is contained in:
parent
db5d41d231
commit
b53646627e
@ -105,8 +105,9 @@ namespace IceCreamShop
|
|||||||
Address = AddressTextBox.Text,
|
Address = AddressTextBox.Text,
|
||||||
DateOpen = DateTimePicker.Value.Date,
|
DateOpen = DateTimePicker.Value.Date,
|
||||||
MaxCapacity = Convert.ToInt32(CapacityUpDown.Value),
|
MaxCapacity = Convert.ToInt32(CapacityUpDown.Value),
|
||||||
ShopIceCreams = null
|
|
||||||
};
|
};
|
||||||
|
if (_id.HasValue)
|
||||||
|
model.ShopIceCreams = null;
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
|
@ -144,12 +144,19 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
|
|||||||
_logger.LogWarning("Read operation failed");
|
_logger.LogWarning("Read operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (element.Status != status - 1 && status != OrderStatus.Ожидается)
|
if (element.Status != status - 1 && status != OrderStatus.Ожидается && element.Status != OrderStatus.Ожидается)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Status change operation failed");
|
_logger.LogWarning("Status change operation failed");
|
||||||
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
|
||||||
}
|
}
|
||||||
if(element.Status == OrderStatus.Выполняется)
|
model.Sum = element.Sum;
|
||||||
|
model.Count = element.Count;
|
||||||
|
model.IceCreamId = element.IceCreamId;
|
||||||
|
model.DateCreate = element.DateCreate;
|
||||||
|
model.DateImplement = element.DateImplement;
|
||||||
|
if (element.ImplementerId.HasValue && element.ImplementerId != 0)
|
||||||
|
model.ImplementerId = element.ImplementerId;
|
||||||
|
if (status == OrderStatus.Готов)
|
||||||
{
|
{
|
||||||
var icecream = _iceCreamStorage.GetElement(new IceCreamSearchModel() { Id = model.IceCreamId });
|
var icecream = _iceCreamStorage.GetElement(new IceCreamSearchModel() { Id = model.IceCreamId });
|
||||||
if (icecream == null)
|
if (icecream == null)
|
||||||
@ -166,8 +173,6 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
|
|||||||
}
|
}
|
||||||
model.Status = status;
|
model.Status = status;
|
||||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||||
if (element.ImplementerId.HasValue)
|
|
||||||
model.ImplementerId = element.ImplementerId;
|
|
||||||
_orderStorage.Update(model);
|
_orderStorage.Update(model);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -37,11 +37,6 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
|
|||||||
Status =
|
Status =
|
||||||
OrderStatus.Принят
|
OrderStatus.Принят
|
||||||
});
|
});
|
||||||
if (orders == null || orders.Count == 0)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
||||||
foreach (var implementer in implementers)
|
foreach (var implementer in implementers)
|
||||||
{
|
{
|
||||||
@ -151,23 +146,26 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var order = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
var orders = await Task.Run(() => _orderLogic.ReadList(new OrderSearchModel
|
||||||
{
|
{
|
||||||
ImplementerId = implementer.Id,
|
ImplementerId = implementer.Id,
|
||||||
Status = OrderStatus.Ожидается,
|
Status = OrderStatus.Ожидается,
|
||||||
}));
|
}));
|
||||||
if (order == null)
|
if (orders == null || orders.Count == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
foreach (var order in orders)
|
||||||
|
{
|
||||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
|
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
|
||||||
_orderLogic.DeliveryOrder(new OrderBindingModel
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = order.Id,
|
Id = order.Id,
|
||||||
ImplementerId = implementer.Id
|
ImplementerId = implementer.Id
|
||||||
});
|
});
|
||||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (InvalidOperationException ex)
|
catch (InvalidOperationException ex)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, "Error try get work");
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
|
Loading…
Reference in New Issue
Block a user