///<inheritdoc/> public override async Task <ScopeDto> AddAsync(ScopeDto dto, CancellationToken cancellationToken = default) { dto.AccessKey = dto.AccessKey == Guid.Empty ? Guid.NewGuid() : dto.AccessKey; dto = await base.AddAsync(dto, cancellationToken); if (dto.AllowLogin) { User user = new User(dto.Id) { Document = GeneratedUserServiceDocument(), Email = new Email($"{dto.Name.ToLower().Replace(" ", string.Empty)}@service.na"), Name = new Name(dto.Name, "Service"), BornDate = DateTime.UtcNow, IsActive = false, Type = UserType.Service }; user = await _userDomain.AddAsync(user, cancellationToken); if (user.Valid) { await _uow.SaveChangesAsync(cancellationToken); } else { _logger.LogWarning($"User is invalid => {string.Join("|", user.Notifications.Select(n => $"{n.Property}-{n.Message}"))}"); } } return(dto); }