/// <summary>
 /// Removes a FinancialForecastParameters from the list of FinancialForecastParameters
 /// in this FinancialInstitution
 /// </summary>
 /// <param name="financialForecastParameters">FinancialForecastParameters to be removed</param>
 public virtual void RemoveFinancialForecastParameters(
     FinancialForecastParameters financialForecastParameters)
 {
     FinancialForecastParameters.Remove (financialForecastParameters);
 }
        /// <summary>
        /// Updates the financial Forecast parameters to the system
        /// </summary>
        /// <param name="financialForecastParameters">Financial Forecast Parameters to update</param>
        /// <exception cref="ZiblerBusinessComponentsException" />
        public void UpdateFinancialForecastParameters(
            FinancialForecastParameters financialForecastParameters)
        {
            try
            {
                IFinancialInstitutionDAO financialInstitutionDAO = _daoFactory.GetFinancialInstitutionDAO ();
                IFinancialForecastParametersDAO financialForecastParametersDAO = _daoFactory.GetFinancialForecastParametersDAO ();

                DateTime? oldValidFrom = financialForecastParametersDAO.GetFinancialForecastParametersDate (
                    financialForecastParameters.Id);

                if (oldValidFrom == null)
                    throw new ZiblerBusinessComponentsException (Resources.RecordNotFound);
                else
                {
                    //If the dates are the same then just go ahead and update
                    if (DateTime.Compare (oldValidFrom.Value,
                                          financialForecastParameters.ValidFrom.Value) == 0)
                    {
                        financialForecastParametersDAO.MakePersistent (financialForecastParameters);
                    }
                    else
                    {
                        if (financialInstitutionDAO.FinancialForecastParameterExists (
                            financialForecastParameters.FinancialInstitution.Name,
                            financialForecastParameters.ValidFrom))
                        {
                            throw new ZiblerBusinessComponentsException (
                                Resources.LoanTrackingParameterOperationsMsgFinancialForecastParameterExists);
                        }
                        else
                        {
                            //Go ahead and update.
                            financialForecastParametersDAO.MakePersistent (
                                financialForecastParameters);
                        }
                    }
                }
            }
            /* If the exception was thrown here, just pass it up */
            catch (ZiblerBusinessComponentsException ex)
            {
                throw;
            }
            /* Catch any Data Layer or other exception and throw an unkown exception */
            catch (Exception ex)
            {
                ZiblerBusinessComponentsUnknownException exc
                = new ZiblerBusinessComponentsUnknownException (ex);

                /* Throw the new exception */
                throw exc;
            }
        }
 /// <summary>
 /// Adds a new FinancialForecastParameters to the list of FinancialForecastParameters
 /// in this FinancialInstitution
 /// </summary>
 /// <param name="financialForecastParameters">FinancialForecastParameters to be added</param>
 public virtual void AddFinancialForecastParameters(
     FinancialForecastParameters financialForecastParameters)
 {
     financialForecastParameters.FinancialInstitution = this;
     FinancialForecastParameters.Add (financialForecastParameters);
 }
        /// <summary>
        /// Creates a new Financial Forecast Parameter into the system for the given financial institution
        /// </summary>
        /// <param name="financialInstitutionName">Financial Institution</param>
        /// <param name="username">Username</param>
        /// <param name="financialForecastParameter">New Financial Forecast Parameter</param>
        public void CreateNewFinancialForecastParameter(string financialInstitutionName,
            string username,
            FinancialForecastParameters financialForecastParameter)
        {
            try
            {
                IFinancialInstitutionDAO financialInstitutionDAO = _daoFactory.GetFinancialInstitutionDAO ();

                //Verify the user does not exist in the system first.
                if (financialInstitutionDAO.FinancialForecastParameterExists (
                    financialInstitutionName,
                    financialForecastParameter.ValidFrom))
                {
                    throw new ZiblerBusinessComponentsException (
                        Resources.LoanTrackingParameterOperationsMsgFinancialForecastParameterExists);
                }
                else
                {
                    //TODO: This may cause performance issues if they have a lot of financial forecast parameters items
                    //		the Add operation retrieves all the items from the database.
                    //Get the financial institution, and add the new compliance checklist
                    FinancialInstitution financialInstitution = financialInstitutionDAO.GetFinancialInstitutionByName (
                        financialInstitutionName);
                    financialInstitution.AddFinancialForecastParameters (financialForecastParameter);
                }
            }
            /* If the exception was thrown here, just pass it up */
            catch (ZiblerBusinessComponentsException ex)
            {
                throw;
            }
            /* Catch any Data Layer or other exception and throw an unkown exception */
            catch (Exception ex)
            {
                ZiblerBusinessComponentsUnknownException exc
                = new ZiblerBusinessComponentsUnknownException (ex);

                /* Throw the new exception */
                throw exc;
            }
        }