diff --git a/modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/PostsController.cs b/modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/PostsController.cs
new file mode 100644
index 0000000000..55a96f6ccc
--- /dev/null
+++ b/modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/PostsController.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Volo.Abp.AspNetCore.Mvc;
+using Volo.Blogging.Posts;
+
+namespace Volo.Blogging.Areas.Blog.Controllers
+{
+ [Area("Blog")]
+ [Route("Blog/[controller]/[action]")]
+ public class PostsController : AbpController
+ {
+ private readonly IPostAppService _postAppService;
+
+ public PostsController(IPostAppService postAppService)
+ {
+ _postAppService = postAppService;
+ }
+
+ [HttpPost]
+ public async Task Delete(Guid id)
+ {
+ await _postAppService.DeleteAsync(id);
+ }
+ }
+}
diff --git a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json
index e1821cab21..2fdf8b127c 100644
--- a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json
+++ b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json
@@ -23,6 +23,7 @@
"Posts": "Posts",
"Edit": "Edit",
"CommentDeletionWarningMessage": "Comment will be deleted.",
+ "PostDeletionWarningMessage": "Post will be deleted.",
"BlogDeletionWarningMessage": "Blog will be deleted.",
"AreYouSure": "Are you sure?",
"Comment": "{0} Comment",
diff --git a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json
index 8680bb9fa4..5eeb05f327 100644
--- a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json
+++ b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json
@@ -24,6 +24,7 @@
"Posts": "Yazılar",
"Edit": "Düzenle",
"CommentDeletionWarningMessage": "Yorum silinecek.",
+ "PostDeletionWarningMessage": "Yazı silinecek.",
"BlogDeletionWarningMessage": "Blog silinecek.",
"AreYouSure": "Emin misiniz?",
"CommentWithCount": "{0} Yorum",
diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml
index 05c5c611b1..1f1f521d10 100644
--- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml
+++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml
@@ -47,15 +47,6 @@
@L["CommentWithCount", @Model.CommentCount]
-
-
- @if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Update) || (CurrentUser.Id == Model.Post.CreatorId))
- {
- |
-
- @L["Edit"]
-
- }
@@ -114,8 +105,6 @@
@L["CommentWithCount", @Model.CommentCount]
-
-
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Update))
{
|
@@ -123,6 +112,13 @@
@L["Edit"]
}
+ @if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Delete) || (CurrentUser.Id == Model.Post.CreatorId))
+ {
+ |
+
+ @L["Delete"]
+
+ }
diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs
index 733afd3d4f..6f76fc4342 100644
--- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs
+++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs
@@ -60,14 +60,7 @@ namespace Volo.Blogging.Pages.Blog.Posts
await GetData();
}
-
- public async Task OnDeleteAsync(Guid commentId)
- {
- await _commentAppService.DeleteAsync(commentId);
-
- await GetData();
- }
-
+
private async Task GetData()
{
Blog = await _blogAppService.GetByShortNameAsync(BlogShortName);
diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js
index 6e316781a7..3775ed6697 100644
--- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js
+++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js
@@ -69,6 +69,35 @@
}
});
+ $('#DeletePostLink').click(function (event) {
+ event.preventDefault();
+ var linkElement = $(this);
+ var deleteCommentId = linkElement.attr('data-postid');
+ var blogShortName = linkElement.attr('data-blogShortName');
+
+ if (deleteCommentId != '' && deleteCommentId !== undefined) {
+ abp.message.confirm(
+ l('PostDeletionWarningMessage'), // TODO: localize
+ l('AreYouSure'),
+ function(isConfirmed) {
+ if (isConfirmed) {
+ $.ajax({
+ type: "POST",
+ url: "/Blog/Posts/Delete",
+ data: { id: deleteCommentId },
+ success: function (response) {
+ window.location.replace('/Blog/' + blogShortName);
+ }
+ });
+ }
+ }
+ );
+ }
+ });
+ $('#DeletePostRouteLink').click(function (event) {
+ console.log("goooo");
+ });
+
$('.updateLink').click(function (event) {
event.preventDefault();
$('div .replyForm').hide();