profileShare

rasmusjy / splitapp-backend-clean-onion

Read-only snapshot

No repository description.

main default branch 429 files Expires Sep 13, 2026, 9:06 AM
UserRepository.cs 824 bytes
1 using App.Domain.Contracts;
2 using App.Domain.Identity;
3 using Microsoft.EntityFrameworkCore;
4
5 namespace App.DAL.EF.Repositories;
6
7 public class UserRepository : BaseRepository<AppUser>, IUserRepository
8 {
9 public UserRepository(AppDbContext dbContext) : base(dbContext)
10 {
11 }
12
13 public async Task<int> CountAsync()
14 {
15 return await DbContext.Users.CountAsync();
16 }
17
18 public async Task<IEnumerable<AppUser>> GetRecentAsync(int take)
19 {
20 return await DbContext.Users
21 .OrderByDescending(u => u.Id)
22 .Take(take)
23 .ToListAsync();
24 }
25
26 public async Task<AppUser?> GetByIdWithRefreshTokensAsync(Guid userId)
27 {
28 return await DbContext.Users
29 .Include(u => u.RefreshTokens)
30 .FirstOrDefaultAsync(u => u.Id == userId);
31 }
32 }
33