Esempio n. 1
0
        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);
            }
        }