Fix photo deserialization/serialization

This commit is contained in:
jvyden 2021-11-07 17:02:56 -05:00
commit 0ffd01f59d
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
2 changed files with 8 additions and 2 deletions

View file

@ -40,7 +40,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
photo.CreatorId = user.UserId; photo.CreatorId = user.UserId;
photo.Creator = user; photo.Creator = user;
foreach (PhotoSubject subject in photo.Subjects) foreach (PhotoSubject subject in photo.SubjectsXmlDontUse) // fine for here
{ {
subject.User = await this.database.Users.FirstOrDefaultAsync(u => u.Username == subject.Username); subject.User = await this.database.Users.FirstOrDefaultAsync(u => u.Username == subject.Username);

View file

@ -33,17 +33,23 @@ namespace LBPUnion.ProjectLighthouse.Types
[XmlElement("plan")] [XmlElement("plan")]
public string PlanHash { get; set; } public string PlanHash { get; set; }
[NotMapped]
private List<PhotoSubject>? subjects; private List<PhotoSubject>? subjects;
[NotMapped] [NotMapped]
[XmlArray("subjects")] [XmlArray("subjects")]
[XmlArrayItem("subject")] [XmlArrayItem("subject")]
public List<PhotoSubject> SubjectsXmlDontUse {
get => null!;
set => Subjects = value;
}
[NotMapped]
public List<PhotoSubject> Subjects { public List<PhotoSubject> Subjects {
get { get {
if (this.subjects != null) return this.subjects; if (this.subjects != null) return this.subjects;
List<PhotoSubject> response = new(); List<PhotoSubject> response = new();
using Database database = new(); using Database database = new();
foreach (string idStr in this.PhotoSubjectIds) foreach (string idStr in this.PhotoSubjectIds)