Browse Source

CmsKit - Add CommentDetailedDto

pull/7955/head
enisn 5 years ago
parent
commit
fcb7b21b51
  1. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentDetailedDto.cs
  2. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentWithDetailsDto.cs
  3. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/ICommentPublicAppService.cs
  4. 10
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs
  5. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs
  6. 4
      modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Comments/CommentPublicController.cs

4
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentDto.cs → modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentDetailedDto.cs

@ -3,7 +3,7 @@
namespace Volo.CmsKit.Public.Comments
{
[Serializable]
public class CommentDto
public class CommentDetailedDto
{
public Guid Id { get; set; }
@ -19,6 +19,6 @@ namespace Volo.CmsKit.Public.Comments
public DateTime CreationTime { get; set; }
public CmsUserDto Author { get; set; } //TODO: Should only have AuthorId for the basic dto. see https://docs.abp.io/en/abp/latest/Best-Practices/Application-Services
public CmsUserDto Author { get; set; }
}
}

2
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentWithDetailsDto.cs

@ -18,7 +18,7 @@ namespace Volo.CmsKit.Public.Comments
public DateTime CreationTime { get; set; }
public List<CommentDto> Replies { get; set; }
public List<CommentDetailedDto> Replies { get; set; }
public CmsUserDto Author { get; set; }
}

4
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/ICommentPublicAppService.cs

@ -9,9 +9,9 @@ namespace Volo.CmsKit.Public.Comments
{
Task<ListResultDto<CommentWithDetailsDto>> GetListAsync(string entityType, string entityId);
Task<CommentDto> CreateAsync(string entityType, string entityId, CreateCommentInput input);
Task<CommentDetailedDto> CreateAsync(string entityType, string entityId, CreateCommentInput input);
Task<CommentDto> UpdateAsync(Guid id, UpdateCommentInput input);
Task<CommentDetailedDto> UpdateAsync(Guid id, UpdateCommentInput input);
Task DeleteAsync(Guid id);
}

10
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs

@ -48,7 +48,7 @@ namespace Volo.CmsKit.Public.Comments
}
[Authorize]
public virtual async Task<CommentDto> CreateAsync(string entityType, string entityId, CreateCommentInput input)
public virtual async Task<CommentDetailedDto> CreateAsync(string entityType, string entityId, CreateCommentInput input)
{
var user = await CmsUserLookupService.GetByIdAsync(CurrentUser.GetId());
@ -75,11 +75,11 @@ namespace Volo.CmsKit.Public.Comments
Id = comment.Id
});
return ObjectMapper.Map<Comment, CommentDto>(comment);
return ObjectMapper.Map<Comment, CommentDetailedDto>(comment);
}
[Authorize]
public virtual async Task<CommentDto> UpdateAsync(Guid id, UpdateCommentInput input)
public virtual async Task<CommentDetailedDto> UpdateAsync(Guid id, UpdateCommentInput input)
{
var comment = await CommentRepository.GetAsync(id);
@ -92,7 +92,7 @@ namespace Volo.CmsKit.Public.Comments
var updatedComment = await CommentRepository.UpdateAsync(comment);
return ObjectMapper.Map<Comment, CommentDto>(updatedComment);
return ObjectMapper.Map<Comment, CommentDetailedDto>(updatedComment);
}
[Authorize]
@ -123,7 +123,7 @@ namespace Volo.CmsKit.Public.Comments
parentComment.Replies = comments
.Where(c => c.Comment.RepliedCommentId == parentComment.Id)
.Select(c => ObjectMapper.Map<Comment, CommentDto>(c.Comment))
.Select(c => ObjectMapper.Map<Comment, CommentDetailedDto>(c.Comment))
.ToList();
foreach (var reply in parentComment.Replies)

2
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs

@ -18,7 +18,7 @@ namespace Volo.CmsKit.Public
{
CreateMap<CmsUser, Comments.CmsUserDto>();
CreateMap<Comment, CommentDto>()
CreateMap<Comment, CommentDetailedDto>()
.Ignore(x=> x.Author);
CreateMap<Comment, CommentWithDetailsDto>()

4
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Comments/CommentPublicController.cs

@ -30,14 +30,14 @@ namespace Volo.CmsKit.Public.Comments
[HttpPost]
[Route("{entityType}/{entityId}")]
public Task<CommentDto> CreateAsync(string entityType, string entityId, CreateCommentInput input)
public Task<CommentDetailedDto> CreateAsync(string entityType, string entityId, CreateCommentInput input)
{
return CommentPublicAppService.CreateAsync(entityType, entityId, input);
}
[HttpPut]
[Route("{id}")]
public Task<CommentDto> UpdateAsync(Guid id, UpdateCommentInput input)
public Task<CommentDetailedDto> UpdateAsync(Guid id, UpdateCommentInput input)
{
return CommentPublicAppService.UpdateAsync(id, input);
}

Loading…
Cancel
Save