using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using System.Diagnostics;
using temp_lwp.Models;

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

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

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

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

        public IActionResult OnGet()
        {
            List<Familia> familias = new List<Familia>()
            {
                new Familia() { Id = 1, Name = "fam1" },
                new Familia() { Id = 2, Name = "fam2" },
                new Familia() { Id = 3, Name = "fam3" },
            };

            var selectList = familias.Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(),
                Text = c.Name
            });

            ViewBag.Familias = selectList;

            return View();
        }

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