public IActionResult CreateDog(int clientId, [FromBody] DogForCreationDto dog) { if (dog.Name == dog.ShortName) { ModelState.AddModelError( "ShortName", "The Name and Short Name cannot be the same (please use less characters with short name field)"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_clientInfoRepository.ClientExists(clientId)) { return(NotFound()); } var finalDog = _mapper.Map <Entities.Dog>(dog); _clientInfoRepository.AddDogForClient(clientId, finalDog); _clientInfoRepository.Save(); var createdDogToReturn = _mapper .Map <Models.DogDto>(finalDog); return(CreatedAtRoute( "GetDog", new { clientId = clientId, id = createdDogToReturn.Id }, createdDogToReturn)); }