using Microsoft.AspNetCore.Mvc;
using PhilExampleCrawler.Common.Models;
using PhilExampleCrawler.DataBase;
using PhilExampleCrawler.DataBase.Models;

namespace WebAPI.Controllers
{
    [ApiController]
    [Route("[controller]/[action]")]
    public class ExamplePageController : ControllerBase
    {
        private readonly ILogger<UserController> _logger;
        private readonly HttpClient _httpClient;


        public ExamplePageController(ILogger<UserController> logger,
                             IHttpClientFactory httpClientFactory)
        {
            _logger = logger;
            _httpClient = httpClientFactory.CreateClient();
        }


        [HttpGet]
        public async Task<IEnumerable<Category>> GetCategoriesAsync()
        {
            var cats = await PhilExampleCrawler.Core.ExamplePageValueCrawler.CrawlExamplePageCategories(_httpClient);
            return cats;
        }

        [HttpGet]
        public IEnumerable<Category> GetRadii()
        {
            var radii = new List<Category>()
            {
                new Category("Unbegrenzt", 0),
                new Category("+ 5 km", 5),
                new Category("+ 10 km", 10),
                new Category("+ 50 km", 50),
                new Category("+ 100 km", 100),
                new Category("+ 500 km", 500),
                new Category("+ 1000 km", 1000),
            };

            return radii;
        }
    }
}