public ActionResult Agregar(int id = 0) { using (var db = new ApplicationDbContext()) { permiso = db.PermisosAvanzados.Where(x => x.Id == id).SingleOrDefault(); } return(View(id == 0 ? new PermisoAvanzado() : permiso)); }
public ActionResult Guardar(PermisoAvanzado persona) { if (ModelState.IsValid) { using (var db = new ApplicationDbContext()) { if (persona.Id > 0) { db.Entry(this).State = EntityState.Modified; } else { db.Entry(this).State = EntityState.Added; } db.SaveChanges(); } return(Redirect("~/PermisoAvanzado")); } else { return(View("~/Views/PermisoAvanzado/Agregar.cshtml", persona)); } }