@page "/admin/blog-posts" @using System.Diagnostics @using Microsoft.AspNetCore.Mvc.TagHelpers @using OliverBooth.Common.Data @using OliverBooth.Common.Data.Blog @using OliverBooth.Common.Data.Web.Users @using OliverBooth.Common.Services @model OliverBooth.Pages.Admin.BlogPosts @inject IBlogPostService BlogPostService @inject IUserService UserService @inject ISessionService SessionService @{ ViewData["Title"] = "Blog Posts"; Layout = "Shared/_AdminLayout"; HttpRequest request = HttpContext.Request; SessionService.TryGetSession(request, out ISession? session); IUser? user = null; if (session is not null) { UserService.TryGetUser(session.UserId, out user); } Debug.Assert(user is not null); }
Total Blog Posts
@BlogPostService.GetBlogPostCount()
@foreach (IBlogPost post in BlogPostService.GetAllBlogPosts(visibility: (BlogPostVisibility)(-1))) { if (post.Visibility != BlogPostVisibility.Published && post.Author.Id != user.Id && !user.HasPermission(Permission.Administrator)) { continue; } string icon = post.Visibility switch { BlogPostVisibility.Private => "key text-danger", BlogPostVisibility.Unlisted => "unlock text-warning", BlogPostVisibility.Published => "circle-check text-success" }; }
Title Posted Author Options
@post.Title @post.Published @post.Author.DisplayName