using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using WebApplication2.Models;
using WebApplication2.Models.ViewModels;

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

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

        public IActionResult Index()
        {
            var berita = GetData();

            ViewBag.MainNews = berita.FirstOrDefault();
            ViewBag.SideNews = berita.Skip(1).Take(4).ToList();

            return View();
        }

        [HttpGet("/faq")]
        public IActionResult Faq()
        {
            return View("~/Views/Faq.cshtml");
        }

        [HttpGet("/kontak")]
        public IActionResult Kontak()
        {
            return View("~/Views/Kontak.cshtml");
        }

        [HttpGet("/sertifikat")]
        public IActionResult Sertifikat()
        {
            return View("~/Views/Sertifikat.cshtml");
        }

        [HttpGet("/tentang-kami")]
        public IActionResult TentangKami()
        {
            return View("~/Views/TentangKami.cshtml");
        }

        [HttpGet("/ulasan")]
        public IActionResult Ulasan()
        {
            return View("~/Views/FormReview.cshtml");
        }

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

        private List<BeritaViewModel> GetData()
        {
            return new List<BeritaViewModel>()
            {
                new BeritaViewModel {
                    Judul = "Komitmen LLHD Terhadap Pemenuhan Permen LHK NO.23 TAHUN 2020",
                    Deskripsi = "Komitmen Laboratorium Lingkungan Hidup Daerah (LLHD) Provinsi DKI Jakarta...",
                    Gambar = "/assets/image/foto/Berita komitmen llhd.png",
                    Tanggal = new DateTime(2025,3,4),
                    Slug = "berita-1"
                },
                new BeritaViewModel {
                    Judul = "Lorem Ipsum Judul",
                    Deskripsi = "Isi berita...",
                    Gambar = "/assets/image/foto/1.jpeg",
                    Tanggal = new DateTime(2025,3,4),
                    Slug = "berita-2"
                },
                new BeritaViewModel {
                    Judul = "Lorem Ipsum Judul",
                    Deskripsi = "Isi berita...",
                    Gambar = "/assets/image/foto/2.jpeg",
                    Tanggal = new DateTime(2025,3,4),
                    Slug = "berita-3"
                },
                new BeritaViewModel {
                    Judul = "Lorem Ipsum Judul",
                    Deskripsi = "Isi berita...",
                    Gambar = "/assets/image/foto/3.jpeg",
                    Tanggal = new DateTime(2025,3,4),
                    Slug = "berita-4"
                },
                new BeritaViewModel {
                    Judul = "Lorem Ipsum Judul",
                    Deskripsi = "Isi berita...",
                    Gambar = "/assets/image/foto/4.jpeg",
                    Tanggal = new DateTime(2025,3,4),
                    Slug = "berita-5"
                }
            };
        }

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