Refactored cache services
This commit is contained in:
@@ -14,8 +14,11 @@ public sealed class UserService(IDbContextFactory<ApplicationDbContext> contextF
|
||||
{
|
||||
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||
|
||||
// TODO: refactor to use TenantUser
|
||||
var user = await context.Users.FirstOrDefaultAsync(u => u.Id == userId, cancellationToken);
|
||||
|
||||
// TODO: refactor to use TenantUser
|
||||
// TODO: Also add to TenantUser
|
||||
if (user is null)
|
||||
context.Users.Add(new Domain.Entities.User
|
||||
{
|
||||
@@ -40,8 +43,10 @@ public sealed class UserService(IDbContextFactory<ApplicationDbContext> contextF
|
||||
{
|
||||
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||
|
||||
// TODO: refactor to use TenantUser
|
||||
var query = context.Users.AsNoTracking();
|
||||
|
||||
// TODO: refactor to use TenantUser
|
||||
if (request.Status.HasValue)
|
||||
query = query.Where(u => u.Status == request.Status.Value);
|
||||
|
||||
@@ -59,6 +64,7 @@ public sealed class UserService(IDbContextFactory<ApplicationDbContext> contextF
|
||||
else
|
||||
query = query.OrderBy(u => u.Id);
|
||||
|
||||
// TODO: refactor to use TenantUser
|
||||
var users = await query.Skip((pagination.Page - 1) * pagination.PageSize)
|
||||
.Take(pagination.PageSize).ToListAsync(cancellationToken);
|
||||
|
||||
@@ -70,6 +76,7 @@ public sealed class UserService(IDbContextFactory<ApplicationDbContext> contextF
|
||||
{
|
||||
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||
|
||||
// TODO: Update TenantUser status as well
|
||||
var changedTotal = await context.Users
|
||||
.Where(f => f.Id == userId)
|
||||
.ExecuteUpdateAsync(f => f.SetProperty(u => u.Status, status), cancellationToken);
|
||||
@@ -82,6 +89,7 @@ public sealed class UserService(IDbContextFactory<ApplicationDbContext> contextF
|
||||
{
|
||||
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||
|
||||
// TODO: refactor to use TenantUser
|
||||
var user = await context.Users.AsNoTracking()
|
||||
.FirstOrDefaultAsync(f => f.Id == userId, cancellationToken);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user