예제 #1
0
        // GET: Carga/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Estampita jugadorBuscado = db.diccionario2[id];

            if (jugadorBuscado == null)
            {
                return(HttpNotFound());
            }
            if (jugadorBuscado.valor == false)
            {
                jugadorBuscado.valor = true;
            }
            else
            {
                jugadorBuscado.valor = false;
            }


            return(RedirectToAction("Index2"));
        }
예제 #2
0
        public ActionResult Create2(HttpPostedFileBase postedFile)
        {
            if (postedFile != null)
            {
                string filepath = string.Empty;

                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 csvData = System.IO.File.ReadAllText(filepath);

                try
                {
                    JArray json = JArray.Parse(csvData);

                    foreach (JObject jsonOperaciones in json.Children <JObject>())
                    {
                        foreach (JProperty property in jsonOperaciones.Properties())
                        {
                            bool      x   = (bool)property.Value;
                            Estampita aux = new Estampita();
                            aux.Nombre = property.Name;
                            aux.valor  = x;
                            db.ListadoFinal.Add(aux);
                            db.diccionario2.Add(aux.Nombre, aux);
                        }
                    }
                    ViewBag.Message = "Cargado Exitosamente";
                }
                catch
                {
                    ViewBag.Message1 = "Dato erroneo.";
                }
            }
            return(View());
        }