public async Task <PlayerCharacter> AddPlayerCharacter(PlayerCharacter playerCharacter)
        {
            var result = await _dbContext.PlayerCharacters.AddAsync(playerCharacter);

            foreach (var attribute in playerCharacter.PlayerAttributes)
            {
                _dbContext.Entry(attribute.BaseAttribute).State = EntityState.Unchanged;
            }

            foreach (var ability in playerCharacter.PlayerAbilities)
            {
                _dbContext.Entry(ability.BaseAbility).State = EntityState.Unchanged;
                foreach (var skill in ability.SupportsPlayerSkills)
                {
                    _dbContext.Entry(skill.BaseSkill).State = EntityState.Unchanged;
                }
            }

            foreach (var skill in playerCharacter.PlayerSkills)
            {
                _dbContext.Entry(skill.BaseSkill).State = EntityState.Unchanged;
            }

            foreach (var value in playerCharacter.TrainingValues)
            {
                _dbContext.Entry(value.BaseTrainingValue).State = EntityState.Unchanged;
            }

            await _dbContext.SaveChangesAsync();

            return(result.Entity);
        }
Example #2
0
        public async Task <PlayerSkill> AddPlayerSkill(PlayerSkill playerSkill)
        {
            var result = await _dbContext.PlayerSkills.AddAsync(playerSkill);

            _dbContext.Entry(playerSkill.BaseSkill).State = EntityState.Unchanged;
            await _dbContext.SaveChangesAsync();

            return(result.Entity);
        }
        public async Task <PlayerAttribute> AddPlayerAttribute(PlayerAttribute playerAttribute)
        {
            var result = await _dbContext.PlayerAttributes.AddAsync(playerAttribute);

            _dbContext.Entry(playerAttribute.BaseAttribute).State = EntityState.Unchanged;
            await _dbContext.SaveChangesAsync();

            return(result.Entity);
        }
Example #4
0
        public async Task <BaseAbility> AddBaseAbility(BaseAbility baseAbility)
        {
            var result = await _dbContext.BaseAbilities.AddAsync(baseAbility);

            foreach (var value in baseAbility.ModifiesBaseTrainingValues)
            {
                _dbContext.Entry(value).State = EntityState.Unchanged;
            }
            _dbContext.Entry(baseAbility.ModifiesBaseTrainingValues).State = EntityState.Unchanged;
            await _dbContext.SaveChangesAsync();

            return(result.Entity);
        }
        public async Task <PlayerAbility> AddPlayerAbility(PlayerAbility playerAbility)
        {
            var result = await _dbContext.PlayerAbilities.AddAsync(playerAbility);

            foreach (var value in playerAbility.BaseAbility.ModifiesBaseTrainingValues)
            {
                _dbContext.Entry(value).State = EntityState.Unchanged;
            }
            foreach (var skill in playerAbility.SupportsPlayerSkills)
            {
                _dbContext.Entry(skill).State           = EntityState.Unchanged;
                _dbContext.Entry(skill.BaseSkill).State = EntityState.Unchanged;
            }
            _dbContext.Entry(playerAbility.BaseAbility).State = EntityState.Unchanged;
            foreach (var attribute in playerAbility.BaseAbility.UsesBaseAttributes)
            {
                _dbContext.Entry(attribute).State = EntityState.Unchanged;
            }
            await _dbContext.SaveChangesAsync();

            return(result.Entity);
        }