mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-03 02:28:39 +00:00
Merge branch 'LBPUnion:main' into main
This commit is contained in:
commit
6be05dff82
2 changed files with 11 additions and 8 deletions
|
@ -5,6 +5,7 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
using Kettu;
|
||||||
using LBPUnion.ProjectLighthouse.Serialization;
|
using LBPUnion.ProjectLighthouse.Serialization;
|
||||||
using LBPUnion.ProjectLighthouse.Types;
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
@ -40,21 +41,25 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
photo.CreatorId = user.UserId;
|
photo.CreatorId = user.UserId;
|
||||||
photo.Creator = user;
|
photo.Creator = user;
|
||||||
|
|
||||||
foreach (PhotoSubject subject in photo.SubjectsXmlDontUse) // fine for here
|
foreach (PhotoSubject subject in photo.Subjects)
|
||||||
{
|
{
|
||||||
subject.User = await this.database.Users.FirstOrDefaultAsync(u => u.Username == subject.Username);
|
subject.User = await this.database.Users.FirstOrDefaultAsync(u => u.Username == subject.Username);
|
||||||
|
|
||||||
if (subject.User == null) return this.BadRequest();
|
if (subject.User == null) continue;
|
||||||
|
|
||||||
subject.UserId = subject.User.UserId;
|
subject.UserId = subject.User.UserId;
|
||||||
|
Logger.Log($"Adding PhotoSubject (userid {subject.UserId}) to db");
|
||||||
|
|
||||||
this.database.PhotoSubjects.Add(subject);
|
this.database.PhotoSubjects.Add(subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.database.SaveChangesAsync();
|
await this.database.SaveChangesAsync();
|
||||||
|
|
||||||
photo.PhotoSubjectCollection = photo.Subjects.Aggregate(string.Empty, (s, subject) => s + subject.PhotoSubjectId);
|
photo.PhotoSubjectIds = photo.Subjects.Select(subject => subject.PhotoSubjectId.ToString()).ToArray();
|
||||||
// photo.Slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == photo.SlotId);
|
|
||||||
|
// photo.Slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == photo.SlotId);
|
||||||
|
|
||||||
|
Logger.Log($"Adding PhotoSubjectCollection ({photo.PhotoSubjectCollection}) to photo");
|
||||||
|
|
||||||
this.database.Photos.Add(photo);
|
this.database.Photos.Add(photo);
|
||||||
|
|
||||||
|
|
|
@ -39,14 +39,12 @@ namespace LBPUnion.ProjectLighthouse.Types
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
[XmlArray("subjects")]
|
[XmlArray("subjects")]
|
||||||
[XmlArrayItem("subject")]
|
[XmlArrayItem("subject")]
|
||||||
public List<PhotoSubject> SubjectsXmlDontUse {
|
public List<PhotoSubject>? SubjectsXmlDontUseLiterallyEver;
|
||||||
get => null!;
|
|
||||||
set => Subjects = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public List<PhotoSubject> Subjects {
|
public List<PhotoSubject> Subjects {
|
||||||
get {
|
get {
|
||||||
|
if (this.SubjectsXmlDontUseLiterallyEver != null) return this.SubjectsXmlDontUseLiterallyEver;
|
||||||
if (this.subjects != null) return this.subjects;
|
if (this.subjects != null) return this.subjects;
|
||||||
|
|
||||||
List<PhotoSubject> response = new();
|
List<PhotoSubject> response = new();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue