public async Task <IActionResult> saveConfigurationForm(string modo) { var client = new HttpClient(); var wclient = new WebClient(); var result = wclient.DownloadString(_configuration["HostUrl"]); var obj = JsonConvert.DeserializeObject <JsonAlimentador>(result); var data = new JsonAlimentador { alerta = obj.alerta, hora1 = obj.hora1, hora2 = obj.hora2, hora3 = obj.hora3, hora4 = obj.hora4, modo = modo, nombreMascota = obj.nombreMascota, porcion = obj.porcion }; var response = await client.PutAsJsonAsync(_configuration["HostUrl"], data); response.EnsureSuccessStatusCode(); ViewBag.modo = modo; return(View("Index")); }
public async Task <IActionResult> saveConfiguration(string nombreMascota, string hora1, string hora2, string hora3, string hora4, int porcion) { var webClient = new WebClient(); var result = webClient.DownloadString(_configuration["HostUrl"]); var obj = JsonConvert.DeserializeObject <JsonAlimentador>(result); var client = new HttpClient(); var data = new JsonAlimentador { nombreMascota = nombreMascota, hora1 = hora1, hora2 = hora2, hora3 = hora3, hora4 = hora4, porcion = porcion, modo = "normal" }; if (obj != null) { data.modo = obj.modo ?? "normal"; } var response = await client.PutAsJsonAsync(_configuration["HostUrl"], data); response.EnsureSuccessStatusCode(); return(RedirectToAction("Index")); }
public async Task <IActionResult> setConfiguration(string nombreMascota, string hora1, string hora2, string hora3, string hora4, int porcion, string alerta, string modo) { var client = new HttpClient(); var data = new JsonAlimentador { alerta = bool.Parse(alerta), nombreMascota = nombreMascota, hora1 = hora1, hora2 = hora2, hora3 = hora3, hora4 = hora4, porcion = porcion, modo = modo }; var response = await client.PutAsJsonAsync(_configuration["HostUrl"], data); response.EnsureSuccessStatusCode(); return(Ok()); }