/// <inheritdoc/>
        public async Task <EventModel> CreateAsync <T>(string userId, EventType eventType, T data, CancellationToken ct)
        {
            Ensure.ArgumentNotNullOrWhiteSpace(userId, nameof(userId));
            Ensure.ArgumentNotNull(data, nameof(data));
            Ensure.ArgumentNotNull(ct, nameof(ct));

            try
            {
                var command = new CreateEventCommand()
                {
                    UserId    = userId,
                    EventType = eventType,
                    Event     = data
                };

                var result = await mediator.Send(command, ct);

                var query = new GetByUserQuery()
                {
                    UserId    = userId,
                    EventType = eventType
                };

                // create a background job for each webhook
                var webhooks = await mediator.Send(query, ct);

                if (webhooks != null && webhooks.Count() > 0)
                {
                    foreach (var webhook in webhooks)
                    {
                        if (webhook != null)
                        {
                            backgroundService.EnqueueWebhookEvent(webhook.Id, result.Id);
                        }
                    }
                }

                return(result);
            }
            catch (Exception e)
            {
                logger.LogError(e, e.Message);
            }

            return(null);
        }