Browse Source

Blogging module creator user name

pull/441/head
Yunus Emre Kalkan 8 years ago
parent
commit
6675d4c15a
  1. 5
      modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Comments/Dtos/CommentWithDetailsDto.cs
  2. 4
      modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Comments/Dtos/CommentWithRepliesDto.cs
  3. 4
      modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Comments/ICommentAppService.cs
  4. 4
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/BloggingApplicationAutoMapperProfile.cs
  5. 49
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Comments/CommentAppService.cs
  6. 59
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs
  7. 2
      modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/IPostTagRepository.cs
  8. 6
      modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostTagRepository.cs
  9. 450
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml
  10. 6
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml

5
modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Comments/Dtos/CommentDto.cs → modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Comments/Dtos/CommentWithDetailsDto.cs

@ -1,12 +1,15 @@
using System;
using Volo.Abp.Application.Dtos;
using Volo.Blogging.Posts;
namespace Volo.Blogging.Comments.Dtos
{
public class CommentDto : FullAuditedEntityDto<Guid>
public class CommentWithDetailsDto : FullAuditedEntityDto<Guid>
{
public Guid? RepliedCommentId { get; set; }
public string Text { get; set; }
public BlogUserDto Writer { get; set; }
}
}

4
modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Comments/Dtos/CommentWithRepliesDto.cs

@ -4,8 +4,8 @@ namespace Volo.Blogging.Comments.Dtos
{
public class CommentWithRepliesDto
{
public CommentDto Comment { get; set; }
public CommentWithDetailsDto Comment { get; set; }
public List<CommentDto> Replies { get; set; } = new List<CommentDto>();
public List<CommentWithDetailsDto> Replies { get; set; } = new List<CommentWithDetailsDto>();
}
}

4
modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Comments/ICommentAppService.cs

@ -10,9 +10,9 @@ namespace Volo.Blogging.Comments
{
Task<List<CommentWithRepliesDto>> GetHierarchicalListOfPostAsync(GetCommentListOfPostAsync input);
Task<CommentDto> CreateAsync(CreateCommentDto input);
Task<CommentWithDetailsDto> CreateAsync(CreateCommentDto input);
Task<CommentDto> UpdateAsync(Guid id, UpdateCommentDto input);
Task<CommentWithDetailsDto> UpdateAsync(Guid id, UpdateCommentDto input);
Task DeleteAsync(Guid id);
}

4
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/BloggingApplicationAutoMapperProfile.cs

@ -16,8 +16,8 @@ namespace Volo.Blogging
{
CreateMap<Blog, BlogDto>();
CreateMap<Post, PostDto>();
CreateMap<Post, PostWithDetailsDto>().Ignore(x=>x.CommentCount);
CreateMap<Comment, CommentDto>();
CreateMap<Post, PostWithDetailsDto>().ForMember(x => x.Writer, opt => opt.Ignore()).Ignore(x=>x.CommentCount);
CreateMap<Comment, CommentWithDetailsDto>().ForMember(x => x.Writer, opt => opt.Ignore());
CreateMap<Tag, TagDto>();
}
}

49
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Comments/CommentAppService.cs

