Skip to content

Commit f35cc73

Browse files
committed
Fix deleting all photos by user
1 parent 29d2b57 commit f35cc73

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

Refresh.Database/GameDatabaseContext.Photos.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,12 @@ public int GetTotalPhotosInLevelByUser(GameLevel level, GameUser? user)
193193

194194
public void DeletePhotosPostedByUser(GameUser user)
195195
{
196-
IEnumerable<GamePhoto> photos = this.GamePhotos.Where(s => s.PublisherId == user.UserId);
197-
198-
this.WriteEnsuringStatistics(user, () =>
196+
IEnumerable<GamePhoto> photos = this.GamePhotos.Where(s => s.PublisherId == user.UserId).ToArray();
197+
198+
foreach (GamePhoto photo in photos)
199199
{
200-
foreach (GamePhoto photo in photos)
201-
{
202-
this.RemovePhoto(photo);
203-
}
204-
205-
user.Statistics!.PhotosByUserCount = 0;
206-
});
200+
// RemovePhoto already takes care of decrementing (effectively resetting) the publisher's photo count
201+
this.RemovePhoto(photo);
202+
}
207203
}
208204
}

0 commit comments

Comments
 (0)