public async Task <IActionResult> TextDetails(TextDetailsModel textDetailsModel) { if (textDetailsModel.Id != null) { uint retries = 0; string result = null; while (result == null && retries != 5) { result = await GetTextDetails(textDetailsModel.Id); ++retries; } textDetailsModel.Rank = (result == null) ? "Something went wrong..." : result; } return(View(textDetailsModel)); }
public async Task <IActionResult> Index(FormModel formModel) { if (formModel.Data != null) { string id; string url = "http://127.0.0.1:5050/api/values"; StringContent stringContent = new StringContent($"{{ \"data\": \"{formModel.Data}\"}}", Encoding.UTF8, "application/json"); using (HttpClient httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain")); using (HttpResponseMessage response = await httpClient.PostAsync(url, stringContent)) using (HttpContent content = response.Content) { id = content.ReadAsStringAsync().Result; } } TextDetailsModel textDetailsModel = new TextDetailsModel(); textDetailsModel.Id = id; return(RedirectToAction("TextDetails", "Home", textDetailsModel)); } return(View(formModel)); }