Revert filescoped (#2227)

* Revert "Add git blame entry (#2226)"

This reverts commit 239286737d.

* Revert "Turn on file scoped namespaces (#2225)"

This reverts commit 34fb4cca2a.
This commit is contained in:
Justin Baur
2022-08-29 15:53:48 -04:00
committed by GitHub
parent 239286737d
commit bae03feffe
1208 changed files with 74317 additions and 73126 deletions

View File

@@ -7,101 +7,102 @@ using Bit.Infrastructure.EntityFramework.Repositories.Queries;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Infrastructure.EntityFramework.Repositories;
public class EmergencyAccessRepository : Repository<Core.Entities.EmergencyAccess, EmergencyAccess, Guid>, IEmergencyAccessRepository
namespace Bit.Infrastructure.EntityFramework.Repositories
{
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 class EmergencyAccessRepository : Repository<Core.Entities.EmergencyAccess, EmergencyAccess, Guid>, IEmergencyAccessRepository
{
var query = new EmergencyAccessReadCountByGrantorIdEmailQuery(grantorId, email, onlyRegisteredUsers);
return await GetCountFromQuery(query);
}
public EmergencyAccessRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.EmergencyAccesses)
{ }
public async Task<EmergencyAccessDetails> GetDetailsByIdGrantorIdAsync(Guid id, Guid grantorId)
{
using (var scope = ServiceScopeFactory.CreateScope())
public async Task<int> GetCountByGrantorIdEmailAsync(Guid grantorId, string email, bool onlyRegisteredUsers)
{
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 query = new EmergencyAccessReadCountByGrantorIdEmailQuery(grantorId, email, onlyRegisteredUsers);
return await GetCountFromQuery(query);
}
}
public async Task<ICollection<EmergencyAccessDetails>> GetExpiredRecoveriesAsync()
{
using (var scope = ServiceScopeFactory.CreateScope())
public async Task<EmergencyAccessDetails> GetDetailsByIdGrantorIdAsync(Guid id, Guid grantorId)
{
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>> GetManyDetailsByGranteeIdAsync(Guid granteeId)
{
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();
}
}
public async Task<ICollection<EmergencyAccessDetails>> GetManyDetailsByGrantorIdAsync(Guid grantorId)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
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
using (var scope = ServiceScopeFactory.CreateScope())
{
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;
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<ICollection<EmergencyAccessDetails>> GetExpiredRecoveriesAsync()
{
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();
}
}
public async Task<ICollection<EmergencyAccessDetails>> GetManyDetailsByGranteeIdAsync(Guid granteeId)
{
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();
}
}
public async Task<ICollection<EmergencyAccessDetails>> GetManyDetailsByGrantorIdAsync(Guid grantorId)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
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;
}
}
}
}