Beispiel #1
0
        /// <inheritdoc />
        public async Task <IWebHook> GetWebHookAsync(IPrincipal user, Guid id, CancellationToken cancellationToken = default)
        {
            var key = await _idGetter.GetPrincipalIdAsync(user, cancellationToken);

            var filterDefinition = Builders <WebHook> .Filter.Where(w => w.PrincipalId == key && w.Id == id);

            var webHook = await _context.Collection
                          .Find(filterDefinition)
                          .FirstOrDefaultAsync(cancellationToken);

            if (webHook == null)
            {
                return(null);
            }

            Prepare(webHook);

            return(webHook);
        }
Beispiel #2
0
        /// <inheritdoc />
        public async Task <IWebHook?> GetWebHookAsync(IPrincipal user, Guid id, CancellationToken cancellationToken = default)
        {
            var key = await _idGetter.GetPrincipalIdAsync(user, cancellationToken);

            var webHook = await _context.WebHooks
                          .Where(w => w.PrincipalId == key && w.Id == id)
                          .Include(w => w.Filters)
                          .AsNoTracking()
                          .FirstOrDefaultAsync(cancellationToken);

            if (webHook == null)
            {
                return(null);
            }

            Prepare(webHook);

            return(webHook);
        }