Browse Source

Merge branch 'dev' into feature/blog-feature

pull/7745/head
Ilkay Ilknur 6 years ago
parent
commit
1ad61ec1a7
  1. 4
      docs/en/UI/Angular/Multi-Tenancy.md
  2. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo.Abp.AspNetCore.Mvc.UI.csproj
  3. 38
      framework/src/Volo.Abp.Ddd.Domain/Microsoft/Extensions/DependencyInjection/ServiceCollectionRepositoryExtensions.cs
  4. 3
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/AbpRepositoryConventionalRegistrar.cs
  5. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryRegistrarBase.cs
  6. 2
      framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo.Abp.EntityFrameworkCore.Oracle.csproj
  7. 59
      framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleExtensions.cs
  8. 60
      framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleExtensions.cs
  9. 42
      framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/Oracle/AbpEntityFrameworkCoreOracleModule.cs
  10. 12
      framework/src/Volo.Abp.EntityFrameworkCore/Microsoft/Extensions/DependencyInjection/AbpEfCoreServiceCollectionExtensions.cs
  11. 2
      framework/src/Volo.Abp.EntityFrameworkCore/Properties/AssemblyInfo.cs
  12. 33
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs
  13. 7
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreDatabaseApi.cs
  14. 22
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs
  15. 1
      framework/src/Volo.Abp.MemoryDb/Volo/Abp/MemoryDb/AbpMemoryDbModule.cs
  16. 2
      framework/src/Volo.Abp.Minify/Volo.Abp.Minify.csproj
  17. 15
      framework/src/Volo.Abp.MongoDB/Microsoft/Extensions/DependencyInjection/AbpMongoDbServiceCollectionExtensions.cs
  18. 2
      framework/src/Volo.Abp.MongoDB/Properties/AssemblyInfo.cs
  19. 39
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbContextOptions.cs
  20. 10
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/MongoDbDatabaseApi.cs
  21. 20
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs
  22. 2
      framework/src/Volo.Abp.Swashbuckle/Volo.Abp.Swashbuckle.csproj
  23. 26
      framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DbContext_Replace_Tests.cs
  24. 2
      framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/TestApp/MongoDb/TestAppMongoDbContext.cs
  25. 5
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/RegisterDto.cs
  26. 3
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs
  27. 1
      modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs
  28. 1960
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219084931_PageSlugChange.Designer.cs
  29. 46
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219084931_PageSlugChange.cs
  30. 3898
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs
  31. 1
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj
  32. 10
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogLookupDto.cs
  33. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogPostDto.cs
  34. 3
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogPostAdminAppService.cs
  35. 24
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogPostDto.cs
  36. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CreatePageInputDto.cs
  37. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/PageDto.cs
  38. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/UpdatePageInputDto.cs
  39. 7
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs
  40. 3
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs
  41. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Contents/ContentAdminAppService.cs
  42. 21
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Pages/PageAdminAppService.cs
  43. 55
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/EntityTagAdminAppService.cs
  44. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/TagAdminAppService.cs
  45. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogPostAdminController.cs
  46. 2
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitErrorCodes.cs
  47. 2
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json
  48. 2
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Pages/PageConsts.cs
  49. 18
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/Content.cs
  50. 9
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/ContentManager.cs
  51. 6
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/IPageRepository.cs
  52. 32
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/Page.cs
  53. 23
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageSlugAlreadyExistsException.cs
  54. 23
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageUrlAlreadyExistException.cs
  55. 1
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/CmsKitTagOptions.cs
  56. 15
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/DefaultTagDefinitionStore.cs
  57. 6
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTag.cs
  58. 25
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTagManager.cs
  59. 21
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs
  60. 3
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagEntityTypeDefiniton.cs
  61. 62
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagManager.cs
  62. 8
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Contents/EfCoreContentRepository.cs
  63. 4
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs
  64. 37
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs
  65. 24
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreEntityTagRepository.cs
  66. 2
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs
  67. 8
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Contents/MongoContentRepository.cs
  68. 12
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs
  69. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/IPagePublicAppService.cs
  70. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs
  71. 6
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Contents/ContentPublicAppService.cs
  72. 27
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PageAppService.cs
  73. 28
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PagePublicAppService.cs
  74. 17
      modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Pages/PagesPublicController.cs
  75. 8
      modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs
  76. 37
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/PageController.cs
  77. 13
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml
  78. 34
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml.cs
  79. 6
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs
  80. 9
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Views/Page/Index.cshtml
  81. 31
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostAdminAppService_Tests.cs
  82. 18
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PageAdminAppService_Tests.cs
  83. 8
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PagePublicAppService_Tests.cs
  84. 4
      modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs
  85. 4
      modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs
  86. 8
      modules/cms-kit/test/Volo.CmsKit.TestBase/Pages/PageRepository_Test.cs
  87. 9
      modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml
  88. 7
      modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml.cs
  89. 9
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeedContributor.cs
  90. 2
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreModule.cs
  91. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContext.cs
  92. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IAbpIdentityServerMongoDbContext.cs
  93. 2
      modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissionDefinitionProvider.cs
  94. 2
      modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissions.cs
  95. 2
      modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/EmailSettingsAppService.cs
  96. 2
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/AbpSettingManagementBlazorModule.cs
  97. 2
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/EmailSettingGroup/EmailSettingGroupViewComponent.razor.cs
  98. 6
      modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Settings/EmailSettingPageContributor.cs
  99. 4
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/de-DE.json
  100. 4
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/en.json

4
docs/en/UI/Angular/Multi-Tenancy.md