@ -5,25 +5,54 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Application.Services;
using Volo.Abp.Guids;
using Volo.Abp.Users;
using Volo.Blogging.Comments.Dtos;
using Volo.Blogging.Posts;
using Volo.Blogging.Users;
namespace Volo.Blogging.Comments
{
// [Authorize(BloggingPermissions.Comments.Default)]
public class CommentAppService : ApplicationService, ICommentAppService
{
protected IBlogUserLookupService UserLookupService;
private readonly ICommentRepository _commentRepository;
private readonly IGuidGenerator _guidGenerator;
public CommentAppService(ICommentRepository commentRepository, IGuidGenerator guidGenerator)
public CommentAppService(ICommentRepository commentRepository, IGuidGenerator guidGenerator, IBlogUserLookupService userLookupService)
{
_commentRepository = commentRepository;
_guidGenerator = guidGenerator;
UserLookupService = userLookupService;
}
public async Task<List<CommentWithRepliesDto>> GetHierarchicalListOfPostAsync(GetCommentListOfPostAsync input)
{
var comments = await GetListOfPostAsync(input);
var userDictionary = new Dictionary<Guid, BlogUserDto>();
foreach (var commentDto in comments)
{
if (commentDto.CreatorId.HasValue)
{
var creatorUser = await UserLookupService.FindByIdAsync(commentDto.CreatorId.Value);
if (creatorUser != null && !userDictionary.ContainsKey(creatorUser.Id))
{
userDictionary.Add(creatorUser.Id, ObjectMapper.Map<BlogUser, BlogUserDto>(creatorUser));
}
}
}
foreach (var commentDto in comments)
{
if (commentDto.CreatorId.HasValue && userDictionary.ContainsKey((Guid)commentDto.CreatorId))
{
commentDto.Writer = userDictionary[(Guid)commentDto.CreatorId];
}
}
var hierarchicalComments = new List<CommentWithRepliesDto>();
foreach (var commentDto in comments)
@ -45,25 +74,25 @@ namespace Volo.Blogging.Comments
return hierarchicalComments;
}
private async Task<List<CommentDto>> GetListOfPostAsync(GetCommentListOfPostAsync input)
private async Task<List<CommentWithDetailsDto>> GetListOfPostAsync(GetCommentListOfPostAsync input)
{
var comments = await _commentRepository.GetListOfPostAsync(input.PostId);
return new List<CommentDto>(
ObjectMapper.Map<List<Comment>, List<CommentDto>>(comments));
return new List<CommentWithDetailsDto>(
ObjectMapper.Map<List<Comment>, List<CommentWithDetailsDto>>(comments));
}
[Authorize(BloggingPermissions.Comments.Create)]
public async Task<CommentDto> CreateAsync(CreateCommentDto input)
public async Task<CommentWithDetailsDto> CreateAsync(CreateCommentDto input)
{
var comment = new Comment(_guidGenerator.Create(), input.PostId, input.RepliedCommentId, input.Text);
comment = await _commentRepository.InsertAsync(comment);
return ObjectMapper.Map<Comment, CommentDto>(comment);
return ObjectMapper.Map<Comment, CommentWithDetailsDto>(comment);
}
public async Task<CommentDto> UpdateAsync(Guid id, UpdateCommentDto input)
public async Task<CommentWithDetailsDto> UpdateAsync(Guid id, UpdateCommentDto input)
{
var comment = await _commentRepository.GetAsync(id);
@ -76,18 +105,18 @@ namespace Volo.Blogging.Comments
}
[Authorize(BloggingPermissions.Comments.Update)]
private async Task<CommentDto> UpdateAsAdminAsync(Guid id, Comment comment, UpdateCommentDto input)
private async Task<CommentWithDetailsDto> UpdateAsAdminAsync(Guid id, Comment comment, UpdateCommentDto input)
{
return await UpdateCommentAsync(id, comment, input);
}
private async Task<CommentDto> UpdateCommentAsync(Guid id, Comment comment, UpdateCommentDto input)
private async Task<CommentWithDetailsDto> UpdateCommentAsync(Guid id, Comment comment, UpdateCommentDto input)
{
comment.SetText(input.Text);
comment = await _commentRepository.UpdateAsync(comment);
return ObjectMapper.Map<Comment, CommentDto>(comment);
return ObjectMapper.Map<Comment, CommentWithDetailsDto>(comment);
}
public async Task DeleteAsync(Guid id)

59
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs

@ -40,32 +40,22 @@ namespace Volo.Blogging.Posts
public async Task<ListResultDto<PostWithDetailsDto>> GetListByBlogIdAndTagName(Guid id, string tagName)
{
var posts = _postRepository.GetPostsByBlogId(id);
var tag = tagName.IsNullOrWhiteSpace()? null: await _tagRepository.GetByNameAsync(tagName);
var allPostDtos = new List<PostWithDetailsDto>(
ObjectMapper.Map<List<Post>, List<PostWithDetailsDto>>(posts));
var filteredPostDtos = new List<PostWithDetailsDto>();
var userDictionary = new Dictionary<Guid, BlogUserDto>();
var postDtos = new List<PostWithDetailsDto>(ObjectMapper.Map<List<Post>, List<PostWithDetailsDto>>(posts));
foreach (var postDto in allPostDtos)
if (tag != null)
{
postDto.Tags = await GetTagsOfPost(postDto.Id);
if (tag != null && postDto.Tags.All(t => t.Id != tag.Id))
{
continue;
}
filteredPostDtos.Add(postDto);
postDtos = await FilterPostsByTag(postDtos, tag);
}
foreach (var postDto in filteredPostDtos)
foreach (var postDto in postDtos)
{
postDto.CommentCount = await _commentRepository.GetCommentCountOfPostAsync(postDto.Id);
}
foreach (var postDto in postDtos)
{
if (postDto.CreatorId.HasValue)
{
var creatorUser = await UserLookupService.FindByIdAsync(postDto.CreatorId.Value);
@ -77,7 +67,7 @@ namespace Volo.Blogging.Posts
}
}
foreach (var postDto in filteredPostDtos)
foreach (var postDto in postDtos)
{
if (postDto.CreatorId.HasValue && userDictionary.ContainsKey((Guid) postDto.CreatorId))
{
@ -85,7 +75,24 @@ namespace Volo.Blogging.Posts
}
}
return new ListResultDto<PostWithDetailsDto>(allPostDtos);
return new ListResultDto<PostWithDetailsDto>(postDtos);
}
private async Task<List<PostWithDetailsDto>> FilterPostsByTag(List<PostWithDetailsDto> allPostDtos, Tag tag)
{
var filteredPostDtos = new List<PostWithDetailsDto>();
foreach (var postDto in allPostDtos)
{
if (await _postTagRepository.FindByTagIdAndPostIdAsync(postDto.Id, tag.Id) == null)
{
continue;
}
filteredPostDtos.Add(postDto);
}
return filteredPostDtos;
}
public async Task<PostWithDetailsDto> GetForReadingAsync(GetPostInput input)
@ -98,6 +105,13 @@ namespace Volo.Blogging.Posts
postDto.Tags = await GetTagsOfPost(postDto.Id);
if (postDto.CreatorId.HasValue)
{
var creatorUser = await UserLookupService.FindByIdAsync(postDto.CreatorId.Value);
postDto.Writer = ObjectMapper.Map<BlogUser, BlogUserDto>(creatorUser);
}
return postDto;
}
@ -109,6 +123,13 @@ namespace Volo.Blogging.Posts
postDto.Tags = await GetTagsOfPost(postDto.Id);
if (postDto.CreatorId.HasValue)
{
var creatorUser = await UserLookupService.FindByIdAsync(postDto.CreatorId.Value);
postDto.Writer = ObjectMapper.Map<BlogUser, BlogUserDto>(creatorUser);
}
return postDto;
}

