@page @using Models; @using System.Globalization @using System.Security.Claims; @model WebApp.Pages.AnnouncementModel @{ Announcement announcement = (Announcement)ViewData["announcement"]; ViewData["Title"] = $"{announcement.Title}"; }

@announcement.Title

Published @announcement.PublishDate.ToString("g") by @announcement.Author.Name @Html.Raw((announcement.Author.Role == UserRole.ADMIN || announcement.Author.Role == UserRole.MANAGER) ? $"({CultureInfo.CurrentCulture.TextInfo.ToTitleCase(announcement.Author.Role.ToString().ToLower())})" : "") @(announcement.IsSticky ? "Pinned" : "")

@if (User.FindFirst(ClaimTypes.Role).Value == "ADMIN" || User.Identity.Name == announcement.Author.Name) { Edit Delete }


@Html.Raw(announcement.Description.Replace(Environment.NewLine, "
"))


Comments

@if (announcement.Comments.Count() == 0) {

No comments found

} else { foreach (Comment comment in announcement.Comments) { DisplayComment(comment, 0); } } @{ void DisplayComment(Comment comment, int level) {
@for (int i = 0; i < level; i++) { }
@comment.Author.Name @Html.Raw((comment.Author.Role == UserRole.ADMIN || comment.Author.Role == UserRole.MANAGER) ? $"({CultureInfo.CurrentCulture.TextInfo.ToTitleCase(comment.Author.Role.ToString().ToLower())})" : "")
@comment.PublishDate.ToString("g")

@Html.Raw(comment.Description.Replace(Environment.NewLine, "
"))

Like Dislike Reply
@if (comment.Responses.Count != 0) { foreach (var response in comment.Responses) { DisplayComment(response, level + 1); } }
} }