PavelAndreyev1337_itransition-course-project/CollectionApp/CollectionApp.WEB/Views/Item/Index.cshtml
@using Microsoft.AspNetCore.Mvc.Localization
@model CollectionApp.DAL.DTO.EntityPageDTO<CollectionApp.DAL.Entities.Item>

@inject IViewLocalizer Localizer

@{
    Layout = "_Layout";
    ViewData["pageNotExist"] = Model.Entities.Count() == 0 && Model.Page.PageNumber == 1;
}

@functions{
    public string CheckBackUrl(string back, string url)
    {
        if (string.IsNullOrEmpty(back))
        {
            return url;
        }
        return back;
    }
}

@if (User.Identity.IsAuthenticated)
{
    <div class="row mt-3">
        <div class="col-12">
            <nav class="mt-2">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item">
                        <a asp-controller="@(CheckBackUrl((string)ViewData["controller"], "Collection"))"
                           asp-action="@(CheckBackUrl((string)ViewData["action"], "Index"))"
                           asp-route-page="@Context.Request.Cookies["collectionPage"]"
                           asp-route-userId="@ViewData["userId"]">
                            @Localizer["Collections"]
                        </a>
                    </li>
                    <li class="breadcrumb-item active">@Localizer["Items"]</li>
                </ol>
            </nav>
        </div>
    </div>
}

@await Html.PartialAsync("../_Items", Model)
@if (!(bool)ViewData["pageNotExist"] && Model.Page.TotalPages > 1)
{
    @await Html.PartialAsync("../_Pagination", Model.Page)
}

<script src="~/js/profile.js"></script>
