public ActionResult Create(SubCategoria subcategoria, bool express) { if (ModelState.IsValid) { db.SubCategoria.Add(subcategoria); db.SaveChanges(); if (express == true) { return RedirectToAction("Express", "Categoria"); } return RedirectToAction("Index"); } ViewBag.IDCATEGORIA = new SelectList(db.Categoria, "ID", "NOMBRE", subcategoria.IDCATEGORIA); return View(subcategoria); }
public ActionResult Create(Categoria categoria, bool express) { tipusu(); if (ModelState.IsValid) { db.Categoria.Add(categoria); db.SaveChanges(); SubCategoria sub = new SubCategoria(); sub.NOMBRE = "OTROS"; sub.IDCATEGORIA = categoria.ID; db.SubCategoria.Add(sub); db.SaveChanges(); if (express == true) { return RedirectToAction("Express"); } return RedirectToAction("Index"); } return View(categoria); }
public ActionResult Edit(SubCategoria subcategoria) { if (ModelState.IsValid) { db.Entry(subcategoria).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.IDCATEGORIA = new SelectList(db.Categoria, "ID", "NOMBRE", subcategoria.IDCATEGORIA); return View(subcategoria); }