/// <summary> /// This builds a base/shell API_ListShare object /// </summary> /// <param name="listShare"></param> /// <returns></returns> private API_ListShare GetShellListShare(ListShare listShare) { var apiShare = new API_ListShare(); var apiUsr = new API_User(); var apiList = new API_List(); DataMethods _dataMethods = new DataMethods(); var uConsumerObj = _dataMethods.User_GetUser(listShare.ConsumerID); var oConsumerObj = _dataMethods.User_GetUser(listShare.OwnerID); var uConsumer = apiUsr.ConvertToAPI_UserWithoutAssociatedLists(uConsumerObj); var uOwner = apiUsr.ConvertToAPI_UserWithoutAssociatedLists(oConsumerObj); apiShare.PublicKey = listShare.PublicKey; apiShare.ConsumerPublicKey = uConsumer.PublicKey; apiShare.OwnerPublicKey = uOwner.PublicKey; apiShare.ConsumerDisplayName = uConsumer.DisplayName; apiShare.OwnerDisplayName = uOwner.DisplayName; return apiShare; }
/// <summary> /// Deprecated Method for adding a new object to the ListShares EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToListShares(ListShare listShare) { base.AddObject("ListShares", listShare); }
/// <summary> /// Creates a new ListShare for the provided List and Consumer /// </summary> /// <param name="listPublicKey"></param> /// <param name="consumerPublicKey"></param> /// <returns></returns> public ListShare ListShare_Create(string listPublicKey, string consumerPublicKey) { ListShare newListShare = new ListShare(); try { var list = List_GetListByPublicKey(listPublicKey); var userConsumer = User_GetUser(consumerPublicKey); var userOwner = User_GetUser(Convert.ToInt32(list.UserID)); if ((list == null) || (userConsumer == null) || (userOwner == null)) { throw new Exception("Unable to resolve source list, user consumer or user owner"); } newListShare.CreateDate = DateTime.Now; newListShare.UserConsumer = userConsumer; newListShare.UserOwner = userOwner; newListShare.List = list; newListShare.PublicKey = GeneratePublicKey(); _gyftoListEntities.ListShares.AddObject(newListShare); _gyftoListEntities.SaveChanges(); } catch (Exception) { throw; } return newListShare; }
/// <summary> /// Create a new ListShare object. /// </summary> /// <param name="listShareID">Initial value of the ListShareID property.</param> /// <param name="listID">Initial value of the ListID 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> /// <param name="ownerID">Initial value of the OwnerID property.</param> public static ListShare CreateListShare(global::System.Int32 listShareID, global::System.Int32 listID, global::System.Int32 consumerID, global::System.String publicKey, global::System.DateTime createDate, global::System.Int32 ownerID) { ListShare listShare = new ListShare(); listShare.ListShareID = listShareID; listShare.ListID = listID; listShare.ConsumerID = consumerID; listShare.PublicKey = publicKey; listShare.CreateDate = createDate; listShare.OwnerID = ownerID; return listShare; }
/// <summary> /// Gets a List Share with Items included /// </summary> /// <param name="publicKey"></param> /// <returns></returns> public ListShare ListShare_GetByPublicKeyWithAssociatedItems(string publicKey) { var rcLS = new ListShare(); rcLS = _gyftoListEntities.ListShares.Include("List").Include("UserOwner").Include("UserConsumer").SingleOrDefault(ls => ls.PublicKey == publicKey); // Need to filter out any items not available for the current ListShare if (rcLS != null) { rcLS.List.Items.Clear(); var filteredItems = ListItem_GetAllByListID(rcLS.ListID, true).Where(i => !ItemExclusion_GetAllByListShareID(rcLS.ListShareID).Any(ie => ie.ItemID == i.ItemID)); var count = filteredItems.Count(); foreach (var li in filteredItems) { rcLS.List.Items.Add(li); } } return rcLS; }