Exemple #1
0
        public UserRoleEnum UserHighestRole()
        {
            var userOrgs = userOrganizationService.GetOrganizationsAndRolesForLoggedUser();

            if (userOrgs.IsNullOrEmpty())
            {
                return(UserRoleEnum.Shirley);
            }
            return(userOrgs.Select(i => i.Role).OrderBy(i => i).FirstOrDefault());
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public VmUserInfo GetUserInfo()
        {
            var userOrgs = userOrganizationService.GetOrganizationsAndRolesForLoggedUser();

            if (userOrgs.IsNullOrEmpty())
            {
                return(null);
            }
            var role = userOrgs.First().Role;

            userOrgs.ForEach(c => role = role < c.Role ? role : c.Role);
            var userOrganizationId = (userOrgs.FirstOrDefault(i => i.IsMain) ?? userOrgs.First()).OrganizationId;

            return(new VmUserInfo
            {
                Name = GetClaimName(),
                Role = role,
                Permisions = userOrgs.Select(x => x.Role).Distinct()
                             .ToDictionary
                             (
                    r => r,
                    r => GetPermisions(GetRoleInfo(r), !userOrganizationId.IsAssigned())
                             ),
                UserOrganization = userOrganizationId,
                UserOrganizations = userOrgs
            });
        }