main
|
Last change
on this file since 0b502c2 was 7fbb91c, checked in by kikisrbinoska <srbinoskakristina07@…>, 3 months ago |
|
Added functional collaboration between users
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Rev | Line | |
|---|
| [877c13c] | 1 | using ChapterX.Domain.Entities;
|
|---|
| 2 | using ChapterX.Domain.Repositories;
|
|---|
| 3 | using ChapterX.Infrastructure.Data.DataContext;
|
|---|
| 4 | using Microsoft.EntityFrameworkCore;
|
|---|
| 5 |
|
|---|
| 6 | namespace ChapterX.Infrastructure.Repositories
|
|---|
| 7 | {
|
|---|
| 8 | public class UserRepository : GenericRepository<User>, IUserRepository
|
|---|
| 9 | {
|
|---|
| 10 | public UserRepository(ApplicationDbContext context) : base(context)
|
|---|
| 11 | {
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| [7fbb91c] | 14 | public override async Task<IEnumerable<User>> GetAllAsync(CancellationToken cancellationToken = default)
|
|---|
| 15 | => await _dbSet
|
|---|
| 16 | .Include(u => u.Admin)
|
|---|
| 17 | .Include(u => u.Writer)
|
|---|
| 18 | .ToListAsync(cancellationToken);
|
|---|
| 19 |
|
|---|
| [877c13c] | 20 | public async Task<User?> GetByEmailAsync(string email, CancellationToken cancellationToken = default)
|
|---|
| [acf690c] | 21 | => await _dbSet
|
|---|
| 22 | .Include(u => u.Admin)
|
|---|
| 23 | .Include(u => u.Writer)
|
|---|
| 24 | .Include(u => u.RegularUser)
|
|---|
| 25 | .FirstOrDefaultAsync(u => u.Email == email, cancellationToken);
|
|---|
| [877c13c] | 26 |
|
|---|
| 27 | public async Task<User?> GetByUsernameAsync(string username, CancellationToken cancellationToken = default)
|
|---|
| 28 | => await _dbSet.FirstOrDefaultAsync(u => u.Username == username, cancellationToken);
|
|---|
| 29 | }
|
|---|
| 30 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.