Пример #1
0
 /// <summary>
 /// Removes a Client from the list of Clients of this Solidarity Group
 /// </summary>
 /// <param name="client">Client to be removed</param>
 public virtual void RemoveClient(Client client)
 {
     Clients.Remove(client);
 }
Пример #2
0
        /// <summary>
        /// Updates a client and makes it persistant in the database
        /// </summary>
        /// <param name="client">Client to update</param>
        /// <exception cref="ZiblerBusinessComponentsException" />
        public void UpdateClient(string financialInstitutionName, Client client)
        {
            try
            {
                IClientDAO clientDAO = _daoFactory.GetClientDAO ();
                IFinancialInstitutionDAO financialInstitutionDAO = _daoFactory.GetFinancialInstitutionDAO ();

                bool update = false;
                string oldCURP = clientDAO.GetClientCURP (client.Id);

                int curpsEqual = String.Compare (oldCURP, client.CURP, true);

                /* If the curps are the same, it means the curp was not
                * changed, so allow update */
                if (curpsEqual == 0)
                {
                    update = true;
                }
                else
                {
                    /* If curps are different, then check the new curp is not
                    * repeated in the system */
                    bool curpExists = financialInstitutionDAO.ClientExists (financialInstitutionName,
                                                                            client.CURP);
                    if (curpExists)
                    {
                        update = false;
                    }
                    else
                    {
                        update = true;
                    }
                }

                if (update)
                {
                    /* Get the old password */
                    string oldPassword = clientDAO.GetClientPassword (client.Id);

                    /* If passwords are different it means thy changed the password, thus we need to
                    * hash it again */
                    if (oldPassword != client.AccountPassword && client.AccountPassword != null)
                    {
                        //Hash the password for the client.
                        string hashedPassword = Encryption.CreateHash (client.AccountPassword);
                        client.AccountPassword = hashedPassword;
                    }

                    clientDAO.MakePersistent (client);
                }
                else
                {
                    throw new ZiblerBusinessComponentsException (
                        Resources.ClientOperationsMsgClientExists);
                }
            }
            /* 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;
            }
        }
Пример #3
0
 /// <summary>
 /// Adds a new Client to the list of Clients of this Solidarity Group
 /// </summary>
 /// <param name="client">Client to be added</param>
 public virtual void AddClient(Client client)
 {
     client.SolidarityGroup = this;
     Clients.Add(client);
 }
Пример #4
0
        /// <summary>
        /// Creates a new Client in the system using
        /// the given Financial Institution and Username.
        /// </summary>
        /// <param name="financialInstitutionName">Financial Institution the client belongs to.</param>
        /// <param name="userName">User creating the Client</param>
        /// <param name="client">Client to be created.</param>		
        /// <exception cref="ZiblerBusinessComponentsException"/>
        public void CreateNewClient(string financialInstitutionName,
            string userName,
            Client client)
        {
            try
            {
                IFinancialInstitutionDAO financialInstitutionDAO = _daoFactory.GetFinancialInstitutionDAO ();
                IClientDAO clientDAO = _daoFactory.GetClientDAO ();

                //Verify the user does not exist in the system first.
                if (financialInstitutionDAO.ClientExists (financialInstitutionName, client.CURP))
                {
                    //If so, then raise an exception with the appropriate message.
                    throw new ZiblerBusinessComponentsException (
                        Resources.ClientOperationsMsgClientExists);
                }
                else
                {
                    //Hash the password for the client.
                    string hashedPassword = Encryption.CreateHash (client.AccountPassword);
                    client.AccountPassword = hashedPassword;

                    //Get the financial institution, and
                    //make the association to the client.
                    FinancialInstitution financialInstitution = financialInstitutionDAO.GetFinancialInstitutionByName (
                        financialInstitutionName);

                    client.FinancialInstitution = financialInstitution;

                    //Note that I use the client DAO
                    //to make this client persistant.
                    clientDAO.MakePersistent (client);
                }
            }
            /* 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;
            }
        }