Clear        


                
                    @model IEnumerable<ProductModel>

@* Generated from Custom Template. *@
@* Model namespace using directive should be added to _ViewImports.cshtml. *@

@{
    var containerDivClass = "container-fluid";
}
@{
    ViewData["Title"] = "Product List";
}

<div class="@containerDivClass">
    <h3>@ViewData["Title"]</h3>
    <hr />
</div>

@if (Model is not null)
{
    <form asp-action="Index" autocomplete="off">
        <div class="@containerDivClass">
            <div class="row">
                <div class="col-12 text-danger">
                    @TempData["Message"]
                </div>
            </div>
            <div class="row mb-3">
                <div class="col-10 text-success">
                    <partial name="_PageModel" model="ViewBag.PageModel" />
                </div>
                <div class="col-2 text-end">
                    @if (User.IsInRole("Admin"))
                    {
                        <a asp-action="Create">Create</a>
                    }
                </div>
            </div>
            <table class="table table-striped table-hover">
                <thead class="table-secondary">
                    <tr>
                        <th>
                            @Html.DisplayNameFor(model => model.Name)
                        </th>
                        <th>
                            @Html.DisplayNameFor(model => model.UnitPrice)
                        </th>
                        <th>
                            @Html.DisplayNameFor(model => model.StockAmount)
                        </th>
                        <th>
                            @Html.DisplayNameFor(model => model.ExpirationDate)
                        </th>
                        <th>
                            @Html.DisplayNameFor(model => model.Category)
                        </th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
		            @foreach (var item in Model) {
				        <tr>
					        <td>
						        @Html.DisplayFor(modelItem => item.Name)
					        </td>
					        <td>
						        @Html.DisplayFor(modelItem => item.UnitPrice)
					        </td>
					        <td>
						        @Html.Raw(item.StockAmount)
					        </td>
					        <td>
						        @Html.DisplayFor(modelItem => item.ExpirationDate)
					        </td>
					        <td>
						        @Html.DisplayFor(modelItem => item.Category)
					        </td>
					        <td class="text-end w-25">
                                @if (User.Identity.IsAuthenticated)
                                {
                                    <a asp-action="Add" asp-controller="Cart" asp-route-productId="@item.Record.Id">Add to Cart</a>
                                    @:&nbsp;|&nbsp;
                                    <a asp-action="Details" asp-route-id="@item.Record.Id">Details</a>
                                    @if (User.IsInRole("Admin"))
                                    {
                                        <text>&nbsp;|&nbsp;</text>
                                        <a asp-action="Edit" asp-route-id="@item.Record.Id">Edit</a>
                                        @:&nbsp;|&nbsp;
                                        <a asp-action="Delete" asp-route-id="@item.Record.Id">Delete</a>
                                    }
                                }
					        </td>
				        </tr>
		            }
                </tbody>
            </table>
        </div>
    </form>
}