Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. [HttpPost]
  2. [ValidateAntiForgeryToken]
  3. public ActionResult CrEd([Bind(Include = "IdUsuario,Nombre,Contrasena,Descripcion,Estatus,IdRol")] Usuarios usuarios, int bandera)
  4. {
  5. if(bandera == 1)
  6. {
  7. if (ModelState.IsValid)
  8. {
  9. db.Usuarios.Add(usuarios);
  10. db.SaveChanges();
  11. return RedirectToAction("Index");
  12. }
  13.  
  14. ViewBag.IdRol = new SelectList(db.UsuariosRol, "IdRol", "Nombre", usuarios.IdRol);
  15. return View(usuarios);
  16. }else
  17. {
  18. if (ModelState.IsValid)
  19. {
  20. db.Entry(usuarios).State = EntityState.Modified;
  21. db.SaveChanges();
  22. return RedirectToAction("Index");
  23. }
  24. ViewBag.IdRol = new SelectList(db.UsuariosRol, "IdRol", "Nombre", usuarios.IdRol);
  25. return View(usuarios);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement