using System.Diagnostics;
using System.Net;
using System.Text.RegularExpressions;
using System.Web;
using API.Models;
using Microsoft.AspNetCore.Mvc;

namespace API.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        public IActionResult Index()
        {
            string value = "<p>ø</p>";

            EditorModel model = new EditorModel
            {
                Text = value
            };

            return View(model);
        }

        [HttpPost]
        public IActionResult Index(EditorModel model)
        {
            var value = Uri.UnescapeDataString(model.Text);

            return Ok();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
