public void AddDemand(Demand oneDemand, Quantity reservedQuantity) { if (_demands.GetDemandById(oneDemand.GetId()) != null) { throw new MrpRunException("You cannot add an already added demand."); } // if it has quantity that is not reserved, remember it for later reserving if (oneDemand.GetType() == typeof(StockExchangeDemand) && reservedQuantity.IsSmallerThan(oneDemand.GetQuantity())) { _openDemands.Add(oneDemand.GetArticle(), new OpenNode <Demand>(oneDemand, oneDemand.GetQuantity().Minus(reservedQuantity), oneDemand.GetArticle())); } // save demand _demands.Add(oneDemand); }