2025-07-23 14:24:59 -04:00
|
|
|
|
using System.Data;
|
|
|
|
|
|
using Bit.Core.AdminConsole.Entities;
|
2025-04-03 11:23:00 -04:00
|
|
|
|
using Bit.Core.Repositories;
|
|
|
|
|
|
using Bit.Core.Settings;
|
2025-07-23 14:24:59 -04:00
|
|
|
|
using Dapper;
|
|
|
|
|
|
using Microsoft.Data.SqlClient;
|
2025-04-03 11:23:00 -04:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Infrastructure.Dapper.Repositories;
|
|
|
|
|
|
|
|
|
|
|
|
public class OrganizationIntegrationRepository : Repository<OrganizationIntegration, Guid>, IOrganizationIntegrationRepository
|
|
|
|
|
|
{
|
|
|
|
|
|
public OrganizationIntegrationRepository(GlobalSettings globalSettings)
|
|
|
|
|
|
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
public OrganizationIntegrationRepository(string connectionString, string readOnlyConnectionString)
|
|
|
|
|
|
: base(connectionString, readOnlyConnectionString)
|
|
|
|
|
|
{ }
|
2025-07-23 14:24:59 -04:00
|
|
|
|
|
|
|
|
|
|
public async Task<List<OrganizationIntegration>> GetManyByOrganizationAsync(Guid organizationId)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var connection = new SqlConnection(ConnectionString))
|
|
|
|
|
|
{
|
|
|
|
|
|
var results = await connection.QueryAsync<OrganizationIntegration>(
|
|
|
|
|
|
"[dbo].[OrganizationIntegration_ReadManyByOrganizationId]",
|
|
|
|
|
|
new { OrganizationId = organizationId },
|
|
|
|
|
|
commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
|
|
|
|
|
|
return results.ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-10 10:39:31 -04:00
|
|
|
|
|
|
|
|
|
|
public async Task<OrganizationIntegration?> GetByTeamsConfigurationTenantIdTeamId(string tenantId, string teamId)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var connection = new SqlConnection(ConnectionString))
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = await connection.QuerySingleOrDefaultAsync<OrganizationIntegration>(
|
|
|
|
|
|
"[dbo].[OrganizationIntegration_ReadByTeamsConfigurationTenantIdTeamId]",
|
|
|
|
|
|
new { TenantId = tenantId, TeamId = teamId },
|
|
|
|
|
|
commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-04-03 11:23:00 -04:00
|
|
|
|
}
|