Exemplo n.º 1
0
        private static Item GetListItemByPublicKey(string listItemPublicKey)
        {
            GyftoList.API.Translations.API_ListItem newListItem = new API.Translations.API_ListItem();
            var gyftoApi = new API_ListItem();
            Item translatedListItem = null;

            var requestURI = string.Format("api/ListItem/GetItem/{0}",listItemPublicKey);
            HttpResponseMessage response = client.GetAsync(requestURI.ToString()).Result;
            if (!response.IsSuccessStatusCode)
            {
                throw new Exception("Error");
            }
            else
            {
                translatedListItem = gyftoApi.ConvertFromAPI_ListItem(response.Content.ReadAsAsync<API_ListItem>().Result);
            }

            return translatedListItem;
        }
Exemplo n.º 2
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;
        }