Загрузка данных


@model IEnumerable<AutoServiceApp.Models.ServiceRequest>

@{
    ViewData["Title"] = "Заявки на обслуживание";
}

<div class="container mt-4">
    <h1>@ViewData["Title"]</h1>
    
    <p>
        <a asp-action="Create" class="btn btn-primary">Создать новую заявку</a>
    </p>

    <table class="table table-striped">
        <thead>
            <tr>
                <th>@Html.DisplayNameFor(model => model.RequestNumber)</th>
                <th>@Html.DisplayNameFor(model => model.CreatedAt)</th>
                <th>ТС</th>
                <th>@Html.DisplayNameFor(model => model.Status)</th>
                <th>@Html.DisplayNameFor(model => model.EstimatedCost)</th>
                <th>Действия</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>@Html.DisplayFor(modelItem => item.RequestNumber)</td>
                    <td>@item.CreatedAt.ToString("dd.MM.yyyy")</td>
                    <td>
                        @if (item.Vehicle != null)
                        {
                            <text>@item.Vehicle.Brand @item.Vehicle.Model</text>
                        }
                    </td>
                    <td>@Html.DisplayFor(modelItem => item.Status)</td>
                    <td>@Html.DisplayFor(modelItem => item.EstimatedCost)</td>
                    <td>
                        <a asp-action="Edit" asp-route-id="@item.Id">Изменить</a> |
                        <a asp-action="Details" asp-route-id="@item.Id">Подробнее</a> |
                        <a asp-action="Delete" asp-route-id="@item.Id">Удалить</a>
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>