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

Location:
ChapterX.Infrastructure/Repositories
Files:
2 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}
  • ChapterX.Infrastructure/Repositories/UserRepository.cs

    r73b69b2 r7fbb91c  
    1212        }
    1313
     14        public override async Task<IEnumerable<User>> GetAllAsync(CancellationToken cancellationToken = default)
     15            => await _dbSet
     16                .Include(u => u.Admin)
     17                .Include(u => u.Writer)
     18                .ToListAsync(cancellationToken);
     19
    1420        public async Task<User?> GetByEmailAsync(string email, CancellationToken cancellationToken = default)
    1521            => await _dbSet
Note: See TracChangeset for help on using the changeset viewer.