Beispiel #1
0
        public ActionResult Edit(SubTemasEditViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                db.Entry(viewModel.SubTema).State = EntityState.Modified;
                db.SaveChanges();
                AccesoClientesHelper.AnyadirSubTemaConHijos(viewModel.SubTema.SubTemaId, viewModel.Clientes.Where(cli => cli.Selected)
                                                            .Select(cli => Convert.ToInt32(cli.Value)).ToList());

                return(RedirectToAction("Index", new { id = viewModel.SubTema.TemaId }));
            }

            viewModel.Tema = db.Temas.Find(viewModel.Tema.TemaId);

            return(View(viewModel));
        }
Beispiel #2
0
        // GET: Admin/SubTemas/Edit/5
        public ActionResult Edit(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SubTema subtema = db.SubTemas.Where(a => a.SubTemaId == id).FirstOrDefault();

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


            SubTemasEditViewModel viewModel = new SubTemasEditViewModel();

            viewModel.Tema    = db.Temas.Find(subtema.TemaId);
            viewModel.SubTema = subtema;
            viewModel.CargarClienteSeleccionado(db);
            return(View(viewModel));
        }