/// <summary> /// Removes an InterestRate from the list of InterestRates /// in this Financial Institution /// </summary> /// <param name="interestRate">Interest rate to be removed</param> public virtual void RemoveInterestRate(InterestRate interestRate) { InterestRates.Remove (interestRate); }
/// <summary> /// Update the Interest Rate and save it to the system /// </summary> /// <param name="interestRateToUpdate">Interest Rate to be updated</param> /// <exception cref="ZiblerBusinessComponentsException" /> public void UpdateInterestRate(InterestRate interestRateToUpdate) { try { IInterestRateDAO interestRateDAO = _daoFactory.GetInterestRateDAO (); IFinancialInstitutionDAO financialInstitutionDAO = _daoFactory.GetFinancialInstitutionDAO (); string oldInterestRateName = interestRateDAO.GetInterestRateName ( interestRateToUpdate.Id); //TODO: Perhaps I should verify that the Interest rate still exists before updating it to the database?? // or is this going to be taken care of by the revision checking. if (String.Compare (oldInterestRateName, interestRateToUpdate.Name, true) != 0) { //If the names are not the same any more then we verify the name does not //exist already in the system. bool interestExists = financialInstitutionDAO.InterestRateExists ( interestRateToUpdate.FinancialInstitution.Name, interestRateToUpdate.Name); if (interestExists) { throw new ZiblerBusinessComponentsException ( Resources.SystemParametersOperationMsgInterestRateExists); } else { //If they are trying to change the type to Tasa Fija, then //we check there is no multiple values associated to this tasa. if (interestRateToUpdate.InterestRateType == InterestRateType.Fija) { int intRateValuesCount = interestRateDAO.InterestRateValuesCount ( interestRateToUpdate.Id); //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); } } interestRateDAO.MakePersistent (interestRateToUpdate); } } else { //If they are trying to change the type to Tasa Fija, then //we check there is no multiple values associated to this tasa. if (interestRateToUpdate.InterestRateType == InterestRateType.Fija) { int intRateValuesCount = interestRateDAO.InterestRateValuesCount ( interestRateToUpdate.Id); //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); } } interestRateDAO.MakePersistent (interestRateToUpdate); } } /* 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 InterestRate to the list of InterestRates /// in this Financial Institution /// </summary> /// <param name="interestRate">Interest rate to be added</param> public virtual void AddInterestRate(InterestRate interestRate) { interestRate.FinancialInstitution = this; InterestRates.Add (interestRate); }
/// <summary> /// Creates a new Interest Rate and adds it to the system /// </summary> /// <param name="financialInstitutionName">Financial Institution name</param> /// <param name="userName">User name</param> /// <param name="interestRate">New Interest rate</param> /// <exception cref="ZiblerBusinessComponentsException" /> public void CreateNewInterestRate(string financialInstitutionName, string userName, InterestRate interestRate) { try { IFinancialInstitutionDAO financialInstitutionDAO = _daoFactory.GetFinancialInstitutionDAO (); //Verify the user does not exist in the system first. if (financialInstitutionDAO.InterestRateExists (financialInstitutionName, interestRate.Name)) { throw new ZiblerBusinessComponentsException ( Resources.SystemParametersOperationMsgInterestRateExists); } else { //Make sure that there is at least one initial value if (interestRate.InterestRateValues.Count < 0) { //If so, then raise an exception with the appropriate message. throw new ZiblerBusinessComponentsException ( Resources.SystemParametersOperationMsgInterestRateHasNoInitialValue); } else { //Before we add it to the financial institution //encrypt it. //Encryption.EncryptProperties(client); //Get the financial institution, and add the new interest to it. FinancialInstitution financialInstitution = financialInstitutionDAO.GetFinancialInstitutionByName ( financialInstitutionName); financialInstitution.AddInterestRate (interestRate); } } } /* 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; } }