@@ -119,67 +119,20 @@ public GamePhoto UploadPhoto(IPhotoUpload photo, IEnumerable<IPhotoUploadSubject
119119 return newPhoto ;
120120 }
121121
122- /// <remarks>
123- /// Migration only!!
124- /// </remarks>
125- public void MigratePhotoSubjects ( GamePhoto photo , bool saveChanges )
122+ public GamePhotoSubject AddSubjectForPhoto ( GamePhoto photo , int playerId , string displayName , GameUser ? user , List < float > bounds , bool save = true )
126123 {
127- List < GamePhotoSubject > subjects = [ ] ;
128-
129- #pragma warning disable CS0618 // obsoletion
130-
131- // If DisplayName is not null, there is a subject in that spot
132- if ( photo . Subject1DisplayName != null )
133- {
134- subjects . Add ( new ( )
135- {
136- Photo = photo ,
137- PlayerId = 1 ,
138- DisplayName = photo . Subject1DisplayName ,
139- User = photo . Subject1User ,
140- Bounds = photo . Subject1Bounds ,
141- } ) ;
142- }
143-
144- if ( photo . Subject2DisplayName != null )
145- {
146- subjects . Add ( new ( )
147- {
148- Photo = photo ,
149- PlayerId = 2 ,
150- DisplayName = photo . Subject2DisplayName ,
151- User = photo . Subject2User ,
152- Bounds = photo . Subject2Bounds ,
153- } ) ;
154- }
155-
156- if ( photo . Subject3DisplayName != null )
157- {
158- subjects . Add ( new ( )
159- {
160- Photo = photo ,
161- PlayerId = 3 ,
162- DisplayName = photo . Subject3DisplayName ,
163- User = photo . Subject3User ,
164- Bounds = photo . Subject3Bounds ,
165- } ) ;
166- }
167-
168- if ( photo . Subject4DisplayName != null )
124+ GamePhotoSubject subject = new ( )
169125 {
170- subjects . Add ( new ( )
171- {
172- Photo = photo ,
173- PlayerId = 4 ,
174- DisplayName = photo . Subject4DisplayName ,
175- User = photo . Subject4User ,
176- Bounds = photo . Subject4Bounds ,
177- } ) ;
178- }
179- #pragma warning restore CS0618
126+ Photo = photo ,
127+ PlayerId = playerId ,
128+ DisplayName = displayName ,
129+ User = user ,
130+ Bounds = bounds ,
131+ } ;
180132
181- this . GamePhotoSubjects . AddRange ( subjects ) ;
182- if ( saveChanges ) this . SaveChanges ( ) ;
133+ this . GamePhotoSubjects . Add ( subject ) ;
134+ if ( save ) this . SaveChanges ( ) ;
135+ return subject ;
183136 }
184137
185138 public void RemovePhoto ( GamePhoto photo )
@@ -227,6 +180,9 @@ public IQueryable<GamePhotoSubject> GetSubjectsInPhoto(GamePhoto photo)
227180 . Where ( s => s . PhotoId == photo . PhotoId )
228181 . OrderBy ( s => s . PlayerId ) ;
229182
183+ public int GetTotalSubjectsInPhoto ( GamePhoto photo )
184+ => this . GamePhotoSubjects . Count ( s => s . PhotoId == photo . PhotoId ) ;
185+
230186 public IQueryable < GameUser > GetUsersInPhoto ( GamePhoto photo )
231187 => this . GetSubjectsInPhoto ( photo )
232188 . Where ( s => s . User != null )
0 commit comments