Esempio n. 1
0
        public async Task <IActionResult> CreateAsync([FromBody] CreateAnimalDto dto)
        {
            await _context.Mammals.AddAsync(new Mammal { Name = dto.Name });

            await _context.SaveChangesAsync();

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PostAsync([FromBody] CreateAnimalDto createAnimalDto)
        {
            var animal = await _animalService.CreateAnimal(_mapper.Map <Animal>(createAnimalDto));

            var readAnimalDto = _mapper.Map <ReadAnimalDto>(animal);

            return(Created(nameof(GetAsync), new Response <ReadAnimalDto>(readAnimalDto)));
        }