Browse Source

property renaming and refactorings

pull/7745/head
Ilkay Ilknur 5 years ago
parent
commit
fad1711fc7
  1. 2022
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.Designer.cs
  2. 23
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.cs
  3. 6
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs
  4. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureDto.cs
  5. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureInputDto.cs
  6. 7
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminAppService.cs
  7. 16
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeature.cs
  8. 8
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultBlogFeatureProvider.cs
  9. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogFeatureDto.cs
  10. 7
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogFeaturePublicAppService.cs
  11. 6
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Blogs/BlogPost.cshtml
  12. 8
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeatureAdminAppService_Test.cs
  13. 2
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeaturePublicAppService_Test.cs
  14. 2
      modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogFeatureRepository_Test.cs

2022
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.Designer.cs

File diff suppressed because it is too large

23
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.cs

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class BlogFeatureEnabledColumnRename : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Enabled",
table: "CmsBlogFeatures",
newName: "IsEnabled");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "IsEnabled",
table: "CmsBlogFeatures",
newName: "Enabled");
}
}
}

6
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs

@ -1220,9 +1220,6 @@ namespace Volo.CmsKit.Migrations
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
@ -1238,6 +1235,9 @@ namespace Volo.CmsKit.Migrations
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<bool>("IsEnabled")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureDto.cs

@ -8,6 +8,6 @@ namespace Volo.CmsKit.Admin.Blogs
{
[NotNull]
public string FeatureName { get; set; }
public bool Enabled { get; set; }
public bool IsEnabled { get; set; }
}
}

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureInputDto.cs

@ -6,6 +6,6 @@ namespace Volo.CmsKit.Admin.Blogs
{
[Required]
public string FeatureName { get; set; }
public bool Enabled { get; set; }
public bool IsEnabled { get; set; }
}
}

7
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminAppService.cs

