using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using isnd.Data;
using System.Linq;
using isnd.ViewModels;
using Unleash;

namespace isnd.Controllers
{
    public class HomeController : Controller
    {
        private readonly ApplicationDbContext _dbContext;
        private readonly IUnleash _unleashĈlient;

        public HomeController(
            ApplicationDbContext dbContext,
            IUnleash unleashĈlient)
        {
            _dbContext = dbContext;
            _unleashĈlient = unleashĈlient;
        }
        
        public IActionResult Index()
        {
            return View(new HomeIndexViewModel{
                PkgCount = _dbContext.Packages.Count(),
                UnleashClient = _unleashĈlient
                });
        }

        public IActionResult About()
        {
            ViewData["Message"] = "Your application description page.";

            return View();
        }

        public IActionResult Contact()
        {
            ViewData["Message"] = "Your contact page.";

            return View();
        }

        public IActionResult Privacy()
        {
            ViewData["Message"] = "Your Privacy page.";

            return View(ViewData);
        }

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