mirror of
https://github.com/bitwarden/server.git
synced 2025-07-18 16:11:28 -05:00
[PM-11127] Write OrganizationInstallation
record when license is retrieved (#5090)
* Add SQL files * Add SQL Server migration * Add Core entity * Add Dapper repository * Add EF repository * Add EF migrations * Save OrganizationInstallation during GetLicense invocation * Run dotnet format
This commit is contained in:
@ -0,0 +1,39 @@
|
||||
using System.Data;
|
||||
using Bit.Core.Billing.Entities;
|
||||
using Bit.Core.Billing.Repositories;
|
||||
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();
|
||||
}
|
||||
}
|
@ -63,6 +63,7 @@ public static class DapperServiceCollectionExtensions
|
||||
services.AddSingleton<IPasswordHealthReportApplicationRepository, PasswordHealthReportApplicationRepository>();
|
||||
services.AddSingleton<ISecurityTaskRepository, SecurityTaskRepository>();
|
||||
services.AddSingleton<IUserAsymmetricKeysRepository, UserAsymmetricKeysRepository>();
|
||||
services.AddSingleton<IOrganizationInstallationRepository, OrganizationInstallationRepository>();
|
||||
|
||||
if (selfHosted)
|
||||
{
|
||||
|
Reference in New Issue
Block a user