lab1hard
This commit is contained in:
parent
066f2f0b26
commit
0e8c49cbe4
@ -88,8 +88,8 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
//логика пополнения магазина
|
||||||
public bool ReplenishShop(ShopSearchModel shopModel, IReinforcedModel reinforced, int count)
|
public bool RefillShop(ShopSearchModel shopModel, IReinforcedModel reinforced, int count)
|
||||||
{
|
{
|
||||||
if (shopModel == null)
|
if (shopModel == null)
|
||||||
{
|
{
|
||||||
@ -103,25 +103,27 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentException("В магазине должен быть хотя бы один товар", nameof(count));
|
throw new ArgumentException("В магазине должен быть хотя бы один товар", nameof(count));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReplenishShop(GetElement). ShopName: {ShopName}. Id: {Id}", shopModel.ShopName, shopModel.Id);
|
_logger.LogInformation("RefillShop(GetElement). ShopName: {ShopName}. Id: {Id}", shopModel.ShopName, shopModel.Id);
|
||||||
|
|
||||||
var shop = _shopStorage.GetElement(shopModel);
|
var shop = _shopStorage.GetElement(shopModel);
|
||||||
|
|
||||||
if (shop == null)
|
if (shop == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReplenishShop(GetElement). Element not found");
|
_logger.LogWarning("RefillShop(GetElement). Element not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (shop.ShopReinforceds.ContainsKey(reinforced.Id))
|
if (shop.ShopReinforceds.ContainsKey(reinforced.Id))//если есть товар то плюс
|
||||||
{
|
{
|
||||||
var shopR = shop.ShopReinforceds[reinforced.Id];
|
var shopR = shop.ShopReinforceds[reinforced.Id];
|
||||||
shopR.Item2 += count;
|
shopR.Item2 += count;
|
||||||
shop.ShopReinforceds[reinforced.Id] = shopR;
|
shop.ShopReinforceds[reinforced.Id] = shopR;
|
||||||
_logger.LogInformation("ReplenishShop. Added {count} '{reinforced}' to '{ShopName}' shop", count, reinforced.ReinforcedName,
|
_logger.LogInformation("RefillShop. Added {count} '{reinforced}' to '{ShopName}' shop", count, reinforced.ReinforcedName,
|
||||||
shop.ShopName);
|
shop.ShopName);
|
||||||
}
|
}
|
||||||
else
|
else//если нет то просто добавляем
|
||||||
{
|
{
|
||||||
shop.ShopReinforceds.Add(reinforced.Id, (reinforced, count));
|
shop.ShopReinforceds.Add(reinforced.Id, (reinforced, count));
|
||||||
_logger.LogInformation("ReplenishShop. Added {count} new '{reinforced}' to '{ShopName}' shop", count, reinforced.ReinforcedName,
|
_logger.LogInformation("RefillShop. Added {count} new '{reinforced}' to '{ShopName}' shop", count, reinforced.ReinforcedName,
|
||||||
shop.ShopName);
|
shop.ShopName);
|
||||||
}
|
}
|
||||||
if (_shopStorage.Update(new ShopBindingModel()
|
if (_shopStorage.Update(new ShopBindingModel()
|
||||||
@ -133,7 +135,7 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogics
|
|||||||
ShopReinforceds = shop.ShopReinforceds,
|
ShopReinforceds = shop.ShopReinforceds,
|
||||||
}) == null)
|
}) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReplenishShop. Update operation failed");
|
_logger.LogWarning("RefillShop. Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -22,6 +22,6 @@ namespace PrecastConcretePlantContracts.BusinessLogicsContracts
|
|||||||
|
|
||||||
bool Delete(ShopBindingModel model);
|
bool Delete(ShopBindingModel model);
|
||||||
|
|
||||||
bool ReplenishShop(ShopSearchModel shopModel, IReinforcedModel reinforced, int count);
|
bool RefillShop(ShopSearchModel shopModel, IReinforcedModel reinforced, int count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ namespace PrecastConcretePlantView
|
|||||||
{
|
{
|
||||||
throw new Exception("Изделие не найдено.");
|
throw new Exception("Изделие не найдено.");
|
||||||
}
|
}
|
||||||
var operationResult = _logicShop.ReplenishShop(new ShopSearchModel
|
var operationResult = _logicShop.RefillShop(new ShopSearchModel
|
||||||
{
|
{
|
||||||
Id = Convert.ToInt32(comboBoxShop.SelectedValue)
|
Id = Convert.ToInt32(comboBoxShop.SelectedValue)
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user