BusinessLogic.Logic.Players.PlayerDeleter.DeleteChampionRecords C# (CSharp) Метод

DeleteChampionRecords() приватный Метод

private DeleteChampionRecords ( int playerId, ApplicationUser currentUser ) : void
playerId int
currentUser ApplicationUser
Результат void
        private void DeleteChampionRecords(int playerId, ApplicationUser currentUser)
        {
            var gameDefinitionIdsThatNeedChampionRecalculated = new HashSet<int>();
            var playerChampionsToDelete = _dataContext.GetQueryable<Champion>()
                .Where(p => p.PlayerId == playerId)
                .ToList();

            foreach (var champion in playerChampionsToDelete)
            {
                var championId = champion.Id;

                var gameDefinitionsWithChampionToDelete = _dataContext.GetQueryable<GameDefinition>()
                    .Where(p => p.ChampionId == championId)
                    .ToList();

                foreach (var gameDef in gameDefinitionsWithChampionToDelete)
                {
                    //--clear out the current champion since recalculating may not clear out the current Champion
                    gameDef.ChampionId = null;
                    _dataContext.Save(gameDef, currentUser);

                    gameDefinitionIdsThatNeedChampionRecalculated.Add(gameDef.Id);
                }

                _dataContext.DeleteById<Champion>(championId, currentUser);
            }

            RecalculateChampions(gameDefinitionIdsThatNeedChampionRecalculated, currentUser);
        }