mirror of
https://github.com/bitwarden/server.git
synced 2025-07-04 17:42:49 -05:00
Turn on file scoped namespaces (#2225)
This commit is contained in:
@ -5,40 +5,39 @@ using Bit.Core.Repositories;
|
||||
using Bit.Core.Settings;
|
||||
using Dapper;
|
||||
|
||||
namespace Bit.Infrastructure.Dapper.Repositories
|
||||
namespace Bit.Infrastructure.Dapper.Repositories;
|
||||
|
||||
public class FolderRepository : Repository<Folder, Guid>, IFolderRepository
|
||||
{
|
||||
public class FolderRepository : Repository<Folder, Guid>, IFolderRepository
|
||||
public FolderRepository(GlobalSettings globalSettings)
|
||||
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public FolderRepository(string connectionString, string readOnlyConnectionString)
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public async Task<Folder> GetByIdAsync(Guid id, Guid userId)
|
||||
{
|
||||
public FolderRepository(GlobalSettings globalSettings)
|
||||
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public FolderRepository(string connectionString, string readOnlyConnectionString)
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public async Task<Folder> GetByIdAsync(Guid id, Guid userId)
|
||||
var folder = await GetByIdAsync(id);
|
||||
if (folder == null || folder.UserId != userId)
|
||||
{
|
||||
var folder = await GetByIdAsync(id);
|
||||
if (folder == null || folder.UserId != userId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return folder;
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<ICollection<Folder>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Folder>(
|
||||
$"[{Schema}].[Folder_ReadByUserId]",
|
||||
new { UserId = userId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
return folder;
|
||||
}
|
||||
|
||||
return results.ToList();
|
||||
}
|
||||
public async Task<ICollection<Folder>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Folder>(
|
||||
$"[{Schema}].[Folder_ReadByUserId]",
|
||||
new { UserId = userId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user