@ -91,10 +91,10 @@ export const environment = {
> **Important Note:** The `application.baseUrl` and the `{0}` placeholder in the value of the `baseUrl` property are required to be able to get tenant from running URL. Other placeholders in API URLs are optional.
After the configuration above, if your app runs on the `mytenant1.mydomain.com`, the app will get tenant name as **mytenant1** and replace the environment object in `ConfigState` on app initialization as follows:
After the configuration above, if your app runs on the `mytenant1.mydomain.com`, the app will get tenant name as **mytenant1** and replace the environment object in `EnvironmentService` on app initialization as follows:
```js
// environment object in ConfigState
// environment object in EnvironmentService
{
//...

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo.Abp.AspNetCore.Mvc.UI.csproj

@ -15,7 +15,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUglify" Version="1.11.4" />
<PackageReference Include="NUglify" Version="1.13.2" />
</ItemGroup>
<ItemGroup>

38
framework/src/Volo.Abp.Ddd.Domain/Microsoft/Extensions/DependencyInjection/ServiceCollectionRepositoryExtensions.cs

@ -7,32 +7,36 @@ namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionRepositoryExtensions
{
public static IServiceCollection AddDefaultRepository(this IServiceCollection services, Type entityType, Type repositoryImplementationType)
public static IServiceCollection AddDefaultRepository(
this IServiceCollection services,
Type entityType,
Type repositoryImplementationType,
bool replaceExisting = false)
{
//IReadOnlyBasicRepository<TEntity>
var readOnlyBasicRepositoryInterface = typeof(IReadOnlyBasicRepository<>).MakeGenericType(entityType);
if (readOnlyBasicRepositoryInterface.IsAssignableFrom(repositoryImplementationType))
{
services.TryAddTransient(readOnlyBasicRepositoryInterface, repositoryImplementationType);
RegisterService(services, readOnlyBasicRepositoryInterface, repositoryImplementationType, replaceExisting);
//IReadOnlyRepository<TEntity>
var readOnlyRepositoryInterface = typeof(IReadOnlyRepository<>).MakeGenericType(entityType);
if (readOnlyRepositoryInterface.IsAssignableFrom(repositoryImplementationType))
{
services.TryAddTransient(readOnlyRepositoryInterface, repositoryImplementationType);
RegisterService(services, readOnlyRepositoryInterface, repositoryImplementationType, replaceExisting);
}
//IBasicRepository<TEntity>
var basicRepositoryInterface = typeof(IBasicRepository<>).MakeGenericType(entityType);
if (basicRepositoryInterface.IsAssignableFrom(repositoryImplementationType))
{
services.TryAddTransient(basicRepositoryInterface, repositoryImplementationType);
RegisterService(services, basicRepositoryInterface, repositoryImplementationType, replaceExisting);
//IRepository<TEntity>
var repositoryInterface = typeof(IRepository<>).MakeGenericType(entityType);
if (repositoryInterface.IsAssignableFrom(repositoryImplementationType))
{
services.TryAddTransient(repositoryInterface, repositoryImplementationType);
RegisterService(services, repositoryInterface, repositoryImplementationType, replaceExisting);
}
}
}
@ -44,26 +48,26 @@ namespace Microsoft.Extensions.DependencyInjection
var readOnlyBasicRepositoryInterfaceWithPk = typeof(IReadOnlyBasicRepository<,>).MakeGenericType(entityType, primaryKeyType);
if (readOnlyBasicRepositoryInterfaceWithPk.IsAssignableFrom(repositoryImplementationType))
{
services.TryAddTransient(readOnlyBasicRepositoryInterfaceWithPk, repositoryImplementationType);
RegisterService(services, readOnlyBasicRepositoryInterfaceWithPk, repositoryImplementationType, replaceExisting);
//IReadOnlyRepository<TEntity, TKey>
var readOnlyRepositoryInterfaceWithPk = typeof(IReadOnlyRepository<,>).MakeGenericType(entityType, primaryKeyType);
if (readOnlyRepositoryInterfaceWithPk.IsAssignableFrom(repositoryImplementationType))
{
services.TryAddTransient(readOnlyRepositoryInterfaceWithPk, repositoryImplementationType);
RegisterService(services, readOnlyRepositoryInterfaceWithPk, repositoryImplementationType, replaceExisting);
}
//IBasicRepository<TEntity, TKey>
var basicRepositoryInterfaceWithPk = typeof(IBasicRepository<,>).MakeGenericType(entityType, primaryKeyType);
if (basicRepositoryInterfaceWithPk.IsAssignableFrom(repositoryImplementationType))
{
services.TryAddTransient(basicRepositoryInterfaceWithPk, repositoryImplementationType);
RegisterService(services, basicRepositoryInterfaceWithPk, repositoryImplementationType, replaceExisting);
//IRepository<TEntity, TKey>
var repositoryInterfaceWithPk = typeof(IRepository<,>).MakeGenericType(entityType, primaryKeyType);
if (repositoryInterfaceWithPk.IsAssignableFrom(repositoryImplementationType))
{
services.TryAddTransient(repositoryInterfaceWithPk, repositoryImplementationType);
RegisterService(services, repositoryInterfaceWithPk, repositoryImplementationType, replaceExisting);
}
}
}
@ -71,5 +75,21 @@ namespace Microsoft.Extensions.DependencyInjection
return services;
}
private static void RegisterService(
IServiceCollection services,
Type serviceType,
Type implementationType,
bool replaceExisting)
{
if (replaceExisting)
{
services.Replace(ServiceDescriptor.Transient(serviceType, implementationType));
}
else
{
services.TryAddTransient(serviceType, implementationType);
}
}
}
}

3
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/AbpRepositoryConventionalRegistrar.cs

@ -6,6 +6,9 @@ using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Domain.Repositories
{
/* Repositories are not injected by class by default.
* This class specializes repository registration to apply this rule.
*/
public class AbpRepositoryConventionalRegistrar : DefaultConventionalRegistrar
{
public static bool ExposeRepositoryClasses { get; set; }

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryRegistrarBase.cs

@ -20,7 +20,7 @@ namespace Volo.Abp.Domain.Repositories
{
foreach (var customRepository in Options.CustomRepositories)
{
Options.Services.AddDefaultRepository(customRepository.Key, customRepository.Value);
Options.Services.AddDefaultRepository(customRepository.Key, customRepository.Value, replaceExisting: true);
}
if (Options.RegisterDefaultRepositories)

2
framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo.Abp.EntityFrameworkCore.Oracle.csproj

@ -19,7 +19,7 @@
</ItemGroup>
<ItemGroup>
<!--<PackageReference Include="Oracle.EntityFrameworkCore" Version="3.19.80" />-->
<PackageReference Include="Oracle.EntityFrameworkCore" Version="5.21.1" />
</ItemGroup>
</Project>

59
framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleExtensions.cs

@ -1,26 +1,33 @@
// using JetBrains.Annotations;
// using Microsoft.EntityFrameworkCore;
// using System;
// using Oracle.EntityFrameworkCore.Infrastructure;
// using Volo.Abp.EntityFrameworkCore.DependencyInjection;
//
// namespace Volo.Abp.EntityFrameworkCore
// {
// public static class AbpDbContextConfigurationContextOracleExtensions
// {
// public static DbContextOptionsBuilder UseOracle(
// [NotNull] this AbpDbContextConfigurationContext context,
// [CanBeNull] Action<OracleDbContextOptionsBuilder> oracleOptionsAction = null)
// {
// TODO: UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
// if (context.ExistingConnection != null)
// {
// return context.DbContextOptions.UseOracle(context.ExistingConnection, oracleOptionsAction);
// }
// else
// {
// return context.DbContextOptions.UseOracle(context.ConnectionString, oracleOptionsAction);
// }
// }
// }
// }
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using System;
using Oracle.EntityFrameworkCore.Infrastructure;
using Volo.Abp.EntityFrameworkCore.DependencyInjection;
namespace Volo.Abp.EntityFrameworkCore
{
public static class AbpDbContextConfigurationContextOracleExtensions
{
public static DbContextOptionsBuilder UseOracle(
[NotNull] this AbpDbContextConfigurationContext context,
[CanBeNull] Action<OracleDbContextOptionsBuilder> oracleOptionsAction = null)
{
if (context.ExistingConnection != null)
{
return context.DbContextOptions.UseOracle(context.ExistingConnection, optionsBuilder =>
{
optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
oracleOptionsAction?.Invoke(optionsBuilder);
});
}
else
{
return context.DbContextOptions.UseOracle(context.ConnectionString, optionsBuilder =>
{
optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
oracleOptionsAction?.Invoke(optionsBuilder);
});
}
}
}
}

60
framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleExtensions.cs

@ -1,30 +1,30 @@
// using JetBrains.Annotations;
// using System;
// using Oracle.EntityFrameworkCore.Infrastructure;
//
// namespace Volo.Abp.EntityFrameworkCore
// {
// public static class AbpDbContextOptionsOracleExtensions
// {
// public static void UseOracle(
// [NotNull] this AbpDbContextOptions options,
// [CanBeNull] Action<OracleDbContextOptionsBuilder> oracleOptionsAction = null)
// {
// options.Configure(context =>
// {
// context.UseOracle(oracleOptionsAction);
// });
// }
//
// public static void UseOracle<TDbContext>(
// [NotNull] this AbpDbContextOptions options,
// [CanBeNull] Action<OracleDbContextOptionsBuilder> oracleOptionsAction = null)
// where TDbContext : AbpDbContext<TDbContext>
// {
// options.Configure<TDbContext>(context =>
// {
// context.UseOracle(oracleOptionsAction);
// });
// }
// }
// }
using JetBrains.Annotations;
using System;
using Oracle.EntityFrameworkCore.Infrastructure;
namespace Volo.Abp.EntityFrameworkCore
{
public static class AbpDbContextOptionsOracleExtensions
{
public static void UseOracle(
[NotNull] this AbpDbContextOptions options,
[CanBeNull] Action<OracleDbContextOptionsBuilder> oracleOptionsAction = null)
{
options.Configure(context =>
{
context.UseOracle(oracleOptionsAction);
});
}
public static void UseOracle<TDbContext>(
[NotNull] this AbpDbContextOptions options,
[CanBeNull] Action<OracleDbContextOptionsBuilder> oracleOptionsAction = null)
where TDbContext : AbpDbContext<TDbContext>
{
options.Configure<TDbContext>(context =>
{
context.UseOracle(oracleOptionsAction);
});
}
}
}

42
framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/Oracle/AbpEntityFrameworkCoreOracleModule.cs

@ -1,22 +1,20 @@
// using Volo.Abp.Guids;
// using Volo.Abp.Modularity;
//
// namespace Volo.Abp.EntityFrameworkCore.Oracle
// {
// [DependsOn(
// typeof(AbpEntityFrameworkCoreModule)
// )]
// public class AbpEntityFrameworkCoreOracleModule : AbpModule
// {
// public override void ConfigureServices(ServiceConfigurationContext context)
// {
// Configure<AbpSequentialGuidGeneratorOptions>(options =>
// {
// if (options.DefaultSequentialGuidType == null)
// {
// options.DefaultSequentialGuidType = SequentialGuidType.SequentialAsBinary;
// }
// });
// }
// }
// }
using Volo.Abp.Guids;
using Volo.Abp.Modularity;
namespace Volo.Abp.EntityFrameworkCore.Oracle
{
[DependsOn(typeof(AbpEntityFrameworkCoreModule))]
public class AbpEntityFrameworkCoreOracleModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpSequentialGuidGeneratorOptions>(options =>
{
if (options.DefaultSequentialGuidType == null)
{
options.DefaultSequentialGuidType = SequentialGuidType.SequentialAsBinary;
}
});
}
}
}

12
framework/src/Volo.Abp.EntityFrameworkCore/Microsoft/Extensions/DependencyInjection/AbpEfCoreServiceCollectionExtensions.cs

@ -21,7 +21,17 @@ namespace Microsoft.Extensions.DependencyInjection
foreach (var dbContextType in options.ReplacedDbContextTypes)
{
services.Replace(ServiceDescriptor.Transient(dbContextType, typeof(TDbContext)));
services.Replace(
ServiceDescriptor.Transient(
dbContextType,
sp => sp.GetRequiredService(typeof(TDbContext))
)
);
services.Configure<AbpDbContextOptions>(opts =>
{
opts.DbContextReplacements[dbContextType] = typeof(TDbContext);
});
}
new EfCoreRepositoryRegistrar(options).AddRepositories();

2
framework/src/Volo.Abp.EntityFrameworkCore/Properties/AssemblyInfo.cs

@ -1,4 +1,5 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@ -8,6 +9,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Volo.Abp.EntityFrameworkCore")]
[assembly: AssemblyTrademark("")]
[assembly: InternalsVisibleTo("Volo.Abp.EntityFrameworkCore.Tests")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from

33
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs

@ -7,19 +7,22 @@ namespace Volo.Abp.EntityFrameworkCore
{
public class AbpDbContextOptions
{
internal List<Action<AbpDbContextConfigurationContext>> DefaultPreConfigureActions { get; set; }
internal List<Action<AbpDbContextConfigurationContext>> DefaultPreConfigureActions { get; }
internal Action<AbpDbContextConfigurationContext> DefaultConfigureAction { get; set; }
internal Dictionary<Type, List<object>> PreConfigureActions { get; set; }
internal Dictionary<Type, List<object>> PreConfigureActions { get; }
internal Dictionary<Type, object> ConfigureActions { get; set; }
internal Dictionary<Type, object> ConfigureActions { get; }
internal Dictionary<Type, Type> DbContextReplacements { get; }
public AbpDbContextOptions()
{
DefaultPreConfigureActions = new List<Action<AbpDbContextConfigurationContext>>();
PreConfigureActions = new Dictionary<Type, List<object>>();
ConfigureActions = new Dictionary<Type, object>();
DbContextReplacements = new Dictionary<Type, Type>();
}
public void PreConfigure([NotNull] Action<AbpDbContextConfigurationContext> action)
@ -57,5 +60,29 @@ namespace Volo.Abp.EntityFrameworkCore
ConfigureActions[typeof(TDbContext)] = action;
}
internal Type GetReplacedTypeOrSelf(Type dbContextType)
{
var replacementType = dbContextType;
while (true)
{
if (DbContextReplacements.TryGetValue(replacementType, out var foundType))
{
if (foundType == dbContextType)
{
throw new AbpException(
"Circular DbContext replacement found for " +
dbContextType.AssemblyQualifiedName
);
}
replacementType = foundType;
}
else
{
return replacementType;
}
}
}
}
}

7
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreDatabaseApi.cs

@ -4,12 +4,11 @@ using Volo.Abp.EntityFrameworkCore;
namespace Volo.Abp.Uow.EntityFrameworkCore
{
public class EfCoreDatabaseApi<TDbContext> : IDatabaseApi, ISupportsSavingChanges
where TDbContext : IEfCoreDbContext
public class EfCoreDatabaseApi : IDatabaseApi, ISupportsSavingChanges
{
public TDbContext DbContext { get; }
public IEfCoreDbContext DbContext { get; }
public EfCoreDatabaseApi(TDbContext dbContext)
public EfCoreDatabaseApi(IEfCoreDbContext dbContext)
{
DbContext = dbContext;
}

22
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.DependencyInjection;
@ -14,8 +15,6 @@ using Volo.Abp.Threading;
namespace Volo.Abp.Uow.EntityFrameworkCore
{
//TODO: Implement logic in DefaultDbContextResolver.Resolve in old ABP.
public class UnitOfWorkDbContextProvider<TDbContext> : IDbContextProvider<TDbContext>
where TDbContext : IEfCoreDbContext
{
@ -25,17 +24,20 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
private readonly IConnectionStringResolver _connectionStringResolver;
private readonly ICancellationTokenProvider _cancellationTokenProvider;
private readonly ICurrentTenant _currentTenant;
private readonly AbpDbContextOptions _options;
public UnitOfWorkDbContextProvider(
IUnitOfWorkManager unitOfWorkManager,
IConnectionStringResolver connectionStringResolver,
ICancellationTokenProvider cancellationTokenProvider,
ICurrentTenant currentTenant)
ICurrentTenant currentTenant,
IOptions<AbpDbContextOptions> options)
{
_unitOfWorkManager = unitOfWorkManager;
_connectionStringResolver = connectionStringResolver;
_cancellationTokenProvider = cancellationTokenProvider;
_currentTenant = currentTenant;
_options = options.Value;
Logger = NullLogger<UnitOfWorkDbContextProvider<TDbContext>>.Instance;
}
@ -63,15 +65,16 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
var connectionStringName = ConnectionStringNameAttribute.GetConnStringName<TDbContext>();
var connectionString = ResolveConnectionString(connectionStringName);
var dbContextKey = $"{typeof(TDbContext).FullName}_{connectionString}";
var targetDbContextType = _options.GetReplacedTypeOrSelf(typeof(TDbContext));
var dbContextKey = $"{targetDbContextType.FullName}_{connectionString}";
var databaseApi = unitOfWork.GetOrAddDatabaseApi(
dbContextKey,
() => new EfCoreDatabaseApi<TDbContext>(
() => new EfCoreDatabaseApi(
CreateDbContext(unitOfWork, connectionStringName, connectionString)
));
return ((EfCoreDatabaseApi<TDbContext>)databaseApi).DbContext;
return (TDbContext)((EfCoreDatabaseApi)databaseApi).DbContext;
}
public async Task<TDbContext> GetDbContextAsync()
@ -85,20 +88,21 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
var connectionStringName = ConnectionStringNameAttribute.GetConnStringName<TDbContext>();
var connectionString = await ResolveConnectionStringAsync(connectionStringName);
var dbContextKey = $"{typeof(TDbContext).FullName}_{connectionString}";
var targetDbContextType = _options.GetReplacedTypeOrSelf(typeof(TDbContext));
var dbContextKey = $"{targetDbContextType.FullName}_{connectionString}";
var databaseApi = unitOfWork.FindDatabaseApi(dbContextKey);
if (databaseApi == null)
{
databaseApi = new EfCoreDatabaseApi<TDbContext>(
databaseApi = new EfCoreDatabaseApi(
await CreateDbContextAsync(unitOfWork, connectionStringName, connectionString)
);
unitOfWork.AddDatabaseApi(dbContextKey, databaseApi);
}
return ((EfCoreDatabaseApi<TDbContext>)databaseApi).DbContext;
return (TDbContext)((EfCoreDatabaseApi)databaseApi).DbContext;
}
private TDbContext CreateDbContext(IUnitOfWork unitOfWork, string connectionStringName, string connectionString)

1
framework/src/Volo.Abp.MemoryDb/Volo/Abp/MemoryDb/AbpMemoryDbModule.cs

@ -1,7 +1,6 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Volo.Abp.Domain;
using Volo.Abp.Domain.Repositories.MemoryDb;
using Volo.Abp.Json;
using Volo.Abp.Modularity;
using Volo.Abp.Uow.MemoryDb;

2
framework/src/Volo.Abp.Minify/Volo.Abp.Minify.csproj

@ -19,7 +19,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="NUglify" Version="1.11.4" />
<PackageReference Include="NUglify" Version="1.13.2" />
</ItemGroup>
</Project>

15
framework/src/Volo.Abp.MongoDB/Microsoft/Extensions/DependencyInjection/AbpMongoDbServiceCollectionExtensions.cs

@ -17,6 +17,21 @@ namespace Microsoft.Extensions.DependencyInjection
{
services.Replace(ServiceDescriptor.Transient(dbContextType, typeof(TMongoDbContext)));
}
foreach (var dbContextType in options.ReplacedDbContextTypes)
{
services.Replace(
ServiceDescriptor.Transient(
dbContextType,
sp => sp.GetRequiredService(typeof(TMongoDbContext))
)
);
services.Configure<AbpMongoDbContextOptions>(opts =>
{
opts.DbContextReplacements[dbContextType] = typeof(TMongoDbContext);
});
}
new MongoDbRepositoryRegistrar(options).AddRepositories();

2
framework/src/Volo.Abp.MongoDB/Properties/AssemblyInfo.cs

@ -1,4 +1,5 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@ -8,6 +9,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Volo.Abp.MongoDB")]
[assembly: AssemblyTrademark("")]
[assembly: InternalsVisibleTo("Volo.Abp.MongoDB.Tests")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from

39
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbContextOptions.cs

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
namespace Volo.Abp.MongoDB
{
public class AbpMongoDbContextOptions
{
internal Dictionary<Type, Type> DbContextReplacements { get; }
public AbpMongoDbContextOptions()
{
DbContextReplacements = new Dictionary<Type, Type>();
}
internal Type GetReplacedTypeOrSelf(Type dbContextType)
{
var replacementType = dbContextType;
while (true)
{
if (DbContextReplacements.TryGetValue(replacementType, out var foundType))
{
if (foundType == dbContextType)
{
throw new AbpException(
"Circular DbContext replacement found for " +
dbContextType.AssemblyQualifiedName
);
}
replacementType = foundType;
}
else
{
return replacementType;
}
}
}
}
}

10
framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/MongoDbDatabaseApi.cs

@ -1,10 +1,12 @@
namespace Volo.Abp.Uow.MongoDB
using Volo.Abp.MongoDB;
namespace Volo.Abp.Uow.MongoDB
{
public class MongoDbDatabaseApi<TMongoDbContext> : IDatabaseApi
public class MongoDbDatabaseApi : IDatabaseApi
{
public TMongoDbContext DbContext { get; }
public IAbpMongoDbContext DbContext { get; }
public MongoDbDatabaseApi(TMongoDbContext dbContext)
public MongoDbDatabaseApi(IAbpMongoDbContext dbContext)
{
DbContext = dbContext;
}

20
framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using MongoDB.Bson;
using MongoDB.Driver;
using Volo.Abp.Data;
@ -22,17 +23,20 @@ namespace Volo.Abp.Uow.MongoDB
private readonly IConnectionStringResolver _connectionStringResolver;
private readonly ICancellationTokenProvider _cancellationTokenProvider;
private readonly ICurrentTenant _currentTenant;
private readonly AbpMongoDbContextOptions _options;
public UnitOfWorkMongoDbContextProvider(
IUnitOfWorkManager unitOfWorkManager,
IConnectionStringResolver connectionStringResolver,
ICancellationTokenProvider cancellationTokenProvider,
ICurrentTenant currentTenant)
ICurrentTenant currentTenant,
IOptions<AbpMongoDbContextOptions> options)
{
_unitOfWorkManager = unitOfWorkManager;
_connectionStringResolver = connectionStringResolver;
_cancellationTokenProvider = cancellationTokenProvider;
_currentTenant = currentTenant;
_options = options.Value;
Logger = NullLogger<UnitOfWorkMongoDbContextProvider<TMongoDbContext>>.Instance;
}
@ -59,7 +63,8 @@ namespace Volo.Abp.Uow.MongoDB
}
var connectionString = ResolveConnectionString();
var dbContextKey = $"{typeof(TMongoDbContext).FullName}_{connectionString}";
var targetDbContextType = _options.GetReplacedTypeOrSelf(typeof(TMongoDbContext));
var dbContextKey = $"{targetDbContextType.FullName}_{connectionString}";
var mongoUrl = new MongoUrl(connectionString);
var databaseName = mongoUrl.DatabaseName;
@ -71,9 +76,9 @@ namespace Volo.Abp.Uow.MongoDB
//TODO: Create only single MongoDbClient per connection string in an application (extract MongoClientCache for example).
var databaseApi = unitOfWork.GetOrAddDatabaseApi(
dbContextKey,
() => new MongoDbDatabaseApi<TMongoDbContext>(CreateDbContext(unitOfWork, mongoUrl, databaseName)));
() => new MongoDbDatabaseApi(CreateDbContext(unitOfWork, mongoUrl, databaseName)));
return ((MongoDbDatabaseApi<TMongoDbContext>) databaseApi).DbContext;
return (TMongoDbContext)((MongoDbDatabaseApi) databaseApi).DbContext;
}
public async Task<TMongoDbContext> GetDbContextAsync(CancellationToken cancellationToken = default)
@ -86,7 +91,8 @@ namespace Volo.Abp.Uow.MongoDB
}
var connectionString = await ResolveConnectionStringAsync();
var dbContextKey = $"{typeof(TMongoDbContext).FullName}_{connectionString}";
var targetDbContextType = _options.GetReplacedTypeOrSelf(typeof(TMongoDbContext));
var dbContextKey = $"{targetDbContextType.FullName}_{connectionString}";
var mongoUrl = new MongoUrl(connectionString);
var databaseName = mongoUrl.DatabaseName;
@ -99,7 +105,7 @@ namespace Volo.Abp.Uow.MongoDB
var databaseApi = unitOfWork.FindDatabaseApi(dbContextKey);
if (databaseApi == null)
{
databaseApi = new MongoDbDatabaseApi<TMongoDbContext>(
databaseApi = new MongoDbDatabaseApi(
await CreateDbContextAsync(
unitOfWork,
mongoUrl,
@ -111,7 +117,7 @@ namespace Volo.Abp.Uow.MongoDB
unitOfWork.AddDatabaseApi(dbContextKey, databaseApi);
}
return ((MongoDbDatabaseApi<TMongoDbContext>) databaseApi).DbContext;
return (TMongoDbContext)((MongoDbDatabaseApi) databaseApi).DbContext;
}
[Obsolete("Use CreateDbContextAsync")]

2
framework/src/Volo.Abp.Swashbuckle/Volo.Abp.Swashbuckle.csproj

@ -15,7 +15,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.0.5" />
</ItemGroup>
<ItemGroup>

26
framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DbContext_Replace_Tests.cs

@ -1,9 +1,11 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Shouldly;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EntityFrameworkCore.TestApp.ThirdDbContext;
using Volo.Abp.TestApp.Domain;
using Volo.Abp.TestApp.EntityFrameworkCore;
using Volo.Abp.Uow;
using Xunit;
@ -13,24 +15,40 @@ namespace Volo.Abp.EntityFrameworkCore
public class DbContext_Replace_Tests : EntityFrameworkCoreTestBase
{
private readonly IBasicRepository<ThirdDbContextDummyEntity, Guid> _dummyRepository;
private readonly IPersonRepository _personRepository;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly AbpDbContextOptions _options;
public DbContext_Replace_Tests()
{
_dummyRepository = ServiceProvider.GetRequiredService<IBasicRepository<ThirdDbContextDummyEntity, Guid>>();
_unitOfWorkManager = ServiceProvider.GetRequiredService<IUnitOfWorkManager>();
_dummyRepository = GetRequiredService<IBasicRepository<ThirdDbContextDummyEntity, Guid>>();
_personRepository = GetRequiredService<IPersonRepository>();
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
_options = GetRequiredService<IOptions<AbpDbContextOptions>>().Value;
}
[Fact]
public async Task Should_Replace_DbContext()
{
_options.GetReplacedTypeOrSelf(typeof(IThirdDbContext)).ShouldBe(typeof(TestAppDbContext));
(ServiceProvider.GetRequiredService<IThirdDbContext>() is TestAppDbContext).ShouldBeTrue();
using (var uow = _unitOfWorkManager.Begin())
{
((await _dummyRepository.GetDbContextAsync()) is IThirdDbContext).ShouldBeTrue();
((await _dummyRepository.GetDbContextAsync()) is TestAppDbContext).ShouldBeTrue();
var instance1 = await _dummyRepository.GetDbContextAsync();
(instance1 is IThirdDbContext).ShouldBeTrue();
var instance2 = await _dummyRepository.GetDbContextAsync();
(instance2 is TestAppDbContext).ShouldBeTrue();
var instance3 = await _personRepository.GetDbContextAsync();
(instance3 is TestAppDbContext).ShouldBeTrue();
// All instances should be the same!
instance3.ShouldBe(instance1);
instance3.ShouldBe(instance2);
await uow.CompleteAsync();
}
}

2
framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/TestApp/MongoDb/TestAppMongoDbContext.cs

@ -15,7 +15,7 @@ namespace Volo.Abp.TestApp.MongoDB
public IMongoCollection<City> Cities => Collection<City>();
protected override void CreateModel(IMongoModelBuilder modelBuilder)
protected internal override void CreateModel(IMongoModelBuilder modelBuilder)
{
base.CreateModel(modelBuilder);

5
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/RegisterDto.cs

@ -1,11 +1,12 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Auditing;
using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Validation;
namespace Volo.Abp.Account
{
public class RegisterDto
public class RegisterDto : ExtensibleObject
{
[Required]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
@ -25,4 +26,4 @@ namespace Volo.Abp.Account
[Required]
public string AppName { get; set; }
}
}
}

3
modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs

@ -6,6 +6,7 @@ using Volo.Abp.Account.Localization;
using Volo.Abp.Account.Settings;
using Volo.Abp.Application.Services;
using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Settings;
namespace Volo.Abp.Account
@ -42,6 +43,8 @@ namespace Volo.Abp.Account
var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.EmailAddress, CurrentTenant.Id);
input.MapExtraPropertiesTo(user);
(await UserManager.CreateAsync(user, input.Password)).CheckErrors();
await UserManager.SetEmailAsync(user,input.EmailAddress);

1
modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs

@ -13,7 +13,6 @@ namespace Volo.CmsKit
OneTimeRunner.Run(() =>
{
GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll();
GlobalFeatureManager.Instance.Modules.CmsKit().Disable<PagesFeature>();
});
}
}

1960
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219084931_PageSlugChange.Designer.cs

File diff suppressed because it is too large

46
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219084931_PageSlugChange.cs

@ -0,0 +1,46 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class PageSlugChange : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CmsPages",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Title = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Slug = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CmsPages", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_CmsPages_TenantId_Slug",
table: "CmsPages",
columns: new[] { "TenantId", "Slug" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CmsPages");
}
}
}

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

File diff suppressed because it is too large

1
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj

@ -10,7 +10,6 @@
<ItemGroup>
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" />

10
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogLookupDto.cs

@ -1,10 +0,0 @@
using System;
namespace Volo.CmsKit.Admin.Blogs
{
public class BlogLookupDto
{
public Guid Id { get; set; }
public string Name { get; set; }
}
}

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateUpdateBlogPostDto.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogPostDto.cs

@ -5,7 +5,7 @@ using Volo.CmsKit.Blogs;
namespace Volo.CmsKit.Admin.Blogs
{
public class CreateUpdateBlogPostDto
public class CreateBlogPostDto
{
[Required]
public Guid BlogId { get; set; }

3
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogPostAdminAppService.cs

@ -11,7 +11,8 @@ namespace Volo.CmsKit.Admin.Blogs
BlogPostDto,
Guid,
PagedAndSortedResultRequestDto,
CreateUpdateBlogPostDto>
CreateBlogPostDto,
UpdateBlogPostDto>
{
Task<BlogPostDto> GetBySlugAsync(string blogSlug, string slug);

24
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogPostDto.cs

@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
using Volo.CmsKit.Blogs;
namespace Volo.CmsKit.Admin.Blogs
{
public class UpdateBlogPostDto
{
[Required]
[DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxTitleLength))]
public string Title { get; set; }
[Required]
[DynamicStringLength(
typeof(BlogPostConsts),
nameof(BlogPostConsts.MaxSlugLength),
nameof(BlogPostConsts.MinSlugLength))]
public string Slug { get; set; }
[DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxShortDescriptionLength))]
public string ShortDescription { get; set; }
}
}

4
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CreatePageInputDto.cs

@ -12,8 +12,8 @@ namespace Volo.CmsKit.Admin.Pages
public string Title { get; set; }
[Required]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxUrlLength))]
public string Url { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))]
public string Slug { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxDescriptionLength))]
public string Description { get; set; }

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/PageDto.cs

@ -7,7 +7,7 @@ namespace Volo.CmsKit.Admin.Pages
{
public string Title { get; set; }
public string Url { get; set; }
public string Slug { get; set; }
public string Description { get; set; }
}

4
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/UpdatePageInputDto.cs

@ -12,8 +12,8 @@ namespace Volo.CmsKit.Admin.Pages
public string Title { get; set; }
[Required]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxUrlLength))]
public string Url { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))]
public string Slug { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxDescriptionLength))]
public string Description { get; set; }

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

@ -23,7 +23,8 @@ namespace Volo.CmsKit.Admin.Blogs
BlogPostDto,
Guid,
PagedAndSortedResultRequestDto,
CreateUpdateBlogPostDto>
CreateBlogPostDto,
UpdateBlogPostDto>
, IBlogPostAdminAppService
{
protected readonly IBlogPostManager BlogPostManager;
@ -63,7 +64,7 @@ namespace Volo.CmsKit.Admin.Blogs
}
[Authorize(CmsKitAdminPermissions.BlogPosts.Create)]
public override async Task<BlogPostDto> CreateAsync(CreateUpdateBlogPostDto input)
public override async Task<BlogPostDto> CreateAsync(CreateBlogPostDto input)
{
_ = await UserLookupService.GetByIdAsync(CurrentUser.GetId());
@ -80,7 +81,7 @@ namespace Volo.CmsKit.Admin.Blogs
}
[Authorize(CmsKitAdminPermissions.BlogPosts.Update)]
public override async Task<BlogPostDto> UpdateAsync(Guid id, CreateUpdateBlogPostDto input)
public override async Task<BlogPostDto> UpdateAsync(Guid id, UpdateBlogPostDto input)
{
var blogPost = await BlogPostRepository.GetAsync(id);

3
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs

@ -24,7 +24,8 @@ namespace Volo.CmsKit.Admin
CreateMap<ContentUpdateDto, Content>(MemberList.Source);
CreateMap<BlogPost, BlogPostDto>(MemberList.Destination);
CreateMap<CreateUpdateBlogPostDto, BlogPost>(MemberList.Source);
CreateMap<CreateBlogPostDto, BlogPost>(MemberList.Source);
CreateMap<UpdateBlogPostDto, BlogPost>(MemberList.Source);
CreateMap<Blog, BlogDto>(MemberList.Destination)
.ReverseMap();

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Contents/ContentAdminAppService.cs

@ -56,7 +56,7 @@ namespace Volo.CmsKit.Admin.Contents
return MapToGetOutputDto(entity);
}
public async Task<ContentDto> GetAsync(
public virtual async Task<ContentDto> GetAsync(
[NotNull] string entityType,
[NotNull] string entityId)
{

21
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Pages/PageAdminAppService.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Application.Dtos;
using Volo.Abp.GlobalFeatures;
@ -14,7 +15,7 @@ namespace Volo.CmsKit.Admin.Pages
[Authorize(CmsKitAdminPermissions.Pages.Default)]
public class PageAdminAppService : CmsKitAdminAppServiceBase, IPageAdminAppService
{
protected readonly IPageRepository PageRepository;
protected IPageRepository PageRepository { get; }
public PageAdminAppService(IPageRepository pageRepository)
{
@ -47,9 +48,9 @@ namespace Volo.CmsKit.Admin.Pages
[Authorize(CmsKitAdminPermissions.Pages.Create)]
public virtual async Task<PageDto> CreateAsync(CreatePageInputDto input)
{
await CheckPageUrlAsync(input.Url);
await CheckPageSlugAsync(input.Slug);
var page = new Page(GuidGenerator.Create(), input.Title, input.Url, input.Description, CurrentTenant?.Id);
var page = new Page(GuidGenerator.Create(), input.Title, input.Slug, input.Description, CurrentTenant?.Id);
await PageRepository.InsertAsync(page);
@ -61,13 +62,13 @@ namespace Volo.CmsKit.Admin.Pages
{
var page = await PageRepository.GetAsync(id);
if (page.Url != input.Url)
if (page.Slug != input.Slug)
{
await CheckPageUrlAsync(input.Url);
await CheckPageSlugAsync(input.Slug);
}
page.Title = input.Title;
page.Url = input.Url;
page.SetTitle(input.Title);
page.SetSlug(input.Slug);
page.Description = input.Description;
await PageRepository.UpdateAsync(page);
@ -81,11 +82,11 @@ namespace Volo.CmsKit.Admin.Pages
await PageRepository.DeleteAsync(id);
}
protected virtual async Task CheckPageUrlAsync(string url)
protected virtual async Task CheckPageSlugAsync(string slug)
{
if (await PageRepository.ExistsAsync(url))
if (await PageRepository.ExistsAsync(slug))
{
throw new PageUrlAlreadyExistException(url);
throw new PageSlugAlreadyExistsException(slug);
}
}
}

55
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/EntityTagAdminAppService.cs

@ -1,19 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using Volo.CmsKit.Admin.Tags;
using Volo.CmsKit.Tags;
namespace Volo.CmsKit.Admin.Tags
{
public class EntityTagAdminAppService : CmsKitAdminAppServiceBase, IEntityTagAdminAppService
{
protected readonly ITagDefinitionStore _tagDefinitionStore;
protected readonly IEntityTagManager _entityTagManager;
protected readonly ITagManager _tagManager;
protected readonly ITagRepository _tagRepository;
protected readonly IEntityTagRepository _entityTagRepository;
protected ITagDefinitionStore TagDefinitionStore { get; }
protected IEntityTagManager EntityTagManager { get; }
protected ITagManager TagManager { get; }
protected ITagRepository TagRepository { get; }
protected IEntityTagRepository EntityTagRepository { get; }
public EntityTagAdminAppService(
ITagDefinitionStore tagDefinitionStore,
@ -22,60 +20,61 @@ namespace Volo.CmsKit.Admin.Tags
ITagRepository tagRepository,
IEntityTagRepository entityTagRepository)
{
_tagDefinitionStore = tagDefinitionStore;
_entityTagManager = entityTagManager;
_tagManager = tagManager;
_tagRepository = tagRepository;
_entityTagRepository = entityTagRepository;
TagDefinitionStore = tagDefinitionStore;
EntityTagManager = entityTagManager;
TagManager = tagManager;
TagRepository = tagRepository;
EntityTagRepository = entityTagRepository;
}
public async Task AddTagToEntityAsync(EntityTagCreateDto input)
public virtual async Task AddTagToEntityAsync(EntityTagCreateDto input)
{
var definition = await _tagDefinitionStore.GetTagEntityTypeDefinitionsAsync(input.EntityType);
var definition = await TagDefinitionStore.GetTagEntityTypeDefinitionsAsync(input.EntityType);
await CheckPolicyAsync(definition.CreatePolicy);
var tag = await _tagManager.GetOrAddAsync(input.EntityType, input.TagName, CurrentTenant?.Id);
var tag = await TagManager.GetOrAddAsync(input.EntityType, input.TagName, CurrentTenant?.Id);
await _entityTagManager.AddTagToEntityAsync(
await EntityTagManager.AddTagToEntityAsync(
tag.Id,
input.EntityType,
input.EntityId,
CurrentTenant?.Id);
}
public async Task RemoveTagFromEntityAsync(EntityTagRemoveDto input)
public virtual async Task RemoveTagFromEntityAsync(EntityTagRemoveDto input)
{
var definition = await _tagDefinitionStore.GetTagEntityTypeDefinitionsAsync(input.EntityType);
var definition = await TagDefinitionStore.GetTagEntityTypeDefinitionsAsync(input.EntityType);
await CheckPolicyAsync(definition.DeletePolicy);
await _entityTagManager.RemoveTagFromEntityAsync(
await EntityTagManager.RemoveTagFromEntityAsync(
input.TagId,
input.EntityType,
input.EntityId,
CurrentTenant?.Id);
}
public async Task SetEntityTagsAsync(EntityTagSetDto input)
public virtual async Task SetEntityTagsAsync(EntityTagSetDto input)
{
var definition = await _tagDefinitionStore.GetTagEntityTypeDefinitionsAsync(input.EntityType);
var definition = await TagDefinitionStore.GetTagEntityTypeDefinitionsAsync(input.EntityType);
await CheckPolicyAsync(definition.UpdatePolicy);
var existingTags = await _tagRepository.GetAllRelatedTagsAsync(input.EntityType, input.EntityId, CurrentTenant?.Id);
var existingTags =
await TagRepository.GetAllRelatedTagsAsync(input.EntityType, input.EntityId, CurrentTenant?.Id);
var deletedTags = existingTags.Where(x => !input.Tags.Contains(x.Name)).ToList();
var addedTags = input.Tags.Where(x => !existingTags.Any(a => a.Name == x));
await _entityTagRepository.DeleteManyAsync(deletedTags.Select(s => s.Id).ToArray());
await EntityTagRepository.DeleteManyAsync(deletedTags.Select(s => s.Id).ToArray());
foreach (var addedTag in addedTags)
{
var tag = await _tagManager.GetOrAddAsync(input.EntityType, addedTag, CurrentTenant?.Id);
var tag = await TagManager.GetOrAddAsync(input.EntityType, addedTag, CurrentTenant?.Id);
await _entityTagManager.AddTagToEntityAsync(tag.Id, input.EntityType, input.EntityId, CurrentTenant?.Id);
}
await EntityTagManager.AddTagToEntityAsync(tag.Id, input.EntityType, input.EntityId, CurrentTenant?.Id);
}
}
}
}
}

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/TagAdminAppService.cs

@ -72,7 +72,7 @@ namespace Volo.CmsKit.Admin.Tags
x.EntityType.ToLower().Contains(input.Filter));
}
public async Task<List<TagDefinitionDto>> GetTagDefinitionsAsync()
public virtual async Task<List<TagDefinitionDto>> GetTagDefinitionsAsync()
{
var definitions = await TagManager.GetTagDefinitionsAsync();

4
modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogPostAdminController.cs

@ -31,7 +31,7 @@ namespace Volo.CmsKit.Admin.Blogs
[HttpPost]
[Authorize(CmsKitAdminPermissions.BlogPosts.Create)]
public virtual Task<BlogPostDto> CreateAsync(CreateUpdateBlogPostDto input)
public virtual Task<BlogPostDto> CreateAsync(CreateBlogPostDto input)
{
return BlogPostAdminAppService.CreateAsync(input);
}
@ -107,7 +107,7 @@ namespace Volo.CmsKit.Admin.Blogs
[HttpPut]
[Route("{id}")]
[Authorize(CmsKitAdminPermissions.BlogPosts.Update)]
public virtual Task<BlogPostDto> UpdateAsync(Guid id, CreateUpdateBlogPostDto input)
public virtual Task<BlogPostDto> UpdateAsync(Guid id, UpdateBlogPostDto input)
{
return BlogPostAdminAppService.UpdateAsync(id, input);
}

2
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitErrorCodes.cs

@ -12,7 +12,7 @@
public static class Pages
{
public const string UrlAlreadyExist = "CmsKit:Page:0001";
public const string SlugAlreadyExist = "CmsKit:Page:0001";
}
public static class Blogs

2
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json

@ -3,7 +3,7 @@
"texts": {
"CmsKit:0002": "Content already exists!",
"CmsKit:0003": "The entity {0} is not taggable.",
"CmsKit:BlogPost:0001": "Same url slug already exists!",
"CmsKit:BlogPost:0001": "The given slug already exists!",
"CmsKit:Media:0001": "'{Name}' is not a valid media name.",
"CmsKit:Page:0001": "The given url ({0}) already exists.",
"CmsKit:Tag:0002": "The entity is not taggable!",

2
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Pages/PageConsts.cs

@ -4,7 +4,7 @@
{
public static int MaxTitleLength { get; set; } = 256;
public static int MaxUrlLength { get; set; } = 256;
public static int MaxSlugLength { get; set; } = 256;
public static int MaxDescriptionLength { get; set; } = 512;
}

18
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/Content.cs

@ -8,12 +8,16 @@ namespace Volo.CmsKit.Contents
{
public class Content : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
[CanBeNull]
public virtual Guid? TenantId { get; protected set; }
[NotNull]
public virtual string EntityType { get; protected set; }
public virtual string EntityId { get; set; }
[NotNull]
public virtual string EntityId { get; protected set; }
[NotNull]
public virtual string Value { get; protected set; }
protected Content()
@ -23,16 +27,22 @@ namespace Volo.CmsKit.Contents
public Content(Guid id, [NotNull] string entityType, [NotNull] string entityId, [NotNull] string value, Guid? tenantId = null) : base(id)
{
EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), ContentConsts.MaxEntityTypeLength);
EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), ContentConsts.MaxEntityIdLength);
SetValue(value);
EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), ContentConsts.MaxEntityTypeLength);
Value = Check.NotNullOrEmpty(value, nameof(value), ContentConsts.MaxValueLength);
TenantId = tenantId;
}
public void SetValue([NotNull] string value)
{
Value = Check.NotNullOrWhiteSpace(value, nameof(value), ContentConsts.MaxValueLength);
Value = Check.NotNullOrEmpty(value, nameof(value), ContentConsts.MaxValueLength);
}
public void SetEntity([NotNull] string entityType, [NotNull] string entityId)
{
EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), ContentConsts.MaxEntityTypeLength);
EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), ContentConsts.MaxEntityIdLength);
}
}
}

9
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/ContentManager.cs

@ -18,14 +18,15 @@ namespace Volo.CmsKit.Contents
ContentRepository = contentRepository;
}
public async Task<Content> InsertAsync(Content content, CancellationToken cancellationToken = default)
public virtual async Task<Content> InsertAsync(Content content, CancellationToken cancellationToken = default)
{
if (await ContentRepository.ExistsAsync(content.EntityType, content.EntityId, content.TenantId, cancellationToken))
if (await ContentRepository.ExistsAsync(content.EntityType, content.EntityId, content.TenantId,
cancellationToken))
{
throw new ContentAlreadyExistException(content.EntityType, content.EntityId);
}
return await ContentRepository.InsertAsync(content);
return await ContentRepository.InsertAsync(content, cancellationToken: cancellationToken);
}
}
}
}

6
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/IPageRepository.cs

@ -17,10 +17,10 @@ namespace Volo.CmsKit.Pages
string sorting = null,
CancellationToken cancellationToken = default);
Task<Page> GetByUrlAsync(string url, CancellationToken cancellationToken = default);
Task<Page> GetBySlugAsync(string slug, CancellationToken cancellationToken = default);
Task<Page> FindByUrlAsync(string url, CancellationToken cancellationToken = default);
Task<Page> FindBySlugAsync(string slug, CancellationToken cancellationToken = default);
Task<bool> ExistsAsync(string url, CancellationToken cancellationToken = default);
Task<bool> ExistsAsync(string slug, CancellationToken cancellationToken = default);
}
}

32
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/Page.cs

@ -8,26 +8,36 @@ namespace Volo.CmsKit.Pages
{
public class Page : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
public Guid? TenantId { get; set; }
[CanBeNull] public virtual Guid? TenantId { get; set; }
public virtual string Title { get; set; }
[NotNull] public virtual string Title { get; protected set; }
[NotNull] public virtual string Slug { get; protected set; }
[CanBeNull] public virtual string Description { get; set; }
public virtual string Url { get; set; }
public virtual string Description { get; set; }
protected Page()
{
}
public Page(Guid id, [NotNull] string title, [NotNull] string url, [CanBeNull] string description = null, Guid? tenantId = null) : base(id)
public Page(Guid id, [NotNull] string title, [NotNull] string slug, [CanBeNull] string description = null,
Guid? tenantId = null) : base(id)
{
Title = Check.NotNullOrWhiteSpace(title, nameof(title), PageConsts.MaxTitleLength);
Url = Check.NotNullOrWhiteSpace(url, nameof(url), PageConsts.MaxUrlLength);
Title = Check.NotNullOrEmpty(title, nameof(title), PageConsts.MaxTitleLength);
Slug = Check.NotNullOrEmpty(slug, nameof(slug), PageConsts.MaxSlugLength);
Description = Check.Length(description, nameof(description), PageConsts.MaxDescriptionLength);
TenantId = tenantId;
}
public virtual void SetTitle(string title)
{
Title = Check.NotNullOrEmpty(title, nameof(title), PageConsts.MaxTitleLength);
}
public virtual void SetSlug(string slug)
{
Slug = Check.NotNullOrEmpty(slug, nameof(slug), PageConsts.MaxSlugLength);
}
}
}

23
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageSlugAlreadyExistsException.cs

@ -0,0 +1,23 @@
using System;
using System.Runtime.Serialization;
using JetBrains.Annotations;
using Volo.Abp;
namespace Volo.CmsKit.Pages
{
[Serializable]
public class PageSlugAlreadyExistsException : BusinessException
{
public PageSlugAlreadyExistsException([NotNull] string slug)
{
Code = CmsKitErrorCodes.Pages.SlugAlreadyExist;
WithData(nameof(Page.Slug), slug);
}
public PageSlugAlreadyExistsException(SerializationInfo serializationInfo, StreamingContext context)
: base(serializationInfo, context)
{
}
}
}

23
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageUrlAlreadyExistException.cs

@ -1,23 +0,0 @@
using System;
using System.Runtime.Serialization;
using JetBrains.Annotations;
using Volo.Abp;
namespace Volo.CmsKit.Pages
{
[Serializable]
public class PageUrlAlreadyExistException : BusinessException
{
public PageUrlAlreadyExistException([NotNull] string url)
{
Code = CmsKitErrorCodes.Pages.UrlAlreadyExist;
WithData(nameof(Page.Url), url);
}
public PageUrlAlreadyExistException(SerializationInfo serializationInfo, StreamingContext context)
: base(serializationInfo, context)
{
}
}
}

1
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/CmsKitTagOptions.cs

@ -1,5 +1,4 @@
using JetBrains.Annotations;
using Volo.CmsKit.Tags;
namespace Volo.CmsKit.Tags
{

15
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/DefaultTagDefinitionStore.cs

@ -11,11 +11,11 @@ namespace Volo.CmsKit.Tags
{
public class DefaultTagDefinitionStore : ITagDefinitionStore, ITransientDependency
{
private readonly CmsKitTagOptions options;
protected CmsKitTagOptions CmsKitTagOptions { get; }
public DefaultTagDefinitionStore(IOptions<CmsKitTagOptions> options)
{
this.options = options.Value;
CmsKitTagOptions = options.Value;
}
/// <summary>
@ -28,7 +28,8 @@ namespace Volo.CmsKit.Tags
{
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
var result = options.EntityTypes.SingleOrDefault(x => x.EntityType == entityType) ?? throw new EntityNotTaggableException(entityType);
var result = CmsKitTagOptions.EntityTypes.SingleOrDefault(x => x.EntityType == entityType) ??
throw new EntityNotTaggableException(entityType);
return Task.FromResult(result);
}
@ -38,7 +39,7 @@ namespace Volo.CmsKit.Tags
/// </summary>
public virtual Task<List<TagEntityTypeDefiniton>> GetTagEntityTypeDefinitionListAsync()
{
return Task.FromResult(options.EntityTypes.ToList());
return Task.FromResult(CmsKitTagOptions.EntityTypes.ToList());
}
/// <summary>
@ -50,9 +51,9 @@ namespace Volo.CmsKit.Tags
{
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
var definition = options.EntityTypes.SingleOrDefault(x => x.EntityType == entityType);
var isDefined = CmsKitTagOptions.EntityTypes.Any(x => x.EntityType == entityType);
return Task.FromResult(definition != null);
return Task.FromResult(isDefined);
}
}
}
}

6
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTag.cs

@ -1,4 +1,6 @@
using System;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
@ -16,10 +18,10 @@ namespace Volo.CmsKit.Tags
{
}
internal EntityTag(Guid tagId, string entityId, Guid? tenantId = null)
internal EntityTag(Guid tagId, [NotNull] string entityId, Guid? tenantId = null)
{
TagId = tagId;
EntityId = entityId;
EntityId = Check.NotNullOrEmpty(entityId,nameof(entityId));
TenantId = tenantId;
}

25
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTagManager.cs

@ -3,50 +3,47 @@ using System;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Volo.CmsKit.Tags;
namespace Volo.CmsKit.Tags
{
public class EntityTagManager : DomainService, IEntityTagManager
{
protected readonly IEntityTagRepository _entityTagRepository;
protected readonly ITagDefinitionStore _tagDefinitionStore;
protected IEntityTagRepository EntityTagRepository { get; }
protected ITagDefinitionStore TagDefinitionStore { get; }
public EntityTagManager(
IEntityTagRepository entityTagRepository,
ITagDefinitionStore tagDefinitionStore)
{
_entityTagRepository = entityTagRepository;
_tagDefinitionStore = tagDefinitionStore;
EntityTagRepository = entityTagRepository;
TagDefinitionStore = tagDefinitionStore;
}
public async Task<EntityTag> AddTagToEntityAsync(
public virtual async Task<EntityTag> AddTagToEntityAsync(
[NotNull] Guid tagId,
[NotNull] string entityType,
[NotNull] string entityId,
[CanBeNull] Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
if (!await _tagDefinitionStore.IsDefinedAsync(entityType))
if (!await TagDefinitionStore.IsDefinedAsync(entityType))
{
throw new EntityNotTaggableException(entityType);
}
var entityTag = new EntityTag(tagId, entityId, tenantId);
return await _entityTagRepository.InsertAsync(entityTag, cancellationToken: cancellationToken);
return await EntityTagRepository.InsertAsync(entityTag, cancellationToken: cancellationToken);
}
public async Task RemoveTagFromEntityAsync(
public virtual async Task RemoveTagFromEntityAsync(
[NotNull] Guid tagId,
[NotNull] string entityType,
[NotNull] string entityId,
[CanBeNull] Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
var entityTag = await _entityTagRepository.FindAsync(tagId, entityId, tenantId, cancellationToken);
await _entityTagRepository.DeleteAsync(entityTag);
var entityTag = await EntityTagRepository.FindAsync(tagId, entityId, tenantId, cancellationToken);
await EntityTagRepository.DeleteAsync(entityTag, cancellationToken: cancellationToken);
}
}
}
}

21
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs

@ -8,11 +8,13 @@ namespace Volo.CmsKit.Tags
{
public class Tag : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
public string EntityType { get; set; }
public virtual Guid? TenantId { get; set; }
public string Name { get; protected set; }
public Guid? TenantId { get; set; }
[NotNull]
public virtual string EntityType { get; protected set; }
[NotNull]
public virtual string Name { get; protected set; }
protected Tag()
{
@ -24,14 +26,19 @@ namespace Volo.CmsKit.Tags
[NotNull] string name,
Guid? tenantId = null) : base(id)
{
EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), TagConsts.MaxEntityTypeLength);
SetName(name);
EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), TagConsts.MaxEntityTypeLength);
Name = Check.NotNullOrEmpty(name, nameof(name), TagConsts.MaxNameLength);
TenantId = tenantId;
}
public void SetName(string name)
public virtual void SetName(string name)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name), TagConsts.MaxNameLength);
}
public virtual void SetEntityType(string entityType)
{
EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), TagConsts.MaxEntityTypeLength);
}
}
}

3
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagEntityTypeDefiniton.cs

@ -25,13 +25,12 @@ namespace Volo.CmsKit.Tags
[CanBeNull] string deletePolicy = null) : base(createPolicy, updatePolicy, deletePolicy)
{
EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
DisplayName = displayName;
}
public bool Equals(TagEntityTypeDefiniton other)
{
return EntityType == other.EntityType;
return EntityType == other?.EntityType;
}
}
}

62
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagManager.cs

@ -1,35 +1,27 @@
using JetBrains.Annotations;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Services;
namespace Volo.CmsKit.Tags
{
public class TagManager : DomainService, ITagManager
{
private readonly ITagRepository _tagRepository;
private readonly ITagDefinitionStore _tagDefinitionStore;
protected ITagRepository TagRepository { get; }
protected ITagDefinitionStore TagDefinitionStore { get; }
public TagManager(
ITagRepository tagRepository,
ITagDefinitionStore tagDefinitionStore)
public TagManager(ITagRepository tagRepository, ITagDefinitionStore tagDefinitionStore)
{
_tagRepository = tagRepository;
_tagDefinitionStore = tagDefinitionStore;
TagRepository = tagRepository;
TagDefinitionStore = tagDefinitionStore;
}
public async Task<Tag> GetOrAddAsync(
[NotNull] string entityType,
[NotNull] string name,
Guid? tenantId = null,
CancellationToken cancellationToken = default)
public virtual async Task<Tag> GetOrAddAsync([NotNull] string entityType, [NotNull] string name,
Guid? tenantId = null, CancellationToken cancellationToken = default)
{
var entity = await _tagRepository.FindAsync(entityType, name, tenantId, cancellationToken);
var entity = await TagRepository.FindAsync(entityType, name, tenantId, cancellationToken);
if (entity == null)
{
@ -39,53 +31,43 @@ namespace Volo.CmsKit.Tags
return entity;
}
public async Task<Tag> InsertAsync(
Guid id,
[NotNull] string entityType,
[NotNull] string name,
Guid? tenantId = null,
CancellationToken cancellationToken = default)
public virtual async Task<Tag> InsertAsync(Guid id, [NotNull] string entityType, [NotNull] string name,
Guid? tenantId = null, CancellationToken cancellationToken = default)
{
if (await _tagRepository.AnyAsync(entityType, name, tenantId, cancellationToken))
if (!await TagDefinitionStore.IsDefinedAsync(entityType))
{
throw new TagAlreadyExistException(entityType, name);
throw new EntityNotTaggableException(entityType);
}
if (!await _tagDefinitionStore.IsDefinedAsync(entityType))
if (await TagRepository.AnyAsync(entityType, name, tenantId, cancellationToken))
{
throw new EntityNotTaggableException(entityType);
throw new TagAlreadyExistException(entityType, name);
}
return await _tagRepository.InsertAsync(
new Tag(
id,
entityType,
name,
tenantId),
return await TagRepository.InsertAsync(new Tag(id, entityType, name, tenantId),
cancellationToken: cancellationToken);
}
public async Task<Tag> UpdateAsync(
Guid id,
[NotNull] string name,
public virtual async Task<Tag> UpdateAsync(Guid id, [NotNull] string name,
CancellationToken cancellationToken = default)
{
var entity = await _tagRepository.GetAsync(id, cancellationToken: cancellationToken);
var entity = await TagRepository.GetAsync(id, cancellationToken: cancellationToken);
if (name != entity.Name &&
await _tagRepository.AnyAsync(entity.EntityType, name, entity.TenantId, cancellationToken))
await TagRepository.AnyAsync(entity.EntityType, name, entity.TenantId, cancellationToken))
{
throw new TagAlreadyExistException(entity.EntityType, name);
}
entity.SetName(name);
return await _tagRepository.UpdateAsync(entity, cancellationToken: cancellationToken);
return await TagRepository.UpdateAsync(entity, cancellationToken: cancellationToken);
}
public Task<List<TagEntityTypeDefiniton>> GetTagDefinitionsAsync(CancellationToken cancellationToken = default)
public virtual Task<List<TagEntityTypeDefiniton>> GetTagDefinitionsAsync(
CancellationToken cancellationToken = default)
{
return _tagDefinitionStore.GetTagEntityTypeDefinitionListAsync();
return TagDefinitionStore.GetTagEntityTypeDefinitionListAsync();
}
}
}

8
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Contents/EfCoreContentRepository.cs

@ -15,7 +15,7 @@ namespace Volo.CmsKit.Contents
{
}
public Task<Content> GetAsync(
public virtual Task<Content> GetAsync(
string entityType,
string entityId,
Guid? tenantId = null,
@ -29,7 +29,7 @@ namespace Volo.CmsKit.Contents
);
}
public Task<Content> FindAsync(
public virtual Task<Content> FindAsync(
string entityType,
string entityId,
Guid? tenantId = null,
@ -43,7 +43,7 @@ namespace Volo.CmsKit.Contents
);
}
public Task DeleteAsync(
public virtual Task DeleteAsync(
string entityType,
string entityId,
Guid? tenantId = null,
@ -56,7 +56,7 @@ namespace Volo.CmsKit.Contents
cancellationToken: GetCancellationToken(cancellationToken));
}
public async Task<bool> ExistsAsync(
public virtual async Task<bool> ExistsAsync(
[NotNull] string entityType,
[NotNull] string entityId,
Guid? tenantId = null,

4
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs

@ -178,10 +178,10 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.ConfigureByConvention();
b.Property(x => x.Title).IsRequired().HasMaxLength(PageConsts.MaxTitleLength);
b.Property(x => x.Url).IsRequired().HasMaxLength(PageConsts.MaxUrlLength);
b.Property(x => x.Slug).IsRequired().HasMaxLength(PageConsts.MaxSlugLength);
b.Property(x => x.Description).HasMaxLength(PageConsts.MaxDescriptionLength);
b.HasIndex(x => new { x.TenantId, x.Url });
b.HasIndex(x => new { x.TenantId, Url = x.Slug });
});
}
else

37
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs

@ -17,13 +17,14 @@ namespace Volo.CmsKit.Pages
{
}
public virtual async Task<int> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
public virtual async Task<int> GetCountAsync(string filter = null,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync()).WhereIf(
!filter.IsNullOrWhiteSpace(),
x =>
x.Title.Contains(filter)
).CountAsync(GetCancellationToken(cancellationToken));
!filter.IsNullOrWhiteSpace(),
x =>
x.Title.Contains(filter)
).CountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<Page>> GetListAsync(
@ -34,27 +35,27 @@ namespace Volo.CmsKit.Pages
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync()).WhereIf(
!filter.IsNullOrWhiteSpace(),
x =>
x.Title.Contains(filter))
.OrderBy(sorting ?? nameof(Page.Title))
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
!filter.IsNullOrWhiteSpace(),
x =>
x.Title.Contains(filter))
.OrderBy(sorting ?? nameof(Page.Title))
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual Task<Page> GetByUrlAsync(string url, CancellationToken cancellationToken = default)
public virtual Task<Page> GetBySlugAsync(string slug, CancellationToken cancellationToken = default)
{
return GetAsync(x => x.Url == url, cancellationToken: GetCancellationToken(cancellationToken));
return GetAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken));
}
public virtual Task<Page> FindByUrlAsync(string url, CancellationToken cancellationToken = default)
public virtual Task<Page> FindBySlugAsync(string slug, CancellationToken cancellationToken = default)
{
return FindAsync(x => x.Url == url, cancellationToken: GetCancellationToken(cancellationToken));
return FindAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> ExistsAsync(string url, CancellationToken cancellationToken = default)
public virtual async Task<bool> ExistsAsync(string slug, CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync()).AnyAsync(x => x.Url == url, GetCancellationToken(cancellationToken));
return await (await GetDbSetAsync()).AnyAsync(x => x.Slug == slug, GetCancellationToken(cancellationToken));
}
}
}
}

24
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreEntityTagRepository.cs

@ -1,8 +1,6 @@
using JetBrains.Annotations;
using Nito.Disposables;
using System;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
@ -11,30 +9,32 @@ using Volo.CmsKit.EntityFrameworkCore;
namespace Volo.CmsKit.Tags
{
public class EfCoreEntityTagRepository: EfCoreRepository<ICmsKitDbContext, EntityTag>, IEntityTagRepository
public class EfCoreEntityTagRepository : EfCoreRepository<ICmsKitDbContext, EntityTag>, IEntityTagRepository
{
public EfCoreEntityTagRepository(IDbContextProvider<ICmsKitDbContext> dbContextProvider) : base(dbContextProvider)
public EfCoreEntityTagRepository(IDbContextProvider<ICmsKitDbContext> dbContextProvider) : base(
dbContextProvider)
{
}
public async Task DeleteManyAsync(Guid[] tagIds, CancellationToken cancellationToken = default)
public virtual async Task DeleteManyAsync(Guid[] tagIds, CancellationToken cancellationToken = default)
{
var dbSet = await GetDbSetAsync();
var dbContext = await GetDbContextAsync();
var dbSet = dbContext.Set<EntityTag>();
dbSet.RemoveRange(dbSet.Where(x => tagIds.Contains(x.TagId)));
await dbContext.SaveChangesAsync(GetCancellationToken(cancellationToken));
}
public Task<EntityTag> FindAsync(
public virtual Task<EntityTag> FindAsync(
[NotNull] Guid tagId,
[NotNull] string entityId,
[CanBeNull] Guid? tenantId,
CancellationToken cancellationToken = default)
{
return base.FindAsync(x =>
x.TagId == tagId &&
x.EntityId == entityId &&
x.TenantId == tenantId,
cancellationToken: cancellationToken);
x.TagId == tagId &&
x.EntityId == entityId &&
x.TenantId == tenantId,
cancellationToken: cancellationToken);
}
}
}

2
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs

@ -5,10 +5,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.VirtualFileSystem;
using Volo.CmsKit.EntityFrameworkCore;
namespace Volo.CmsKit.Tags

8
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Contents/MongoContentRepository.cs

@ -15,7 +15,7 @@ namespace Volo.CmsKit.MongoDB.Contents
{
}
public Task<Content> GetAsync(
public virtual Task<Content> GetAsync(
string entityType,
string entityId,
Guid? tenantId = null,
@ -29,7 +29,7 @@ namespace Volo.CmsKit.MongoDB.Contents
);
}
public Task<Content> FindAsync(
public virtual Task<Content> FindAsync(
string entityType,
string entityId,
Guid? tenantId = null,
@ -43,7 +43,7 @@ namespace Volo.CmsKit.MongoDB.Contents
);
}
public Task DeleteAsync(string entityType, string entityId, Guid? tenantId = null, CancellationToken cancellationToken = default)
public virtual Task DeleteAsync(string entityType, string entityId, Guid? tenantId = null, CancellationToken cancellationToken = default)
{
return DeleteAsync(x =>
x.EntityType == entityType &&
@ -52,7 +52,7 @@ namespace Volo.CmsKit.MongoDB.Contents
cancellationToken: GetCancellationToken(cancellationToken));
}
public async Task<bool> ExistsAsync([NotNull] string entityType, [NotNull] string entityId, Guid? tenantId = null, CancellationToken cancellationToken = default)
public virtual async Task<bool> ExistsAsync([NotNull] string entityType, [NotNull] string entityId, Guid? tenantId = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).AnyAsync(x =>
x.EntityType == entityType &&

12
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs

@ -51,19 +51,19 @@ namespace Volo.CmsKit.MongoDB.Pages
.ToListAsync(cancellation);
}
public virtual Task<Page> GetByUrlAsync(string url, CancellationToken cancellationToken = default)
public virtual Task<Page> GetBySlugAsync(string slug, CancellationToken cancellationToken = default)
{
return GetAsync(x => x.Url == url, cancellationToken: GetCancellationToken(cancellationToken));
return GetAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken));
}
public virtual Task<Page> FindByUrlAsync(string url, CancellationToken cancellationToken = default)
public virtual Task<Page> FindBySlugAsync(string slug, CancellationToken cancellationToken = default)
{
return FindAsync(x => x.Url == url, cancellationToken: GetCancellationToken(cancellationToken));
return FindAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> ExistsAsync(string url, CancellationToken cancellationToken = default)
public virtual async Task<bool> ExistsAsync(string slug, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).AnyAsync(x => x.Url == url, GetCancellationToken(cancellationToken));
return await (await GetMongoQueryableAsync(cancellationToken)).AnyAsync(x => x.Slug == slug, GetCancellationToken(cancellationToken));
}
}
}

4
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/IPageAppService.cs → modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/IPagePublicAppService.cs

@ -3,8 +3,8 @@ using JetBrains.Annotations;
namespace Volo.CmsKit.Public.Pages
{
public interface IPageAppService
public interface IPagePublicAppService
{
Task<PageDto> FindByUrlAsync([NotNull] string url);
Task<PageDto> FindBySlugAsync([NotNull] string slug);
}
}

2
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs

@ -7,6 +7,6 @@ namespace Volo.CmsKit.Public.Pages
{
public string Title { get; set; }
public string Url { get; set; }
public string Slug { get; set; }
}
}

6
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Contents/ContentAppService.cs → modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Contents/ContentPublicAppService.cs

@ -3,11 +3,11 @@ using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Public.Contents
{
public class ContentAppService : CmsKitAppServiceBase, IContentAppService
public class ContentPublicAppService : CmsKitAppServiceBase, IContentAppService
{
protected readonly IContentRepository ContentRepository;
protected IContentRepository ContentRepository { get; }
public ContentAppService(IContentRepository contentRepository)
public ContentPublicAppService(IContentRepository contentRepository)
{
ContentRepository = contentRepository;
}

27
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PageAppService.cs

@ -1,27 +0,0 @@
using System.Threading.Tasks;
using Volo.CmsKit.Pages;
namespace Volo.CmsKit.Public.Pages
{
public class PageAppService : CmsKitPublicAppServiceBase, IPageAppService
{
protected readonly IPageRepository PageRepository;
public PageAppService(IPageRepository pageRepository)
{
PageRepository = pageRepository;
}
public virtual async Task<PageDto> FindByUrlAsync(string url)
{
var page = await PageRepository.FindByUrlAsync(url);
if (page == null)
{
return null;
}
return ObjectMapper.Map<Page, PageDto>(page);
}
}
}

28
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PagePublicAppService.cs

@ -0,0 +1,28 @@
using System.Threading.Tasks;
using Volo.CmsKit.Pages;
namespace Volo.CmsKit.Public.Pages
{
public class PagePublicAppService : CmsKitPublicAppServiceBase, IPagePublicAppService
{
protected IPageRepository PageRepository { get; }
public PagePublicAppService(IPageRepository pageRepository)
{
PageRepository = pageRepository;
}
public virtual async Task<PageDto> FindBySlugAsync(string slug)
{
PageDto pageDto = null;
var page = await PageRepository.FindBySlugAsync(slug);
if (page !=null)
{
pageDto = ObjectMapper.Map<Page, PageDto>(page);
}
return pageDto;
}
}
}

17
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Pages/PagesPublicController.cs

@ -1,26 +1,29 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.GlobalFeatures;
namespace Volo.CmsKit.Public.Pages
{
[RequiresGlobalFeature(typeof(PagesFeature))]
[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Route("api/cms-kit-public/comments")]
public class PagesPublicController : IPageAppService
[Route("api/cms-kit-public/pages")]
public class PagesPublicController : IPagePublicAppService
{
protected readonly IPageAppService PageAppService;
protected IPagePublicAppService PageAppService { get; }
public PagesPublicController(IPageAppService pageAppService)
public PagesPublicController(IPagePublicAppService pageAppService)
{
PageAppService = pageAppService;
}
[HttpGet]
[Route("url/{url}")]
public Task<PageDto> FindByUrlAsync(string url)
[Route("{slug}")]
public virtual Task<PageDto> FindBySlugAsync(string slug)
{
return PageAppService.FindByUrlAsync(url);
return PageAppService.FindBySlugAsync(slug);
}
}
}

8
modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs

@ -59,9 +59,13 @@ namespace Volo.CmsKit.Public.Web
public override void PostConfigureServices(ServiceConfigurationContext context)
{
Configure<RazorPagesOptions>(options =>
if (GlobalFeatureManager.Instance.IsEnabled<PagesFeature>())
{
});
Configure<RazorPagesOptions>(options =>
{
options.Conventions.AddPageRoute("/CmsKit/Pages/Index", @"/pages/{slug:minlength(1)}");
});
}
}
}
}

37
modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/PageController.cs

@ -1,37 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ActionConstraints;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.GlobalFeatures;
using Volo.CmsKit.Public.Pages;
namespace Volo.CmsKit.Public.Web.Controllers
{
[RequiresGlobalFeature(typeof(PagesFeature))]
public class PageController : CmsKitPublicControllerBase
{
protected IPageAppService PageAppService { get; }
public PageController(IPageAppService pageAppService)
{
PageAppService = pageAppService;
}
//[HttpGet("/{*url}", Order = int.MaxValue)]
public async Task<IActionResult> IndexAsync(string url)
{
var page = await PageAppService.FindByUrlAsync(url);
if (page == null)
{
return NotFound();
}
return View("~/Views/Page/Index.cshtml", page);
}
}
}

13
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml

@ -0,0 +1,13 @@
@page
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.CmsKit.Localization
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages
@model Volo.CmsKit.Public.Web.Pages.CmsKit.Pages.IndexModel
@inject IHtmlLocalizer<CmsKitResource> L
@await Component.InvokeAsync(typeof(DefaultPageViewComponent),
new
{
pageId = Model.Page.Id,
title = Model.Page.Title
})

34
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml.cs

@ -0,0 +1,34 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.CmsKit.Public.Pages;
using Volo.CmsKit.Web.Pages;
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Pages
{
public class IndexModel : CommonPageModel
{
[BindProperty(SupportsGet = true)]
public string Slug { get; set; }
protected IPagePublicAppService PagePublicAppService { get; }
public PageDto Page;
public IndexModel(IPagePublicAppService pagePublicAppService)
{
PagePublicAppService = pagePublicAppService;
}
public async Task<IActionResult> OnGetAsync()
{
Page = await PagePublicAppService.FindBySlugAsync(Slug);
if (Page == null)
{
return NotFound();
}
return Page();
}
}
}

6
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs

@ -9,11 +9,11 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages
[ViewComponent(Name = "CmsDefaultPage")]
public class DefaultPageViewComponent : AbpViewComponent
{
protected readonly IPageAppService PageAppService;
protected IPagePublicAppService PagePublicAppService { get; }
public DefaultPageViewComponent(IPageAppService pageAppService)
public DefaultPageViewComponent(IPagePublicAppService pagePublicAppService)
{
PageAppService = pageAppService;
PagePublicAppService = pagePublicAppService;
}
public virtual async Task<IViewComponentResult> InvokeAsync(Guid pageId, string title, string description)

9
modules/cms-kit/src/Volo.CmsKit.Public.Web/Views/Page/Index.cshtml

@ -1,9 +0,0 @@
@model Volo.CmsKit.Public.Pages.PageDto
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages
@await Component.InvokeAsync(typeof(DefaultPageViewComponent), new
{
pageId = Model.Id,
title = Model.Title
})

31
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostAdminAppService_Tests.cs

@ -31,7 +31,7 @@ namespace Volo.CmsKit.Blogs
var slug = "my-awesome-new-post";
var shortDescription = "This blog is all about awesomeness 🤗!";
var created = await blogPostAdminAppService.CreateAsync(new CreateUpdateBlogPostDto
var created = await blogPostAdminAppService.CreateAsync(new CreateBlogPostDto
{
BlogId = cmsKitTestData.Blog_Id,
Title = title,
@ -55,7 +55,7 @@ namespace Volo.CmsKit.Blogs
var slug = "another-my-awesome-new-post";
var shortDescription = "This blog is all about awesomeness 🤗!";
var dto = new CreateUpdateBlogPostDto
var dto = new CreateBlogPostDto
{
// Non-existing Id
BlogId = Guid.NewGuid(),
@ -114,7 +114,7 @@ namespace Volo.CmsKit.Blogs
{
var nonExistingSlug = "any-other-url";
var exception = await Should.ThrowAsync<EntityNotFoundException>(async () =>
await blogPostAdminAppService.GetBySlugAsync(nonExistingSlug, cmsKitTestData.Page_1_Url));
await blogPostAdminAppService.GetBySlugAsync(nonExistingSlug, cmsKitTestData.Page_1_Slug));
exception.EntityType.ShouldBe(typeof(Blog));
}
@ -137,9 +137,8 @@ namespace Volo.CmsKit.Blogs
var title = "[Solved] Another Blog Post";
var slug = "another-short-blog-post";
await blogPostAdminAppService.UpdateAsync(cmsKitTestData.BlogPost_2_Id, new CreateUpdateBlogPostDto
await blogPostAdminAppService.UpdateAsync(cmsKitTestData.BlogPost_2_Id, new UpdateBlogPostDto
{
BlogId = cmsKitTestData.Blog_Id,
ShortDescription = shortDescription,
Title = title,
Slug = slug,
@ -152,31 +151,11 @@ namespace Volo.CmsKit.Blogs
blogPost.Slug.ShouldBe(slug);
}
[Fact]
public async Task UpdateAsync_ShouldThrowException_WhileChangingWithNonExistingBlogId()
{
var nonExistingId = Guid.NewGuid();
var dto = new CreateUpdateBlogPostDto
{
BlogId = nonExistingId,
Title = cmsKitTestData.Page_2_Title,
Slug = cmsKitTestData.BlogPost_2_Slug
};
var exception = await Should.ThrowAsync<EntityNotFoundException>(async () =>
await blogPostAdminAppService.UpdateAsync(cmsKitTestData.BlogPost_2_Id, dto));
exception.EntityType.ShouldBe(typeof(Blog));
exception.Id.ShouldBe(nonExistingId);
}
[Fact]
public async Task UpdateAsync_ShouldThrowException_WhileUpdatingWithAlreadyExistingSlug()
{
var dto = new CreateUpdateBlogPostDto
var dto = new UpdateBlogPostDto
{
BlogId = cmsKitTestData.Blog_Id,
Title = "Some new title",
Slug = cmsKitTestData.BlogPost_1_Slug
};

18
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PageAdminAppService_Tests.cs

@ -64,12 +64,12 @@ namespace Volo.CmsKit.Pages
var dto = new CreatePageInputDto
{
Title = "test",
Url = "test-url"
Slug = "test-url"
};
await Should.NotThrowAsync(async () => await _pageAdminAppService.CreateAsync(dto));
var page = await _pageRepository.GetByUrlAsync(dto.Url);
var page = await _pageRepository.GetBySlugAsync(dto.Slug);
page.Title.ShouldBe(dto.Title);
}
@ -80,12 +80,12 @@ namespace Volo.CmsKit.Pages
var dto = new CreatePageInputDto
{
Title = "test",
Url = _data.Page_1_Url
Slug = _data.Page_1_Slug
};
var exception = await Should.ThrowAsync<PageUrlAlreadyExistException>(async () => await _pageAdminAppService.CreateAsync(dto));
var exception = await Should.ThrowAsync<PageSlugAlreadyExistsException>(async () => await _pageAdminAppService.CreateAsync(dto));
exception.Code.ShouldBe(CmsKitErrorCodes.Pages.UrlAlreadyExist);
exception.Code.ShouldBe(CmsKitErrorCodes.Pages.SlugAlreadyExist);
}
[Fact]
@ -95,7 +95,7 @@ namespace Volo.CmsKit.Pages
{
Title = _data.Page_1_Title + "++",
Description = "new description",
Url = _data.Page_1_Url+ "test"
Slug = _data.Page_1_Slug+ "test"
};
await Should.NotThrowAsync(async () => await _pageAdminAppService.UpdateAsync(_data.Page_1_Id, dto));
@ -105,8 +105,8 @@ namespace Volo.CmsKit.Pages
updatedPage.Title.ShouldNotBe(_data.Page_1_Title);
updatedPage.Title.ShouldBe(dto.Title);
updatedPage.Url.ShouldNotBe(_data.Page_1_Url);
updatedPage.Url.ShouldBe(dto.Url);
updatedPage.Slug.ShouldNotBe(_data.Page_1_Slug);
updatedPage.Slug.ShouldBe(dto.Slug);
updatedPage.Description.ShouldNotBe(_data.Page_1_Description);
updatedPage.Description.ShouldBe(dto.Description);
@ -119,7 +119,7 @@ namespace Volo.CmsKit.Pages
{
Title = _data.Page_1_Title + "++",
Description = "new description",
Url = _data.Page_2_Url
Slug = _data.Page_2_Slug
};
await Should.ThrowAsync<Exception>(async () => await _pageAdminAppService.UpdateAsync(_data.Page_1_Id, dto));

8
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PagePublicAppService_Tests.cs

@ -9,18 +9,18 @@ namespace Volo.CmsKit.Pages
public class PagePublicAppService_Tests : CmsKitApplicationTestBase
{
private readonly CmsKitTestData _data;
private readonly IPageAppService _pageAppService;
private readonly IPagePublicAppService _pageAppService;
public PagePublicAppService_Tests()
{
_data = GetRequiredService<CmsKitTestData>();
_pageAppService = GetRequiredService<IPageAppService>();
_pageAppService = GetRequiredService<IPagePublicAppService>();
}
[Fact]
public async Task ShouldFindByUrlAsync()
{
var page = await _pageAppService.FindByUrlAsync(_data.Page_1_Url);
var page = await _pageAppService.FindBySlugAsync(_data.Page_1_Slug);
page.ShouldNotBeNull();
page.Title.ShouldBe(_data.Page_1_Title);
@ -29,7 +29,7 @@ namespace Volo.CmsKit.Pages
[Fact]
public async Task ShouldNotGetByUrlAsync()
{
var page = await _pageAppService.FindByUrlAsync("not-exist-url");
var page = await _pageAppService.FindBySlugAsync("not-exist-url");
page.ShouldBeNull();
}

4
modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs

@ -310,13 +310,13 @@ namespace Volo.CmsKit
private async Task SeedPagesAsync()
{
var page1 = new Page(_cmsKitTestData.Page_1_Id, _cmsKitTestData.Page_1_Title, _cmsKitTestData.Page_1_Url, _cmsKitTestData.Page_1_Description);
var page1 = new Page(_cmsKitTestData.Page_1_Id, _cmsKitTestData.Page_1_Title, _cmsKitTestData.Page_1_Slug, _cmsKitTestData.Page_1_Description);
var page1Content = new Content(_guidGenerator.Create(), nameof(Page), page1.Id.ToString(), _cmsKitTestData.Page_1_Content);
await _pageRepository.InsertAsync(page1);
await _contentRepository.InsertAsync(page1Content);
var page2 = new Page(_cmsKitTestData.Page_2_Id, _cmsKitTestData.Page_2_Title, _cmsKitTestData.Page_2_Url, _cmsKitTestData.Page_2_Description);
var page2 = new Page(_cmsKitTestData.Page_2_Id, _cmsKitTestData.Page_2_Title, _cmsKitTestData.Page_2_Slug, _cmsKitTestData.Page_2_Description);
var page2Content = new Content(_guidGenerator.Create(), nameof(Page), page2.Id.ToString(), _cmsKitTestData.Page_2_Content);
await _pageRepository.InsertAsync(page2);

4
modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs

@ -45,7 +45,7 @@ namespace Volo.CmsKit
public string Page_1_Title { get; } = "Imagine Dragons - Believer Lyrics";
public string Page_1_Url { get; } = "imagine-dragons-believer-lyrics";
public string Page_1_Slug { get; } = "imagine-dragons-believer-lyrics";
public string Page_1_Description { get; } = "You can get the lyrics of the music.";
@ -55,7 +55,7 @@ namespace Volo.CmsKit
public string Page_2_Title { get; } = "Imagine Dragons - Believer Lyrics (Page 2)";
public string Page_2_Url { get; } = "imagine-dragons-believer-lyrics-2";
public string Page_2_Slug { get; } = "imagine-dragons-believer-lyrics-2";
public string Page_2_Description { get; } = "You can get the lyrics of the music.";

8
modules/cms-kit/test/Volo.CmsKit.TestBase/Pages/PageRepository_Test.cs

@ -53,7 +53,7 @@ namespace Volo.CmsKit.Pages
[Fact]
public async Task ShouldGetByUrlAsync()
{
var page = await _pageRepository.GetByUrlAsync(_cmsKitTestData.Page_1_Url);
var page = await _pageRepository.GetBySlugAsync(_cmsKitTestData.Page_1_Slug);
page.ShouldNotBeNull();
page.Description.ShouldBe(_cmsKitTestData.Page_1_Description);
@ -62,7 +62,7 @@ namespace Volo.CmsKit.Pages
[Fact]
public async Task ShouldFindByUrlAsync()
{
var page = await _pageRepository.FindByUrlAsync(_cmsKitTestData.Page_1_Url);
var page = await _pageRepository.FindBySlugAsync(_cmsKitTestData.Page_1_Slug);
page.ShouldNotBeNull();
page.Description.ShouldBe(_cmsKitTestData.Page_1_Description);
@ -71,7 +71,7 @@ namespace Volo.CmsKit.Pages
[Fact]
public async Task ShouldNotFindByUrlAsync()
{
var page = await _pageRepository.FindByUrlAsync("not-exist-lyrics");
var page = await _pageRepository.FindBySlugAsync("not-exist-lyrics");
page.ShouldBeNull();
}
@ -79,7 +79,7 @@ namespace Volo.CmsKit.Pages
[Fact]
public async Task ShouldBeExistAsync()
{
var page = await _pageRepository.ExistsAsync(_cmsKitTestData.Page_1_Url);
var page = await _pageRepository.ExistsAsync(_cmsKitTestData.Page_1_Slug);
page.ShouldBeTrue();
}

9
modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml

@ -44,14 +44,13 @@
var disabled = Model.IsDisabled(feature.Provider.Name);
<div class="mt-2">
<input type="text" name="FeatureGroups[@i].Features[@j].ProviderName" value="@feature.Provider.Name" hidden/>
<input type="text" name="FeatureGroups[@i].Features[@j].Type" value="@feature.ValueType?.Name" hidden/>
<input type="text" abp-id-name="@Model.FeatureGroups[i].Features[j].Type" value="@feature.ValueType?.Name" hidden/>
@if (feature.ValueType is ToggleStringValueType)
{
<abp-input asp-for="@feature.Value"
type="checkbox"
name="FeatureGroups[@i].Features[@j].BoolValue"
abp-id-name="@Model.FeatureGroups[i].Features[j].BoolValue"
label="@feature.DisplayName"
disabled="@disabled"
group-data-feature-name="@feature.Name"
@ -70,7 +69,7 @@
<abp-input asp-for="@feature.Value"
label="@feature.DisplayName"
name="featureGroups[@i].Features[@j].Value"
abp-id-name="@Model.FeatureGroups[i].Features[j].Value"
disabled="@disabled"
type="@type"
group-data-feature-name="@feature.Name"
@ -99,7 +98,7 @@
</div>
}
<input value="@feature.Name" name="FeatureGroups[@i].Features[@j].Name" hidden=""/>
<input value="@feature.Name" abp-id-name="@Model.FeatureGroups[i].Features[j].Name" hidden/>
</div>
}
</div>

7
modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml.cs

@ -75,13 +75,6 @@ namespace Volo.Abp.FeatureManagement.Web.Pages.FeatureManagement
return providerName != ProviderName && providerName != DefaultValueFeatureValueProvider.ProviderName;
}
public class ProviderInfoViewModel
{
public string ProviderName { get; set; }
public string ProviderKey { get; set; }
}
public class FeatureGroupViewModel
{
public List<FeatureViewModel> Features { get; set; }

9
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeedContributor.cs

@ -6,6 +6,11 @@ namespace Volo.Abp.Identity
{
public class IdentityDataSeedContributor : IDataSeedContributor, ITransientDependency
{
public const string AdminEmailPropertyName = "AdminEmail";
public const string AdminEmailDefaultValue = "admin@abp.io";
public const string AdminPasswordPropertyName = "AdminPassword";
public const string AdminPasswordDefaultValue = "1q2w3E*";
protected IIdentityDataSeeder IdentityDataSeeder { get; }
public IdentityDataSeedContributor(IIdentityDataSeeder identityDataSeeder)
@ -16,8 +21,8 @@ namespace Volo.Abp.Identity
public virtual Task SeedAsync(DataSeedContext context)
{
return IdentityDataSeeder.SeedAsync(
context?["AdminEmail"] as string ?? "admin@abp.io",
context?["AdminPassword"] as string ?? "1q2w3E*",
context?[AdminEmailPropertyName] as string ?? AdminEmailDefaultValue,
context?[AdminPasswordPropertyName] as string ?? AdminPasswordDefaultValue,
context?.TenantId
);
}

2
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreModule.cs

@ -17,6 +17,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
options.AddRepository<IdentityRole, EfCoreIdentityRoleRepository>();
options.AddRepository<IdentityClaimType, EfCoreIdentityClaimTypeRepository>();
options.AddRepository<OrganizationUnit, EfCoreOrganizationUnitRepository>();
options.AddRepository<IdentitySecurityLog, EFCoreIdentitySecurityLogRepository>();
options.AddRepository<IdentityLinkUser, EfCoreIdentityLinkUserRepository>();
});
}
}

2
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/AbpIdentityServerMongoDbContext.cs

@ -7,9 +7,11 @@ using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.MongoDB;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.IdentityServer.MongoDB
{
[IgnoreMultiTenancy]
[ConnectionStringName(AbpIdentityServerDbProperties.ConnectionStringName)]
public class AbpIdentityServerMongoDbContext : AbpMongoDbContext, IAbpIdentityServerMongoDbContext
{

2
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/IAbpIdentityServerMongoDbContext.cs

@ -7,9 +7,11 @@ using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.MongoDB;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.IdentityServer.MongoDB
{
[IgnoreMultiTenancy]
[ConnectionStringName(AbpIdentityServerDbProperties.ConnectionStringName)]
public interface IAbpIdentityServerMongoDbContext : IAbpMongoDbContext
{

2
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissionDefinitionProvider.cs

@ -10,7 +10,7 @@ namespace Volo.Abp.SettingManagement
public override void Define(IPermissionDefinitionContext context)
{
var moduleGroup = context.AddGroup(SettingManagementPermissions.GroupName, L("Permission:SettingManagement"));
moduleGroup.AddPermission(SettingManagementPermissions.EmailSettingManagement, L("Permission:EmailSettingManagement"), multiTenancySide: MultiTenancySides.Host);
moduleGroup.AddPermission(SettingManagementPermissions.EmailSetting, L("Permission:EmailSetting"), multiTenancySide: MultiTenancySides.Host);
}
private static LocalizableString L(string name)

2
modules/setting-management/src/Volo.Abp.SettingManagement.Application.Contracts/Volo/Abp/SettingManagement/SettingManagementPermissions.cs

@ -6,7 +6,7 @@ namespace Volo.Abp.SettingManagement
{
public const string GroupName = "SettingManagement";
public const string EmailSettingManagement = GroupName + ".EmailSettingManagement";
public const string EmailSetting = GroupName + ".EmailSetting";
public static string[] GetAll()
{

2
modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/EmailSettingsAppService.cs

@ -5,7 +5,7 @@ using Volo.Abp.Emailing;
namespace Volo.Abp.SettingManagement
{
[Authorize(SettingManagementPermissions.EmailSettingManagement)]
[Authorize(SettingManagementPermissions.EmailSetting)]
public class EmailSettingsAppService : SettingManagementAppServiceBase, IEmailSettingsAppService
{
protected ISettingManager SettingManager { get; }

2
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/AbpSettingManagementBlazorModule.cs

@ -36,7 +36,7 @@ namespace Volo.Abp.SettingManagement.Blazor
Configure<SettingManagementComponentOptions>(options =>
{
options.Contributors.Add(new EmailSettingManagementPageContributor());
options.Contributors.Add(new EmailSettingPageContributor());
});
}
}

2
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/EmailSettingGroup/EmailSettingGroupViewComponent.razor.cs

@ -35,7 +35,7 @@ namespace Volo.Abp.SettingManagement.Blazor.Pages.SettingManagement.EmailSetting
{
await EmailSettingsAppService.UpdateAsync(ObjectMapper.Map<EmailSettingsDto, UpdateEmailSettingsDto>(EmailSettings));
await UiMessageService.Success(L["SavedSuccessfully"]);
await UiMessageService.Success(L["SuccessfullySaved"]);
}
}
}

6
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Settings/EmailSettingManagementPageContributor.cs → modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Settings/EmailSettingPageContributor.cs

@ -7,7 +7,7 @@ using Volo.Abp.SettingManagement.Localization;
namespace Volo.Abp.SettingManagement.Blazor.Settings
{
public class EmailSettingManagementPageContributor: ISettingComponentContributor
public class EmailSettingPageContributor: ISettingComponentContributor
{
public async Task ConfigureAsync(SettingComponentCreationContext context)
{
@ -20,7 +20,7 @@ namespace Volo.Abp.SettingManagement.Blazor.Settings
context.Groups.Add(
new SettingComponentGroup(
"Volo.Abp.SettingManagement",
l["Menu:EmailSettingManagement"],
l["Menu:EmailSetting"],
typeof(EmailSettingGroupViewComponent)
)
);
@ -35,7 +35,7 @@ namespace Volo.Abp.SettingManagement.Blazor.Settings
{
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
return await authorizationService.IsGrantedAsync(SettingManagementPermissions.EmailSettingManagement);
return await authorizationService.IsGrantedAsync(SettingManagementPermissions.EmailSetting);
}
}
}

4
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/de-DE.json

@ -4,8 +4,8 @@
"Settings": "Einstellungen",
"SuccessfullySaved": "Erfolgreich gespeichert",
"Permission:SettingManagement": "Einstellungen-Verwaltung",
"Permission:EmailSettingManagement": "E-Mail-Einstellungen",
"Menu:EmailSettingManagement": "E-Mail-Verwaltung",
"Permission:EmailSetting": "E-Mail-Einstellungen",
"Menu:EmailSetting": "E-Mail-Einstellung",
"SmtpHost": "Host",
"SmtpPort": "Port",
"SmtpUserName": "Benutzername",

4
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/Localization/Resources/AbpSettingManagement/en.json

@ -4,8 +4,8 @@
"Settings": "Settings",
"SuccessfullySaved": "Successfully saved",
"Permission:SettingManagement": "Setting Management",
"Permission:EmailSettingManagement": "Email Settings",
"Menu:EmailSettingManagement": "Email management",
"Permission:EmailSetting": "Email Setting",
"Menu:EmailSetting": "Email Setting",
"SmtpHost": "Host",
"SmtpPort": "Port",
"SmtpUserName": "User name",

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save