2
modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/IPostTagRepository.cs

@ -7,5 +7,7 @@ namespace Volo.Blogging.Posts
public interface IPostTagRepository : IBasicRepository<PostTag>
{
void DeleteOfPost(Guid id);
Task<PostTag> FindByTagIdAndPostIdAsync(Guid postId, Guid tagId);
}
}

6
modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostTagRepository.cs

@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Blogging.EntityFrameworkCore;
@ -18,5 +19,10 @@ namespace Volo.Blogging.Posts
var recordsToDelete = DbSet.Where(pt=>pt.PostId == id);
DbSet.RemoveRange(recordsToDelete);
}
public async Task<PostTag> FindByTagIdAndPostIdAsync(Guid postId, Guid tagId)
{
return await DbSet.FirstOrDefaultAsync(pt=> pt.PostId == postId && pt.TagId == tagId);
}
}
}

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

@ -19,16 +19,83 @@
<abp-style src="/Pages/Blog/Shared/Styles/blog.css" />
</abp-style-bundle>
}
<div class="vs-blog">
<div class="vs-blog-header">
<div class="vs-blog-title">
<div class="row">
<div class="col">
<h1 class="my-0 display-inline-block">
@L["Volosoft"]
<small class="text-muted">
@L["Blog"]
</small>
<div class="vs-blog">
<div class="vs-blog-header">
<div class="vs-blog-title">
<div class="row">
<div class="col">
<h1 class="my-0 display-inline-block">
@L["Volosoft"]
<small class="text-muted">
@L["Blog"]
</small>
</h1>
</div>
<div class="article-owner">
<div class="article-infos">
<div class="user-card">
<a href="#">
<img src="https://placeimg.com/60/60/people" class="article-avatar">
</a>
<a href="#">
<strong> @(Model.Post.Writer == null ? "" : Model.Post.Writer.UserName)</strong>, @ConvertDatetimeToTimeAgo(Model.Post.CreationTime)
</a>
<span class="seperator">|</span>
<a href="#">
<i class="fa fa-eye"></i> @Model.Post.ReadCount @L["Read"]
</a>
<span class="seperator">|</span>
<a href="#">
<i class="fa fa-comment"></i> @Model.CommentCount @L["Comment"]
</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>
<div class="col-sm-4 text-right">
<br />
<a asp-page="/Blog/Posts/Index" asp-route-blogShortName="@Model.BlogShortName">
<i class="fa fa fa-angle-left"></i> @L["Blog"]
</a>
<span class="vs-seperator">|</span>
<a href="#">
<i class="fa fa-twitter"></i>
</a>
<span class="vs-seperator">|</span>
<a href="#">
<i class="fa fa-github"></i>
</a>
<span class="vs-seperator">|</span>
<a href="#">
<i class="fa fa-stack-overflow"></i>
</a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 mx-auto">
<section class="hero-section">
<div class="hero-articles">
<div class="img-container" style="min-height: 480px; background: url(@Model.Post.CoverImage) center center no-repeat; background-size: cover; ">
</div>
<div class="hero-content">
<p class="tags">
@foreach (var tag in Model.Post.Tags)
{
<a asp-page="/Blog/Posts/Index" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
}
</p>
<h1>
<a href="#">@Model.Post.Title</a>
</h1>
</div>
<div class="article-owner">
@ -38,19 +105,19 @@
<img src="https://placeimg.com/60/60/people" class="article-avatar">
</a>
<a href="#">
<strong> Halil İbrahim Kalkan</strong>, @ConvertDatetimeToTimeAgo(Model.Post.CreationTime)
<strong> @(Model.Post.Writer == null ? "" : Model.Post.Writer.UserName)</strong>, @ConvertDatetimeToTimeAgo(Model.Post.CreationTime)
</a>
<span class="seperator">|</span>
<span class="vs-seperator">|</span>
<a href="#">
<i class="fa fa-eye"></i> @Model.Post.ReadCount @L["Read"]
</a>
<span class="seperator">|</span>
<span class="vs-seperator">|</span>
<a href="#">
<i class="fa fa-comment"></i> @Model.CommentCount @L["Comment"]
</a>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Update) || (CurrentUser.Id == Model.Post.CreatorId))
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Update))
{
<span class="seperator">|</span>
<a asp-page="./Edit" asp-route-postId="@Model.Post.Id" asp-route-blogShortName="@Model.BlogShortName">
@ -60,257 +127,196 @@
</div>
</div>
</div>
<div class="col-sm-4 text-right">
<br />
<a asp-page="/Blog/Posts/Index" asp-route-blogShortName="@Model.BlogShortName">
<i class="fa fa fa-angle-left"></i> @L["Blog"]
</a>
<span class="vs-seperator">|</span>
<a href="#">
<i class="fa fa-twitter"></i>
</a>
<span class="vs-seperator">|</span>
<a href="#">
<i class="fa fa-github"></i>
</a>
<span class="vs-seperator">|</span>
<a href="#">
<i class="fa fa-stack-overflow"></i>
</a>
</div>
</div>
</div>
</section>
</div>
<div class="row">
<div class="col-md-12 mx-auto">
<section class="hero-section">
<div class="hero-articles">
<div class="img-container" style="min-height: 480px; background: url(@Model.Post.CoverImage) center center no-repeat; background-size: cover; ">
</div>
<div class="hero-content">
<p class="tags">
@foreach (var tag in Model.Post.Tags)
{
<a asp-page="/Blog/Posts/Index" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
}
</p>
<h1>
<a href="#">@Model.Post.Title</a>
</h1>
</div>
<div class="article-owner">
<div class="article-infos">
<div class="user-card">
<a href="#">
<img src="https://placeimg.com/60/60/people" class="article-avatar">
</a>
<a href="#">
<strong> Halil İbrahim Kalkan</strong>, @ConvertDatetimeToTimeAgo(Model.Post.CreationTime)
</a>
<span class="vs-seperator">|</span>
<a href="#">
<i class="fa fa-eye"></i> @Model.Post.ReadCount @L["Read"]
</a>
<span class="vs-seperator">|</span>
<a href="#">
<i class="fa fa-comment"></i> @Model.CommentCount @L["Comment"]
</a>
</div>
<div class="row">
<div class="col-md-8 mx-auto">
<section class="post-content">
<p>@Html.Raw(Model.FormattedContent)</p>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Posts.Update))
{
<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>
</div>
</section>
</div>
</section>
</div>
</div>
<div class="row">
<div class="col-md-8 mx-auto">
<section class="post-content">
<p>@Html.Raw(Model.FormattedContent)</p>
</section>
<div class="row">
<div class="col-md-8 mx-auto">
<div class="tags">
<h5>@L["TagsInThisArticle"]</h5>
@foreach (var tag in Model.Post.Tags)
{
<a asp-page="/Blog/Posts/Index" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
}
</div>
</div>
<div class="row">
<div class="col-md-8 mx-auto">
<div class="tags">
<h5>@L["TagsInThisArticle"]</h5>
@foreach (var tag in Model.Post.Tags)
{
<a asp-page="/Blog/Posts/Index" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
}
<div class="comment-form mt-4">
<div class="vs-blog-title mb-0">
<h3>@L["LeaveComment"]</h3>
</div>
<div class="comment-form mt-4">
<div class="vs-blog-title mb-0">
<h3>@L["LeaveComment"]</h3>
</div>
<div class="clearfix bg-light p-4">
<div>
<form method="post">
<input name="postId" value="@Model.Post.Id" hidden />
<input name="repliedCommentId" id="repliedCommentId" hidden />
<div class="form-group">
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4"></textarea>
</div>
<abp-button button-type="Primary" class="btn-rounded float-right" type="submit" text="@L["Submit"].Value" />
</form>
</div>
<div class="clearfix bg-light p-4">
<div>
<form method="post">
<input name="postId" value="@Model.Post.Id" hidden />
<input name="repliedCommentId" id="repliedCommentId" hidden />
<div class="form-group">
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4"></textarea>
</div>
<abp-button button-type="Primary" class="btn-rounded float-right" type="submit" text="@L["Submit"].Value" />
</form>
</div>
</div>
<div class="comment-area">
</div>
<div class="comment-area">
@foreach (var commentWithRepliesDto in Model.CommentsWithReplies)
{
<div class="media">
<img class="d-flex mr-3 rounded-circle comment-avatar" src="https://placeimg.com/120/120/people" alt="">
<div class="media-body">
<h5 class="comment-owner">
@(commentWithRepliesDto.Comment.Writer == null ? "" : commentWithRepliesDto.Comment.Writer.UserName)
<span class="float-right">@ConvertDatetimeToTimeAgo(commentWithRepliesDto.Comment.CreationTime)</span>
</h5>
<p id="@commentWithRepliesDto.Comment.Id">
@commentWithRepliesDto.Comment.Text
</p>
<div class="comment-buttons font-75 bg-light">
@foreach (var commentWithRepliesDto in Model.CommentsWithReplies)
{
<div class="media">
<img class="d-flex mr-3 rounded-circle comment-avatar" src="https://placeimg.com/120/120/people" alt="">
<div class="media-body">
<h5 class="comment-owner">
Armağan Ünlü
<span class="float-right">@ConvertDatetimeToTimeAgo(commentWithRepliesDto.Comment.CreationTime)</span>
</h5>
<p id="@commentWithRepliesDto.Comment.Id">
@commentWithRepliesDto.Comment.Text
</p>
<div class="comment-buttons font-75 bg-light">
<a href="#" class="tag replyLink" data-relpyid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-reply" aria-hidden="true"></i> @L["Reply"]
</a>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete))
{
<span class="seperator">|</span>
<a href="#" class="tag deleteLink" data-deleteid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-trash" aria-hidden="true"></i> @L["Delete"]
</a>
}
<a href="#" class="tag replyLink" data-relpyid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-reply" aria-hidden="true"></i> @L["Reply"]
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<span class="seperator">|</span>
<a href="#" class="tag updateLink" data-updateid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-pencil" aria-hidden="true"></i> @L["Edit"]
</a>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete))
{
<span class="seperator">|</span>
<a href="#" class="tag deleteLink" data-deleteid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-trash" aria-hidden="true"></i> @L["Delete"]
</a>
}
}
</div>
<div class="comment-form mt-4 replyForm">
<div class="clearfix bg-light p-4">
<h3 class="mt-0">
@L["ReplyTo"]
@(commentWithRepliesDto.Comment.Writer == null ? "" : commentWithRepliesDto.Comment.Writer.UserName)
</h3>
<div>
<form method="post">
<input name="postId" value="@Model.Post.Id" hidden />
<input name="repliedCommentId" value="@commentWithRepliesDto.Comment.Id" hidden />
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<span class="seperator">|</span>
<a href="#" class="tag updateLink" data-updateid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-pencil" aria-hidden="true"></i> @L["Edit"]
</a>
}
<div class="form-group">
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4"></textarea>
</div>
<abp-button button-type="Primary" class="btn-rounded float-right" type="submit" text="@L["Comment"].Value" />
</form>
</div>
</div>
</div>
<div class="comment-form mt-4 replyForm">
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<div class="comment-form mt-4 editForm">
<div class="clearfix bg-light p-4">
<h3 class="mt-0">@L["ReplyTo"] Armağan Ünlü</h3>
<div>
<form method="post">
<input name="postId" value="@Model.Post.Id" hidden />
<input name="repliedCommentId" value="@commentWithRepliesDto.Comment.Id" hidden />
<form class="editFormClass">
<input name="commentId" value="@commentWithRepliesDto.Comment.Id" hidden />
<div class="form-group">
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4"></textarea>
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4">@commentWithRepliesDto.Comment.Text</textarea>
</div>
<abp-button button-type="Primary" class="btn-rounded float-right" type="submit" text="@L["Comment"].Value" />
<abp-button button-type="Primary" class="btn-rounded float-right" type="submit" text="@L["Submit"].Value" />
</form>
</div>
</div>
</div>
}
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<div class="comment-form mt-4 editForm">
<div class="clearfix bg-light p-4">
<div>
<form class="editFormClass">
<input name="commentId" value="@commentWithRepliesDto.Comment.Id" hidden />
<div class="form-group">
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4">@commentWithRepliesDto.Comment.Text</textarea>
</div>
<abp-button button-type="Primary" class="btn-rounded float-right" type="submit" text="@L["Submit"].Value" />
</form>
</div>
</div>
</div>
}
@foreach (var reply in commentWithRepliesDto.Replies)
{
<div class="media">
<img class="d-flex mr-3 rounded-circle answer-avatar" src="https://placeimg.com/120/120/people?t=1535457179534" alt="">
<div class="media-body">
<h5 class="comment-owner">
@(reply.Writer == null ? "" : reply.Writer.UserName)
<span class="float-right">@ConvertDatetimeToTimeAgo(reply.CreationTime)</span>
</h5>
<p id="@reply.Id">
@reply.Text
</p>
<div class="comment-buttons font-75 bg-light">
<a href="#" class="tag replyLink" data-relpyid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-reply" aria-hidden="true"></i> @L["Reply"]
</a>
@foreach (var reply in commentWithRepliesDto.Replies)
{
<div class="media">
<img class="d-flex mr-3 rounded-circle answer-avatar" src="https://placeimg.com/120/120/people?t=1535457179534" alt="">
<div class="media-body">
<h5 class="comment-owner">
Zlatan Ibrahimovic
<span class="float-right">@ConvertDatetimeToTimeAgo(reply.CreationTime)</span>
</h5>
<p id="@reply.Id">
@reply.Text
</p>
<div class="comment-buttons font-75 bg-light">
<a href="#" class="tag replyLink" data-relpyid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-reply" aria-hidden="true"></i> @L["Reply"]
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<span class="seperator">|</span>
<a href="#" class="tag deleteLink" data-deleteid="@reply.Id">
<i class="fa fa-trash" aria-hidden="true"></i> @L["Delete"]
</a>
}
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<span class="seperator">|</span>
<a href="#" class="tag deleteLink" data-deleteid="@reply.Id">
<i class="fa fa-trash" aria-hidden="true"></i> @L["Delete"]
</a>
}
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<span class="seperator">|</span>
<a href="#" class="tag updateLink" data-updateid="@reply.Id">
<i class="fa fa-pencil" aria-hidden="true"></i> @L["Edit"]
</a>
}
</div>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<span class="seperator">|</span>
<a href="#" class="tag updateLink" data-updateid="@reply.Id">
<i class="fa fa-pencil" aria-hidden="true"></i> @L["Edit"]
</a>
}
<div class="comment-form mt-4 replyForm">
<div class="clearfix bg-light p-4">
<h3 class="mt-0">
@L["ReplyTo"]
@(commentWithRepliesDto.Comment.Writer == null ? "" : commentWithRepliesDto.Comment.Writer.UserName)
</h3>
<div>
<form method="post">
<input name="postId" value="@Model.Post.Id" hidden />
<input name="repliedCommentId" value="@commentWithRepliesDto.Comment.Id" hidden />
<div class="form-group">
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4"></textarea>
</div>
<abp-button button-type="Primary" class="btn-rounded float-right" type="submit" text="@L["Submit"].Value" />
</form>
</div>
</div>
</div>
<div class="comment-form mt-4 replyForm">
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<div class="comment-form mt-4 editForm">
<div class="clearfix bg-light p-4">
<h3 class="mt-0">@L["ReplyTo"] Armağan Ünlü</h3>
<div>
<form method="post">
<input name="postId" value="@Model.Post.Id" hidden />
<input name="repliedCommentId" value="@commentWithRepliesDto.Comment.Id" hidden />
<form class="editFormClass">
<input name="commentId" value="@reply.Id" hidden />
<div class="form-group">
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4"></textarea>
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4">@reply.Text</textarea>
</div>
<abp-button button-type="Primary" class="btn-rounded float-right" type="submit" text="@L["Submit"].Value" />
</form>
</div>
</div>
</div>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<div class="comment-form mt-4 editForm">
<div class="clearfix bg-light p-4">
<div>
<form class="editFormClass">
<input name="commentId" value="@reply.Id" hidden />
<div class="form-group">
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4">@reply.Text</textarea>
</div>
<abp-button button-type="Primary" class="btn-rounded float-right" type="submit" text="@L["Submit"].Value" />
</form>
</div>
</div>
</div>
}
</div>
}
</div>
}
</div>
</div>
}
</div>
}
</div>
</div>
}
</div>
</div>
</div>
</div>

