Ignore:
Timestamp:
03/24/26 23:03:39 (3 months ago)
Author:
kikisrbinoska <srbinoskakristina07@…>
Branches:
main
Children:
a7550ca
Parents:
73b69b2
Message:

Added functional collaboration between users

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ChapterX.Infrastructure/Repositories/CollaborationRepository.cs

    r73b69b2 r7fbb91c  
    22using ChapterX.Domain.Repositories;
    33using ChapterX.Infrastructure.Data.DataContext;
    4 using System;
    5 using System.Collections.Generic;
    6 using System.Linq;
    7 using System.Text;
    8 using System.Threading.Tasks;
     4using Microsoft.EntityFrameworkCore;
    95
    106namespace ChapterX.Infrastructure.Repositories
     
    1511        {
    1612        }
     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        }
    1727    }
    1828}
Note: See TracChangeset for help on using the changeset viewer.