bps-rw/Controllers/DataKecamatanController.cs

48 lines
1.7 KiB
C#

using Microsoft.AspNetCore.Mvc;
namespace BpsRwApp.Controllers
{
[Route("[controller]/[action]")]
public class DataKecamatanController : AppControllerBase
{
public IActionResult Index()
{
return View();
}
[HttpGet]
public IActionResult Table()
{
var data = Enumerable.Range(0, 100)
.Select(index =>
{
var wilayah = ControllerSampleData.WilayahSeeds[index % ControllerSampleData.WilayahSeeds.Length];
var jumlahRumahMemilah = 540 + (index * 13 % 320);
var jumlahRumahNasabah = jumlahRumahMemilah + 60 + (index % 9) * 5;
var neracaSampah = jumlahRumahMemilah - 25 + (index % 6) * 4;
var jumlahBankSampah = 45 + (index % 8) * 6;
return new
{
kecamatan = $"{wilayah.Kecamatan}, {wilayah.Kota}",
jumlah_rumah_memilah = jumlahRumahMemilah,
jumlah_rumah_nasabah = jumlahRumahNasabah,
neraca_sampah = neracaSampah,
jumlah_bank_sampah = jumlahBankSampah,
aksi = "<div class=\"flex gap-2\">" +
"<a href=\"#\" class=\"btn btn-ghost btn-square btn-xs\"><span class=\"icon icon-fill text-sm\">more_horiz</span></a>" +
"</div>",
};
})
.ToArray();
var response = new
{
data = data
};
return Json(response);
}
}
}