Some unit tests, names and small fixes

This commit is contained in:
Amelia 2025-05-15 23:58:42 +02:00
parent 23c4a451b4
commit 06914d1135
No known key found for this signature in database
GPG key ID: D6D0ECE365407EAA
10 changed files with 332 additions and 13 deletions

View file

@ -1,19 +1,29 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using API.Entities;
using API.Extensions.QueryExtensions;
using AutoMapper;
using Microsoft.EntityFrameworkCore;
namespace API.Data.Repositories;
[Flags]
public enum ReadingProfileIncludes
{
None = 0,
Series = 1 << 1,
Library = 1 << 2
}
public interface IAppUserReadingProfileRepository
{
Task<IList<AppUserReadingProfile>> GetProfilesForUser(int userId);
Task<AppUserReadingProfile?> GetProfileForSeries(int userId, int seriesId);
Task<AppUserReadingProfile?> GetProfileForLibrary(int userId, int libraryId);
Task<AppUserReadingProfile?> GetProfile(int profileId);
Task<AppUserReadingProfile?> GetProfile(int profileId, ReadingProfileIncludes includes = ReadingProfileIncludes.None);
void Add(AppUserReadingProfile readingProfile);
void Update(AppUserReadingProfile readingProfile);
@ -44,10 +54,11 @@ public class AppUserReadingProfileRepository(DataContext context, IMapper mapper
.FirstOrDefaultAsync();
}
public async Task<AppUserReadingProfile?> GetProfile(int profileId)
public async Task<AppUserReadingProfile?> GetProfile(int profileId, ReadingProfileIncludes includes = ReadingProfileIncludes.None)
{
return await context.AppUserReadingProfile
.Where(rp => rp.Id == profileId)
.Includes(includes)
.FirstOrDefaultAsync();
}