using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using OnlyOneAccessTemplate.Services;
using OnlyOneAccessTemplate.Models;

namespace OnlyOneAccessTemplate.Controllers
{
    public class HomeController : BaseController
    {
        public HomeController(
            ISiteConfigurationService siteConfig,
            ILanguageService languageService,
            ISeoService seoService,
            IMemoryCache cache,
            IConfiguration configuration)
            : base(siteConfig, languageService, seoService, cache, configuration)
        {
        }

        [Route("")]
        [Route("pt")]
        public IActionResult Index()
        {
            var language = GetCurrentLanguage();
            var siteConfig = _siteConfig.GetConfiguration(language);
            
            ViewBag.PageTitle = siteConfig.SiteTitle;
            ViewBag.PageDescription = siteConfig.SiteDescription;
            ViewBag.CurrentPage = "home";

            return View(siteConfig);
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View();
        }

    }
}