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.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 ReadingListItemsRepository : GenericRepository<ReadingListItems>, IReadingListItemsRepository
|
|---|
| 9 | {
|
|---|
| 10 | public ReadingListItemsRepository(ApplicationDbContext context) : base(context)
|
|---|
| 11 | {
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | public async Task<bool> ExistsAsync(int listId, int storyId, CancellationToken cancellationToken = default)
|
|---|
| 15 | => await _dbSet.AnyAsync(i => i.ListId == listId && i.StoryId == storyId, cancellationToken);
|
|---|
| 16 |
|
|---|
| 17 | public async Task<bool> DeleteByListAndStoryAsync(int listId, int storyId, CancellationToken cancellationToken = default)
|
|---|
| 18 | {
|
|---|
| 19 | var item = await _dbSet.FirstOrDefaultAsync(i => i.ListId == listId && i.StoryId == storyId, cancellationToken);
|
|---|
| 20 | if (item == null) return false;
|
|---|
| 21 | _dbSet.Remove(item);
|
|---|
| 22 | await _context.SaveChangesAsync(cancellationToken);
|
|---|
| 23 | return true;
|
|---|
| 24 | }
|
|---|
| 25 | }
|
|---|
| 26 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.