public async Task <IActionResult> PutSkill(int id, SkillDto skillDto)
        {
            var skill = _mapper.Map <Skill>(skillDto);

            if (id != skill.Id)
            {
                return(BadRequest());
            }

            skill.SkillCategory = null;

            _context.SetModified(skill);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!await SkillExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutPlayerType(int id, PlayerTypeDto playerTypeDto)
        {
            if (!await PlayerTypeExists(id))
            {
                return(NotFound());
            }

            if (id != playerTypeDto.Id || !await ValidatePlayerTypeDto(playerTypeDto))
            {
                return(BadRequest());
            }

            var playerType = _mapper.Map <PlayerType>(playerTypeDto);


            _context.SetModified(playerType);

            var existingStaringSkills = await _context.StartingSkill.Where(c => c.PlayerTypeId == playerType.Id).ToListAsync();

            // Delete Existing StaringSkill Records
            foreach (var existingStartingSkill in existingStaringSkills)
            {
                if (!playerType.StartingSkills.Exists(s => s.SkillId == existingStartingSkill.SkillId))
                {
                    _context.StartingSkill.Remove(existingStartingSkill);
                }
            }

            // Add Or Update mew StartingSkill Records
            foreach (var startingSkill in playerType.StartingSkills)
            {
                var existingStartingSkill = await _context.StartingSkill.FindAsync(startingSkill.Id);

                if (existingStartingSkill == null)
                {
                    await _context.StartingSkill.AddAsync(existingStartingSkill);
                }
                else
                {
                    existingStartingSkill.PlayerTypeId = playerType.Id;
                    existingStartingSkill.SkillId      = startingSkill.SkillId;

                    _context.SetModified(existingStartingSkill);
                }
            }

            var existingAvailableSkillCategories = await _context.AvailableSkillCategory.Where(c => c.PlayerTypeId == playerType.Id).ToListAsync();

            // Delete Existing AvailableSkill Records
            foreach (var existingAvailableSkillCategory in existingAvailableSkillCategories)
            {
                if (!playerType.AvailableSkillCategories.Exists(s => s.Id == existingAvailableSkillCategory.Id))
                {
                    _context.AvailableSkillCategory.Remove(existingAvailableSkillCategory);
                }
            }

            // Delete Existing AvailableSkill Records
            foreach (var availableSkillCatagory in playerType.AvailableSkillCategories)
            {
                var existingAvailableSkillCategory = await _context.AvailableSkillCategory.FindAsync(availableSkillCatagory.Id);

                if (existingAvailableSkillCategory == null)
                {
                    await _context.AvailableSkillCategory.AddAsync(existingAvailableSkillCategory);
                }
                else
                {
                    existingAvailableSkillCategory.PlayerTypeId    = playerType.Id;
                    existingAvailableSkillCategory.LevelUpTypeId   = availableSkillCatagory.LevelUpTypeId;
                    existingAvailableSkillCategory.SkillCategoryId = availableSkillCatagory.SkillCategoryId;

                    _context.SetModified(existingAvailableSkillCategory);
                }
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!await PlayerTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }