예제 #1
0
        public static UserAccessModel GetUserAccess(string upn)
        {
            var result = new UserAccessModel();
            var user   = SQLAdapter.GetUserByUPN(upn);

            if (user == null)
            {
                throw new Exception("User " + upn + " does not exist");
            }

            result.IsGlobalAdmin = user.IsGlobalAdmin == true;

            var userRoleMappings = SQLAdapter.GetUsersByUPN(upn);

            result.IsLecturer     = userRoleMappings.Any(m => m.Role.Name == Constants.LECTURER_ROLE);
            result.IsDemonstrator = userRoleMappings.Any(m => m.Role.Name == Constants.DEMONSTRATOR_ROLE);

            return(result);
        }