source: ChapterX.Infrastructure/Repositories/ReadingListRepository.cs@ b373fea

main
Last change on this file since b373fea was 73b69b2, checked in by kikisrbinoska <srbinoskakristina07@…>, 3 months ago

Fixed reading lists,comments and likes

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[877c13c]1using ChapterX.Domain.Entities;
2using ChapterX.Domain.Repositories;
3using ChapterX.Infrastructure.Data.DataContext;
4using Microsoft.EntityFrameworkCore;
5
6namespace ChapterX.Infrastructure.Repositories
7{
8 public class ReadingListRepository : GenericRepository<ReadingList>, IReadingListRepository
9 {
10 public ReadingListRepository(ApplicationDbContext context) : base(context)
11 {
12 }
13
[acf690c]14 public override async Task<IEnumerable<ReadingList>> GetAllAsync(CancellationToken cancellationToken = default)
15 {
16 return await _dbSet
[73b69b2]17 .Include(r => r.User)
[acf690c]18 .Include(r => r.ReadingListItems)
[73b69b2]19 .ThenInclude(i => i.Story)
20 .ThenInclude(s => s.Writer)
21 .ThenInclude(w => w!.User)
22 .Include(r => r.ReadingListItems)
23 .ThenInclude(i => i.Story)
24 .ThenInclude(s => s.HasGenres)
25 .ThenInclude(hg => hg.Genre)
[acf690c]26 .ToListAsync(cancellationToken);
27 }
28
[877c13c]29 public async Task<IEnumerable<ReadingList>> GetByUserIdAsync(int userId, CancellationToken cancellationToken = default)
30 {
31 return await _dbSet
32 .Where(r => r.UserId == userId)
[73b69b2]33 .Include(r => r.User)
34 .Include(r => r.ReadingListItems)
35 .ThenInclude(i => i.Story)
36 .ThenInclude(s => s.Writer)
37 .ThenInclude(w => w!.User)
[acf690c]38 .Include(r => r.ReadingListItems)
[73b69b2]39 .ThenInclude(i => i.Story)
40 .ThenInclude(s => s.HasGenres)
41 .ThenInclude(hg => hg.Genre)
[877c13c]42 .ToListAsync(cancellationToken);
43 }
44 }
45}
Note: See TracBrowser for help on using the repository browser.