예제 #1
0
 /// <summary>
 /// Adds a new Interest Rate Value to the list of
 /// Interest Rate Values in this Interest Rate
 /// </summary>
 /// <param name="interestRateValue">Interest Rate Value to be added</param>
 public virtual void AddInterestRateValue(InterestRateValue interestRateValue)
 {
     interestRateValue.InterestRate = this;
     InterestRateValues.Add(interestRateValue);
 }
예제 #2
0
 /// <summary>
 /// Removes an Interest Rate Value from the list of
 /// Interest Rate Values in this Interest Rate
 /// </summary>
 /// <param name="interestRateValue">Interest Rate Value to be removed</param>
 public virtual void RemoveInterestRateValue(InterestRateValue interestRateValue)
 {
     InterestRateValues.Remove(interestRateValue);
 }
예제 #3
0
        /// <summary>
        /// Creates a new Interest Rate Value for the given Interest Rate
        /// </summary>
        /// <param name="interestRateId">Interest Rate Id</param>
        /// <param name="interestRateVersion">Interest Rate version</param>
        /// <param name="interestRateValue">New Interest Rate Value</param>
        public void CreateNewInterestRateValue(int interestRateId,
            int interestRateVersion,
            InterestRateValue interestRateValue)
        {
            try
            {
                IInterestRateDAO interestRateDAO = _daoFactory.GetInterestRateDAO ();

                InterestRate interestRate = GetInterestRate (interestRateId, interestRateVersion);

                //If they are trying to change the type to Tasa Fija, then
                //we check there is no multiple values associated to this tasa.
                if (interestRate.InterestRateType == InterestRateType.Fija)
                {
                    int intRateValuesCount = interestRateDAO.InterestRateValuesCount (
                        interestRateId);

                    //If it has multiple interest rate values, then we don't persist, we ask
                    //them to delete those values first.
                    if (intRateValuesCount >= 1)
                    {
                        throw new ZiblerBusinessComponentsException (
                            Resources.SystemParametersOperationsMsgInterestRateHasMultipleValues);
                    }
                }

                //Verify if there is another interest rate value already assigned to the same date.
                bool hasInterestRateValue = interestRateDAO.HasInterestRateValueOnDate (
                    interestRateId,
                    interestRateValue.ValidFrom);

                if (hasInterestRateValue)
                {
                    throw new ZiblerBusinessComponentsException (
                        Resources.SystemParametersOperationsMsgInterestRateValueExistsForDate);
                }
                else
                {
                    //Update the interest rate and add the new value
                    interestRate.AddInterestRateValue (interestRateValue);
                }
            }
            /* 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;
            }
        }