using NorthBridgeContract.BusinessLogicsContracts; using NorthBridgeContract.DataModels; using NorthBridgeContract.StoragesContracts; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace NorthBridgeBusinessLogic.Implementations { public class SupplyBusinessLogicContract : ISupplyBusinessLogicContract { private readonly ISupplyStorageContract _supplyStorageContract; public SupplyBusinessLogicContract(ISupplyStorageContract supplyStorageContract) { _supplyStorageContract = supplyStorageContract; } public void CreateSupply(SupplyDataModel supply) { supply.Validate(); _supplyStorageContract.AddSupply(supply); } public SupplyDataModel GetSupplyById(string supplyId) { var supply = _supplyStorageContract.GetSupplyById(supplyId); if (supply == null) { throw new ArgumentException($"Supply with ID {supplyId} not found."); } return supply; } public List GetSuppliesByStorageId(string storageId) { return _supplyStorageContract.GetSuppliesByStorageId(storageId); } public void AddOrUpdateComponentInSupply(ComponentInSupplyDataModel componentInSupply) { componentInSupply.Validate(); _supplyStorageContract.AddOrUpdateComponentInSupply(componentInSupply); } public void UpdateComponentCountInSupply(string supplyId, string componentId, int newCount) { if (newCount <= 0) { throw new ArgumentException("Component count must be greater than zero."); } _supplyStorageContract.UpdateComponentCountInSupply(supplyId, componentId, newCount); } public void RemoveComponentFromSupply(string supplyId, string componentId) { _supplyStorageContract.RemoveComponentFromSupply(supplyId, componentId); } } }