mirror of
https://github.com/bitwarden/server.git
synced 2025-04-30 01:02:21 -05:00

* Revert "Add git blame entry (#2226)" This reverts commit 239286737d15cb84a893703ee5a8b33a2d67ad3d. * Revert "Turn on file scoped namespaces (#2225)" This reverts commit 34fb4cca2aa78deb84d4cbc359992a7c6bba7ea5.
38 lines
1.5 KiB
C#
38 lines
1.5 KiB
C#
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using Bit.Core.Entities;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Repositories;
|
|
using Bit.Core.Settings;
|
|
using Dapper;
|
|
|
|
namespace Bit.Infrastructure.Dapper.Repositories
|
|
{
|
|
public class OrganizationConnectionRepository : Repository<OrganizationConnection, Guid>, IOrganizationConnectionRepository
|
|
{
|
|
public OrganizationConnectionRepository(GlobalSettings globalSettings)
|
|
: base(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
|
{ }
|
|
|
|
public async Task<ICollection<OrganizationConnection>> GetByOrganizationIdTypeAsync(Guid organizationId, OrganizationConnectionType type)
|
|
{
|
|
using (var connection = new SqlConnection(ConnectionString))
|
|
{
|
|
var results = await connection.QueryAsync<OrganizationConnection>(
|
|
$"[{Schema}].[OrganizationConnection_ReadByOrganizationIdType]",
|
|
new
|
|
{
|
|
OrganizationId = organizationId,
|
|
Type = type
|
|
},
|
|
commandType: CommandType.StoredProcedure);
|
|
|
|
return results.ToList();
|
|
}
|
|
}
|
|
|
|
public async Task<ICollection<OrganizationConnection>> GetEnabledByOrganizationIdTypeAsync(Guid organizationId, OrganizationConnectionType type) =>
|
|
(await GetByOrganizationIdTypeAsync(organizationId, type)).Where(c => c.Enabled).ToList();
|
|
}
|
|
}
|