Esempio n. 1
0
        public string[] GetRolesForUser(string username)
        {
            var  rolesList = new List <string>();
            var  cx        = new CodeBoxEntities();
            User user      = cx.Users.FirstOrDefault(u => u.Username == username);

            if (user != null)
            {
                foreach (var r in user.Roles)
                {
                    rolesList.Add(r.Name);
                }
                return(rolesList.ToArray());
            }
            return(null);
        }