1
0
mirror of https://github.com/bitwarden/server synced 2025-12-30 15:14:02 +00:00

Run formatting (#2230)

This commit is contained in:
Justin Baur
2022-08-29 16:06:55 -04:00
committed by GitHub
parent 9b7aef0763
commit 7f5f010e1e
1205 changed files with 73813 additions and 75022 deletions

View File

@@ -4,64 +4,63 @@ using Bit.Infrastructure.EntityFramework.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Infrastructure.EntityFramework.Repositories
namespace Bit.Infrastructure.EntityFramework.Repositories;
public class TaxRateRepository : Repository<Core.Entities.TaxRate, TaxRate, string>, ITaxRateRepository
{
public class TaxRateRepository : Repository<Core.Entities.TaxRate, TaxRate, string>, ITaxRateRepository
public TaxRateRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.TaxRates)
{ }
public async Task ArchiveAsync(Core.Entities.TaxRate model)
{
public TaxRateRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.TaxRates)
{ }
public async Task ArchiveAsync(Core.Entities.TaxRate model)
using (var scope = ServiceScopeFactory.CreateScope())
{
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
var entity = await dbContext.FindAsync<Core.Entities.TaxRate>(model);
entity.Active = false;
await dbContext.SaveChangesAsync();
}
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()
public async Task<ICollection<Core.Entities.TaxRate>> GetAllActiveAsync()
{
using (var scope = ServiceScopeFactory.CreateScope())
{
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);
}
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)
public async Task<ICollection<Core.Entities.TaxRate>> GetByLocationAsync(Core.Entities.TaxRate taxRate)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
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);
}
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)
public async Task<ICollection<Core.Entities.TaxRate>> SearchAsync(int skip, int count)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
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);
}
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);
}
}
}