示例#1
0
 public ActionResult Edit([Bind(Include = "GTAccount")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
 public ActionResult Edit([Bind(Include = "Name")] Permission permission)
 {
     if (ModelState.IsValid)
     {
         db.Entry(permission).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(permission));
 }
示例#3
0
        public ActionResult Edit(CreateRoleViewModel model, String[] selectedPermissions)
        {
            var role = model.Role;

            role.Permissions = new List <Permission>();

            foreach (var s in selectedPermissions)
            {
                var permission = db.Permissions
                                 .FirstOrDefault(p => p.Name == s);
                role.Permissions.Add(permission);
            }

            if (ModelState.IsValid)
            {
                db.Entry(role).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }