public async Task <IActionResult> PostLink(string targetObjectID, string[] objectBIDs, string[] objectLinkTypes) { var link = new ObjectLinkPostViewModel() { ObjectBID = long.Parse(objectBIDs[0]), ObjectLinkType = objectLinkTypes[0], TargetObjectID = long.Parse(targetObjectID) }; using (var httpClient = new HttpClient()) { var requestUri = $"{Configuration.DefaultAPI}/objectlinks/post"; httpClient.DefaultRequestHeaders.Add("CurrentUserID", CurrentUserID.ToString()); httpClient.DefaultRequestHeaders.Add("CurrentHomeID", CurrentHomeID.ToString()); using (var response = await httpClient.PostAsJsonAsync(requestUri, link)) { string content = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { link = JsonConvert.DeserializeObject <ObjectLinkPostViewModel>(content); } } } return(Json(ObjectLinksRenderer.BuildPostLink(link))); }
private async Task <List <string> > GetLinks(long targetObjectID) { var links = new List <ObjectLinkPostViewModel>(); using (var httpClient = new HttpClient()) { var requestUri = $"{Configuration.DefaultAPI}/objectlinks/{targetObjectID}"; httpClient.DefaultRequestHeaders.Add("CurrentUserID", CurrentUserID.ToString()); httpClient.DefaultRequestHeaders.Add("CurrentHomeID", CurrentHomeID.ToString()); using (var response = await httpClient.GetAsync(requestUri)) { string content = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { links = JsonConvert.DeserializeObject <List <ObjectLinkPostViewModel> >(content); } } } var result = ObjectLinksRenderer.BuildLinks(links); return(result); }