@page
@model Catalog26.Pages.TDSynnex.IndexModel

@{
    ViewData["Title"] = "TDSynnex Pricing and Availability";
}

<h2>TDSynnex Pricing and Availability</h2>

<p>
    <a asp-page="Create">Create New</a>
</p>

<form asp-page="./Index" method="get">
    <div class="form-actions no-color">
        <p>
            Search Field:
            <select name="filterBy">
                <option value="mfgpartno" selected="@(Model.FilterBy == "mfgpartno")">MfgPartNo</option>
                <option value="vendorpartno" selected="@(Model.FilterBy == "vendorpartno")">VendorPartNo</option>
                <option value="mfgname" selected="@(Model.FilterBy == "mfgname")">MfgName</option>
                <option value="description" selected="@(Model.FilterBy == "description")">Product Description</option>
            </select>
            Search String:
            <input type="text" name="searchString" value="@Model.CurrentFilter" />
            <input type="submit" value="Search" class="btn btn-primary" />
            <a asp-page="./Index">Back to full list</a>
        </p>
    </div>
</form>

<table class="table">
    <thead>
        <tr>
            @*
            <th>
                <a asp-page="./Index" asp-route-sortOrder="@Model.MfgPartNoSort"
                   asp-route-currentFilter="@Model.CurrentFilter">
                    @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].MfgPartNo)
                </a>
            </th>
            <th>
                <a asp-page="./Index" asp-route-sortOrder="@Model.VendorPartNoSort"
                   asp-route-currentFilter="@Model.CurrentFilter">
                    @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].VendorPartNo)
                </a>
            </th>
            *@
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].MfgPartNo)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].VendorPartNo)
            </th>
            <th>
                Action
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].PartDescription)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].MfgName)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].TotalQtyOnHand)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].ContractPrice)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].MSRP)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].UnitCost)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].VendorCategoryCode)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].UNSPSCCode)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].SKUCreatedDate)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].PromoFlag)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].PromoComment)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.TDSPriceAvailability[0].PromoExpDate)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model.TDSPriceAvailability)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.MfgPartNo)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.VendorPartNo)
                </td>
                <td>
                    <a asp-page="./Details" asp-route-id="@item.Id">View</a> |
                    <a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
                    <a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.PartDescription)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.MfgName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.TotalQtyOnHand)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.ContractPrice)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.MSRP)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.UnitCost)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.VendorCategoryCode)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.UNSPSCCode)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.SKUCreatedDate)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.PromoFlag)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.PromoComment)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.PromoExpDate)
                </td>
            </tr>
        }
    </tbody>
</table>

@{
    var prevDisabled = !Model.TDSPriceAvailability.HasPreviousPage ? "disabled" : "";
    var nextDisabled = !Model.TDSPriceAvailability.HasNextPage ? "disabled" : "";
}

<a asp-page="./Index"
   asp-route-pageIndex="@(Model.TDSPriceAvailability.PageIndex - 1)"
   asp-route-currentFilter="@Model.CurrentFilter"
   asp-route-filterBy="@Model.FilterBy"
   class="btn btn-primary @prevDisabled">
    Previous
</a>
<a asp-page="./Index"
   asp-route-pageIndex="@(Model.TDSPriceAvailability.PageIndex + 1)"
   asp-route-currentFilter="@Model.CurrentFilter"
   asp-route-filterBy="@Model.FilterBy"
   class="btn btn-primary @nextDisabled">
    Next
</a>
