diff --git a/ProjectLighthouse/Controllers/PhotosController.cs b/ProjectLighthouse/Controllers/PhotosController.cs index af1c7622..7255fc6c 100644 --- a/ProjectLighthouse/Controllers/PhotosController.cs +++ b/ProjectLighthouse/Controllers/PhotosController.cs @@ -71,7 +71,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("photos/user/{id:int}")] public async Task SlotPhotos(int id) { - List photos = await this.database.Photos.Take(10).ToListAsync(); + List photos = await this.database.Photos.Include(p => p.Creator).Take(10).ToListAsync(); string response = photos.Aggregate(string.Empty, (s, photo) => s + photo.Serialize(id)); return this.Ok(LbpSerializer.StringElement("photos", response)); } @@ -83,7 +83,9 @@ namespace LBPUnion.ProjectLighthouse.Controllers // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (user == null) return this.NotFound(); - List photos = await this.database.Photos.Where(p => p.CreatorId == userFromQuery.UserId) + List photos = await this.database.Photos.Include + (p => p.Creator) + .Where(p => p.CreatorId == userFromQuery.UserId) .OrderByDescending(s => s.Timestamp) .Skip(pageStart - 1) .Take(Math.Min(pageSize, 30)) @@ -100,7 +102,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers if (user == null) return this.NotFound(); List photos = new(); - foreach (Photo photo in this.database.Photos) + foreach (Photo photo in this.database.Photos.Include(p => p.Creator)) { photos.AddRange(photo.Subjects.Where(subject => subject.User.UserId == userFromQuery.UserId).Select(_ => photo)); } diff --git a/ProjectLighthouse/Types/Photo.cs b/ProjectLighthouse/Types/Photo.cs index 2bafa2bb..bbbf39ef 100644 --- a/ProjectLighthouse/Types/Photo.cs +++ b/ProjectLighthouse/Types/Photo.cs @@ -92,7 +92,7 @@ namespace LBPUnion.ProjectLighthouse.Types LbpSerializer.StringElement("medium", this.MediumHash) + LbpSerializer.StringElement("large", this.LargeHash) + LbpSerializer.StringElement("plan", this.PlanHash) + - LbpSerializer.StringElement("author", this.CreatorId) + + LbpSerializer.StringElement("author", this.Creator.Username) + LbpSerializer.StringElement("subjects", subjectsAggregate) + slot;