Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.6 kB
3
Indexable
Never
@model List<EntityLayer.Entities.Category>
@{
    ViewBag.Title = "Index";
}

<a class="btn btn-primary" href="/AdminCategory/Create">Kategori Ekle</a>
<br />
<br />
<table class="table table-bordered" id="table">
    <tr>
        <th>Ad</th>
        <th>Açıklama</th>
        <th>Sil</th>
        <th>Güncelle</th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>@item.Name</td>
            <td>@item.Description</td>
            @*  <td> <a class="btn btn-danger btnSil" data-id="@item.Id" onclick="confirmDelete(this)"> Sil </a> </td>*@
            <td> <a class="btn btn-danger btnSil" data-id="@item.Id">Sil </a>
            <td>
            <td><a class="btn btn-primary" href="/AdminCategory/Update/@item.Id">Güncelle</a></td>
        </tr>
    }
</table>

<script src="~/Scripts/jquery-1.8.3.min.js"></script>

<script type="text/javascript">
    $(function () {
        $("#table").on("click", ".btnSil", function () {

            var btn = $(this);
            bootbox.confirm("Silmek istediğinize emin misiniz?", function (result) {

                if (result) {
                    var id = btn.data("id");
                    $.ajax({
                        type: "GET",
                        URL: "AdminCategory/Delete/" + id,
                        succes: function () {
                            btn.parent().parent().remove();
                        }
                    });
                } else {
                    bootbox.confirm("Hata oluştu");
                }

            })

        });
    });
</script>