Example #1
0
 /// <summary>
 /// Creates a store attribute.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public IAzManAttribute <IAzManStore> CreateAttribute(string key, string value)
 {
     try
     {
         int storeAttributeId = this.db.StoreAttributeInsert(this.storeId, key, value);
         IAzManAttribute <IAzManStore> result = new SqlAzManStoreAttribute(this.db, this, storeAttributeId, key, value, this.ens);
         this.raiseStoreAttributeCreated(this, result);
         if (this.ens != null)
         {
             this.ens.AddPublisher(result);
         }
         return(result);
     }
     catch (System.Data.SqlClient.SqlException sqlex)
     {
         if (sqlex.Number == 2601) //Index Duplicate Error
         {
             throw SqlAzManException.AttributeDuplicateException(key, this, sqlex);
         }
         else
         {
             throw SqlAzManException.GenericException(sqlex);
         }
     }
 }
Example #2
0
        /// <summary>
        /// Gets the store attribute.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        public IAzManAttribute <IAzManStore> GetAttribute(string key)
        {
            StoreAttributesResult sar;

            if ((sar = (from t in this.db.StoreAttributes() where t.StoreId == this.storeId && t.AttributeKey == key select t).FirstOrDefault()) != null)
            {
                IAzManAttribute <IAzManStore> result = new SqlAzManStoreAttribute(this.db, this, sar.StoreAttributeId.Value, sar.AttributeKey, sar.AttributeValue, this.ens);
                if (this.ens != null)
                {
                    this.ens.AddPublisher(result);
                }
                return(result);
            }
            else
            {
                throw SqlAzManException.AttributeNotFoundException(key, this.name, null);
            }
        }
Example #3
0
        /// <summary>
        /// Gets the store attributes.
        /// </summary>
        /// <returns></returns>
        public IAzManAttribute <IAzManStore>[] GetAttributes()
        {
            IAzManAttribute <IAzManStore>[] attributes;
            var ds = (from tf in this.db.StoreAttributes()
                      where tf.StoreId == this.storeId
                      select tf).ToList();

            attributes = new SqlAzManStoreAttribute[ds.Count];
            int index = 0;

            foreach (var row in ds)
            {
                attributes[index] = new SqlAzManStoreAttribute(this.db, this, row.StoreAttributeId.Value, row.AttributeKey, row.AttributeValue, this.ens);
                if (this.ens != null)
                {
                    this.ens.AddPublisher(attributes[index]);
                }
                index++;
            }
            return(attributes);
        }