@model ThAmCo.Products.Models.ViewModels.ProductsIndexModel

@{
    ViewData["Title"] = "Index";
}

<h1>Index</h1>

<form asp-action="Index" method="get">
    <div class="form-group">
        <label>Name</label>
        <input type="text" class="form-control" asp-for="Name" />
    </div>
    <div class="form-group">
        <label>Description</label>
        <input type="text" class="form-control" asp-for="Description" />
    </div>
    <div class="form-group">
        <label>Brand</label>
        <select asp-for="BrandId" class="form-control" asp-items="ViewBag.BrandList"></select>
    </div>
    <div class="form-group">
        <label>Category</label>
        <select asp-for="CategoryId" class="form-control" asp-items="ViewBag.CategoryList"></select>
    </div>
    <div class="form-group">
        <label>Lowest Price</label>
        <input type="number" min="0" step="0.01" asp-for="PriceLow" class="form-control" />
    </div>
    <div class="form-group">
        <label>Highest Price</label>
        <input type="number" min="0" step="0.01" asp-for="PriceHigh" class="form-control" />
    </div>
    <div class="form-group">
        <input type="submit" value="Search" class="btn btn-default" />
    </div>
</form>

<table class="table">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Products.FirstOrDefault().Product.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Products.FirstOrDefault().Product.Description)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Products.FirstOrDefault().Price)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Products.FirstOrDefault().Stock)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Products.FirstOrDefault().Product.Brand)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Products.FirstOrDefault().Product.Category)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
@foreach (var item in Model.Products) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Product.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Product.Description)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Price)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Stock)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Product.Brand.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Product.Category.Name)
            </td>
            <td>
                <a asp-action="Details" asp-route-id="@item.Product.Id">View</a>
            </td>
        </tr>
}
    </tbody>
</table>
