2025-07-08 11:46:24 -04:00
|
|
|
|
// FIXME: Update this file to be null safe and then delete the line below
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
|
|
using System.Data;
|
2025-07-17 12:02:25 -05:00
|
|
|
|
using Bit.Core.Billing.Organizations.Entities;
|
|
|
|
|
|
using Bit.Core.Billing.Organizations.Repositories;
|
2024-12-11 13:55:00 -05:00
|
|
|
|
using Bit.Core.Settings;
|
|
|
|
|
|
using Bit.Infrastructure.Dapper.Repositories;
|
|
|
|
|
|
using Dapper;
|
|
|
|
|
|
using Microsoft.Data.SqlClient;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Bit.Infrastructure.Dapper.Billing.Repositories;
|
|
|
|
|
|
|
|
|
|
|
|
public class OrganizationInstallationRepository(
|
|
|
|
|
|
GlobalSettings globalSettings) : Repository<OrganizationInstallation, Guid>(
|
|
|
|
|
|
globalSettings.SqlServer.ConnectionString,
|
|
|
|
|
|
globalSettings.SqlServer.ReadOnlyConnectionString), IOrganizationInstallationRepository
|
|
|
|
|
|
{
|
|
|
|
|
|
public async Task<OrganizationInstallation> GetByInstallationIdAsync(Guid installationId)
|
|
|
|
|
|
{
|
|
|
|
|
|
var sqlConnection = new SqlConnection(ConnectionString);
|
|
|
|
|
|
|
|
|
|
|
|
var results = await sqlConnection.QueryAsync<OrganizationInstallation>(
|
|
|
|
|
|
"[dbo].[OrganizationInstallation_ReadByInstallationId]",
|
|
|
|
|
|
new { InstallationId = installationId },
|
|
|
|
|
|
commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
|
|
|
|
|
|
return results.FirstOrDefault();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ICollection<OrganizationInstallation>> GetByOrganizationIdAsync(Guid organizationId)
|
|
|
|
|
|
{
|
|
|
|
|
|
var sqlConnection = new SqlConnection(ConnectionString);
|
|
|
|
|
|
|
|
|
|
|
|
var results = await sqlConnection.QueryAsync<OrganizationInstallation>(
|
|
|
|
|
|
"[dbo].[OrganizationInstallation_ReadByOrganizationId]",
|
|
|
|
|
|
new { OrganizationId = organizationId },
|
|
|
|
|
|
commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
|
|
|
|
|
|
return results.ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|