public async Task RunCommand(AddInstanceUserCommand command, CancellationToken cancellationToken) { switch (command) { case AddInstanceUserCommand.Close: pageContext.ActiveObject = null; break; case AddInstanceUserCommand.Add: loading = true; Add.Recheck(); try { var user = new InstanceUser { UserId = IdMode ? UserId : users[SelectedIndex].Id, }; var newUser = await instanceUserClient.Create(user, cancellationToken).ConfigureAwait(true); instanceUserRootViewModel.DirectAdd(newUser); } finally { loading = false; Add.Recheck(); } break; default: throw new ArgumentOutOfRangeException(nameof(command), command, "Invalid command!"); } }
public bool CanRunCommand(AddInstanceUserCommand command) { return(command switch { AddInstanceUserCommand.Close => true, AddInstanceUserCommand.Add => !loading && rightsProvider.InstanceUserRights.HasFlag(InstancePermissionSetRights.Create), _ => throw new ArgumentOutOfRangeException(nameof(command), command, "Invalid command!"), });
public bool CanRunCommand(AddInstanceUserCommand command) { switch (command) { case AddInstanceUserCommand.Close: return(true); case AddInstanceUserCommand.Add: return(!loading && rightsProvider.InstanceUserRights.HasFlag(InstanceUserRights.WriteUsers)); default: throw new ArgumentOutOfRangeException(nameof(command), command, "Invalid command!"); } }