Exemplo n.º 1
0
        private DBACL GetAclFromReader(IDataReader dataReader)
        {
            var item = new DBACL();

            item.AclId            = NopSqlDataHelper.GetInt(dataReader, "ACLID");
            item.CustomerActionId = NopSqlDataHelper.GetInt(dataReader, "CustomerActionID");
            item.CustomerRoleId   = NopSqlDataHelper.GetInt(dataReader, "CustomerRoleID");
            item.Allow            = NopSqlDataHelper.GetBoolean(dataReader, "Allow");
            return(item);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets an ACL by identifier
        /// </summary>
        /// <param name="aclId">ACL identifier</param>
        /// <returns>ACL</returns>
        public override DBACL GetAclById(int aclId)
        {
            DBACL     item      = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_ACLLoadByPrimaryKey");

            db.AddInParameter(dbCommand, "ACLID", DbType.Int32, aclId);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    item = GetAclFromReader(dataReader);
                }
            }
            return(item);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates the ACL
        /// </summary>
        /// <param name="aclId">The ACL identifier</param>
        /// <param name="customerActionId">The customer action identifier</param>
        /// <param name="customerRoleId">The customer role identifier</param>
        /// <param name="allow">The value indicating whether action is allowed</param>
        /// <returns>An ACL</returns>
        public override DBACL UpdateAcl(int aclId, int customerActionId,
                                        int customerRoleId, bool allow)
        {
            DBACL     item      = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_ACLUpdate");

            db.AddInParameter(dbCommand, "ACLID", DbType.Int32, aclId);
            db.AddInParameter(dbCommand, "CustomerActionID", DbType.Int32, customerActionId);
            db.AddInParameter(dbCommand, "CustomerRoleID", DbType.Int32, customerRoleId);
            db.AddInParameter(dbCommand, "Allow", DbType.Boolean, allow);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                item = GetAclById(aclId);
            }

            return(item);
        }