public async Task <SkillModel> CreateSkillAsync(int heroId, SkillModel skillModel) { await ValidateHero(heroId); if (skillModel.HeroId != null && skillModel.HeroId != heroId) { throw new BadRequestException($"You cant create the skill with that hero id, try with {heroId}"); } skillModel.HeroId = heroId; SkillEntity skillEntity = _mapper.Map <SkillEntity>(skillModel); skillEntity.HeroId = heroId; _libraryRepository.CreateSkill(skillEntity); var res = await _libraryRepository.SaveChangesAsync(); if (res) { return(_mapper.Map <SkillModel>(skillEntity)); } throw new Exception("Database Exception"); }