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 void UploadPhoto ( IPhotoUpload photo , IEnumerable < IPhotoUploadSubject > subjects , GameUser publisher , GameLevel ? level )
3032 {
3133 GamePhoto newPhoto = new ( )
3234 {
@@ -36,33 +38,26 @@ 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 . LevelSlotType ,
43+ OriginalLevelId = photo . LevelId ,
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 ;
50+ float [ ] bounds = new float [ PhotoHelper . SubjectBoundCount ] ;
4851
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 )
52+ List < GamePhotoSubject > gameSubjects = new ( subjects . Count ( ) ) ;
53+ foreach ( IPhotoUploadSubject subject in subjects )
5954 {
6055 GameUser ? subjectUser = null ;
6156
6257 if ( ! string . IsNullOrEmpty ( subject . Username ) )
6358 subjectUser = this . GetUserByUsername ( subject . Username ) ;
6459
65- SerializedPhotoSubject . ParseBoundsList ( subject . BoundsList , bounds ) ;
60+ PhotoHelper . ParseBoundsList ( subject . BoundsList , bounds ) ;
6661
6762 gameSubjects . Add ( new GamePhotoSubject ( subjectUser , subject . DisplayName , bounds ) ) ;
6863
0 commit comments