@using Shared.DTOs
@inject HttpClient _hc
@layout BlogLayout
@page "/ListBlog"
@inject NavigationManager Navigation
<PageTitle>دانشنامه</PageTitle>
<main>

    <!-- breadcrumb-area-start -->
    <div class="breadcrumb__area breadcrumb-height p-relative blue-bg-2">
        <div class="breadcrumb__shape-1">
            <img src="img/breadcrumb/breadcrumb-shape-1.png" alt="">
        </div>
        <div class="breadcrumb__shape-2">
            <img src="img/breadcrumb/breadcrumb-shape-2.png" alt="">
        </div>
        <div class="container">
            <div class="row">
                <div class="col-xl-9 col-lg-7">
                    <div class="breadcrumb__content">
                        <h3 class="breadcrumb__title ">دانشـــــنامه</h3>
                        <div class="breadcrumb__list wow tpfadeUp" data-wow-duration=".9s" data-wow-delay=".4s" style="visibility: visible; animation-duration: 0.9s; animation-delay: 0.4s; animation-name: tpfadeUp;">
                            <span class="child-one"><a href="#">خانه</a></span>
                            <span class="dvdr"><i class="fal fa-angle-left"></i></span>
                            <span>وبلاگ</span>
                        </div>
                    </div>
                </div>
                <div class="col-xl-3 col-lg-5 col-lg-4 text-center text-md-end">
                    <div class="breadcrumb__img p-relative text-start z-index">
                        <img class="z-index-3" src="img/breadcrumb/breadcrumb-3.png" alt="">
                        <div class="breadcrumb__sub-img wow tpfadeUp" data-wow-duration=".9s" data-wow-delay=".4s" style="visibility: visible; animation-duration: 0.9s; animation-delay: 0.4s; animation-name: tpfadeUp;">
                            <img src="img/breadcrumb/breadcrumb-sub-1.png" alt="">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- breadcrumb-area-end -->
    <!-- blog-grid-area-start -->
    <div class="blog-grid-area pt-100 pb-100">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="blog-grid-arrow p-relative">
                  
                     
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- blog-grid-area-end -->
    <!--Portfolio Start-->
    <div class="portfolio blog-grid-inner mb-80">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-lg-8">
                    <div class="tp-about__section-box text-center mb-40">
                        <h3 class="tp-section-title">بیشتر بدانیم</h3>
                    </div>
                </div>
            </div>
            <div class="row">
                @for (int i = 0; i < request?.list.Count; i++)
            {
                    <ItemBlog Item="request.list[i]" />
            }
            </div>
          
            <nav aria-label="Page navigation">
                <br />
                <ul class="pagination justify-content-center">
                    @for (int page = 1; page <= request?.PageCount; page++)
                    {
                        if (page == PageIndex)
                        {
                            <li class="page-item disabled">
                                <a class="page-link" href="@Navigation.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
                            </li>
                        }
                        else
                        {
                            <li class="page-item">
                                <a class="page-link" href="@Navigation.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
                            </li>
                        }
                    }
                   
                </ul>
            </nav>
        </div>
    </div>
    <!--Portfolio End-->


</main>

@code {
    [Parameter,SupplyParameterFromQuery]
    public int? PageIndex { get; set; }

    public Shared.DTOs.PagingDto<BlogDto>? request { get; set; }

    protected override async Task OnParametersSetAsync()
    {
        if (PageIndex == null) PageIndex = 1;
        request = await _hc.GetFromJsonAsync<PagingDto<BlogDto>>($"Base/LastBlog?PageIndex={PageIndex ?? 1}&PageSize=6");
        await base.OnParametersSetAsync();
    }
 
}
