mirror of
https://github.com/bitwarden/server
synced 2025-12-18 09:13:19 +00:00
Turn on file scoped namespaces (#2225)
This commit is contained in:
@@ -7,102 +7,101 @@ using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Repositories
|
||||
namespace Bit.Infrastructure.EntityFramework.Repositories;
|
||||
|
||||
public class EmergencyAccessRepository : Repository<Core.Entities.EmergencyAccess, EmergencyAccess, Guid>, IEmergencyAccessRepository
|
||||
{
|
||||
public class EmergencyAccessRepository : Repository<Core.Entities.EmergencyAccess, EmergencyAccess, Guid>, IEmergencyAccessRepository
|
||||
public EmergencyAccessRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
|
||||
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.EmergencyAccesses)
|
||||
{ }
|
||||
|
||||
public async Task<int> GetCountByGrantorIdEmailAsync(Guid grantorId, string email, bool onlyRegisteredUsers)
|
||||
{
|
||||
public EmergencyAccessRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
|
||||
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.EmergencyAccesses)
|
||||
{ }
|
||||
var query = new EmergencyAccessReadCountByGrantorIdEmailQuery(grantorId, email, onlyRegisteredUsers);
|
||||
return await GetCountFromQuery(query);
|
||||
}
|
||||
|
||||
public async Task<int> GetCountByGrantorIdEmailAsync(Guid grantorId, string email, bool onlyRegisteredUsers)
|
||||
public async Task<EmergencyAccessDetails> GetDetailsByIdGrantorIdAsync(Guid id, Guid grantorId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var query = new EmergencyAccessReadCountByGrantorIdEmailQuery(grantorId, email, onlyRegisteredUsers);
|
||||
return await GetCountFromQuery(query);
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var view = new EmergencyAccessDetailsViewQuery();
|
||||
var query = view.Run(dbContext).Where(ea =>
|
||||
ea.Id == id &&
|
||||
ea.GrantorId == grantorId
|
||||
);
|
||||
return await query.FirstOrDefaultAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<EmergencyAccessDetails> GetDetailsByIdGrantorIdAsync(Guid id, Guid grantorId)
|
||||
public async Task<ICollection<EmergencyAccessDetails>> GetExpiredRecoveriesAsync()
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var view = new EmergencyAccessDetailsViewQuery();
|
||||
var query = view.Run(dbContext).Where(ea =>
|
||||
ea.Id == id &&
|
||||
ea.GrantorId == grantorId
|
||||
);
|
||||
return await query.FirstOrDefaultAsync();
|
||||
}
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var view = new EmergencyAccessDetailsViewQuery();
|
||||
var query = view.Run(dbContext).Where(ea =>
|
||||
ea.Status == EmergencyAccessStatusType.RecoveryInitiated
|
||||
);
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<EmergencyAccessDetails>> GetExpiredRecoveriesAsync()
|
||||
public async Task<ICollection<EmergencyAccessDetails>> GetManyDetailsByGranteeIdAsync(Guid granteeId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var view = new EmergencyAccessDetailsViewQuery();
|
||||
var query = view.Run(dbContext).Where(ea =>
|
||||
ea.Status == EmergencyAccessStatusType.RecoveryInitiated
|
||||
);
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var view = new EmergencyAccessDetailsViewQuery();
|
||||
var query = view.Run(dbContext).Where(ea =>
|
||||
ea.GranteeId == granteeId
|
||||
);
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<EmergencyAccessDetails>> GetManyDetailsByGranteeIdAsync(Guid granteeId)
|
||||
public async Task<ICollection<EmergencyAccessDetails>> GetManyDetailsByGrantorIdAsync(Guid grantorId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var view = new EmergencyAccessDetailsViewQuery();
|
||||
var query = view.Run(dbContext).Where(ea =>
|
||||
ea.GranteeId == granteeId
|
||||
);
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var view = new EmergencyAccessDetailsViewQuery();
|
||||
var query = view.Run(dbContext).Where(ea =>
|
||||
ea.GrantorId == grantorId
|
||||
);
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<EmergencyAccessDetails>> GetManyDetailsByGrantorIdAsync(Guid grantorId)
|
||||
public async Task<ICollection<EmergencyAccessNotify>> GetManyToNotifyAsync()
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var view = new EmergencyAccessDetailsViewQuery();
|
||||
var query = view.Run(dbContext).Where(ea =>
|
||||
ea.Status == EmergencyAccessStatusType.RecoveryInitiated
|
||||
);
|
||||
var notifies = await query.Select(ea => new EmergencyAccessNotify
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var view = new EmergencyAccessDetailsViewQuery();
|
||||
var query = view.Run(dbContext).Where(ea =>
|
||||
ea.GrantorId == grantorId
|
||||
);
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<EmergencyAccessNotify>> GetManyToNotifyAsync()
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var view = new EmergencyAccessDetailsViewQuery();
|
||||
var query = view.Run(dbContext).Where(ea =>
|
||||
ea.Status == EmergencyAccessStatusType.RecoveryInitiated
|
||||
);
|
||||
var notifies = await query.Select(ea => new EmergencyAccessNotify
|
||||
{
|
||||
Id = ea.Id,
|
||||
GrantorId = ea.GrantorId,
|
||||
GranteeId = ea.GranteeId,
|
||||
Email = ea.Email,
|
||||
KeyEncrypted = ea.KeyEncrypted,
|
||||
Type = ea.Type,
|
||||
Status = ea.Status,
|
||||
WaitTimeDays = ea.WaitTimeDays,
|
||||
RecoveryInitiatedDate = ea.RecoveryInitiatedDate,
|
||||
LastNotificationDate = ea.LastNotificationDate,
|
||||
CreationDate = ea.CreationDate,
|
||||
RevisionDate = ea.RevisionDate,
|
||||
GranteeName = ea.GranteeName,
|
||||
GranteeEmail = ea.GranteeEmail,
|
||||
GrantorEmail = ea.GrantorEmail,
|
||||
}).ToListAsync();
|
||||
return notifies;
|
||||
}
|
||||
Id = ea.Id,
|
||||
GrantorId = ea.GrantorId,
|
||||
GranteeId = ea.GranteeId,
|
||||
Email = ea.Email,
|
||||
KeyEncrypted = ea.KeyEncrypted,
|
||||
Type = ea.Type,
|
||||
Status = ea.Status,
|
||||
WaitTimeDays = ea.WaitTimeDays,
|
||||
RecoveryInitiatedDate = ea.RecoveryInitiatedDate,
|
||||
LastNotificationDate = ea.LastNotificationDate,
|
||||
CreationDate = ea.CreationDate,
|
||||
RevisionDate = ea.RevisionDate,
|
||||
GranteeName = ea.GranteeName,
|
||||
GranteeEmail = ea.GranteeEmail,
|
||||
GrantorEmail = ea.GrantorEmail,
|
||||
}).ToListAsync();
|
||||
return notifies;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user