mirror of
https://github.com/bitwarden/server
synced 2025-12-12 14:23:38 +00:00
Revert filescoped (#2227)
* Revert "Add git blame entry (#2226)" This reverts commit239286737d. * Revert "Turn on file scoped namespaces (#2225)" This reverts commit34fb4cca2a.
This commit is contained in:
@@ -5,51 +5,52 @@ using Bit.Core.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Repositories;
|
||||
|
||||
public class ProviderRepository : Repository<Provider, Models.Provider, Guid>, IProviderRepository
|
||||
namespace Bit.Infrastructure.EntityFramework.Repositories
|
||||
{
|
||||
|
||||
public ProviderRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
|
||||
: base(serviceScopeFactory, mapper, context => context.Providers)
|
||||
{ }
|
||||
|
||||
public async Task<ICollection<Provider>> SearchAsync(string name, string userEmail, int skip, int take)
|
||||
public class ProviderRepository : Repository<Provider, Models.Provider, Guid>, IProviderRepository
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
|
||||
public ProviderRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
|
||||
: base(serviceScopeFactory, mapper, context => context.Providers)
|
||||
{ }
|
||||
|
||||
public async Task<ICollection<Provider>> SearchAsync(string name, string userEmail, int skip, int take)
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var query = !string.IsNullOrWhiteSpace(userEmail) ?
|
||||
(from p in dbContext.Providers
|
||||
join pu in dbContext.ProviderUsers
|
||||
on p.Id equals pu.ProviderId
|
||||
join u in dbContext.Users
|
||||
on pu.UserId equals u.Id
|
||||
where (string.IsNullOrWhiteSpace(name) || p.Name.Contains(name)) &&
|
||||
u.Email == userEmail
|
||||
orderby p.CreationDate descending
|
||||
select new { p, pu, u }).Skip(skip).Take(take).Select(x => x.p) :
|
||||
(from p in dbContext.Providers
|
||||
where string.IsNullOrWhiteSpace(name) || p.Name.Contains(name)
|
||||
orderby p.CreationDate descending
|
||||
select new { p }).Skip(skip).Take(take).Select(x => x.p);
|
||||
var providers = await query.ToArrayAsync();
|
||||
return Mapper.Map<List<Provider>>(providers);
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var query = !string.IsNullOrWhiteSpace(userEmail) ?
|
||||
(from p in dbContext.Providers
|
||||
join pu in dbContext.ProviderUsers
|
||||
on p.Id equals pu.ProviderId
|
||||
join u in dbContext.Users
|
||||
on pu.UserId equals u.Id
|
||||
where (string.IsNullOrWhiteSpace(name) || p.Name.Contains(name)) &&
|
||||
u.Email == userEmail
|
||||
orderby p.CreationDate descending
|
||||
select new { p, pu, u }).Skip(skip).Take(take).Select(x => x.p) :
|
||||
(from p in dbContext.Providers
|
||||
where string.IsNullOrWhiteSpace(name) || p.Name.Contains(name)
|
||||
orderby p.CreationDate descending
|
||||
select new { p }).Skip(skip).Take(take).Select(x => x.p);
|
||||
var providers = await query.ToArrayAsync();
|
||||
return Mapper.Map<List<Provider>>(providers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<ProviderAbility>> GetManyAbilitiesAsync()
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
public async Task<ICollection<ProviderAbility>> GetManyAbilitiesAsync()
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
return await GetDbSet(dbContext)
|
||||
.Select(e => new ProviderAbility
|
||||
{
|
||||
Enabled = e.Enabled,
|
||||
Id = e.Id,
|
||||
UseEvents = e.UseEvents,
|
||||
}).ToListAsync();
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
return await GetDbSet(dbContext)
|
||||
.Select(e => new ProviderAbility
|
||||
{
|
||||
Enabled = e.Enabled,
|
||||
Id = e.Id,
|
||||
UseEvents = e.UseEvents,
|
||||
}).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user