Example #1
0
        public async Task <ActionResult <Pet> > CreateAsync(Pet pet)
        {
            await _repository.AddPetAsync(pet);

            return(CreatedAtAction(nameof(GetByIdAsync),
                                   new { id = pet.Id }, pet));
        }
Example #2
0
        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));
        }