6
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml

@ -93,7 +93,7 @@
<img src="https://placeimg.com/120/120/people" class="article-avatar">
</a>
<a>
<strong>Armağan Ünlü</strong>, @ConvertDatetimeToTimeAgo(post.CreationTime)
<strong>@post.Writer.UserName</strong>, @ConvertDatetimeToTimeAgo(post.CreationTime)
</a>
<span class="vs-seperator">|</span>
<a>
@ -135,7 +135,7 @@
<div class="article-infos">
<div class="user-card">
<a asp-page="./Detail" asp-route-postUrl="@post.Url" asp-route-blogShortName="@Model.BlogShortName">
<strong>Armağan Ünlü</strong>, @ConvertDatetimeToTimeAgo(post.CreationTime)
<strong>@post.Writer.UserName</strong>, @ConvertDatetimeToTimeAgo(post.CreationTime)
</a>
</div>
</div>
@ -192,7 +192,7 @@
<img src="https://placeimg.com/120/120/pople" class="article-avatar">
</a>
<a>
<strong>Armağan Ünlü</strong>, @ConvertDatetimeToTimeAgo(post.CreationTime)
<strong>@post.Writer.UserName</strong>, @ConvertDatetimeToTimeAgo(post.CreationTime)
</a>
<span class="vs-seperator">|</span>
<a>

Loading…
Cancel
Save