public async Task <Guid> AddGroup(AddGroupCommand command, CancellationToken cancellationToken) { if (command == null) { throw new ArgumentNullException(nameof(command)); } command.EnsureIsValid(); var groupPersisted = await authorizationRepository.GetGroupBy(command.Name, command.Domain, cancellationToken).ConfigureAwait(false); if (groupPersisted is not null) { throw new BusinessException(Messages.GroupAlreadyExist); } var group = new Group() { Name = command.Name, Description = command.Description, Domain = command.Domain }; await authorizationRepository.AddGroup(group, cancellationToken).ConfigureAwait(false); return(group.Id); }