Ejemplo n.º 1
0
        public AddInstanceUserViewModel(PageContextViewModel pageContext, InstanceUserRootViewModel instanceUserRootViewModel, IInstanceUserClient instanceUserClient, IInstanceUserRightsProvider rightsProvider, IUserProvider userProvider)
        {
            this.pageContext = pageContext ?? throw new ArgumentNullException(nameof(pageContext));
            this.instanceUserRootViewModel = instanceUserRootViewModel ?? throw new ArgumentNullException(nameof(instanceUserRootViewModel));
            this.instanceUserClient        = instanceUserClient ?? throw new ArgumentNullException(nameof(instanceUserClient));
            this.rightsProvider            = rightsProvider ?? throw new ArgumentNullException(nameof(rightsProvider));

            users       = userProvider.GetUsers()?.Where(x => x.Id != userProvider.CurrentUser.Id).ToList();
            UserStrings = users?.Select(x => String.Format(CultureInfo.InvariantCulture, "{0} ({1})", x.Name, x.Id)).ToList();
            rightsProvider.OnUpdated += (a, b) => Add.Recheck();

            Close = new EnumCommand <AddInstanceUserCommand>(AddInstanceUserCommand.Close, this);
            Add   = new EnumCommand <AddInstanceUserCommand>(AddInstanceUserCommand.Add, this);
        }
Ejemplo n.º 2
0
        public AddInstanceUserViewModel(PageContextViewModel pageContext, InstanceUserRootViewModel instanceUserRootViewModel, IInstancePermissionSetClient instanceUserClient, IInstanceUserRightsProvider rightsProvider, IUserProvider userProvider)
        {
            this.pageContext = pageContext ?? throw new ArgumentNullException(nameof(pageContext));
            this.instanceUserRootViewModel = instanceUserRootViewModel ?? throw new ArgumentNullException(nameof(instanceUserRootViewModel));
            this.instanceUserClient        = instanceUserClient ?? throw new ArgumentNullException(nameof(instanceUserClient));
            this.rightsProvider            = rightsProvider ?? throw new ArgumentNullException(nameof(rightsProvider));

            users  = userProvider.GetUsers()?.Where(x => x.Id != userProvider.CurrentUser.Id).ToList();
            groups = userProvider.GetGroups()?.Where(x => x.Id != userProvider.CurrentUser.Group?.Id).ToList();
            var userStrings = users?.Select(x => String.Format(CultureInfo.InvariantCulture, "User {0} ({1})", x.Name, x.Id)).ToList() ?? new List <string>();

            userStrings.AddRange(groups?.Select(x => $"Group {x.Name} ({x.Id})") ?? Enumerable.Empty <string>());
            if (userStrings.Count > 0)
            {
                UserStrings = userStrings;
            }

            rightsProvider.OnUpdated += (a, b) => Add.Recheck();

            Close = new EnumCommand <AddInstanceUserCommand>(AddInstanceUserCommand.Close, this);
            Add   = new EnumCommand <AddInstanceUserCommand>(AddInstanceUserCommand.Add, this);
        }