public ActionResult Importar(HttpPostedFileBase postedFile) { string filePath = string.Empty; if (postedFile != null) { string path = Server.MapPath("~/Uploads/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } filePath = path + Path.GetFileName(postedFile.FileName); string extension = Path.GetExtension(postedFile.FileName); postedFile.SaveAs(filePath); string JSON_DATA = System.IO.File.ReadAllText(filePath); var pelicula = Pelicula.FromJson(JSON_DATA); foreach (var item in pelicula) { Data1.Instance.Pelicula.Add(new Pelicula { Nombre = item.Value.Nombre, Año = item.Value.Año, Genero = item.Value.Genero, Tipo = item.Value.Tipo }); //aqui tengo que ingresar datos al arbol pero no se como peliculas toadd = new peliculas(item.Value.Nombre, item.Value.Tipo, item.Value.Año, item.Value.Genero, 0); if (item.Value.Tipo == "Show") { nshow.insetNode(toadd, 0); yshow.insetNode(toadd, 1); gshow.insetNode(toadd, 2); } if (item.Value.Tipo == "Pelicula") { nmovie.insetNode(toadd, 0); ymovie.insetNode(toadd, 1); gmovie.insetNode(toadd, 2); } if (item.Value.Tipo == "Documental") { ndoc.insetNode(toadd, 0); ydoc.insetNode(toadd, 1); gdoc.insetNode(toadd, 2); } } } return(RedirectToAction("Importar")); }
public ActionResult Sign_In(FormCollection collection) { try { if (collection["Nombre"] != null) { var model = new Usuarios { Nombre = collection["Nombre"], Apellido = collection["Apellido"], Edad = Convert.ToInt16(collection["Edad"]), Username = collection["Username"], Password = collection["Password"] }; Data.Instance.usuarios.Add(model); List <Usuarios> JSON_USER = new List <Usuarios>(); foreach (var item in Data.Instance.usuarios) { users toadd = new users(item.Edad, item.Nombre, item.Apellido, item.Username, item.Password); nuser.insetNode(toadd, 0); } var JSON_USER2 = ""; JSON_USER2 = JsonConvert.SerializeObject(Data.Instance.usuarios); historial_user.escribirArchivo(JSON_USER2); } return(View()); } catch { return(View()); } }