blogging refactor

pull/2542/head
Yunus Emre Kalkan 6 years ago
parent e434fc30c4
commit 4f1bd2d69d

File diff suppressed because one or more lines are too long

@ -2213,9 +2213,9 @@ pumpify@^1.3.5:
inherits "^2.0.3"
pump "^2.0.0"
"raphael@git+https://github.com/nhn/raphael.git#2.2.0-c":
"raphael@https://github.com/nhn/raphael.git#2.2.0-c":
version "2.2.0-c"
resolved "git+https://github.com/nhn/raphael.git#78a6ed3ec269f33b6457b0ec66f8c3d1f2ed70e0"
resolved "https://github.com/nhn/raphael.git#78a6ed3ec269f33b6457b0ec66f8c3d1f2ed70e0"
dependencies:
eve "git://github.com/adobe-webplatform/eve.git#eef80ed"

@ -180,14 +180,14 @@ namespace Volo.Blogging.Posts
return url;
}
private async Task SaveTags(List<String> newTags, Post post)
private async Task SaveTags(ICollection<string> newTags, Post post)
{
await RemoveOldTags(newTags, post);
await AddNewTags(newTags, post);
}
private async Task RemoveOldTags(List<string> newTags, Post post)
private async Task RemoveOldTags(ICollection<string> newTags, Post post)
{
foreach (var oldTag in post.Tags)
{
@ -209,7 +209,7 @@ namespace Volo.Blogging.Posts
}
}
private async Task AddNewTags(List<string> newTags, Post post)
private async Task AddNewTags(IEnumerable<string> newTags, Post post)
{
var tags = await _tagRepository.GetListAsync(post.BlogId);
@ -219,7 +219,7 @@ namespace Volo.Blogging.Posts
if (tag == null)
{
tag = await _tagRepository.InsertAsync(new Tag(post.BlogId, newTag, 1));
tag = await _tagRepository.InsertAsync(new Tag(GuidGenerator.Create(), post.BlogId, newTag, 1));
}
else
{
@ -249,7 +249,7 @@ namespace Volo.Blogging.Posts
return new List<string>(tags.Split(",").Select(t => t.Trim()));
}
private Task<List<PostWithDetailsDto>> FilterPostsByTag(List<PostWithDetailsDto> allPostDtos, Tag tag)
private Task<List<PostWithDetailsDto>> FilterPostsByTag(IEnumerable<PostWithDetailsDto> allPostDtos, Tag tag)
{
var filteredPostDtos = allPostDtos.Where(p => p.Tags?.Any(t => t.Id == tag.Id) ?? false).ToList();

@ -20,8 +20,9 @@ namespace Volo.Blogging.Tagging
}
public Tag(Guid blogId, [NotNull] string name, int usageCount = 0, string description = null)
public Tag(Guid id, Guid blogId, [NotNull] string name, int usageCount = 0, string description = null)
{
Id = id;
Name = Check.NotNullOrWhiteSpace(name, nameof(name));
BlogId = blogId;
Description = description;

@ -14,7 +14,7 @@ namespace Volo.Blogging
[InlineData("bbb")]
public void SetName(string name)
{
var tag = new Tag(Guid.NewGuid(), "abp", 0, "abp tag");
var tag = new Tag(Guid.NewGuid(), Guid.NewGuid(), "abp", 0, "abp tag");
tag.SetName(name);
tag.Name.ShouldBe(name);
}
@ -25,7 +25,7 @@ namespace Volo.Blogging
[InlineData(3)]
public void IncreaseUsageCount(int number)
{
var tag = new Tag(Guid.NewGuid(), "abp", 0, "abp tag");
var tag = new Tag(Guid.NewGuid(), Guid.NewGuid(), "abp", 0, "abp tag");
tag.IncreaseUsageCount(number);
tag.UsageCount.ShouldBe(number);
}
@ -36,7 +36,7 @@ namespace Volo.Blogging
[InlineData(3)]
public void DecreaseUsageCount(int number)
{
var tag = new Tag(Guid.NewGuid(), "abp", 10, "abp tag");
var tag = new Tag(Guid.NewGuid(), Guid.NewGuid(), "abp", 10, "abp tag");
tag.DecreaseUsageCount(number);
tag.UsageCount.ShouldBe(10 - number);
}
@ -44,7 +44,7 @@ namespace Volo.Blogging
[Fact]
public void DecreaseUsageCount_Should_Greater_ThanOrEqual_Zero()
{
var tag = new Tag(Guid.NewGuid(), "abp", 10, "abp tag");
var tag = new Tag(Guid.NewGuid(), Guid.NewGuid(), "abp", 10, "abp tag");
tag.DecreaseUsageCount(100);
tag.UsageCount.ShouldBe(0);
}
@ -54,7 +54,7 @@ namespace Volo.Blogging
[InlineData("bbb")]
public void SetDescription(string description)
{
var tag = new Tag(Guid.NewGuid(), "abp", 0, "abp tag");
var tag = new Tag(Guid.NewGuid(), Guid.NewGuid(), "abp", 0, "abp tag");
tag.SetDescription(description);
tag.Description.ShouldBe(description);
}

@ -43,8 +43,8 @@ namespace Volo.Blogging
await _postRepository.InsertAsync(new Post(_testData.Blog1Post2Id, _testData.Blog1Id, "title2", "coverImage2", "url2"));
await _commentRepository.InsertAsync(new Comment(_testData.Blog1Post1Comment1Id,_testData.Blog1Post1Id,null,"text"));
await _commentRepository.InsertAsync(new Comment(_testData.Blog1Post1Comment2Id, _testData.Blog1Post1Id, _testData.Blog1Post1Comment1Id, "text"));
await _tagRepository.InsertAsync(new Tag(_testData.Blog1Id, _testData.Tag1Name, 10));
await _tagRepository.InsertAsync(new Tag(_testData.Blog1Id, _testData.Tag2Name));
await _tagRepository.InsertAsync(new Tag(Guid.NewGuid(), _testData.Blog1Id, _testData.Tag1Name, 10));
await _tagRepository.InsertAsync(new Tag(Guid.NewGuid(), _testData.Blog1Id, _testData.Tag2Name));
}
}

Loading…
Cancel
Save