public async Task <ActionResult <Pet> > CreateAsync(Pet pet) { await _repository.AddPetAsync(pet); return(CreatedAtAction(nameof(GetByIdAsync), new { id = pet.Id }, pet)); }
public async Task <IActionResult> CreateAsync([FromBody] Pet pet) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _repository.AddPetAsync(pet); return(CreatedAtAction(nameof(GetById), new { id = pet.Id }, pet)); }
public async Task <IActionResult> CreateAsync([FromBody] Pet pet) { #region snippet_ModelStateIsValidCheck if (!ModelState.IsValid) { return(BadRequest(ModelState)); } #endregion await _repository.AddPetAsync(pet); return(CreatedAtAction(nameof(GetByIdAsync), new { id = pet.Id }, pet)); }