76 lines
2.7 KiB
C#
76 lines
2.7 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace BpsRwApp.Controllers
|
|
{
|
|
[Route("[controller]/[action]")]
|
|
public class SliderUtamaController : AppControllerBase
|
|
{
|
|
public IActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult Table()
|
|
{
|
|
var data = Enumerable.Range(1, 3)
|
|
.Select(index =>
|
|
{
|
|
var isPublished = index % 3 != 0;
|
|
var publishToggle = isPublished
|
|
? $"<input type=\"checkbox\" class=\"toggle toggle-success text-primary-500 toggle-publish\" data-id=\"{index}\" checked />"
|
|
: $"<input type=\"checkbox\" class=\"toggle toggle-success toggle-publish\" data-id=\"{index}\" />";
|
|
|
|
return new
|
|
{
|
|
no = index,
|
|
judul = "Pengelolaan Sampah Lingkup Rukun Warga",
|
|
deskripsi = "Program dari Dinas Lingkungan Hidup Provinsi Jakarta yang bertujuan untuk mengoptimalkan pengelolaan sampah di tingkat RW",
|
|
gambar = "/images/hero-bg.png",
|
|
publish = publishToggle,
|
|
aksi = "<div class=\"flex gap-2\">" +
|
|
$"<button class=\"btn bg-white text-primary-500 btn-sm border-primary-500 rounded-full btn-edit\" data-id=\"{index}\">Edit</button>" +
|
|
$"<button class=\"btn bg-white text-gray-800 btn-sm border-gray-800 rounded-full btn-detail\" data-id=\"{index}\">Detail</button>" +
|
|
"</div>",
|
|
};
|
|
})
|
|
.ToArray();
|
|
|
|
var response = new
|
|
{
|
|
data = data
|
|
};
|
|
|
|
return Json(response);
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult Create()
|
|
{
|
|
// create data
|
|
return Json(new { success = true, message = "Slider berhasil ditambahkan" });
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult Update()
|
|
{
|
|
// update data
|
|
return Json(new { success = true, message = "Slider berhasil diupdate" });
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult Delete(int id)
|
|
{
|
|
// delete data
|
|
return Json(new { success = true, message = "Slider berhasil dihapus" });
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult TogglePublish(int id, bool isPublished)
|
|
{
|
|
// publish status
|
|
return Json(new { success = true, message = $"Status publish berhasil diubah menjadi {(isPublished ? "Published" : "Unpublished")}" });
|
|
}
|
|
}
|
|
}
|