public void OnPost() { nombre = Request.Form[nameof(nombre)]; dni = Request.Form[nameof(dni)].ToString().Replace(".", ""); fiebre = Request.Form[nameof(fiebre)].ToString().Contains("true")? "SI" : "NO"; tos = Request.Form[nameof(tos)].ToString().Contains("true")? "SI" : "NO";; garganta = Request.Form[nameof(garganta)].ToString().Contains("true")? "SI" : "NO";; olfato = Request.Form[nameof(olfato)].ToString().Contains("true")? "SI" : "NO";; respirar = Request.Form[nameof(respirar)].ToString().Contains("true")? "SI" : "NO";; diarrea = Request.Form[nameof(diarrea)].ToString().Contains("true")? "SI" : "NO";; vomito = Request.Form[nameof(vomito)].ToString().Contains("true")? "SI" : "NO";; erupciones = Request.Form[nameof(erupciones)].ToString().Contains("true")? "SI" : "NO";; cabeza = Request.Form[nameof(cabeza)].ToString().Contains("true")? "SI" : "NO";; muscular = Request.Form[nameof(muscular)].ToString().Contains("true")? "SI" : "NO";; sangrado = Request.Form[nameof(sangrado)].ToString().Contains("true")? "SI" : "NO";; piel = Request.Form[nameof(piel)].ToString().Contains("true")? "SI" : "NO";; contacto = Request.Form[nameof(contacto)].ToString().Contains("true")? "SI" : "NO";; contacto_desc = Request.Form[nameof(contacto_desc)]; test = Request.Form[nameof(test)].ToString().Contains("true")? "SI" : "NO";; test_desc = Request.Form[nameof(test_desc)]; fecha_test = Request.Form[nameof(fecha_test)]; surveyform sr = new surveyform(); sr.nombre = nombre.ToUpper(); sr.dni = dni.ToUpper(); sr.fiebre = fiebre; sr.tos = tos; sr.garganta = garganta; sr.olfato = olfato; sr.respirar = respirar; sr.diarrea = diarrea; sr.vomito = vomito; sr.erupciones = erupciones; sr.cabeza = cabeza; sr.muscular = muscular; sr.sangrado = sangrado; sr.piel = piel; sr.contacto = contacto; sr.contacto_desc = contacto_desc; sr.test = test; sr.test_desc = test_desc; sr.fecha_test = fecha_test; //Obtengo el directorio para el archivo var service = HttpContext.RequestServices.GetService(typeof(Microsoft.AspNetCore.Hosting.IHostingEnvironment)) as Microsoft.AspNetCore.Hosting.IHostingEnvironment; string folderName = "json/"; string webRootPath = service.WebRootPath; string newPath = Path.Combine(webRootPath, folderName); //Serializo el objeto a json string objeto = JsonConvert.SerializeObject(sr); //Escribo en disco el archivo System.IO.File.WriteAllText(newPath + @"/person_" + dni + ".json", objeto); // Genero el QR qrsourcefile = "https://api.qrserver.com/v1/create-qr-code/?data=https://usurvey.azurewebsites.net/About?id=" + dni + "&size=100x100"; }
public void OnGet() { string id = Request.Query["id"]; if (id != null) { Message = "Usuario DNI " + id; //Obtengo el directorio para el archivo json var service = HttpContext.RequestServices.GetService(typeof(Microsoft.AspNetCore.Hosting.IHostingEnvironment)) as Microsoft.AspNetCore.Hosting.IHostingEnvironment; string folderName = "json/"; string webRootPath = service.WebRootPath; string Path = System.IO.Path.Combine(webRootPath, folderName); // Cargo el json en la entidad surveyform sf = JsonConvert.DeserializeObject <surveyform>(System.IO.File.ReadAllText(Path + @"/person_" + id + ".json")); nombre = sf.nombre; dni = sf.dni; nombre = sf.nombre; dni = sf.dni; fiebre = sf.fiebre; tos = sf.tos; garganta = sf.garganta; olfato = sf.olfato; respirar = sf.respirar; diarrea = sf.diarrea; vomito = sf.vomito; erupciones = sf.erupciones; cabeza = sf.cabeza; muscular = sf.muscular; sangrado = sf.sangrado; piel = sf.piel; contacto = sf.contacto; contacto_desc = sf.contacto_desc; test = sf.test; test_desc = sf.test_desc; fecha_test = sf.fecha_test; temperatura = sf.temperatura; Message = (temperatura != null) ? "Esta DDJJ ya se encuentra completa. Usuario DNI: " + dni + " Nombre: " + nombre + " Temperatura: º" + temperatura : ""; } else { temperatura = ""; Message = "No se encontro la declaracion para el usuario, o el codigo de seguridad es incorrecto."; } }
public void OnPost() { temperatura = ""; string id = Request.Query["id"]; temperatura = Request.Form[nameof(temperatura)]; var service = HttpContext.RequestServices.GetService(typeof(Microsoft.AspNetCore.Hosting.IHostingEnvironment)) as Microsoft.AspNetCore.Hosting.IHostingEnvironment; string folderName = "json/"; string webRootPath = service.WebRootPath; string Path = System.IO.Path.Combine(webRootPath, folderName); // Cargo el json en la entidad surveyform sf = JsonConvert.DeserializeObject <surveyform>(System.IO.File.ReadAllText(Path + @"/person_" + id + ".json")); sf.temperatura = temperatura; //Serializo el objeto a json string objeto = JsonConvert.SerializeObject(sf); //Escribo en disco el archivo System.IO.File.WriteAllText(Path + @"/person_" + sf.dni + ".json", objeto); }