Esempio n. 1
0
        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
                    });
                }
            }
            return(RedirectToAction("Importar"));
        }
Esempio n. 2
0
        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"));
        }