@ -4,12 +4,15 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.Admin.Blogs;
using Volo.CmsKit.Blogs;
using Volo.CmsKit.GlobalFeatures;
using Volo.CmsKit.Permissions;
namespace Volo.CmsKit.Admin.Blogs
{
[RequiresGlobalFeature(typeof(BlogsFeature))]
public class BlogFeatureAdminAppService : CmsKitAdminAppServiceBase, IBlogFeatureAdminAppService
{
protected IBlogFeatureRepository BlogFeatureRepository { get; }
@ -37,12 +40,12 @@ namespace Volo.CmsKit.Admin.Blogs
var blogFeature = await BlogFeatureRepository.FindAsync(blogId, dto.FeatureName);
if (blogFeature == null)
{
var newBlogFeature = new BlogFeature(blogId, dto.FeatureName, dto.Enabled);
var newBlogFeature = new BlogFeature(blogId, dto.FeatureName, dto.IsEnabled);
await BlogFeatureRepository.InsertAsync(newBlogFeature);
}
else
{
blogFeature.Enabled = dto.Enabled;
blogFeature.IsEnabled = dto.IsEnabled;
await BlogFeatureRepository.UpdateAsync(blogFeature);
}
}

16
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeature.cs

@ -7,19 +7,19 @@ namespace Volo.CmsKit.Blogs
{
public class BlogFeature : FullAuditedAggregateRoot<Guid>, IEquatable<BlogFeature>
{
public BlogFeature(Guid blogId, [NotNull] string featureName, bool enabled = true)
{
BlogId = blogId;
FeatureName = Check.NotNullOrWhiteSpace(featureName, nameof(featureName));
Enabled = enabled;
}
public Guid BlogId { get; protected set; }
public string FeatureName { get; protected set; }
public bool Enabled { get; set; } = true;
public bool IsEnabled { get; set; } = true;
public BlogFeature(Guid blogId, [NotNull] string featureName, bool isEnabled = true)
{
BlogId = blogId;
FeatureName = Check.NotNullOrWhiteSpace(featureName, nameof(featureName));
IsEnabled = isEnabled;
}
public bool Equals(BlogFeature other)
{
return BlogId == other?.BlogId && FeatureName == other?.FeatureName;

8
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultDefaultBlogFeatureProvider.cs → modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultBlogFeatureProvider.cs

@ -1,22 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace Volo.CmsKit.Blogs
{
public class DefaultDefaultBlogFeatureProvider : IDefaultBlogFeatureProvider, ITransientDependency
public class DefaultBlogFeatureProvider : IDefaultBlogFeatureProvider, ITransientDependency
{
public Task<List<BlogFeature>> GetDefaultFeaturesAsync(Guid blogId)
public virtual Task<List<BlogFeature>> GetDefaultFeaturesAsync(Guid blogId)
{
return Task.FromResult(new List<BlogFeature>
{
new BlogFeature(blogId, BlogPostConsts.CommentsFeatureName),
new BlogFeature(blogId, BlogPostConsts.ReactionsFeatureName),
new BlogFeature(blogId, BlogPostConsts.RatingsFeatureName),
new BlogFeature(blogId, BlogPostConsts.RatingsFeatureName),
new BlogFeature(blogId, BlogPostConsts.TagsFeatureName),
});
}
}

2
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogFeatureDto.cs

@ -6,6 +6,6 @@ namespace Volo.CmsKit.Public.Blogs
public class BlogFeatureDto : EntityDto<Guid>
{
public string FeatureName { get; set; }
public bool Enabled { get; set; }
public bool IsEnabled { get; set; }
}
}

7
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogFeaturePublicAppService.cs

@ -36,12 +36,9 @@ namespace Volo.CmsKit.Public.Blogs
private async Task<BlogFeatureDto> GetFromDatabaseAsync(Guid blogId, string featureName)
{
var feature = await BlogFeatureRepository.FindAsync(blogId, featureName);
if (feature == null)
{
feature = new BlogFeature(blogId, featureName);
}
var blogFeature = feature ?? new BlogFeature(blogId, featureName);
return ObjectMapper.Map<BlogFeature, BlogFeatureDto>(feature);
return ObjectMapper.Map<BlogFeature, BlogFeatureDto>(blogFeature);
}
}
}

6
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Blogs/BlogPost.cshtml

@ -35,7 +35,7 @@
@if (GlobalFeatureManager.Instance.IsEnabled<ReactionsFeature>())
{
if (Model.ReactionsFeature?.Enabled == true)
if (Model.ReactionsFeature?.IsEnabled == true)
{
@await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new
{
@ -48,7 +48,7 @@
@if (GlobalFeatureManager.Instance.IsEnabled<RatingsFeature>())
{
if (Model.RatingsFeature?.Enabled == true)
if (Model.RatingsFeature?.IsEnabled == true)
{
@await Component.InvokeAsync(typeof(RatingViewComponent), new
{
@ -62,7 +62,7 @@
@if (GlobalFeatureManager.Instance.IsEnabled<CommentsFeature>())
{
if (Model.CommentsFeature?.Enabled == true)
if (Model.CommentsFeature?.IsEnabled == true)
{
@await Component.InvokeAsync(typeof(DefaultBlogPostCommentViewComponent), new
{

8
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeatureAdminAppService_Test.cs

@ -24,7 +24,7 @@ namespace Volo.CmsKit.Blogs
var dto = new BlogFeatureInputDto
{
FeatureName = "My.Awesome.Feature",
Enabled = true
IsEnabled = true
};
await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto);
@ -33,7 +33,7 @@ namespace Volo.CmsKit.Blogs
feature.ShouldNotBeNull();
feature.BlogId.ShouldBe(testData.Blog_Id);
feature.Enabled.ShouldBe(dto.Enabled);
feature.IsEnabled.ShouldBe(dto.IsEnabled);
}
[Fact]
@ -42,7 +42,7 @@ namespace Volo.CmsKit.Blogs
var dto = new BlogFeatureInputDto
{
FeatureName = testData.BlogFeature_2_FeatureName,
Enabled = !testData.BlogFeature_2_Enabled
IsEnabled = !testData.BlogFeature_2_Enabled
};
await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto);
@ -51,7 +51,7 @@ namespace Volo.CmsKit.Blogs
feature.ShouldNotBeNull();
feature.BlogId.ShouldBe(testData.Blog_Id);
feature.Enabled.ShouldBe(dto.Enabled);
feature.IsEnabled.ShouldBe(dto.IsEnabled);
}
[Fact]

2
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeaturePublicAppService_Test.cs

@ -37,7 +37,7 @@ namespace Volo.CmsKit.Blogs
var defaultFeature = new BlogFeature(Guid.Empty, nonExistingFeatureName);
result.ShouldNotBeNull();
result.Enabled.ShouldBe(defaultFeature.Enabled);
result.IsEnabled.ShouldBe(defaultFeature.IsEnabled);
}
}
}

2
modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogFeatureRepository_Test.cs

@ -45,7 +45,7 @@ namespace Volo.CmsKit.Blogs
result.ShouldNotBeNull();
result.FeatureName.ShouldBe(testData.BlogFeature_1_FeatureName);
result.Enabled.ShouldBe(testData.BlogFeature_1_Enabled);
result.IsEnabled.ShouldBe(testData.BlogFeature_1_Enabled);
}
[Fact]

Loading…
Cancel
Save