// // GET: /Roles/Details/5 public async Task<ActionResult> Details(string id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var role = await RoleManager.FindByIdAsync(id); // Get the list of Users in this Role var users = new List<ApplicationUser>(); // Get the list of Users in this Role foreach (var user in UserManager.Users.ToList()) { if (await UserManager.IsInRoleAsync(user.Id, role.Name)) { users.Add(user); } } var resourceOperation = ResourceCollection.ResourceOperation.DistinctBy(x => x.ResourceName).ToList(); ResourceOperationPermission rop = new ResourceOperationPermission(); var permissions = rop.GetCurrentRolePermission(role.Name, role.Id, resourceOperation); var viewModel = new Detail() { ResourceOperation = permissions.ResourceOperation, RoleId = permissions.RoleId, RoleName = permissions.RoleName, Users = users.ToDictionary(x => x.Email, x => x.Email) }; return View(viewModel); }
// // GET: /Roles/Edit/Admin public async Task<ActionResult> Edit(string id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var role = await RoleManager.FindByIdAsync(id); if (role == null) { return HttpNotFound(); } //RoleViewModel roleModel = new RoleViewModel { Id = role.Id, Name = role.Name }; var resourceOperation = ResourceCollection.ResourceOperation.DistinctBy(x => x.ResourceName).ToList(); ResourceOperationPermission rop = new ResourceOperationPermission(); var viewModel = rop.GetCurrentRolePermission(role.Name, role.Id, resourceOperation); return View(viewModel); }