main
|
Last change
on this file since 73b69b2 was 73b69b2, checked in by kikisrbinoska <srbinoskakristina07@…>, 3 months ago |
|
Fixed reading lists,comments and likes
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 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 StoryRepository : GenericRepository<Story>, IStoryRepository
|
|---|
| 9 | {
|
|---|
| 10 | public StoryRepository(ApplicationDbContext context) : base(context)
|
|---|
| 11 | {
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | public override async Task<IEnumerable<Story>> GetAllAsync(CancellationToken cancellationToken = default)
|
|---|
| 15 | {
|
|---|
| 16 | return await _dbSet
|
|---|
| 17 | .Include(s => s.HasGenres)
|
|---|
| 18 | .ThenInclude(hg => hg.Genre)
|
|---|
| 19 | .Include(s => s.Writer)
|
|---|
| 20 | .ThenInclude(w => w!.User)
|
|---|
| 21 | .ToListAsync(cancellationToken);
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | public async Task<IEnumerable<Story>> GetByWriterIdAsync(int writerId, CancellationToken cancellationToken = default)
|
|---|
| 25 | {
|
|---|
| 26 | return await _dbSet
|
|---|
| 27 | .Include(s => s.Writer)
|
|---|
| 28 | .Where(s => s.Writer != null && s.Writer.Id == writerId)
|
|---|
| 29 | .ToListAsync(cancellationToken);
|
|---|
| 30 | }
|
|---|
| 31 | }
|
|---|
| 32 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.