public async Task <IActionResult> contagion([Microsoft.AspNetCore.Mvc.FromBody] ListOfExStays listStays) { var Stays = new List <Stay>(); foreach (var externalStay in listStays.stays) { Stays.Add(externalStay.ToLocalStay()); } await _infectionManager.UpdateRiskStatusFromStays(Stays.AsQueryable()); return(Ok()); }
public async Task notifyOtherServers(IQueryable <Stay> userStays) { await otherServersDo(async (serverId, baseUrl) => { WebRequest request = WebRequest.Create(baseUrl + "contagion/new"); request.Method = "POST"; request.ContentType = "application/json"; request.Headers.Add("Accept", "application/json"); using (var streamWriter = new StreamWriter(request.GetRequestStream())) { string json = JsonConvert.SerializeObject(ListOfExStays.FromListOfStays(userStays)); streamWriter.Write(json); } try { WebResponse response = await request.GetResponseAsync(); var reader = new StreamReader(response.GetResponseStream()); string responseContent = reader.ReadToEnd(); Console.WriteLine(responseContent); } catch (WebException ex) { // Que hacer si se produce una excepcion. Console.WriteLine(ex); } return(true); }); }