Example #1
0
        public async Task <ActionResult <IEnumerable <Adult> > > GetAdults()
        {
            await dbAction.InsertInit();

            List <Adult> adultList = new List <Adult>();

            for (int x = 0; x < dbAction.getsize(); x++)
            {
                Adult a = dbAction.GetAdultById(x);
                adultList.Add(a);
                Console.WriteLine("Loop: " + x);
            }
            return(adultList);
        }
        public async Task <ActionResult <IEnumerable <Adult> > > GetAdults()
        {
            try
            {
                await dbAction.InsertInit();

                List <Adult> adultList = new List <Adult>();
                for (int x = 0; x < dbAction.getsize(); x++)
                {
                    Adult a = dbAction.GetAdultById(x);
                    adultList.Add(a);
                    int p = x + 1;
                    Console.WriteLine("Loop: " + p);
                }
                return(Ok(JsonSerializer.Serialize(adultList, new JsonSerializerOptions {
                    WriteIndented = true
                })));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(StatusCode(500, e.Message));
            }
        }