예제 #1
0
        public async Task <ActionResult <City> > GetCity(int id)
        {
            var city = await _cityRepository.Get(id);

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

            return(Ok(city));
        }
예제 #2
0
        public async Task <ActionResult <User> > GetUser(int id)
        {
            try
            {
                var user = await _userRepository.Get(id);

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

                return(Ok(user));
            }
            catch (Exception e)
            {
                return(BadRequest(new { message = "Error to find user", exception = e.Message, innerExeption = e.InnerException?.Message }));
            }
        }