Warning if not using 'simple using'

This commit is contained in:
nicolas.dorier
2022-01-14 17:50:29 +09:00
parent c6a7e90c1a
commit 50d4b55f73
40 changed files with 5355 additions and 5732 deletions

View File

@@ -28,19 +28,17 @@ namespace BTCPayServer.Security.Greenfield
public async Task<List<APIKeyData>> GetKeys(APIKeyQuery query)
{
using (var context = _applicationDbContextFactory.CreateContext())
using var context = _applicationDbContextFactory.CreateContext();
var queryable = context.ApiKeys.AsQueryable();
if (query != null)
{
var queryable = context.ApiKeys.AsQueryable();
if (query != null)
if (query.UserId != null && query.UserId.Any())
{
if (query.UserId != null && query.UserId.Any())
{
queryable = queryable.Where(data => query.UserId.Contains(data.UserId));
}
queryable = queryable.Where(data => query.UserId.Contains(data.UserId));
}
return await queryable.ToListAsync();
}
return await queryable.ToListAsync();
}
public async Task CreateKey(APIKeyData key)
@@ -50,11 +48,9 @@ namespace BTCPayServer.Security.Greenfield
throw new InvalidOperationException("cannot save a bitpay legacy api key with this repository");
}
using (var context = _applicationDbContextFactory.CreateContext())
{
await context.ApiKeys.AddAsync(key);
await context.SaveChangesAsync();
}
using var context = _applicationDbContextFactory.CreateContext();
await context.ApiKeys.AddAsync(key);
await context.SaveChangesAsync();
}
public async Task<bool> Remove(string id, string getUserId)