// GET api/ListItem/GetItem/5 public API_ListItem GetItem(string id) { API_ListItem returnItem = new API_ListItem(); using (_dataMethods = new DataMethods()) { var item = _dataMethods.ListItem_GetByPublicKey(id); if (item == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } else { returnItem = returnItem.ConvertToAPI_ListItem(item, item.List.PublicKey); } } return returnItem; }
private static Item CreateListItem(string listPublicKey, Item newItem) { GyftoList.API.Translations.API_ListItem newListItem = new API.Translations.API_ListItem(); var gyftoApi = new API_ListItem(); var translatedListItem = gyftoApi.ConvertToAPI_ListItem(newItem, listPublicKey); Uri apiURI = null; HttpResponseMessage response = client.PostAsJsonAsync("api/listitem/postitem", translatedListItem).Result; if (!response.IsSuccessStatusCode) { throw new Exception("Error"); } else { apiURI = response.Headers.Location; } return newItem; }
/// <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; }