public void DeleteMultipleAttribute(
            Guid accountId,
            string attributeCode)
        {
            string sqlText = "delete from member_account_attribute " +
                            "where account_id = @accountId " +
                            "and account_attribute_type_id = @typeId";

            DAOCommand cmd = new DAOCommand((SQLiteConnection)this.GetConnection());
            DAOAction act = new DAOAction();
            act.Action = sqlText;

            act.AddParameter("@accountId", accountId.ToString());
            //act.AddParameter("@oldValue", oldValue);

            //retrieve the type id from the singleton
            int typeId = SingletonBase<AccountAttributeType>.GetInstance()[attributeCode].Id;

            act.AddParameter("@typeId", typeId);

            cmd.AddAction(act);

            try
            {
                cmd.ExecuteCommand();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
 /// <summary>
 /// Add a DAOAction to the execution.
 /// </summary>
 /// <param name="action"></param>
 public void AddAction(DAOAction action)
 {
     this.actions.Add(action);
 }
        public void DeleteContact(Guid AccountId, int ContactId)
        {
            string sqlText = " delete from member_account_contact " +
                           " where account_id = @accountId and contact_id = @contactId; " +
                           " delete from member_contact " +
                           " where contact_id = @contactId ";

            DAOCommand cmd = new DAOCommand((SQLiteConnection)this.GetConnection());
            DAOAction act = new DAOAction();
            act.Action = sqlText;

            act.AddParameter("@contactId", ContactId);
            act.AddParameter("@accountId", AccountId.ToString());

            cmd.AddAction(act);

            try
            {
                cmd.ExecuteCommand();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        /// <summary>
        /// Insert an attribute for a user.
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="attributeCode"></param>
        /// <param name="value"></param>
        public void InsertAttribute(
            Guid accountId,
            string attributeCode,
            string value)
        {
            string sqlText = "insert into member_account_attribute " +
                        "(account_id, account_attribute_type_id, account_attribute_value) " +
                        "values " +
                        "(@accountId, @typeId, @value)";

            DAOCommand cmd = new DAOCommand((SQLiteConnection)this.GetConnection());
            DAOAction act = new DAOAction();
            act.Action = sqlText;

            act.AddParameter("@accountId", accountId.ToString());
            act.AddParameter("@value", value);

                        //retrieve the type id from the singleton
            int typeId = SingletonBase<AccountAttributeType>.GetInstance()[attributeCode].Id;

            act.AddParameter("@typeId", typeId);

            cmd.AddAction(act);

            try {
                cmd.ExecuteCommand();
            } catch(Exception e) {
                throw e;
            }
        }
        /// <summary>
        /// Creates an account.
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="password"></param>
        /// <param name="username"></param>
        /// <param name="statusCode"></param>
        public void CreateAccount(
            Guid accountId,
            string password,
            string username,
            string statusCode)
        {
            DAOCommand cmd = new DAOCommand((SQLiteConnection)this.GetConnection());

                    //create the account in the member_account
            DAOAction act1 = new DAOAction();

            string sqlText = "insert into member_account " +
                        "(account_id, password, account_status_id) " +
                            "values " +
                        "(@accountId, @password, @statusId)";

            act1.Action = sqlText;

            act1.AddParameter("@accountId", accountId.ToString());
            act1.AddParameter("@password", password);

                    //retrieve the type id from the singleton
            int statusId = SingletonBase<AccountStatus>.GetInstance()[statusCode].Id;

            act1.AddParameter("@statusId", statusId);

            //add the user name into the username table
            DAOAction act2 = new DAOAction();

            string sqlText2 = "insert into member_account_username " +
                        "(account_id, username) " +
                            "values " +
                        "(@accountId, @username)";

            act2.Action = sqlText2;

            act2.AddParameter("@accountId", accountId.ToString());
            act2.AddParameter("@username", username);

            cmd.AddAction(act1);
            cmd.AddAction(act2);
            try {
                cmd.ExecuteCommand();
            } catch(Exception e) {
                throw e;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Updates the attribute for a user.
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="attributeCode"></param>
        /// <param name="newValue"></param>
        public void UpdateAttribute(
            Guid	accountId,
            string	attributeCode,
            string	newValue)
        {
            string sqlText = "update member_account_attribute " +
                    "set account_attribute_value = @attrValue " +
                    "where account_id = @accountId and account_attribute_type_id = @typeId";

            DAOCommand cmd = new DAOCommand((SqlConnection)this.GetConnection());
            DAOAction act = new DAOAction();
            act.Action = sqlText;

            act.AddParameter("@accountId", accountId);
            act.AddParameter("@attrValue", newValue);

                        //retrieve the type id from the singleton
            int typeId = SingletonBase<AccountAttributeType>.GetInstance()[attributeCode].Id;

            act.AddParameter("@typeId", typeId);

            cmd.AddAction(act);

            try {
                cmd.ExecuteCommand();
            } catch(Exception e) {
                throw e;
            }
        }