private bool IsUserInRoles(ApplicationRoleCollection rc, IPrincipal user) { if (rc.Count() == 0) return true; if (!user.Identity.IsAuthenticated) return false; foreach (ApplicationRole r in rc) { if (user.IsInRole(r.Name)) return true; } return false; }
public ApplicationRoleCollection GetRoles(string area, string controller, string action) { List<ApplicationRole> rr = (from MvcControllerACL acl in _context.MvcControllerACLs join ApplicationRole rl in _context.Roles on acl.RoleId equals rl.Id where acl.Area == area & acl.Controller == controller & acl.Action == action select rl) .ToList(); ApplicationRoleCollection c = new ApplicationRoleCollection(); c.AddRange(rr); return c; }