Exemplo n.º 1
0
        public async Task <ActionResult <Dragon> > GetDragon(int id)
        {
            var dragon = await _dragonService.GetDragonById(id);

            if (dragon == null)
            {
                return(NotFound());
            }

            return(dragon);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> HitAsync(int dragonId)
        {
            int    heroIdClaim = 0;
            bool   isHeroId    = GetAuthHeroId(ref heroIdClaim);
            Dragon dragon      = await _dragonService.GetDragonById(dragonId);

            Hero hero = await _heroService.GetHeroByIdAsync(heroIdClaim);

            if (hero == null || !isHeroId || dragon == null)
            {
                return(BadRequest(new { errorText = "Couldnt find a hero or a dragon" }));
            }
            //--------------------------
            int dragonHealtPointNow = await _hitService.HeroHitDragon(dragon, hero);

            return(Ok(dragonHealtPointNow));
        }