Esempio 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;
        }
Esempio 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;
 }
Esempio 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();
        }
Esempio 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;
        }
Esempio n. 5
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();
        }
Esempio n. 6
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;
        }
Esempio n. 7
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;
        }
Esempio n. 8
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;
        }