public async Task Remove(RemoveRoleCommand command) { command.Validate(); if (AddNotifications(command)) { return; } LedgerIdentityRole role = await GetByName(command.RoleName); if (NotifyNullRole(role)) { return; } bool canDelete = await CanDeleteRole(role); if (!canDelete) { AddNotification("Falha ao remover", "Não é possível remover essa role enquanto ouver usuários nela."); return; } IdentityResult result = await _roleManager.DeleteAsync(role); if (result.Succeeded) { await Publish(new RoleRemovedIntegrationEvent(role.Name)); } else { AddNotifications(result); } }
public async Task <IActionResult> Remove(string name, [FromBody] RemoveRoleCommand command) { command.RoleName = name; await _roleApplicationService.Remove(command); return(CreateResponse()); }
public async Task Fails_when_group_do_not_exists() => await Run(async sut => { var command = new RemoveRoleCommand(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()); Func <Task> action = async() => await sut.SendAsync(command); await action.Should().ThrowAsync <GroupNotFoundException>(); });
private void NewUser_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { StartCreateNewCommand.RaiseCanExecuteChanged(); AddRoleCommand.RaiseCanExecuteChanged(); RemoveRoleCommand.RaiseCanExecuteChanged(); AddRolesCommand.RaiseCanExecuteChanged(); RemoveRolesCommand.RaiseCanExecuteChanged(); AddMultipleRolesCommand.RaiseCanExecuteChanged(); }
public async Task Fails_when_role_do_not_exists() => await Run(async sut => { var group = await GroupBuilder.For(sut).CreateGroup("group1").Build(); var command = new RemoveRoleCommand(group.OwnerId, group.GroupId, Guid.NewGuid()); Func <Task> action = async() => await sut.SendAsync(command); await action.Should().ThrowAsync <RoleNotFoundException>(); });
void UpateCommands() { AvailableToCurrentRoleCommand.RaiseCanExecuteChanged(); CurrentToAvailableRoleCommand.RaiseCanExecuteChanged(); AddMultipleRolesCommand.RaiseCanExecuteChanged(); StarEditUserCommand.RaiseCanExecuteChanged(); DeleteUserCommand.RaiseCanExecuteChanged(); AddRoleCommand.RaiseCanExecuteChanged(); RemoveRoleCommand.RaiseCanExecuteChanged(); }
public Task RemoveRole(RemoveRoleCommand removeRoleCommand, Contexts contexts) { if (removeRoleCommand.Roles.Count > 5) { throw new InvalidArgumentsException(); } var safeRoles = this._queryBus.Execute(new GetDiscordServerSafeRolesQuery(contexts.Server.Id)).SafeRoles; return(this._rolesService.DeleteRoleFromUser(safeRoles, contexts, removeRoleCommand.Roles)); }
public async Task RemoveRole(RemoveRoleCommand removeRoleCommand, Contexts contexts) { if (!removeRoleCommand.Roles.Any()) { throw new NotEnoughArgumentsException(); } var safeRoles = this._queryBus.Execute(new GetDiscordServerSafeRolesQuery(contexts.Server.Id)).SafeRoles; await this._rolesService.DeleteRoleFromUser(safeRoles, contexts, removeRoleCommand.Roles); }
public async Task RemoveRole(RemoveRoleCommand command, CancellationToken cancellationToken) { if (command == null) { throw new ArgumentNullException(nameof(command)); } command.EnsureIsValid(); var role = await authorizationRepository.GetRoleById(command.Id, cancellationToken).ConfigureAwait(false); if (role is null) { throw new BusinessException(Messages.RoleNotFound); } await authorizationRepository.RemoveRole(role, cancellationToken).ConfigureAwait(false); }
public void Handle(RemoveRoleCommand message) { this.Handle(message.AcSession, message.EntityId, true); }
public async Task <IActionResult> Remove(RemoveRoleCommand command, CancellationToken cancellationToken = default) { await authorizationAppService.RemoveRole(command, cancellationToken); return(Ok()); }
public async Task RemoveRole(RemoveRoleCommand removeRoleCommand, Contexts contexts) { var safeRoles = this._queryBus.Execute(new GetDiscordServerSafeRolesQuery(contexts.Server.Id)).SafeRoles; await this._rolesService.DeleteRoleFromUser(safeRoles, contexts, removeRoleCommand.Roles); }