public void Funded(Fund fund) { if (fund == null) { throw new InvestingDomainException("Fund must provide when set fund for investment."); } if (this._investmentStatusId != InvestmentStatus.Prepare.Id) { throw new InvestingDomainException("Investment's fund setting can only be change at prepare state."); } if (this._investmentTypeId != InvestmentType.Live.Id) { throw new InvestingDomainException("The investment type must be live for allocating fund."); } if (!fund.Account.Equals(this.Account)) { throw new InvestingDomainException("The fund account must be the same with the investment account."); } var quantityList = fund.GetFundingQuantity(this.InvestmentId); if (!quantityList.Any()) { throw new InvestingDomainException("No allocated fund found in the fund provided."); } this.InitialBalance = quantityList.First(); }