/// <summary>
 /// Create a new ItemShare object.
 /// </summary>
 /// <param name="itemShareID">Initial value of the ItemShareID property.</param>
 /// <param name="listShareID">Initial value of the ListShareID property.</param>
 /// <param name="itemID">Initial value of the ItemID property.</param>
 /// <param name="consumerID">Initial value of the ConsumerID property.</param>
 /// <param name="publicKey">Initial value of the PublicKey property.</param>
 /// <param name="createDate">Initial value of the CreateDate property.</param>
 public static ItemShare CreateItemShare(global::System.Int32 itemShareID, global::System.Int32 listShareID, global::System.Int32 itemID, global::System.Int32 consumerID, global::System.String publicKey, global::System.DateTime createDate)
 {
     ItemShare itemShare = new ItemShare();
     itemShare.ItemShareID = itemShareID;
     itemShare.ListShareID = listShareID;
     itemShare.ItemID = itemID;
     itemShare.ConsumerID = consumerID;
     itemShare.PublicKey = publicKey;
     itemShare.CreateDate = createDate;
     return itemShare;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the ItemShares EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToItemShares(ItemShare itemShare)
 {
     base.AddObject("ItemShares", itemShare);
 }
Esempio n. 3
0
        /// <summary>
        /// Creates a new ItemShare for a given ListShare and Item
        /// </summary>
        /// <param name="listShareID"></param>
        /// <param name="itemID"></param>
        /// <returns></returns>
        public ItemShare ItemShare_Create(int listShareID, int itemID)
        {
            var newItemShare = new ItemShare();
            try
            {
                newItemShare.CreateDate = DateTime.Now;
                newItemShare.PublicKey = GeneratePublicKey();
                newItemShare.ListShareID = listShareID;
                newItemShare.ItemID = itemID;

                using(_gyftoListEntities = new GyftoListEntities())
                {
                    _gyftoListEntities.ItemShares.AddObject(newItemShare);
                    _gyftoListEntities.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Unable to create ItemShare - Error: '{1}'", ex.InnerException.ToString()));
            }

            return newItemShare;
        }