Esempio n. 1
0
        public async Task <IActionResult> Post([FromBody] Hero hero)
        {
            if (hero.IsValid())
            {
                await _heroesRepository.AddAsync(hero);

                await _heroesRepository.SaveAsync();

                return(CreatedAtAction("Get", new { id = hero.Id }));
            }
            else
            {
                return(BadRequest());
            }
        }