public ActionResult Edit(GramaticasEditViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                ActualizarCuerpo(viewModel.Gramatica);
                viewModel.Gramatica.Cuerpo          = null;
                db.Entry(viewModel.Gramatica).State = EntityState.Modified;
                db.SaveChanges();
                AccesoClientesHelper.AnyadirGramaticaConHijos(viewModel.Gramatica.GramaticaId, viewModel.Clientes.Where(cli => cli.Selected)
                                                              .Select(cli => Convert.ToInt32(cli.Value)).ToList());

                return(RedirectToAction("Index", "Bloques", new { id = viewModel.SubTema.SubTemaId, pestanya = (int)PestanyasBloques.Gramaticas }));
            }

            viewModel.SubTema = db.SubTemas.Find(viewModel.SubTema.SubTemaId);
            viewModel.Tema    = db.Temas.Find(viewModel.SubTema.TemaId);

            return(View(viewModel));
        }
        // GET: Admin/Gramaticas/Edit/5
        public ActionResult Edit(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Gramatica gramatica = db.Gramaticas.Include(gra => gra.GramaticaCuerpo).FirstOrDefault(a => a.GramaticaId == id);

            if (gramatica == null)
            {
                return(HttpNotFound());
            }


            GramaticasEditViewModel viewModel = new GramaticasEditViewModel();

            viewModel.Gramatica = gramatica;
            viewModel.SubTema   = db.SubTemas.Find(gramatica.SubTemaId);
            viewModel.Tema      = db.Temas.Find(viewModel.SubTema.TemaId);
            viewModel.CargarClienteSeleccionado(db);
            return(View(viewModel));
        }