VadVergasov_Programming/5/Lab_153503_Verhasau/Lab_153503_Verhasau/Views/Souvenir/Index.cshtml
@model List<Domain.Entities.Souvenir>
@{
    ViewBag.Title = "Каталог";
    var request = ViewContext.HttpContext.Request;
    var returnUrl = request.Path + request.QueryString.ToUriComponent();
    string? category = request.RouteValues["category"]?.ToString();
    string currentCategory = ViewData["currentCategory"] as string ?? "Все";
    var CategoryList = ViewData["allCategories"] as List<Category> ?? new List<Category>();
    int currentPage = ViewData["currentPage"] as int? ?? 1;
    int totalPages = ViewData["totalPages"] as int? ?? 1;
    int prev = currentPage == 0 ? 0 : currentPage - 1,
        next = currentPage == totalPages - 1 ? totalPages - 1 : currentPage + 1;
}
<div class="container row" style="margin: 1rem">
    <div class="col-2 border-2">
        <ul class="nav ">
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle"
                   data-bs-toggle="dropdown"
                   role="button"
                   aria-expanded="false">
                    @currentCategory
                </a>
                <ul class="dropdown-menu">
                    <li>
                        <a class="dropdown-item"
                           asp-controller="souvenir"
                           asp-route-category=@null>Все</a>
                    </li>
                    @foreach (var item in CategoryList)
                    {
                        <li>
                            <a class="dropdown-item"
                               asp-controller="souvenir"
                               asp-route-category="@item.NormalizedName">
                                @item.Name
                            </a>
                        </li>
                    }
                </ul>
            </li>
        </ul>
    </div>
    @{
        await Html.RenderPartialAsync("_SouvenirCardsAndPagerPartial", new
        {
            CurrentPage = currentPage,
            TotalPages = totalPages,
            Souvenirs = Model,
            ReturnUrl = returnUrl,
            InAdminArea = false,
            Category = category,
        });
    }
</div>
