/// <summary>
 /// Creates an authorization attribute.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public IAzManAttribute <IAzManAuthorization> CreateAttribute(string key, string value)
 {
     try
     {
         //db.tAuthorizationattributes.Insert(this.authorizationId, key, value);
         int authorizationAttributeId = 0;
         authorizationAttributeId = this.db.AuthorizationAttributeInsert(this.authorizationId, key, value, this.item.Application.ApplicationId);
         this.db.SubmitChanges();
         IAzManAttribute <IAzManAuthorization> result = new SqlAzManAuthorizationAttribute(this.db, this, authorizationAttributeId, key, value, this.ens);
         this.raiseAuthorizationAttributeCreated(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);
         }
     }
 }
예제 #2
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);
         }
     }
 }