protected IQueryable <CoreMatter> GetMatters(string userName)
        {
            var roles   = GetRoles(userName);
            var isAdmin = false;

            foreach (var role in roles)
            {
                if (role.Name.ToLower() == "discouser" && role.ApplicationName.ToLower() == "global")
                {
                    isAdmin = true; break;
                }
            }


            MembershipUser user = Membership.GetUser(userName);

            if (user == null)
            {
                throw new UnauthorizedAccessException(string.Format("User {0} has no access to the PartnerView application.", userName));
            }
            Guid guidUserId = new Guid(Convert.ToString(user.ProviderUserKey));

            if (isAdmin)
            {
                return(cmRepository.GetMatters().GroupJoin(
                           cmRepository.GetEthicalWalls(),
                           m => m.Id,
                           e => e.MatterId,
                           (x, y) => new { Matters = x, EthicalWalls = y })
                       .SelectMany(
                           x => x.EthicalWalls.DefaultIfEmpty(),
                           (x, y) => new { Matters = x.Matters, EthicalWalls = y })
                       .Where(j => j.EthicalWalls.UserName != userName)
                       .Select(j => j.Matters));
            }
            else
            {
                var userMatters = cmRepository.GetUserMatters().Where(u => u.UserName == userName).Select(m => m.Matter);
                return(userMatters.GroupJoin(
                           cmRepository.GetEthicalWalls(),
                           m => m.Id,
                           e => e.MatterId,
                           (x, y) => new { Matters = x, EthicalWalls = y })
                       .SelectMany(
                           x => x.EthicalWalls.DefaultIfEmpty(),
                           (x, y) => new { Matters = x.Matters, EthicalWalls = y })
                       .Where(j => j.EthicalWalls.UserName != userName)
                       .Select(j => j.Matters));
            }
        }