@model IEnumerable<turf_tasker.Models.LawnCareEvent>

@{
    ViewData["Title"] = "Lawn Care Log";
}

<h1>@ViewData["Title"]</h1>

<p>
    <a asp-action="Create" class="btn btn-primary">Create New Event</a>
</p>

<!-- Add the search form -->
<form asp-action="Index" method="get">
    <div class="form-actions no-color">
        <p>
            Find by type or note: 
            <input type="text" name="searchString" value="@ViewData["CurrentFilter"]" />
            <input type="submit" value="Search" class="btn btn-secondary" /> |
            <a asp-action="Index">Back to Full List</a>
        </p>
    </div>
</form>


<table class="table">
    <thead>
        <tr>
            <th>
                <!-- Make the header a clickable link for sorting -->
                <a asp-action="Index" asp-route-sortOrder="@ViewData["TypeSortParm"]" asp-route-searchString="@ViewData["CurrentFilter"]">
                    @Html.DisplayNameFor(model => model.EventType)
                </a>
            </th>
            <th>
                <!-- Make the header a clickable link for sorting -->
                <a asp-action="Index" asp-route-sortOrder="@ViewData["DateSortParm"]" asp-route-searchString="@ViewData["CurrentFilter"]">
                    @Html.DisplayNameFor(model => model.EventDate)
                </a>
            </th>
            <th>
                @Html.DisplayNameFor(model => model.MowingPattern)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Notes)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
@foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.EventType)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.EventDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.MowingPattern)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Notes)
            </td>
            <td>
                <a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
                <a asp-action="Details" asp-route-id="@item.Id">Details</a> |
                <a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
            </td>
        </tr>
}
    </tbody>
</table>