@page
@using Models;
@model WebApp.Pages.DeleteAnnouncementModel
@{
    ViewData["Title"] = "Delete announcement";
    Announcement announcement = (Announcement)ViewData["announcement"];
}

@if (announcement == null)
{
    <div class="alert alert-danger" role="alert">
        Unable to find announcement! Do you have permission?
    </div>
    <a type="button" class="btn btn-primary" asp-page="Announcements">Return to all announcements</a>
}
else
{
    <form method="post">
        <h1>Are you sure you want to delete this announcement?</h1>
        <div class="card">
            <div class="card-body">
                <h5 class="card-title">@announcement.Title</h5>
                <h6 class="card-subtitle mb-2 text-body-secondary">@announcement.Author.Name - @announcement.PublishDate</h6>
                <p class="card-text">@Html.Raw(announcement.Description.Replace(Environment.NewLine, "<br />"))</p>
            </div>
        </div>
        <input type="hidden" asp-for="AnnouncementId" value="@announcement.ID" />
        <input type="submit" value="Yes" class="btn btn-danger" />
        <a type="button" class="btn btn-secondary" asp-page="Announcements">No</a>
    </form>
}