public async Task <HeroModel> CreateHeroAsync(int breedId, HeroModel heroModel) { ValidateBreed(breedId); if (heroModel.BreedId != null && heroModel.BreedId != breedId) { throw new BadRequestException($"You cant create the hero with that breed id, try with {breedId}"); } heroModel.BreedId = breedId; HeroEntity heroEntity = _mapper.Map <HeroEntity>(heroModel); _libraryRepository.CreateHero(heroEntity); var res = await _libraryRepository.SaveChangesAsync(); if (res) { return(_mapper.Map <HeroModel>(heroEntity)); } throw new Exception("Database Exception"); }