Browse Source

Blogging Module Post Delete

pull/441/head
Yunus Emre Kalkan 8 years ago
parent
commit
25944aed71
  1. 26
      modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/PostsController.cs
  2. 1
      modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json
  3. 1
      modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json
  4. 18
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml
  5. 9
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs
  6. 29
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js

26
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);
}
}
}

1
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",

1
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",

18
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml

@ -47,15 +47,6 @@
<a>
<i class="fa fa-comment"></i> @L["CommentWithCount", @Model.CommentCount]
</a>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Update) || (CurrentUser.Id == Model.Post.CreatorId))
{
<span class="seperator">|</span>
<a asp-page="./Edit" asp-route-postId="@Model.Post.Id" asp-route-blogShortName="@Model.BlogShortName">
<i class="fa fa-pencil"></i> @L["Edit"]
</a>
}
</div>
</div>
</div>
@ -114,8 +105,6 @@
<a>
<i class="fa fa-comment"></i> @L["CommentWithCount", @Model.CommentCount]
</a>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Update))
{
<span class="seperator">|</span>
@ -123,6 +112,13 @@
<i class="fa fa-pencil"></i> @L["Edit"]
</a>
}
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Delete) || (CurrentUser.Id == Model.Post.CreatorId))
{
<span class="seperator">|</span>
<a href="#" id="DeletePostLink" data-postid="@Model.Post.Id" data-blogShortName="@Model.BlogShortName">
<i class="fa fa-trash"></i> @L["Delete"]
</a>
}
</div>
</div>
</div>

9
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);

29
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();

Loading…
Cancel
Save