main
|
Last change
on this file since 3ae4bab was 7fbb91c, checked in by kikisrbinoska <srbinoskakristina07@…>, 3 months ago |
|
Added functional collaboration between users
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Rev | Line | |
|---|
| [877c13c] | 1 | using ChapterX.Domain.Entities;
|
|---|
| 2 | using ChapterX.Domain.Repositories;
|
|---|
| 3 | using ChapterX.Infrastructure.Data.DataContext;
|
|---|
| [7fbb91c] | 4 | using Microsoft.EntityFrameworkCore;
|
|---|
| [877c13c] | 5 |
|
|---|
| 6 | namespace ChapterX.Infrastructure.Repositories
|
|---|
| 7 | {
|
|---|
| 8 | public class CollaborationRepository : GenericRepository<Collaboration>, ICollaborationRepository
|
|---|
| 9 | {
|
|---|
| 10 | public CollaborationRepository(ApplicationDbContext context) : base(context)
|
|---|
| 11 | {
|
|---|
| 12 | }
|
|---|
| [7fbb91c] | 13 |
|
|---|
| 14 | public override async Task<IEnumerable<Collaboration>> GetAllAsync(CancellationToken cancellationToken = default)
|
|---|
| 15 | => await _dbSet
|
|---|
| 16 | .Include(c => c.User)
|
|---|
| 17 | .ToListAsync(cancellationToken);
|
|---|
| 18 |
|
|---|
| 19 | public async Task<bool> DeleteByUserAndStoryAsync(int userId, int storyId, CancellationToken cancellationToken = default)
|
|---|
| 20 | {
|
|---|
| 21 | var collab = await _dbSet.FirstOrDefaultAsync(c => c.UserId == userId && c.StoryId == storyId, cancellationToken);
|
|---|
| 22 | if (collab == null) return false;
|
|---|
| 23 | _dbSet.Remove(collab);
|
|---|
| 24 | await _context.SaveChangesAsync(cancellationToken);
|
|---|
| 25 | return true;
|
|---|
| 26 | }
|
|---|
| [877c13c] | 27 | }
|
|---|
| 28 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.