Clear        


                
                    @model IEnumerable<CartItemGroupByModel>

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

@{
    var containerDivClass = "container";
}
@{
    ViewData["Title"] = "Cart";
}

<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">
                    @if (Model.Count() == 1)
                    {
                        @("No cart items found.")
                    }
                </div>
                <div class="col-2 text-end">
                    @if (Model.Count() > 1)
                    {
                        <a asp-action="Clear">Clear Cart</a>
                    }
                </div>
            </div>
            @if (Model.Count() > 1)
            {
                <table class="table table-striped table-hover">
                    <thead class="table-secondary">
                        <tr>
                            <th>
                                @Html.DisplayNameFor(model => model.ProductName)
                            </th>
                            <th>
                                @Html.DisplayNameFor(model => model.ProductCount)
                            </th>
                            <th>
                                @Html.DisplayNameFor(model => model.ProductUnitPrice)
                            </th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            @if (item.IsTotal)
                            {
                                <tr class="table-dark">
                                    <td>@item.ProductName</td>
                                    <td>@item.TotalProductCount</td>
                                    <td>@item.TotalProductUnitPrice</td>
                                    <td></td>
                                </tr>
                            }
                            else
                            {
                                <tr>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.ProductName)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.ProductCount)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.ProductUnitPrice)
                                    </td>
                                    <td class="text-end w-25">
                                        <a asp-action="Remove" asp-route-productId="@item.ProductId">Remove from Cart</a>
                                    </td>
                                </tr>
                            }
                        }
                    </tbody>
                </table>
            }
        </div>
    </form>
}