Exemplo n.º 1
0
        public List<API_List> GetUserLists(string userPublicKey)
        {
            var rcList = new List<API_List>();
            try
            {
                //
                using (_dataAccess = new DataMethods())
                {
                    var usr = _dataAccess.User_GetUser(userPublicKey);
                    if (usr != null)
                    {
                        var converter = new API_List();
                        var usrLists = _dataAccess.List_GetListByUserID(usr.UserID);
                        foreach (var l in usrLists)
                        {
                            rcList.Add(converter.ConvertToAPI_ListWithAllItems(l));
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to source User: " + userPublicKey);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return rcList;
        }
Exemplo n.º 2
0
 public List<API_User> GetAllUsers()
 {
     var rcUsrs = new List<API_User>();
             var rc = _dataAccess.User_GetAllUsers();
             if (rc == null)
             {
                 throw new HttpResponseException(HttpStatusCode.NotFound);
             }
             else
             {
                 var apiUsr = new API_User();
                 foreach (var usr in rc)
                 {
                     rcUsrs.Add(apiUsr.ConvertToAPI_UserWithoutAssociatedLists(usr));
                 }
             }
             return rcUsrs;
 }
Exemplo n.º 3
0
        /// <summary>
        /// NOTE: THIS WAS ALL AUTO-GENED BY VS2012
        /// </summary>
        // GET api/ListShare
        public IQueryable<API_ListShare>GetListShares()
        {
            API_ListShare converter = new API_ListShare();
            var rcListShares = new List<API_ListShare>();

            using (var dataMethods = new Data.DataMethods())
            {
                var listshares = dataMethods.ListShare_GetAll();
                if (listshares != null)
                {
                    foreach (var s in listshares)
                    {
                        var newItem = converter.ConvertToAPI_ListShareWithAssociatedList(s);
                        rcListShares.Add(newItem);
                    }
                }
            }

            return rcListShares.AsQueryable();
        }
Exemplo n.º 4
0
        // GET api/ListItem/GetItems
        public List<API_ListItem> GetItems()
        {
            List<API_ListItem> returnItems = new List<API_ListItem>();

            try
            {
                using (_dataMethods = new DataMethods())
                {
                    var listItems = _dataMethods.ListItem_GetAll();
                    foreach (var i in listItems)
                    {
                        returnItems.Add(converter.ConvertToAPI_ListItem(i,i.List.PublicKey));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return returnItems;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates an List object with associated List Items from an API_List object
        /// </summary>
        /// <param name="inputList"></param>
        /// <returns></returns>
        public List ConvertFromAPI_List(API_List inputList)
        {
            // First get the base list
            var rcList = new List()
            {
                Description = inputList.Description
                ,
                PublicKey = inputList.PublicKey
                ,
                Title = inputList.ListName
            };

            // Next, add converted Items
            if (inputList.Items.Count > 0)
            {
                var apiListItem = new API_ListItem();
                foreach (var i in inputList.Items)
                {
                    rcList.Items.Add(apiListItem.ConvertFromAPI_ListItem(i));
                }
            }

            // Finally, add converted ListShares
            // TODO: ADD 'CONVERT FROM' FOR API_ListShare
            if (inputList.ListShares.Count > 0)
            {
                var apiListShare = new API_ListShare();
                foreach(var s in inputList.ListShares)
                {

                }
            }

            return rcList;
        }
Exemplo n.º 6
0
        /// <summary>
        /// This method converts a List to an API_List object.
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public API_List ConvertToAPI_ListWithAllItems(List list)
        {
            var rcList = _CreateShellList(list);
            try
            {
                if ((rcList != null) && (list.Items != null) && (list.Items.Count > 0))
                {
                    API_ListItem apiListItem = new API_ListItem();
                    foreach (var i in list.Items.OrderBy(li => li.Ordinal))
                    {
                        rcList.Items.Add(apiListItem.ConvertToAPI_ListItem(i, rcList.PublicKey));
                    }
                }
            }
            catch (ObjectDisposedException)
            {

            }

            return rcList;
        }
Exemplo n.º 7
0
        public IQueryable<API_ListItem> GetItemsForList(string id)
        {
            var rcListItem = new List<API_ListItem>();
            if (id != string.Empty)
            {
                using (_dataMethods = new DataMethods())
                {
                    var list = _dataMethods.List_GetListByPublicKey(id);
                    if (list == null)
                    {
                        throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
                    }
                    else
                    {
                        // Convert each ListItem to an API_ListItem
                        foreach (var i in list.Items)
                        {
                            rcListItem.Add(converter.ConvertToAPI_ListItem(i, id));
                        }
                    }
                }
            }
            else
            {
                throw new HttpException("List Public Key not Provided!");
            }

            return rcListItem.AsQueryable();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates a new Gyfto List
        /// </summary>
        /// <param name="listTitle"></param>
        /// <param name="listDescription"></param>
        /// <param name="userPublicKey"></param>
        /// <returns></returns>
        public List List_CreateList(string listTitle, string listDescription, string userPublicKey)
        {
            List newList = new List();

            try
            {
                newList.Active = true;
                newList.CreateDate = DateTime.Now;
                newList.Description = listDescription;
                newList.Title = listTitle;
                newList.User = User_GetUser(userPublicKey);
                newList.PublicKey = GeneratePublicKey();

                _gyftoListEntities.Lists.AddObject(newList);
                _gyftoListEntities.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return newList;
        }
Exemplo n.º 9
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Lists EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToLists(List list)
 {
     base.AddObject("Lists", list);
 }
Exemplo n.º 10
0
        public List<User> ListItem_GetAllConsumersByListItemPublicKey(string listItemPublicKey)
        {
            var rcUsers = new List<User>();

            using (_gyftoListEntities = new GyftoListEntities())
            {
                // First, get the list of all the consumers for the List this Item is associated to
                var currentItem = ListItem_GetByPublicKey(listItemPublicKey);
                var listConsumers = ListShare_GetCoConsumersForListShare(currentItem.List.PublicKey);

                // Cache all the Item Exclusions
                var itemExclusions = ItemExclusion_GetByItemPublicKey(listItemPublicKey);

                // Next, weed out any Item Exclusions
                foreach (var ls in ListShare_GetAllByListItemPublicKey(listItemPublicKey))
                {
                    if (itemExclusions.Where(ie => ie.ListShareID == ls.ListShareID && ie.ItemID == currentItem.ItemID).Count() == 0)
                    {
                        rcUsers.Add(ls.UserConsumer);
                    }
                }
            }

            return rcUsers;
        }
Exemplo n.º 11
0
        /// <summary>
        /// This returns all the Items for a given List
        /// </summary>
        /// <param name="listID">Internal List ID</param>
        /// <param name="onlyActive">True = only get Active items</param>
        /// <returns></returns>
        public List<Item> ListItem_GetAllByListID(int listID, bool onlyActive)
        {
            var rcItems = new List<Item>();
            if (onlyActive)
            {
                rcItems = _gyftoListEntities.Items.Where(i => i.ListID == listID && i.Active == true).ToList();
            }
            else
            {
                rcItems = _gyftoListEntities.Items.Where(i => i.ListID == listID).ToList();
            }

            return rcItems;
        }
Exemplo n.º 12
0
        /// <summary>
        /// This returns all Items within Gyfto
        /// </summary>
        /// <returns></returns>
        public List<Item> ListItem_GetAll()
        {
            List<Item> rcListItems = new List<Item>();
            try
            {
                rcListItems = _gyftoListEntities.Items.Where(i => i.Active == true).ToList();
            }
            catch (Exception)
            {

                throw;
            }

            return rcListItems;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Gets an Item Exclusion by it's associated Item 
        /// </summary>
        /// <param name="itemPublicKey"></param>
        /// <returns></returns>
        public List<ItemExclusion> ItemExclusion_GetByItemPublicKey(string itemPublicKey)
        {
            var rc = new List<ItemExclusion>();
            try
            {
                var item = ListItem_GetByPublicKey(itemPublicKey);
                if (item != null)
                {
                    rc = _gyftoListEntities.ItemExclusions.Where(i => i.ItemID == item.ItemID).ToList();
                }
                else
                {
                    throw new Exception(string.Format("Unable to get Item with Public Key '{0}'", itemPublicKey));
                }
            }
            catch (Exception)
            {
                throw;
            }

            return rc;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Return a collection of List Item Exclusions by List Share Public Key
        /// </summary>
        /// <param name="publicKey">List Share Public Key</param>
        /// <returns></returns>
        public List<ItemExclusion> ItemExclusion_GetAllByListShare(string publicKey)
        {
            //TODO: Test by attempting to get all the Item Exclusions for a know List Share
            var rcItemExclusions = new List<ItemExclusion>();

            //Get the List Share, then iterate across all the Items and then all the associated Item Exclusions
            var listShare = ListShare_GetByPublicKeyWithAssociatedItems(publicKey);
            return _gyftoListEntities.ItemExclusions.Where(i => i.ListShareID == listShare.ListShareID).ToList();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Returns a list of Gyfto Users
        /// </summary>
        /// <returns></returns>
        public List<User> User_GetAllUsers()
        {
            //return _gyftoListEntities.Users;
            List<User> returnUsers = new List<User>();

            try
            {
                //using (_gyftoListEntities = new GyftoListEntities())
                //{
                    foreach (var usr in _gyftoListEntities.Users)
                    {
                        returnUsers.Add(usr);
                    }
                //}
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Unable to return list of All Users - Error: '{0}'", ex.InnerException.ToString()));
            }

            return returnUsers;
        }
Exemplo n.º 16
0
 /// <summary>
 /// Create a new List object.
 /// </summary>
 /// <param name="listID">Initial value of the ListID property.</param>
 /// <param name="createDate">Initial value of the CreateDate property.</param>
 public static List CreateList(global::System.Int32 listID, global::System.DateTime createDate)
 {
     List list = new List();
     list.ListID = listID;
     list.CreateDate = createDate;
     return list;
 }
Exemplo n.º 17
0
        /// <summary>
        /// Gets all the ListShares for a specific List
        /// </summary>
        /// <param name="listPublicKey"></param>
        /// <returns></returns>
        public List<ListShare> ListShare_GetAllByListPublicKey(string listPublicKey)
        {
            var rcListShare = new List<ListShare>();

            //using (_gyftoListEntities = new GyftoListEntities())
            //{

                List usrList = _gyftoListEntities.Lists.SingleOrDefault(l => l.PublicKey == listPublicKey);
                rcListShare = _gyftoListEntities.ListShares.Where(ls => ls.ListID == usrList.ListID).ToList();

            //}
            return rcListShare;
        }
Exemplo n.º 18
0
        /// <summary>
        /// Gets all the ListShares for a particular User/Owner by their PublicKey
        /// </summary>
        /// <param name="ownerPublicKey"></param>
        /// <returns></returns>
        public List<ListShare> ListShare_GetAllListSharesForOwner(string ownerPublicKey)
        {
            List<ListShare> listShares = new List<ListShare>();

            User usrOwner = _gyftoListEntities.Users.Where(c => c.PublicKey == ownerPublicKey).First();
            listShares = _gyftoListEntities.ListShares.Where(ls => ls.OwnerID == usrOwner.UserID).ToList();

            return listShares;
        }
Exemplo n.º 19
0
        /// <summary>
        /// Returns all Consumers of List Shares for a base List
        /// </summary>
        /// <param name="listPublicKey"></param>
        /// <returns></returns>
        public List<User> ListShare_GetCoConsumersForListShare(string listPublicKey)
        {
            var rcUsers = new List<User>();

            try
            {
                // Get the base list
                foreach (var ls in ListShare_GetAllByListPublicKey(listPublicKey))
                {
                    rcUsers.Add(ls.UserConsumer);
                }

            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Unable to located Co-Consumers for this List Share - '{0}'",ex.InnerException.ToString()));
            }

            return rcUsers;
        }