-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathBlogPostAdminActions.razor
More file actions
45 lines (40 loc) · 1.63 KB
/
Copy pathBlogPostAdminActions.razor
File metadata and controls
45 lines (40 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@using LinkDotNet.Blog.Domain
@using LinkDotNet.Blog.Infrastructure.Persistence
@using LinkDotNet.Blog.Web.Features.Services.Tags
@using NCronJob
@inject NavigationManager NavigationManager
@inject IToastService ToastService
@inject IRepository<BlogPost> BlogPostRepository
@inject IInstantJobRegistry InstantJobRegistry
@inject ITagQueryService TagQueryService
<AuthorizeView>
<div class="d-flex justify-content-start gap-2">
<a id="edit-blogpost" type="button" class="btn btn-primary d-flex align-items-center gap-2" href="update/@BlogPostId" aria-label="edit">
<i class="pencil"></i>
<div class="vr"></div><span>Edit</span>
</a>
<button id="delete-blogpost" type="button" class="btn btn-danger d-flex align-items-center gap-2" @onclick="ShowConfirmDialog" aria-label="delete">
<i class="bin2"></i>
<div class="vr"></div><span>Delete</span>
</button>
</div>
<ConfirmDialog @ref="ConfirmDialog" Title="Delete Blog Post" Content="Do you want to delete the Blog Post?" OnYesPressed="@DeleteBlogPostAsync">
</ConfirmDialog>
</AuthorizeView>
@code {
[Parameter, EditorRequired]
public required string BlogPostId { get; set; }
private ConfirmDialog ConfirmDialog { get; set; } = default!;
private async Task DeleteBlogPostAsync()
{
await BlogPostRepository.DeleteAsync(BlogPostId);
await TagQueryService.ClearTagCacheAsync();
InstantJobRegistry.RunInstantJob<SimilarBlogPostJob>(true);
ToastService.ShowSuccess("The Blog Post was successfully deleted");
NavigationManager.NavigateTo("/");
}
private void ShowConfirmDialog()
{
ConfirmDialog.Open();
}
}