@model IEnumerable<Web.ViewModel.NewsLetterVM.NewsLetterViewModel>

@{
    ViewData["Title"] = "Newsletter list";
}

<div class="container mt-5">

    <partial name="_Notification" />

    <div class="card bg-default mb-3 ">
        <div class="card-header">Subscribers</div>
        <div class="card-body">
            <h4 class="card-title">Subscribers list</h4>
            <div class="alert alert-info" role="alert">
              
                Total Subscribed Users: <strong>@ViewBag.TotalSubscribedUsers</strong>
            </div>
            <p>
               
                <a asp-action="Create" class="btn btn-primary @(@ViewBag.TotalSubscribedUsers <= 0 ? "disabled" : "")">compose newsletter</a>
            </p>

            <table class="table table-responsive w-100 d-block d-md-table ">
                <thead>
                    <tr>
                        <th scope="col">Id</th>
                        <th scope="col">Name</th>
                        <th scope="col">Email</th>
                        <th scope="col">IsSubscribed</th>
                        <th scope="col" class="d-flex justify-content-end">Action</th>
                    </tr>
                </thead>
                <tbody class="justify-content-center">
                    @foreach (var item in Model)
                    {
                        <tr class=" table-secondary">

                            <td>@item.Id</td>
                            <td>@item.Name</td>
                            <td>@item.Email</td>
                            <td>
                                @if(item.IsSubscribed==true)
                                {
                                    <span class="badge badge-success p-1">Subscribed @Html.DisplayFor(modelItem => item.IsSubscribed)</span>
                                }
                                else
                                {
                                    <span class="badge badge-secondary p-1">Not subscribed @Html.DisplayFor(modelItem => item.IsSubscribed)</span>
                                }

                                </td>
                            <td class="d-flex justify-content-end">
                                <a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger btn-m"><i class="bi bi-trash"></i> Delete</a>
                              
                            </td>
                        </tr>
                    }

                </tbody>
            </table>

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

