using Microsoft.AspNetCore.Mvc;
using kehati.Database;
using kehati.Models.View;
using Microsoft.EntityFrameworkCore;

namespace kehati.Controllers
{
    public class MapController : Controller
    {
        private readonly ApplicationDbContext db;

        public MapController(ApplicationDbContext context)
        {
            db = context;
        }
        public async Task<IActionResult> Index()
        {
            ViewBag.lokasiHome = await db.Lokasi
                        .Where(x => x.Lat != null)
                        .Include(x => x.LokasiFauna)
                        .Include(x => x.LokasiTumbuhan)
                        .OrderByDescending(l => l.MsLokasiId)
                        .ToListAsync();
            return View();
        }

        public IActionResult Detail(string slug)
        {
            ViewBag.Slug = slug;
            return View();
        }
    }
}