turf-tasker/Views/LawnCareEvents/Index.cshtml

78 lines
No EOL
2.6 KiB
Text

@model IEnumerable<turf_tasker.Models.LawnCareEvent>
@{
ViewData["Title"] = "Lawn Care Log";
}
<div class="text-center">
<h1>@ViewData["Title"]</h1>
<p>
<a asp-action="Create" class="btn btn-primary">Create New Event</a>
<a asp-action="Calendar" class="btn btn-info ms-2">View Calendar</a>
</p>
</div>
<!-- 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" class="btn btn-primary">Reset Filter</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>
<div class="d-flex flex-wrap gap-2">
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-sm btn-outline-primary">Edit</a>
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-sm btn-outline-info">Details</a>
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-sm btn-outline-danger">Delete</a>
</div>
</td>
</tr>
}
</tbody>
</table>