@{
    var currentUser = UserManager.FindByNameAsync(User.Identity.Name);
    ViewData["Title"] = "Blog";
}

@model BlogViewModel

<div id="banner-area">
    <img src="~/images/banner/banner2.jpg" alt="" />
    <div class="parallax-overlay"></div>
    <div class="banner-title-content">
        <div class="text-center">
            <h2>Blog Page</h2>
            <ul class="breadcrumb">
                <li>Home</li>
                <li><a asp-area="" asp-controller="Blog" asp-action="Index"> Blog</a></li>
                @if (SignInManager.IsSignedIn(User) && currentUser.Result.IsBlocked == false)
                {
                    @if (User.IsInRole(Roles.Administrator.ToString()) || User.IsInRole(Roles.Author.ToString()) || User.IsInRole(Roles.Contributor.ToString()) || User.IsInRole(Roles.Editor.ToString()))
                    {
                        <li>
                            <a asp-area="" asp-controller="Blog" asp-action="CreatePost" class="btn btn-primary solid square">
                                Create Post
                            </a>
                        </li>
                    }
                }
            </ul>
        </div>
    </div>
</div>
<section id="main-container">
    <div class="container">
        <partial name="_TempDataPartial" />
        <div class="row">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                @foreach (var post in Model.Posts)
                {
                    @await Html.PartialAsync("_BlogPostPartial", post)
                }
                <div class="row" style="text-align: center">
                    @Html.PagedListPager((IPagedList)Model.Posts,
                            page => Url.Action("Index", "Blog",
                    new { page = page, serch = Model.Search }),
                    PagedListRenderOptions.OnlyShowFivePagesAtATime)
                </div>
            </div>
            @await Component.InvokeAsync("Blog", new { Model.Search })
        </div>
    </div>
</section>