Esempio n. 1
0
 /// <summary>
 /// Gets the itemName attribute.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <returns></returns>
 public IAzManAttribute<IAzManItem> GetAttribute(string key)
 {
     ItemAttributesResult iar;
     if ((iar = (from t in this.db.ItemAttributes() where t.ItemId == this.itemId && t.AttributeKey == key select t).FirstOrDefault()) != null)
     {
         IAzManAttribute<IAzManItem> result = new SqlAzManItemAttribute(this.db, this, iar.ItemAttributeId.Value, iar.AttributeKey, iar.AttributeValue, this.ens);
         if (this.ens != null)
             this.ens.AddPublisher(result);
         return result;
     }
     else
     {
         throw SqlAzManException.AttributeNotFoundException(key, this.application.Store.Name, this.application.Name, this.name, null);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Gets the itemName attributes.
 /// </summary>
 /// <returns></returns>
 public IAzManAttribute<IAzManItem>[] GetAttributes()
 {
     IAzManAttribute<IAzManItem>[] attributes;
     var ia = from tf in this.db.ItemAttributes()
              where tf.ItemId == this.itemId
              select tf;
     attributes = new SqlAzManItemAttribute[ia.Count()];
     int index = 0;
     foreach (var row in ia)
     {
         attributes[index] = new SqlAzManItemAttribute(this.db, this, row.ItemAttributeId.Value, row.AttributeKey, row.AttributeValue, this.ens);
         if (this.ens != null)
             this.ens.AddPublisher(attributes[index]);
         index++;
     }
     return attributes;
 }
Esempio n. 3
0
 /// <summary>
 /// Creates an itemName attribute.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public IAzManAttribute<IAzManItem> CreateAttribute(string key, string value)
 {
     try
     {
         int itemAttributeId = this.db.ItemAttributeInsert(this.itemId, key, value, this.application.ApplicationId);
         IAzManAttribute<IAzManItem> result = new SqlAzManItemAttribute(this.db, this, itemAttributeId, key, value, this.ens);
         this.raiseItemAttributeCreated(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);
     }
 }