Fix tests - temp this introduced another bug

This commit is contained in:
Amelia 2025-05-30 13:29:29 +02:00
parent 558a1d73f5
commit 12235a62a2
No known key found for this signature in database
GPG key ID: D6D0ECE365407EAA
3 changed files with 12 additions and 2 deletions

View file

@ -790,8 +790,13 @@ public class AccountController : BaseApiController
var profile = new AppUserReadingProfileBuilder(user.Id)
.WithName("Default Profile")
.Build();
_unitOfWork.AppUserReadingProfileRepository.Attach(profile);
user.UserPreferences.ReadingProfiles.Add(profile);
user.UserPreferences.DefaultReadingProfile = profile;
// TODO: This doesn't save, but I've had to revert it having the full entity or everything would start failing
// in tests because of foreign key constrains. This HAS to be resolved as the code does expect there to always be a
// default profile
user.UserPreferences.DefaultReadingProfileId = profile.Id;
}
/// <summary>

View file

@ -47,6 +47,7 @@ public interface IAppUserReadingProfileRepository
void Add(AppUserReadingProfile readingProfile);
void Add(SeriesReadingProfile readingProfile);
void Attach(AppUserReadingProfile readingProfile);
void Update(AppUserReadingProfile readingProfile);
void Update(SeriesReadingProfile readingProfile);
void Remove(AppUserReadingProfile readingProfile);
@ -183,6 +184,11 @@ public class AppUserReadingProfileRepository(DataContext context, IMapper mapper
context.SeriesReadingProfile.Add(readingProfile);
}
public void Attach(AppUserReadingProfile readingProfile)
{
context.AppUserReadingProfile.Attach(readingProfile);
}
public void Update(AppUserReadingProfile readingProfile)
{
context.AppUserReadingProfile.Update(readingProfile).State = EntityState.Modified;

View file

@ -12,7 +12,6 @@ public class AppUserPreferences
#region ReadingProfiles
public int DefaultReadingProfileId { get; set; }
public AppUserReadingProfile DefaultReadingProfile { get; set; }
public ICollection<AppUserReadingProfile> ReadingProfiles { get; set; } = null!;