/// <inheritdoc cref="IWhitelistRepository" />
        /// <summary>
        ///     Gets a <see cref="BlacklistWhitelist" /> item by its type.
        /// </summary>
        /// <param name="whitelistItemType">The <see cref="BlacklistWhitelist" />'s type to query for.</param>
        /// <returns>A <see cref="Task" /> representing any asynchronous operation.</returns>
        /// <seealso cref="IWhitelistRepository" />
        public async Task <BlacklistWhitelist> GetWhitelistItemByType(BlacklistWhitelistType whitelistItemType)
        {
            await using var connection = new NpgsqlConnection(this.connectionSettings.ToConnectionString());
            await connection.OpenAsync();

            return(await connection.QueryFirstOrDefaultAsync <BlacklistWhitelist>(SelectStatements.SelectWhitelistItemByType, new { Type = whitelistItemType }));
        }
Exemplo n.º 2
0
        /// <inheritdoc cref="IUserRepository" />
        /// <summary>
        ///     Gets the whitelist items for a <see cref="User" />.
        /// </summary>
        /// <param name="userId">The user identifier to query for.</param>
        /// <param name="type">The <see cref="BlacklistWhitelistType" />.</param>
        /// <returns>A <see cref="Task" /> representing any asynchronous operation.</returns>
        /// <seealso cref="IUserRepository" />
        public async Task <List <BlacklistWhitelist> > GetWhitelistItemsForUser(Guid userId, BlacklistWhitelistType type)
        {
            await using var connection = new NpgsqlConnection(this.connectionSettings.ToConnectionString());
            await connection.OpenAsync();

            var whiteListItems = await connection.QueryAsync <BlacklistWhitelist>(SelectStatements.SelectWhitelistItemsForUser, new { UserId = userId, Type = type });

            return(whiteListItems?.ToList() ?? new List <BlacklistWhitelist>());
        }
Exemplo n.º 3
0
        /// <inheritdoc cref="IUserRepository" />
        /// <summary>
        ///     Gets the whitelist items for a <see cref="User" />.
        /// </summary>
        /// <param name="userId">The user identifier to query for.</param>
        /// <param name="type">The <see cref="BlacklistWhitelistType" />.</param>
        /// <returns>A <see cref="Task" /> representing any asynchronous operation.</returns>
        /// <seealso cref="IUserRepository" />
        public async Task <List <BlacklistWhitelist> > GetWhitelistItemsForUser(Guid userId, BlacklistWhitelistType type)
        {
            await Task.Delay(1);

            return(this.whiteLists.ContainsKey(userId) ? this.whiteLists[userId].Where(b => b.Type == type).ToList() : new List <BlacklistWhitelist>());
        }
Exemplo n.º 4
0
        /// <inheritdoc cref="IUserRepository" />
        /// <summary>
        ///     Gets the blacklist items for a <see cref="User" />.
        /// </summary>
        /// <param name="userId">The user identifier to query for.</param>
        /// <param name="type">The <see cref="BlacklistWhitelistType" />.</param>
        /// <returns>A <see cref="Task" /> representing any asynchronous operation.</returns>
        /// <seealso cref="IUserRepository" />
        public async Task <IEnumerable <BlacklistWhitelist> > GetBlacklistItemsForUser(Guid userId, BlacklistWhitelistType type)
        {
            await using var connection = new NpgsqlConnection(this.connectionSettings.ToConnectionString());
            await connection.OpenAsync();

            return(await connection.QueryAsync <BlacklistWhitelist>(SelectStatements.SelectBlacklistItemsForUser, new { UserId = userId, Type = type }));
        }