38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using System.Diagnostics;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using kehati.Models.View;
|
|
using kehati.Database;
|
|
using kehati.Helpers;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace kehati.Controllers
|
|
{
|
|
public class LokasiController : Controller
|
|
{
|
|
private readonly ApplicationDbContext db;
|
|
public LokasiController(ApplicationDbContext context)
|
|
{
|
|
db = context;
|
|
}
|
|
public async Task<IActionResult> Index(int page = 1)
|
|
{
|
|
ViewBag.lokasiHome = await Pagination.PaginateAsync(
|
|
db.Lokasi
|
|
.Include(x => x.LokasiFauna)
|
|
.Include(x => x.LokasiTumbuhan)
|
|
.OrderByDescending(l => l.MsLokasiId),
|
|
page,12);
|
|
return View();
|
|
}
|
|
|
|
public async Task<IActionResult> Detail(string slug)
|
|
{
|
|
var decode = Custom.DecodeInt(slug);
|
|
ViewBag.data = await db.Lokasi.FirstOrDefaultAsync(x => x.MsLokasiId == decode);
|
|
ViewBag.lokasiTumbuhan = await db.LokasiTumbuhan.Include(x => x.Tumbuhan).Where(x => x.MsLokasiId == decode).ToListAsync();
|
|
ViewBag.lokasiFauna = await db.LokasiFauna.Include(x => x.Fauna).Where(x => x.MsLokasiId == decode).ToListAsync();
|
|
return View();
|
|
}
|
|
}
|
|
} |