private void SaveRatingHistory() { var ratingHistoryChunk = new RatingHistory[ChunkSize]; var count = 0; var userIdentities = _gameSessions.Identities; foreach (var game in _gameSessions.Games) { if (count < ChunkSize) { var userRatingHistory = new RatingHistory { UserId = userIdentities[game.Key], ManualStepsCount = game.Value.ManualStepNumber, RootCounter = (int)game.Value.GameCash.RootCounter.Value, Data = DateTime.Now, TotalEarned = game.Value.GameCash.TotalEarned, }; ratingHistoryChunk[count] = userRatingHistory; count++; } else { if (ratingHistoryChunk.FirstOrDefault() != null) { _localNodeRatingDataAccess.PersistUsersRatingHistory(ratingHistoryChunk); ratingHistoryChunk = new RatingHistory[ChunkSize]; count = 0; } } } if (count < ChunkSize) { if (ratingHistoryChunk.FirstOrDefault() != null) { _localNodeRatingDataAccess.PersistUsersRatingHistory(ratingHistoryChunk); ratingHistoryChunk = new RatingHistory[ChunkSize]; count = 0; } } //RatingHistory userRatingHistory; //foreach (var game in _gameSessions.Games) //{ // userRatingHistory = new RatingHistory // { // UserId = game.Key, // ManualStepsCount = game.Value.ManualStepNumber, // RootCounter = (Int32)game.Value.GameCash.RootCounter.Value, // Data = DateTime.Now, // TotalEarned = game.Value.GameCash.TotalEarned, // }; // _localRatingDataAccess.PersistUsersRatingHistory(ratingHistoryChunk); //}; }