33using Refresh . Database . Models . Users ;
44using Refresh . Database . Models . Levels ;
55using Refresh . Database . Models . Photos ;
6+ using Refresh . Database . Query ;
7+ using Refresh . Database . Helpers ;
68
79namespace Refresh . Database ;
810
@@ -26,7 +28,7 @@ public partial class GameDatabaseContext // Photos
2628 . Include ( p => p . Subject4User )
2729 . Include ( p => p . Subject4User ! . Statistics ) ;
2830
29- public void UploadPhoto ( SerializedPhoto photo , GameUser publisher )
31+ public GamePhoto UploadPhoto ( IPhotoUpload photo , IEnumerable < IPhotoUploadSubject > subjects , GameUser publisher , GameLevel ? level )
3032 {
3133 GamePhoto newPhoto = new ( )
3234 {
@@ -36,33 +38,24 @@ public void UploadPhoto(SerializedPhoto photo, GameUser publisher)
3638 PlanHash = photo . PlanHash ,
3739
3840 Publisher = publisher ,
39- LevelType = photo . Level ? . Type ?? "" ,
40- OriginalLevelId = photo . Level ? . LevelId ?? 0 ,
41- OriginalLevelName = photo . Level ? . Title ?? "" ,
41+ Level = level ,
42+ LevelType = photo . LevelType ?? "" ,
43+ OriginalLevelId = photo . LevelId ?? 0 ,
44+ OriginalLevelName = photo . LevelTitle ?? "" ,
4245
4346 TakenAt = DateTimeOffset . FromUnixTimeSeconds ( Math . Clamp ( photo . Timestamp , this . _time . EarliestDate , this . _time . TimestampSeconds ) ) ,
4447 PublishedAt = this . _time . Now ,
4548 } ;
4649
47- GameLevel ? level = null ;
48-
49- if ( photo . Level ? . Type is "user" or "developer" )
50- {
51- level = this . GetLevelByIdAndType ( photo . Level . Type , photo . Level . LevelId ) ;
52- newPhoto . Level = level ;
53- }
54-
55- float [ ] bounds = new float [ SerializedPhotoSubject . FloatCount ] ;
56-
57- List < GamePhotoSubject > gameSubjects = new ( photo . PhotoSubjects . Count ) ;
58- foreach ( SerializedPhotoSubject subject in photo . PhotoSubjects )
50+ List < GamePhotoSubject > gameSubjects = new ( subjects . Count ( ) ) ;
51+ foreach ( IPhotoUploadSubject subject in subjects )
5952 {
6053 GameUser ? subjectUser = null ;
6154
6255 if ( ! string . IsNullOrEmpty ( subject . Username ) )
6356 subjectUser = this . GetUserByUsername ( subject . Username ) ;
6457
65- SerializedPhotoSubject . ParseBoundsList ( subject . BoundsList , bounds ) ;
58+ float [ ] bounds = PhotoHelper . ParseBoundsList ( subject . BoundsList ) ;
6659
6760 gameSubjects . Add ( new GamePhotoSubject ( subjectUser , subject . DisplayName , bounds ) ) ;
6861
@@ -96,6 +89,7 @@ public void UploadPhoto(SerializedPhoto photo, GameUser publisher)
9689 }
9790
9891 this . CreatePhotoUploadEvent ( publisher , newPhoto ) ;
92+ return newPhoto ;
9993 }
10094
10195 public void RemovePhoto ( GamePhoto photo )
0 commit comments