Eliseev E.E. LabWork02_Hard #7
@ -212,7 +212,6 @@ namespace BlacksmithWorkshop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void AddManufactureToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormAddManufacture));
|
||||
|
@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -78,7 +79,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
_logger.LogInformation("AddManufacture. ShopName:{ShopName}. Id: {Id}", model?.ShopName, model?.Id);
|
||||
var shop = _shopStorage.GetElement(model);
|
||||
|
||||
if (shop == null)
|
||||
if (shop == null || !CheckShopCount(shop, count))
|
||||
{
|
||||
_logger.LogWarning("Add Manufacture operation failed");
|
||||
|
||||
@ -106,6 +107,24 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
return true;
|
||||
}
|
||||
|
||||
//проверка на переполнение магазина
|
||||
private bool CheckShopCount(ShopViewModel model, int count)
|
||||
{
|
||||
int _countManufactures = 0;
|
||||
|
||||
foreach (var manufacture in model.Manufactures)
|
||||
{
|
||||
_countManufactures += model.Manufactures[manufacture.Key].Item2;
|
||||
}
|
||||
|
||||
if(_countManufactures + count > model.MaxCountManufactures)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Create(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
Loading…
Reference in New Issue
Block a user