mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-07 12:28:39 +00:00
Fix photo deserialization/serialization
This commit is contained in:
parent
632e430b36
commit
0ffd01f59d
2 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue