public async Task <ActionResult> Edit([Bind(Include = "RoleId,RoleName,RoleDescription,Claims")] RoleClaimsViewModel model) { if (ModelState.IsValid) { ApplicationRole role = await RoleManager.FindByIdAsync(model.RoleId); if (role == null) { return(HttpNotFound()); } // remove old claims in this role role.Claims.Clear(); // edit role props role.Name = model.RoleName; role.Description = model.RoleDescription; DbContext.Entry(role).State = EntityState.Modified; // add role claims IEnumerable <string> claimIds = model.Claims.Where(x => x.Status == true).Select(x => x.ClaimId); RoleManager.AddClaims(role.Id, claimIds); DbContext.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }