fix
This commit is contained in:
parent
5a09463d31
commit
ccd0354ab9
@ -82,17 +82,21 @@ namespace ShipyardBusinessLogic.BusinessLogics
|
||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||
{
|
||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (model.Status + 1 != newStatus)
|
||||
if (viewModel == null)
|
||||
{
|
||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (viewModel.Status + 1 != newStatus)
|
||||
{
|
||||
_logger.LogWarning("Change status operation failed");
|
||||
return false;
|
||||
}
|
||||
model.Status = newStatus;
|
||||
if (model.Status == OrderStatus.Готов)
|
||||
if (model.Status == OrderStatus.Готов)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
var ship = _shipStorage.GetElement(new() { Id = viewModel.ShipId });
|
||||
if (ship == null)
|
||||
if (ship == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(ship));
|
||||
}
|
||||
@ -100,16 +104,15 @@ namespace ShipyardBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new Exception($"AddShips operation failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
model.DateImplement = viewModel.DateImplement;
|
||||
}
|
||||
CheckModel(model);
|
||||
CheckModel(model, false);
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
_logger.LogWarning("Update operation failed");
|
||||
_logger.LogWarning("Change status operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -116,6 +116,7 @@ namespace ShipyardBusinessLogic.BusinessLogics
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
return false;
|
||||
throw new ArgumentException("Количество кораблей должно быть больше 0", nameof(count));
|
||||
}
|
||||
_logger.LogInformation("AddShip. ShopName:{ShopName}. Id:{Id}", model.ShopName, model.Id);
|
||||
@ -166,6 +167,10 @@ namespace ShipyardBusinessLogic.BusinessLogics
|
||||
foreach (var shop in _shopStorage.GetFullList())
|
||||
{
|
||||
int freeQuantity = shop.Capacity - shop.Ships.Select(x => x.Value.Item2).Sum();
|
||||
if (freeQuantity <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (freeQuantity < count)
|
||||
{
|
||||
if (!AddShip(new() { Id = shop.Id }, model, freeQuantity))
|
||||
|
Loading…
x
Reference in New Issue
Block a user