Exemplo n.º 1
0
        public IActionResult Get(int?id, string name)
        {
            //Graph::GraphServiceClient graphClient = GetGraphServiceClient(new[] { GraphScopes.UserReadBasicAll });

            ////var users = await graphClient.Users.Request().GetAsync();

            //var users = graphClient.Users.Request().GetAsync();

            //_logger.LogInformation("Get heroes called, users found {0}", users);


            if (!String.IsNullOrEmpty(name))
            {
                _logger.LogInformation("GetById heroes called for name {0}", name);

                Heroes hero = _heroesService.GetOneByName(name);
                if (hero != null)
                {
                    return(Ok(hero));
                }
                else
                {
                    return(NotFound());
                }
            }
            if (id != null)
            {
                _logger.LogInformation("GetById heroes called for id {0}", id);
                Heroes hero = _heroesService.GetOneById(id);
                if (hero != null)
                {
                    return(Ok(hero));
                }
                else
                {
                    return(NotFound());
                }
            }
            _logger.LogInformation("Get heroes called ");
            IEnumerable <Heroes> allheroes = _heroesService.GetAll();

            if (allheroes != null)
            {
                return(Ok(allheroes));
            }
            return(NotFound());
        }
        public IActionResult Get(int?id, string name)
        {
            if (!String.IsNullOrEmpty(name))
            {
                _logger.LogInformation("GetById heroes called for name {0}", name);

                Heroes hero = _heroesService.GetOneByName(name);
                if (hero != null)
                {
                    return(Ok(hero));
                }
                else
                {
                    return(NotFound());
                }
            }
            if (id != null)
            {
                _logger.LogInformation("GetById heroes called for id {0}", id);
                Heroes hero = _heroesService.GetOneById(id);
                if (hero != null)
                {
                    return(Ok(hero));
                }
                else
                {
                    return(NotFound());
                }
            }
            _logger.LogInformation("Get heroes called");
            IEnumerable <Heroes> allheroes = _heroesService.GetAll();

            if (allheroes != null)
            {
                return(Ok(allheroes));
            }
            return(NotFound());
        }