public static bool AddAccountFinanicalTarget(AccountFinancialTargetHelper accountFinancialTarget) { using (IDalSession session = NHSessionFactory.CreateSession()) { if (accountFinancialTarget.ParentAccountID != 0) { ICustomerAccount account = (ICustomerAccount)AccountMapper.GetAccount(session, accountFinancialTarget.ParentAccountID); ICurrency currency = InstrumentMapper.GetCurrency(session, accountFinancialTarget.CurrencyID); ILogin createdBy = LoginMapper.GetCurrentLogin(session); if (account.CurrentFinancialTarget != null && account.CurrentFinancialTarget.TargetAmount.Quantity == accountFinancialTarget.TargetAmountSize && account.CurrentFinancialTarget.TargetAmount.Underlying.Key == currency.Key && account.CurrentFinancialTarget.DepositPerYear.Quantity == accountFinancialTarget.DepositPerYearSize && account.CurrentFinancialTarget.DepositPerYear.Underlying.Key == currency.Key && account.CurrentFinancialTarget.TargetEndDate == accountFinancialTarget.TargetEndDate) return false; AccountFinancialTarget newTarget = new AccountFinancialTarget(); newTarget.ParentAccount = account; newTarget.TargetAmount = new Money(accountFinancialTarget.TargetAmountSize, currency); newTarget.DepositPerYear = new Money(accountFinancialTarget.DepositPerYearSize, currency); newTarget.TargetEndDate = accountFinancialTarget.TargetEndDate; newTarget.CreatedBy = createdBy; newTarget.CreationDate = DateTime.Now; account.CurrentFinancialTarget = newTarget; session.Update(account); } else throw new ApplicationException("Could not identify Account"); return true; } }
public AccountFinancialTargetHelper(AccountFinancialTarget parent) { this.Key = parent.Key; this.ParentAccountID = parent.ParentAccount.Key; this.TargetAmountSize = parent.TargetAmount.Quantity; this.DepositPerYearSize = parent.DepositPerYear.Quantity; this.CurrencyID = parent.TargetAmount.Underlying.Key; this.CreatedByID = parent.CreatedBy.Key; this.TargetEndDate = parent.TargetEndDate; }