2022-06-29 19:46:41 -04:00
|
|
|
|
using System.Data;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities.Provider;
|
2021-06-30 09:35:26 +02:00
|
|
|
|
using Bit.Core.Models.Data;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Repositories;
|
2021-06-03 18:58:29 +02:00
|
|
|
|
using Bit.Core.Settings;
|
2021-06-30 09:35:26 +02:00
|
|
|
|
using Dapper;
|
2023-01-10 15:58:41 -05:00
|
|
|
|
using Microsoft.Data.SqlClient;
|
2021-06-03 18:58:29 +02:00
|
|
|
|
|
2022-01-11 10:40:51 +01:00
|
|
|
|
namespace Bit.Infrastructure.Dapper.Repositories;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2022-01-11 10:40:51 +01:00
|
|
|
|
public class ProviderOrganizationRepository : Repository<ProviderOrganization, Guid>, IProviderOrganizationRepository
|
2021-06-03 18:58:29 +02:00
|
|
|
|
{
|
|
|
|
|
|
public ProviderOrganizationRepository(GlobalSettings globalSettings)
|
|
|
|
|
|
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
public ProviderOrganizationRepository(string connectionString, string readOnlyConnectionString)
|
|
|
|
|
|
: base(connectionString, readOnlyConnectionString)
|
|
|
|
|
|
{ }
|
2021-12-16 15:35:09 +01:00
|
|
|
|
|
2021-06-30 09:35:26 +02:00
|
|
|
|
public async Task<ICollection<ProviderOrganizationOrganizationDetails>> GetManyDetailsByProviderAsync(Guid providerId)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-06-30 09:35:26 +02:00
|
|
|
|
using (var connection = new SqlConnection(ConnectionString))
|
|
|
|
|
|
{
|
|
|
|
|
|
var results = await connection.QueryAsync<ProviderOrganizationOrganizationDetails>(
|
|
|
|
|
|
"[dbo].[ProviderOrganizationOrganizationDetails_ReadByProviderId]",
|
|
|
|
|
|
new { ProviderId = providerId },
|
|
|
|
|
|
commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
|
|
|
|
|
|
return results.ToList();
|
|
|
|
|
|
}
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2021-07-08 17:05:32 +02:00
|
|
|
|
|
2021-07-15 16:37:27 +02:00
|
|
|
|
public async Task<ProviderOrganization> GetByOrganizationId(Guid organizationId)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-07-08 17:05:32 +02:00
|
|
|
|
using (var connection = new SqlConnection(ConnectionString))
|
|
|
|
|
|
{
|
|
|
|
|
|
var results = await connection.QueryAsync<ProviderOrganization>(
|
2021-07-15 16:37:27 +02:00
|
|
|
|
"[dbo].[ProviderOrganization_ReadByOrganizationId]",
|
|
|
|
|
|
new { OrganizationId = organizationId },
|
2021-07-08 17:05:32 +02:00
|
|
|
|
commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
|
2021-07-15 16:37:27 +02:00
|
|
|
|
return results.SingleOrDefault();
|
2021-07-08 17:05:32 +02:00
|
|
|
|
}
|
2021-06-03 18:58:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|