1
0
mirror of https://github.com/bitwarden/server synced 2025-12-30 07:03:42 +00:00

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

@@ -4,63 +4,64 @@ using Bit.Infrastructure.EntityFramework.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Infrastructure.EntityFramework.Repositories;
public class TaxRateRepository : Repository<Core.Entities.TaxRate, TaxRate, string>, ITaxRateRepository
namespace Bit.Infrastructure.EntityFramework.Repositories
{
public TaxRateRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.TaxRates)
{ }
public async Task ArchiveAsync(Core.Entities.TaxRate model)
public class TaxRateRepository : Repository<Core.Entities.TaxRate, TaxRate, string>, ITaxRateRepository
{
using (var scope = ServiceScopeFactory.CreateScope())
public TaxRateRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.TaxRates)
{ }
public async Task ArchiveAsync(Core.Entities.TaxRate model)
{
var dbContext = GetDatabaseContext(scope);
var entity = await dbContext.FindAsync<Core.Entities.TaxRate>(model);
entity.Active = false;
await dbContext.SaveChangesAsync();
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
var entity = await dbContext.FindAsync<Core.Entities.TaxRate>(model);
entity.Active = false;
await dbContext.SaveChangesAsync();
}
}
}
public async Task<ICollection<Core.Entities.TaxRate>> GetAllActiveAsync()
{
using (var scope = ServiceScopeFactory.CreateScope())
public async Task<ICollection<Core.Entities.TaxRate>> GetAllActiveAsync()
{
var dbContext = GetDatabaseContext(scope);
var results = await dbContext.TaxRates
.Where(t => t.Active)
.ToListAsync();
return Mapper.Map<List<Core.Entities.TaxRate>>(results);
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
var results = await dbContext.TaxRates
.Where(t => t.Active)
.ToListAsync();
return Mapper.Map<List<Core.Entities.TaxRate>>(results);
}
}
}
public async Task<ICollection<Core.Entities.TaxRate>> GetByLocationAsync(Core.Entities.TaxRate taxRate)
{
using (var scope = ServiceScopeFactory.CreateScope())
public async Task<ICollection<Core.Entities.TaxRate>> GetByLocationAsync(Core.Entities.TaxRate taxRate)
{
var dbContext = GetDatabaseContext(scope);
var results = await dbContext.TaxRates
.Where(t => t.Active &&
t.Country == taxRate.Country &&
t.PostalCode == taxRate.PostalCode)
.ToListAsync();
return Mapper.Map<List<Core.Entities.TaxRate>>(results);
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
var results = await dbContext.TaxRates
.Where(t => t.Active &&
t.Country == taxRate.Country &&
t.PostalCode == taxRate.PostalCode)
.ToListAsync();
return Mapper.Map<List<Core.Entities.TaxRate>>(results);
}
}
}
public async Task<ICollection<Core.Entities.TaxRate>> SearchAsync(int skip, int count)
{
using (var scope = ServiceScopeFactory.CreateScope())
public async Task<ICollection<Core.Entities.TaxRate>> SearchAsync(int skip, int count)
{
var dbContext = GetDatabaseContext(scope);
var results = await dbContext.TaxRates
.Skip(skip)
.Take(count)
.Where(t => t.Active)
.OrderBy(t => t.Country).ThenByDescending(t => t.PostalCode)
.ToListAsync();
return Mapper.Map<List<Core.Entities.TaxRate>>(results);
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
var results = await dbContext.TaxRates
.Skip(skip)
.Take(count)
.Where(t => t.Active)
.OrderBy(t => t.Country).ThenByDescending(t => t.PostalCode)
.ToListAsync();
return Mapper.Map<List<Core.Entities.TaxRate>>(results);
}
}
}
}