@model List<ResultTeamDto>
@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/AdminLayout/Index.cshtml";
    int count = 0;
}

<div class="content">
    <div class="container-fluid">
        <h4 class="page-title">Ana Sayfa Ekibimiz İşlemleri</h4>
        <a href="/Team/CreateTeam/" class="btn btn-outline-primary">Yeni Ekle</a>
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-body">
                        <table class="table table-head-bg-success table-striped table-hover">
                            <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Adı Soyadı</th>
                                    <th scope="col">Ünvanı</th>
                                    <th scope="col">Facebook</th>
                                    <th scope="col">Instagram</th>
                                    <th scope="col">Linkedin</th>
                                    <th scope="col">Görsel</th>
                                    <th scope="col">İşlemler</th>
                                </tr>
                            </thead>
                            <tbody>
                                @if (Model == null || !Model.Any())
                                {
                                    <tr>
                                        <td colspan="3">Kayıt bulunamadı.</td>
                                    </tr>
                                }
                                else
                                {
                                    @foreach (var item in Model)
                                    {
                                        count++;
                                        <tr>
                                            <td>@count</td>
                                            <td>@item.NameSurname</td>
                                            <td>@item.Title</td>
                                            <td>@item.Facebook</td>
                                            <td>@item.Instagram</td>
                                            <td>@item.Linkedin</td>
                                            <td>
                                                <img width="75" height="75" src="@item.ImageUrl" alt="Görsel" />
                                            </td>
                                            <td>
                                                <a href="/Team/UpdateTeam/@item.TeamID" class="btn btn-outline-success">Güncelle</a>
                                                <button onclick="showDeleteConfirmation('@item.TeamID')" class="btn btn-outline-danger">Sil</button>
                                            </td>
                                        </tr>
                                    }
                                }
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Delete Confirmation Modal -->
<div class="modal fade" id="deleteConfirmationModal" tabindex="-1" aria-labelledby="deleteConfirmationModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="deleteConfirmationModalLabel">Ekip Üyesi Sil</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                Bu ekip üyesini silmek istediğinize emin misiniz?
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">İptal</button>
                <form id="deleteForm" method="post">
                    @Html.AntiForgeryToken()
                    <button type="submit" class="btn btn-danger">Sil</button>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    document.addEventListener('DOMContentLoaded', function () {
        var deleteModal = new bootstrap.Modal(document.getElementById('deleteConfirmationModal'));
        var deleteForm = document.getElementById('deleteForm');

        // Delete modal açma işlevi
        window.showDeleteConfirmation = function (teamId) {
            deleteForm.action = "/Team/DeleteTeam/" + teamId;
            deleteModal.show();
        };

        // Modal'ın kapanma işlevi için data-bs-dismiss kullanımını kontrol edin
        document.querySelectorAll('[data-bs-dismiss="modal"]').forEach(function (element) {
            element.addEventListener('click', function () {
                deleteModal.hide();
            });
        });
    });
</script>







