コード例 #1
0
    public IActionResult GetAdults()
    {
        IEnumerable <Adult> adults = AdultService.GetAdultAsync();

        Console.WriteLine(adults);
        return(Ok(adults));
    }
コード例 #2
0
        public async Task <ActionResult <Adult> > GetAdult([FromRoute] string address, [FromRoute] int id)
        {
            try
            {
                Adult adult = await adultService.GetAdultAsync(id, address);

                return(Ok(adult));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
コード例 #3
0
        public async Task <ActionResult <IList <Adult> > > GetAdults([FromQuery] string name, [FromQuery] int?age, [FromQuery] int?id)
        {
            try
            {
                IList <Adult> adults = await adultService.GetAdultAsync(name, age, id);

                return(Ok(adults));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(StatusCode(500, e.Message));
            }
        }
コード例 #4
0
        public async Task <ActionResult <Adult> > GetAdultAsync([FromRoute] int id)
        {
            try
            {
                Adult adultAsync = await _adultService.GetAdultAsync(id);

                return(Ok(adultAsync));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                throw;
            }
        }
コード例 #5
0
        public async Task <ActionResult <IList <Adult> > > GetAdults()
        {
            try
            {
                IList <Adult> adults = await adultService.GetAdultAsync();

                return(Ok(adults));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(StatusCode(500, e.Message));
            }
        }