ПИбд-23 Салин Олег Алексеевич Лабораторная работа №6 (Усложненная) #23

Closed
Oleja123 wants to merge 13 commits from Lab6_Hard into Lab5_Hard
3 changed files with 22 additions and 18 deletions
Showing only changes of commit b53646627e - Show all commits

View File

@ -105,8 +105,9 @@ namespace IceCreamShop
Address = AddressTextBox.Text,
DateOpen = DateTimePicker.Value.Date,
MaxCapacity = Convert.ToInt32(CapacityUpDown.Value),
ShopIceCreams = null
};
if (_id.HasValue)
model.ShopIceCreams = null;
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)
{

View File

@ -144,12 +144,19 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
_logger.LogWarning("Read operation failed");
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");
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 });
if (icecream == null)
@ -166,8 +173,6 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
}
model.Status = status;
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
if (element.ImplementerId.HasValue)
model.ImplementerId = element.ImplementerId;
_orderStorage.Update(model);
return true;
}

View File

@ -37,11 +37,6 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
Status =
OrderStatus.Принят
});
if (orders == null || orders.Count == 0)
{
_logger.LogWarning("DoWork. Orders is null or empty");
return;
}
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
foreach (var implementer in implementers)
{
@ -151,22 +146,25 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
}
try
{
var order = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
var orders = await Task.Run(() => _orderLogic.ReadList(new OrderSearchModel
{
ImplementerId = implementer.Id,
Status = OrderStatus.Ожидается,
}));
if (order == null)
if (orders == null || orders.Count == 0)
{
return;
}
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
_orderLogic.DeliveryOrder(new OrderBindingModel
foreach (var order in orders)
{
Id = order.Id,
ImplementerId = implementer.Id
});
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
_orderLogic.FinishOrder(new OrderBindingModel
{
Id = order.Id,
ImplementerId = implementer.Id
});
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
}
}
catch (InvalidOperationException ex)
{