From 229452046de82c4bf4140e407bab929ecbb66cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Sun, 21 Nov 2021 23:31:21 +0300 Subject: [PATCH] use file-scoped namespacing for cmsKit module --- .../CmsKitHttpApiHostModule.cs | 259 +- .../Controllers/HomeController.cs | 11 +- .../CmsKitHttpApiHostMigrationsDbContext.cs | 25 +- ...itHttpApiHostMigrationsDbContextFactory.cs | 33 +- .../Migrations/20210609081519_Initial.cs | 906 ++++--- .../host/Volo.CmsKit.HttpApi.Host/Program.cs | 63 +- .../host/Volo.CmsKit.HttpApi.Host/Startup.cs | 19 +- .../CmsKitIdentityServerModule.cs | 315 ++- .../IdentityServerHostMigrationsDbContext.cs | 31 +- ...ityServerHostMigrationsDbContextFactory.cs | 33 +- .../IdentityServerDataSeedContributor.cs | 299 ++- .../Migrations/20201013055450_Initial.cs | 2141 ++++++++-------- .../Pages/Index.cshtml.cs | 11 +- .../Volo.CmsKit.IdentityServer/Program.cs | 63 +- .../Volo.CmsKit.IdentityServer/Startup.cs | 19 +- .../CmsKitBrandingProvider.cs | 11 +- .../CmsKitWebAutoMapperProfile.cs | 11 +- .../CmsKitWebHostMenuContributor.cs | 73 +- .../CmsKitWebHostModule.cs | 329 ++- .../Controllers/AccountController.cs | 7 +- .../Pages/CmsKitPageModel.cs | 13 +- .../Pages/Index.cshtml.cs | 21 +- .../host/Volo.CmsKit.Web.Host/Program.cs | 63 +- .../host/Volo.CmsKit.Web.Host/Startup.cs | 19 +- .../CmsKitWebUnifiedModule.cs | 311 ++- .../EntityFrameworkCore/UnifiedDbContext.cs | 35 +- .../UnifiedDbContextFactory.cs | 33 +- .../Migrations/20211110134400_Initial.cs | 2191 ++++++++--------- .../Pages/Index.cshtml.cs | 7 +- .../host/Volo.CmsKit.Web.Unified/Program.cs | 69 +- .../host/Volo.CmsKit.Web.Unified/Startup.cs | 19 +- .../Volo/CmsKit/Admin/Blogs/BlogDto.cs | 15 +- .../CmsKit/Admin/Blogs/BlogFeatureInputDto.cs | 17 +- .../CmsKit/Admin/Blogs/BlogGetListInput.cs | 11 +- .../Volo/CmsKit/Admin/Blogs/BlogPostDto.cs | 31 +- .../Admin/Blogs/BlogPostGetListInput.cs | 13 +- .../CmsKit/Admin/Blogs/BlogPostListDto.cs | 33 +- .../Volo/CmsKit/Admin/Blogs/CreateBlogDto.cs | 21 +- .../CmsKit/Admin/Blogs/CreateBlogPostDto.cs | 37 +- .../Admin/Blogs/IBlogAdminAppService.cs | 7 +- .../Blogs/IBlogFeatureAdminAppService.cs | 11 +- .../Admin/Blogs/IBlogPostAdminAppService.cs | 21 +- .../Volo/CmsKit/Admin/Blogs/UpdateBlogDto.cs | 23 +- .../CmsKit/Admin/Blogs/UpdateBlogPostDto.cs | 35 +- .../CmsKitAdminApplicationContractsModule.cs | 13 +- .../Admin/CmsKitAdminRemoteServiceConsts.cs | 11 +- .../Volo/CmsKit/Admin/Comments/CmsUserDto.cs | 19 +- .../Volo/CmsKit/Admin/Comments/CommentDto.cs | 25 +- .../Admin/Comments/CommentGetListInput.cs | 25 +- .../Admin/Comments/CommentWithAuthorDto.cs | 29 +- .../Admin/Comments/ICommentAdminAppService.cs | 15 +- .../CreateMediaInputWithStream.cs | 17 +- .../IMediaDescriptorAdminAppService.cs | 15 +- .../MediaDescriptors/MediaDescriptorDto.cs | 21 +- .../Admin/Menus/IMenuItemAdminAppService.cs | 25 +- .../CmsKit/Admin/Menus/MenuCreateInput.cs | 11 +- .../CmsKit/Admin/Menus/MenuItemCreateInput.cs | 31 +- .../CmsKit/Admin/Menus/MenuItemMoveInput.cs | 13 +- .../CmsKit/Admin/Menus/MenuItemUpdateInput.cs | 31 +- .../CmsKit/Admin/Menus/MenuUpdateInput.cs | 11 +- .../Volo/CmsKit/Admin/Menus/PageLookupDto.cs | 13 +- .../CmsKit/Admin/Menus/PageLookupInputDto.cs | 13 +- .../CmsKit/Admin/Menus/UpdateMainMenuInput.cs | 13 +- .../CmsKit/Admin/Pages/CreatePageInputDto.cs | 37 +- .../CmsKit/Admin/Pages/GetPagesInputDto.cs | 13 +- .../Admin/Pages/IPageAdminAppService.cs | 9 +- .../Volo/CmsKit/Admin/Pages/PageDto.cs | 25 +- .../CmsKit/Admin/Pages/UpdatePageInputDto.cs | 37 +- .../CmsKit/Admin/Tags/EntityTagCreateDto.cs | 21 +- .../CmsKit/Admin/Tags/EntityTagRemoveDto.cs | 21 +- .../Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs | 15 +- .../Admin/Tags/IEntityTagAdminAppService.cs | 13 +- .../CmsKit/Admin/Tags/ITagAdminAppService.cs | 9 +- .../Volo/CmsKit/Admin/Tags/TagCreateDto.cs | 21 +- .../CmsKit/Admin/Tags/TagDefinitionDto.cs | 13 +- .../Volo/CmsKit/Admin/Tags/TagGetListInput.cs | 11 +- .../Volo/CmsKit/Admin/Tags/TagUpdateDto.cs | 17 +- ...CmsKitAdminPermissionDefinitionProvider.cs | 111 +- .../Permissions/CmsKitAdminPermissions.cs | 103 +- .../CmsKit/Admin/Blogs/BlogAdminAppService.cs | 107 +- .../Admin/Blogs/BlogFeatureAdminAppService.cs | 51 +- .../Admin/Blogs/BlogPostAdminAppService.cs | 155 +- .../CmsKit/Admin/CmsKitAdminAppServiceBase.cs | 41 +- ...CmsKitAdminApplicationAutoMapperProfile.cs | 41 +- .../Admin/CmsKitAdminApplicationModule.cs | 147 +- .../Admin/Comments/CommentAdminAppService.cs | 103 +- .../MediaDescriptorAdminAppService.cs | 93 +- .../Admin/Menus/MenuItemAdminAppService.cs | 199 +- .../CmsKit/Admin/Pages/PageAdminAppService.cs | 143 +- .../Admin/Tags/EntityTagAdminAppService.cs | 97 +- .../CmsKit/Admin/Tags/TagAdminAppService.cs | 173 +- .../ClientProxies/BlogAdminClientProxy.cs | 7 +- .../BlogFeatureAdminClientProxy.cs | 7 +- .../ClientProxies/BlogPostAdminClientProxy.cs | 7 +- .../ClientProxies/CommentAdminClientProxy.cs | 7 +- .../EntityTagAdminClientProxy.cs | 7 +- .../MediaDescriptorAdminClientProxy.cs | 7 +- .../ClientProxies/MenuItemAdminClientProxy.cs | 7 +- .../ClientProxies/PageAdminClientProxy.cs | 7 +- .../ClientProxies/TagAdminClientProxy.cs | 7 +- .../Admin/CmsKitAdminHttpApiClientModule.cs | 31 +- .../CmsKit/Admin/Blogs/BlogAdminController.cs | 97 +- .../Admin/Blogs/BlogFeatureAdminController.cs | 45 +- .../Admin/Blogs/BlogPostAdminController.cs | 91 +- .../CmsKit/Admin/CmsKitAdminController.cs | 11 +- .../CmsKit/Admin/CmsKitAdminHttpApiModule.cs | 35 +- .../Admin/Comments/CommentAdminController.cs | 61 +- .../MediaDescriptorAdminController.cs | 47 +- .../Admin/Menus/MenuItemAdminController.cs | 113 +- .../CmsKit/Admin/Pages/PageAdminController.cs | 87 +- .../Admin/Tags/EntityTagAdminController.cs | 53 +- .../CmsKit/Admin/Tags/TagAdminController.cs | 97 +- .../CmsKitAdminWebModule.cs | 257 +- .../Menus/CmsKitAdminMenuContributor.cs | 143 +- .../Menus/CmsKitAdminMenus.cs | 57 +- .../Pages/CmsKit/BlogPosts/Create.cshtml.cs | 85 +- .../Pages/CmsKit/BlogPosts/Index.cshtml.cs | 9 +- .../Pages/CmsKit/BlogPosts/Update.cshtml.cs | 129 +- .../Pages/CmsKit/Blogs/CreateModal.cshtml.cs | 51 +- .../CmsKit/Blogs/FeaturesModal.cshtml.cs | 89 +- .../Pages/CmsKit/Blogs/Index.cshtml.cs | 9 +- .../Pages/CmsKit/Blogs/UpdateModal.cshtml.cs | 73 +- .../Pages/CmsKit/Comments/Details.cshtml.cs | 47 +- .../Pages/CmsKit/Comments/Index.cshtml.cs | 17 +- .../Menus/MenuItems/CreateModal.cshtml.cs | 79 +- .../CmsKit/Menus/MenuItems/Index.cshtml.cs | 9 +- .../Menus/MenuItems/UpdateModal.cshtml.cs | 107 +- .../Pages/CmsKit/Pages/Create.cshtml.cs | 69 +- .../Pages/CmsKit/Pages/Index.cshtml.cs | 13 +- .../Pages/CmsKit/Pages/Update.cshtml.cs | 115 +- .../TagEditor/TagEditorViewComponent.cs | 65 +- .../Pages/CmsKit/Tags/CreateModal.cshtml.cs | 67 +- .../Pages/CmsKit/Tags/EditModal.cshtml.cs | 77 +- .../Pages/CmsKit/Tags/Index.cshtml.cs | 7 +- .../Pages/CmsKitAdminPageBase.cs | 17 +- .../Pages/CmsKitAdminPageModel.cs | 17 +- .../Properties/launchSettings.json | 27 + .../CmsKitApplicationContractsModule.cs | 15 +- .../Volo/CmsKit/CmsKitApplicationModule.cs | 17 +- .../Volo/CmsKit/Blogs/BlogFeatureCacheItem.cs | 15 +- .../Volo/CmsKit/Blogs/BlogFeatureCacheKey.cs | 25 +- .../Volo/CmsKit/Blogs/BlogFeatureDto.cs | 13 +- .../CmsKit/Blogs/IBlogFeatureAppService.cs | 9 +- .../CmsKitCommonApplicationContractsModule.cs | 17 +- .../CmsKit/CmsKitCommonRemoteServiceConsts.cs | 11 +- .../IMediaDescriptorAppService.cs | 11 +- .../Volo/CmsKit/Menus/MenuItemDto.cs | 31 +- .../CmsKitPermissionDefinitionProvider.cs | 25 +- .../CmsKit/Permissions/CmsKitPermissions.cs | 15 +- .../Volo/CmsKit/Tags/ITagAppService.cs | 11 +- .../Volo/CmsKit/Tags/TagDto.cs | 15 +- .../Volo/CmsKit/Users/CmsUserDto.cs | 17 +- .../CmsKit/Blogs/BlogFeatureAppService.cs | 61 +- .../CmsKit/Blogs/BlogFeatureChangedHandler.cs | 47 +- .../Volo/CmsKit/CmsKitAppServiceBase.cs | 11 +- ...msKitCommonApplicationAutoMapperProfile.cs | 19 +- .../CmsKit/CmsKitCommonApplicationModule.cs | 27 +- .../MediaDescriptorAppService.cs | 33 +- .../CmsKit/Menus/MenuApplicationConsts.cs | 11 +- .../Volo/CmsKit/Menus/MenuChangedHandler.cs | 49 +- .../Volo/CmsKit/Tags/TagAppService.cs | 31 +- .../ClientProxies/BlogFeatureClientProxy.cs | 7 +- .../MediaDescriptorClientProxy.cs | 7 +- .../CmsKit/CmsKitCommonHttpApiClientModule.cs | 33 +- .../CmsKit/Blogs/BlogFeatureController.cs | 35 +- .../Volo/CmsKit/CmsKitCommonHttpApiModule.cs | 41 +- .../Volo/CmsKit/CmsKitControllerBase.cs | 11 +- .../MediaDescriptorController.cs | 35 +- .../CmsKitCommonWebModule.cs | 63 +- .../CmsKitUiCommentOptions.cs | 15 +- .../Volo.CmsKit.Common.Web/CmsKitUiOptions.cs | 21 +- .../Contents/IContentRenderer.cs | 11 +- .../Contents/PlainTextContentRenderer.cs | 13 +- .../Icons/LocalizableIconDictionary.cs | 44 +- .../Pages/CommonPageModel.cs | 13 +- .../Properties/launchSettings.json | 27 + .../Reactions/ReactionIconDictionary.cs | 19 +- ...oduleFeaturesDictionaryCmsKitExtensions.cs | 41 +- .../Volo/CmsKit/Blogs/BlogConsts.cs | 11 +- .../Volo/CmsKit/Blogs/BlogFeatureConsts.cs | 9 +- .../Volo/CmsKit/Blogs/BlogPostConsts.cs | 21 +- .../Volo/CmsKit/CmsKitDomainSharedModule.cs | 45 +- .../Volo/CmsKit/CmsKitErrorCodes.cs | 87 +- .../Volo/CmsKit/Comments/CommentConsts.cs | 15 +- .../Volo/CmsKit/Entities/CmsEntityConsts.cs | 11 +- .../CmsKit/GlobalFeatures/BlogsFeature.cs | 19 +- .../CmsKit/GlobalFeatures/CmsUserFeature.cs | 21 +- .../CmsKit/GlobalFeatures/CommentsFeature.cs | 35 +- .../GlobalFeatures/GlobalCmsKitFeatures.cs | 51 +- .../CmsKit/GlobalFeatures/MediaFeature.cs | 39 +- .../Volo/CmsKit/GlobalFeatures/MenuFeature.cs | 17 +- .../CmsKit/GlobalFeatures/PagesFeature.cs | 37 +- .../CmsKit/GlobalFeatures/RatingsFeature.cs | 37 +- .../CmsKit/GlobalFeatures/ReactionsFeature.cs | 33 +- .../Volo/CmsKit/GlobalFeatures/TagsFeature.cs | 35 +- .../CmsKit/Localization/CmsKitResource.cs | 11 +- .../MediaDescriptors/MediaDescriptorConsts.cs | 23 +- .../Volo/CmsKit/Menus/MenuConsts.cs | 9 +- .../Volo/CmsKit/Menus/MenuItemConsts.cs | 11 +- .../Volo/CmsKit/Pages/PageConsts.cs | 42 +- .../Volo/CmsKit/Ratings/RatingConsts.cs | 17 +- .../CmsKit/Reactions/StandardReactions.cs | 31 +- .../CmsKit/Reactions/UserReactionConsts.cs | 13 +- .../Volo/CmsKit/Tags/TagConsts.cs | 13 +- .../Volo/CmsKit/Blogs/Blog.cs | 65 +- .../Volo/CmsKit/Blogs/BlogFeature.cs | 23 +- .../Volo/CmsKit/Blogs/BlogFeatureManager.cs | 59 +- .../Volo/CmsKit/Blogs/BlogManager.cs | 57 +- .../Volo/CmsKit/Blogs/BlogPost.cs | 137 +- .../Volo/CmsKit/Blogs/BlogPostManager.cs | 115 +- .../BlogPostSlugAlreadyExistException.cs | 33 +- .../Blogs/BlogSlugAlreadyExistException.cs | 25 +- .../Blogs/DefaultBlogFeatureProvider.cs | 11 +- .../CmsKit/Blogs/IBlogFeatureRepository.cs | 13 +- .../Volo/CmsKit/Blogs/IBlogPostRepository.cs | 35 +- .../Volo/CmsKit/Blogs/IBlogRepository.cs | 39 +- .../Blogs/IDefaultBlogFeatureProvider.cs | 9 +- .../Volo/CmsKit/CmsKitDbProperties.cs | 13 +- .../Volo/CmsKit/CmsKitDomainModule.cs | 91 +- .../Volo/CmsKit/CmsKitDomainServiceBase.cs | 7 +- .../CmsKit/Comments/CmsKitCommentOptions.cs | 11 +- .../Volo/CmsKit/Comments/Comment.cs | 75 +- .../Comments/CommentEntityTypeDefinition.cs | 11 +- .../Volo/CmsKit/Comments/CommentManager.cs | 59 +- .../CommentWithAuthorQueryResultItem.cs | 11 +- ...DefaultCommentEntityTypeDefinitionStore.cs | 41 +- .../Comments/EntityNotCommentableException.cs | 27 +- .../ICommentEntityTypeDefinitionStore.cs | 7 +- .../CmsKit/Comments/ICommentRepository.cs | 71 +- .../Volo/CmsKit/EntityTypeDefinition.cs | 23 +- .../Volo/CmsKit/IEntityTypeDefinitionStore.cs | 13 +- .../MediaDescriptors/CmsKitMediaOptions.cs | 11 +- .../DefaultMediaDescriptorDefinitionStore.cs | 71 +- .../EntityCantHaveMediaException.cs | 25 +- .../IMediaDescriptorDefinitionStore.cs | 7 +- .../IMediaDescriptorRepository.cs | 11 +- .../InvalidMediaDescriptorNameException.cs | 27 +- .../CmsKit/MediaDescriptors/MediaContainer.cs | 13 +- .../MediaDescriptors/MediaDescriptor.cs | 59 +- .../MediaDescriptors/MediaDescriptorChecks.cs | 19 +- .../MediaDescriptorDefinition.cs | 23 +- .../MediaDescriptorManager.cs | 39 +- .../Volo/CmsKit/Menus/IMenuItemRepository.cs | 7 +- .../Volo/CmsKit/Menus/MenuItem.cs | 137 +- .../Volo/CmsKit/Menus/MenuItemManager.cs | 73 +- .../Volo/CmsKit/Menus/PageChangedHandler.cs | 55 +- .../Volo/CmsKit/Pages/IPageRepository.cs | 31 +- .../Volo/CmsKit/Pages/Page.cs | 99 +- .../Volo/CmsKit/Pages/PageManager.cs | 77 +- .../Pages/PageSlugAlreadyExistsException.cs | 27 +- .../Volo/CmsKit/PolicySpecifiedDefinition.cs | 61 +- .../CmsKit/Ratings/CmsKitRatingOptions.cs | 11 +- .../DefaultRatingEntityTypeDefinitionStore.cs | 41 +- .../Ratings/EntityCantHaveRatingException.cs | 25 +- .../IRatingEntityTypeDefinitionStore.cs | 9 +- .../Volo/CmsKit/Ratings/IRatingRepository.cs | 31 +- .../Volo/CmsKit/Ratings/Rating.cs | 81 +- .../Ratings/RatingEntityTypeDefinition.cs | 11 +- .../Volo/CmsKit/Ratings/RatingManager.cs | 67 +- .../RatingWithStarCountQueryResultItem.cs | 13 +- .../CmsKit/Reactions/CmsKitReactionOptions.cs | 11 +- .../DefaultReactionDefinitionStore.cs | 79 +- .../EntityCantHaveReactionException.cs | 25 +- .../Reactions/IReactionDefinitionStore.cs | 11 +- .../Reactions/IUserReactionRepository.cs | 43 +- .../CmsKit/Reactions/ReactionDefinition.cs | 27 +- .../Reactions/ReactionEntityTypeDefinition.cs | 27 +- .../Volo/CmsKit/Reactions/ReactionManager.cs | 165 +- .../Volo/CmsKit/Reactions/ReactionSummary.cs | 13 +- .../ReactionSummaryQueryResultItem.cs | 11 +- .../Volo/CmsKit/Reactions/UserReaction.cs | 53 +- .../CmsKitSettingDefinitionProvider.cs | 17 +- .../Volo/CmsKit/Settings/CmsKitSettings.cs | 17 +- .../Volo/CmsKit/SlugNormalizer.cs | 13 +- .../Volo/CmsKit/Tags/CmsKitTagOptions.cs | 11 +- .../CmsKit/Tags/DefaultTagDefinitionStore.cs | 93 +- .../CmsKit/Tags/EntityNotTaggableException.cs | 21 +- .../Volo/CmsKit/Tags/EntityTag.cs | 41 +- .../Volo/CmsKit/Tags/EntityTagManager.cs | 105 +- .../Volo/CmsKit/Tags/IEntityTagRepository.cs | 21 +- .../Volo/CmsKit/Tags/ITagDefinitionStore.cs | 9 +- .../Volo/CmsKit/Tags/ITagRepository.cs | 43 +- .../Volo/CmsKit/Tags/Tag.cs | 67 +- .../CmsKit/Tags/TagAlreadyExistException.cs | 17 +- .../CmsKit/Tags/TagEntityTypeDefinitions.cs | 7 +- .../CmsKit/Tags/TagEntityTypeDefiniton.cs | 35 +- .../Volo/CmsKit/Tags/TagManager.cs | 87 +- .../Volo/CmsKit/Users/CmsUser.cs | 111 +- .../Volo/CmsKit/Users/CmsUserLookupService.cs | 27 +- .../Volo/CmsKit/Users/CmsUserSynchronizer.cs | 55 +- .../CmsKit/Users/ICmsUserLookupService.cs | 7 +- .../Volo/CmsKit/Users/ICmsUserRepository.cs | 7 +- .../Blogs/EfCoreBlogFeatureRepository.cs | 41 +- .../CmsKit/Blogs/EfCoreBlogPostRepository.cs | 149 +- .../Volo/CmsKit/Blogs/EfCoreBlogRepository.cs | 79 +- .../Comments/EfCoreCommentRepository.cs | 289 ++- .../EntityFrameworkCore/CmsKitDbContext.cs | 49 +- .../CmsKitDbContextModelCreatingExtensions.cs | 368 ++- .../CmsKitEntityFrameworkCoreModule.cs | 45 +- .../EntityFrameworkCore/ICmsKitDbContext.cs | 33 +- .../EfCoreMediaDescriptorRepository.cs | 11 +- .../CmsKit/Menus/EfCoreMenuItemRepository.cs | 9 +- .../Volo/CmsKit/Pages/EfCorePageRepository.cs | 89 +- .../CmsKit/Ratings/EfCoreRatingRepository.cs | 81 +- .../Reactions/EfCoreUserReactionRepository.cs | 117 +- .../CmsKit/Tags/EfCoreEntityTagRepository.cs | 55 +- .../Volo/CmsKit/Tags/EfCoreTagRepository.cs | 147 +- .../CmsKit/Users/EfCoreCmsUserRepository.cs | 11 +- .../Volo/CmsKit/CmsKitHttpApiClientModule.cs | 17 +- .../Volo/CmsKit/CmsKitHttpApiModule.cs | 17 +- .../Abp/CmsKit/AbpCmsKitInstallerModule.cs | 23 +- .../CmsKit/CmsKitInstallerPipelineBuilder.cs | 29 +- .../Blogs/MongoBlogFeatureRepository.cs | 41 +- .../MongoDB/Blogs/MongoBlogPostRepository.cs | 167 +- .../MongoDB/Blogs/MongoBlogRepository.cs | 95 +- .../CmsKit/MongoDB/CmsKitMongoDbContext.cs | 47 +- .../MongoDB/CmsKitMongoDbContextExtensions.cs | 117 +- .../CmsKit/MongoDB/CmsKitMongoDbModule.cs | 45 +- .../Comments/MongoCommentRepository.cs | 326 ++- .../CmsKit/MongoDB/ICmsKitMongoDbContext.cs | 35 +- .../MongoMediaDescriptorRepository.cs | 11 +- .../MongoDB/Menus/MongoMenuItemRepository.cs | 9 +- .../MongoDB/Pages/MongoPageRepository.cs | 105 +- .../MongoDB/Ratings/MongoRatingRepository.cs | 83 +- .../Reactions/MongoUserReactionRepository.cs | 113 +- .../MongoDB/Tags/MongoEntityTagRepository.cs | 53 +- .../CmsKit/MongoDB/Tags/MongoTagRepository.cs | 153 +- .../MongoDB/Users/MongoCmsUserRepository.cs | 11 +- .../CmsKit/Public/Blogs/BlogPostPublicDto.cs | 25 +- .../Public/Blogs/GetBlogFeatureInput.cs | 11 +- .../Public/Blogs/IBlogPostPublicAppService.cs | 11 +- .../CmsKitPublicApplicationContractsModule.cs | 15 +- .../Public/CmsKitPublicRemoteServiceConsts.cs | 11 +- .../Volo/CmsKit/Public/Comments/CmsUserDto.cs | 17 +- .../Volo/CmsKit/Public/Comments/CommentDto.cs | 27 +- .../Public/Comments/CommentWithDetailsDto.cs | 27 +- .../Public/Comments/CreateCommentInput.cs | 17 +- .../Public/Comments/CreatedCommentEvent.cs | 11 +- .../Comments/ICommentPublicAppService.cs | 15 +- .../Public/Comments/UpdateCommentInput.cs | 17 +- .../Public/Menus/IMenuItemPublicAppService.cs | 11 +- .../Public/Pages/IPagePublicAppService.cs | 11 +- .../Volo/CmsKit/Public/Pages/PageDto.cs | 21 +- .../Public/Ratings/CreateUpdateRatingInput.cs | 17 +- .../Public/Ratings/IRatingPublicAppService.cs | 15 +- .../Volo/CmsKit/Public/Ratings/RatingDto.cs | 27 +- .../Public/Ratings/RatingWithStarCountDto.cs | 17 +- .../Reactions/IReactionPublicAppService.cs | 13 +- .../CmsKit/Public/Reactions/ReactionDto.cs | 17 +- .../Reactions/ReactionWithSelectionDto.cs | 15 +- .../Public/Blogs/BlogPostPublicAppService.cs | 53 +- .../Public/CmsKitPublicAppServiceBase.cs | 11 +- .../Public/CmsKitPublicApplicationModule.cs | 29 +- .../Comments/CommentPublicAppService.cs | 187 +- .../Public/Menus/MenuItemPublicAppService.cs | 55 +- .../Public/Pages/PagePublicAppService.cs | 35 +- .../PublicApplicationAutoMapperProfile.cs | 31 +- .../Public/Ratings/RatingPublicAppService.cs | 107 +- .../Reactions/ReactionPublicAppService.cs | 133 +- .../BlogPostPublicClientProxy.cs | 7 +- .../ClientProxies/CommentPublicClientProxy.cs | 7 +- .../MenuItemPublicClientProxy.cs | 7 +- .../ClientProxies/PagesPublicClientProxy.cs | 7 +- .../ClientProxies/RatingPublicClientProxy.cs | 7 +- .../ReactionPublicClientProxy.cs | 7 +- .../ClientProxies/TagPublicClientProxy.cs | 7 +- .../Public/CmsKitPublicHttpApiClientModule.cs | 31 +- .../Public/Blogs/BlogPostPublicController.cs | 47 +- .../Public/CmsKitPublicControllerBase.cs | 7 +- .../Public/CmsKitPublicHttpApiModule.cs | 21 +- .../Comments/CommentPublicController.cs | 71 +- .../Public/Menus/MenuItemPublicController.cs | 33 +- .../Public/Pages/PagesPublicController.cs | 35 +- .../Public/Ratings/RatingPublicController.cs | 59 +- .../Reactions/ReactionPublicController.cs | 59 +- .../CmsKit/Public/Tags/TagPublicController.cs | 35 +- .../CmsKitPublicWebAutoMapperProfile.cs | 9 +- .../CmsKitPublicWebModule.cs | 113 +- .../CmsKitPublicWidgetsController.cs | 27 +- .../Menus/CmsKitPublicMenuContributor.cs | 81 +- .../Menus/CmsKitPublicMenus.cs | 21 +- .../DefaultBlogPostCommentViewComponent.cs | 47 +- .../CommentingScriptBundleContributor.cs | 15 +- .../CommentingStyleBundleContributor.cs | 11 +- .../Commenting/CommentingViewComponent.cs | 83 +- .../Pages/DefaultPageViewComponent.cs | 69 +- .../Rating/RatingScriptBundleContributor.cs | 17 +- .../Rating/RatingStyleBundleContributor.cs | 15 +- .../Components/Rating/RatingViewComponent.cs | 97 +- ...eactionSelectionScriptBundleContributor.cs | 15 +- ...ReactionSelectionStyleBundleContributor.cs | 13 +- .../ReactionSelectionViewComponent.cs | 133 +- .../Components/Tags/TagViewComponent.cs | 61 +- .../Pages/CmsKitPublicPageBase.cs | 21 +- .../Pages/CmsKitPublicPageModelBase.cs | 13 +- .../Public/CmsKit/Blogs/BlogPost.cshtml.cs | 81 +- .../Pages/Public/CmsKit/Blogs/Index.cshtml.cs | 49 +- .../Pages/Public/CmsKit/Pages/Index.cshtml.cs | 45 +- .../Properties/launchSettings.json | 27 + .../Renderers/IMarkdownToHtmlRenderer.cs | 9 +- .../Renderers/MarkdownToHtmlRenderer.cs | 25 +- .../src/Volo.CmsKit.Web/CmsKitWebModule.cs | 17 +- .../Properties/launchSettings.json | 27 + .../Blogs/BlogAdminAppService_Tests.cs | 147 +- .../Blogs/BlogFeatureAdminAppService_Test.cs | 91 +- .../Blogs/BlogFeaturePublicAppService_Test.cs | 51 +- .../Blogs/BlogPostAdminAppService_Tests.cs | 255 +- .../Blogs/BlogPostPublicAppService_Tests.cs | 83 +- .../CmsKitApplicationTestBase.cs | 29 +- .../CmsKitApplicationTestModule.cs | 15 +- .../Comments/CommentAdminAppService_Tests.cs | 73 +- .../Comments/CommentPublicAppService_Tests.cs | 141 +- .../MediaDescriptorAdminAppService_Tests.cs | 65 +- .../Menus/MenuItemAdminAppService_Tests.cs | 117 +- .../Pages/PageAdminAppService_Tests.cs | 227 +- .../Pages/PagePublicAppService_Tests.cs | 51 +- .../Ratings/RatingPublicAppService_Tests.cs | 167 +- .../ReactionPublicAppService_Tests.cs | 165 +- .../Tags/TagAdminAppService_Tests.cs | 83 +- .../Tags/TagPublicAppService_Tests.cs | 71 +- .../Blogs/BlogManager_Test.cs | 83 +- .../Blogs/BlogPostManager_Tests.cs | 109 +- .../Blogs/SlugExtensions_Tests.cs | 251 +- .../CmsKitDomainTestBase.cs | 31 +- .../CmsKitDomainTestModule.cs | 21 +- .../Comments/CommentManager_Test.cs | 91 +- .../Features/GlobalCmsKitFeatures_Tests.cs | 37 +- .../MediaDescriptorManager_Test.cs | 61 +- .../Menus/MenuManager_Test.cs | 107 +- .../Pages/PageManager_Test.cs | 93 +- .../Ratings/RatingManager_Test.cs | 85 +- .../Reactions/ReactionManager_Tests.cs | 121 +- .../Tags/EntityTagManager_Tests.cs | 139 +- ...TagEntityTypeDefinitionDictionary_Tests.cs | 83 +- .../Tags/TagManager_Tests.cs | 211 +- .../Blogs/BlogFeatureRepository_Test.cs | 9 +- .../Blogs/BlogPostRepository_Test.cs | 7 +- .../Blogs/BlogRepository_Test.cs | 9 +- .../CmsKitEntityFrameworkCoreTestBase.cs | 15 +- .../CmsKitEntityFrameworkCoreTestModule.cs | 53 +- .../Comments/CommentRepository_Tests.cs | 7 +- .../Menus/MenuRepository_Test.cs | 11 +- .../Pages/PageRepository_Test.cs | 11 +- .../Ratings/RatingRepository_Tests.cs | 11 +- .../Reactions/UserReactionRepository_Tests.cs | 7 +- .../Tags/EntityTagRepository_Test.cs | 9 +- .../Tags/TagRepository_Test.cs | 11 +- .../ClientDemoService.cs | 21 +- .../CmsKitConsoleApiClientModule.cs | 17 +- .../ConsoleTestAppHostedService.cs | 23 +- .../Program.cs | 25 +- .../Blogs/BlogFeatureRepository_Test.cs | 9 +- .../MongoDB/Blogs/BlogPostRepository_Test.cs | 11 +- .../MongoDB/Blogs/BlogRepository_Test.cs | 9 +- .../MongoDB/CmsKitMongoDbTestBase.cs | 15 +- .../MongoDB/CmsKitMongoDbTestModule.cs | 33 +- .../Comments/CommentRepository_Tests.cs | 9 +- .../MongoDB/Menus/MenuRepository_Test.cs | 13 +- .../MongoDB/MongoDbFixture.cs | 27 +- .../MongoDB/MongoTestCollection.cs | 13 +- .../MongoDB/Pages/PageRepository_Test.cs | 13 +- .../MongoDB/Ratings/RatingRepository_Tests.cs | 13 +- .../Reactions/UserReactionRepository_Tests.cs | 9 +- .../MongoDB/Tags/EntityTagRepository_Test.cs | 11 +- .../MongoDB/Tags/TagRepository_Test.cs | 13 +- .../Blogs/BlogFeatureRepository_Test.cs | 95 +- .../Blogs/BlogPostRepository_Test.cs | 269 +- .../Blogs/BlogRepository_Test.cs | 155 +- .../CmsKitDataSeedContributor.cs | 685 +++--- .../CmsKitFakeCurrentUser.cs | 79 +- .../Volo.CmsKit.TestBase/CmsKitTestBase.cs | 69 +- .../CmsKitTestBaseModule.cs | 81 +- .../Volo.CmsKit.TestBase/CmsKitTestData.cs | 141 +- .../Comments/CommentRepository_Tests.cs | 99 +- .../Volo.CmsKit.TestBase/FakeBlobProvider.cs | 45 +- .../Menus/MenuItemRepository_Test.cs | 25 +- .../Pages/PageRepository_Test.cs | 171 +- .../Ratings/RatingRepository_Tests.cs | 57 +- .../Reactions/UserReactionRepository_Tests.cs | 97 +- .../Security/FakeCurrentPrincipalAccessor.cs | 45 +- .../Tags/EntityTagRepository_Test.cs | 41 +- .../Tags/TagRepository_Test.cs | 221 +- 482 files changed, 14459 insertions(+), 14922 deletions(-) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Admin.Web/Properties/launchSettings.json create mode 100644 modules/cms-kit/src/Volo.CmsKit.Common.Web/Properties/launchSettings.json create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Properties/launchSettings.json create mode 100644 modules/cms-kit/src/Volo.CmsKit.Web/Properties/launchSettings.json diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs index c88dd06bea..d3ea4874a7 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs @@ -35,160 +35,159 @@ using Volo.Abp.Security.Claims; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.VirtualFileSystem; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitApplicationModule), + typeof(CmsKitEntityFrameworkCoreModule), + typeof(CmsKitHttpApiModule), + typeof(AbpAspNetCoreMvcUiMultiTenancyModule), + typeof(AbpAutofacModule), + typeof(AbpCachingStackExchangeRedisModule), + typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpAuditLoggingEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(BlobStoringDatabaseEntityFrameworkCoreModule) + )] +public class CmsKitHttpApiHostModule : AbpModule { - [DependsOn( - typeof(CmsKitApplicationModule), - typeof(CmsKitEntityFrameworkCoreModule), - typeof(CmsKitHttpApiModule), - typeof(AbpAspNetCoreMvcUiMultiTenancyModule), - typeof(AbpAutofacModule), - typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpEntityFrameworkCoreSqlServerModule), - typeof(AbpAuditLoggingEntityFrameworkCoreModule), - typeof(AbpPermissionManagementEntityFrameworkCoreModule), - typeof(AbpSettingManagementEntityFrameworkCoreModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(BlobStoringDatabaseEntityFrameworkCoreModule) - )] - public class CmsKitHttpApiHostModule : AbpModule + private const string DefaultCorsPolicyName = "Default"; + + public override void PreConfigureServices(ServiceConfigurationContext context) + { + FeatureConfigurer.Configure(); + } + + public override void ConfigureServices(ServiceConfigurationContext context) { - private const string DefaultCorsPolicyName = "Default"; + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); - public override void PreConfigureServices(ServiceConfigurationContext context) + Configure(options => { - FeatureConfigurer.Configure(); - } + options.UseSqlServer(); + }); - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - var hostingEnvironment = context.Services.GetHostingEnvironment(); - var configuration = context.Services.GetConfiguration(); + options.IsEnabled = MultiTenancyConsts.IsEnabled; + }); - Configure(options => + if (hostingEnvironment.IsDevelopment()) + { + Configure(options => { - options.UseSqlServer(); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain.Shared", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application.Contracts", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application", Path.DirectorySeparatorChar))); }); + } - Configure(options => + context.Services.AddSwaggerGen( + options => { - options.IsEnabled = MultiTenancyConsts.IsEnabled; + options.SwaggerDoc("v1", new OpenApiInfo { Title = "CmsKit API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); }); - if (hostingEnvironment.IsDevelopment()) - { - Configure(options => - { - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain.Shared", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application.Contracts", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application", Path.DirectorySeparatorChar))); - }); - } - - context.Services.AddSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "CmsKit API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - }); - - Configure(options => + Configure(options => + { + options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); + options.Languages.Add(new LanguageInfo("en", "en", "English")); + options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); + options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); + options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); + options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); + options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); + options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); + options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); + options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); + options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); + options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); + options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); + options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); + options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); + }); + + context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(options => { - options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); - options.Languages.Add(new LanguageInfo("en", "en", "English")); - options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); - options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); - options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); - options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); - options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); - options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); - options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); - options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); - options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); - options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); - options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); - options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = false; + options.Audience = "CmsKit"; }); - context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) - .AddJwtBearer(options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = false; - options.Audience = "CmsKit"; - }); + Configure(options => + { + options.KeyPrefix = "CmsKit:"; + }); + + if (!hostingEnvironment.IsDevelopment()) + { + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services + .AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "CmsKit-Protection-Keys"); + } - Configure(options => + context.Services.AddCors(options => + { + options.AddPolicy(DefaultCorsPolicyName, builder => { - options.KeyPrefix = "CmsKit:"; + builder + .WithOrigins( + configuration["App:CorsOrigins"] + .Split(",", StringSplitOptions.RemoveEmptyEntries) + .Select(o => o.RemovePostFix("/")) + .ToArray() + ) + .WithAbpExposedHeaders() + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials(); }); + }); + } - if (!hostingEnvironment.IsDevelopment()) - { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - context.Services - .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "CmsKit-Protection-Keys"); - } + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); - context.Services.AddCors(options => - { - options.AddPolicy(DefaultCorsPolicyName, builder => - { - builder - .WithOrigins( - configuration["App:CorsOrigins"] - .Split(",", StringSplitOptions.RemoveEmptyEntries) - .Select(o => o.RemovePostFix("/")) - .ToArray() - ) - .WithAbpExposedHeaders() - .SetIsOriginAllowedToAllowWildcardSubdomains() - .AllowAnyHeader() - .AllowAnyMethod() - .AllowCredentials(); - }); - }); + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); } - - public override void OnApplicationInitialization(ApplicationInitializationContext context) + else { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); + app.UseErrorPage(); + app.UseHsts(); + } - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseErrorPage(); - app.UseHsts(); - } - - app.UseHttpsRedirection(); - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseCors(DefaultCorsPolicyName); - app.UseAuthentication(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } - app.UseAbpRequestLocalization(); - app.UseAuthorization(); - app.UseSwagger(); - app.UseSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); - }); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); + app.UseHttpsRedirection(); + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseCors(DefaultCorsPolicyName); + app.UseAuthentication(); + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); } + app.UseAbpRequestLocalization(); + app.UseAuthorization(); + app.UseSwagger(); + app.UseSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); + }); + app.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Controllers/HomeController.cs b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Controllers/HomeController.cs index a9d544e8af..fe2926e7a5 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Controllers/HomeController.cs +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Controllers/HomeController.cs @@ -1,13 +1,12 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; -namespace Volo.CmsKit.Controllers +namespace Volo.CmsKit.Controllers; + +public class HomeController : AbpController { - public class HomeController : AbpController + public ActionResult Index() { - public ActionResult Index() - { - return Redirect("~/swagger"); - } + return Redirect("~/swagger"); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContext.cs b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContext.cs index d833e84caa..ff494fd75f 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContext.cs +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContext.cs @@ -2,22 +2,21 @@ using Volo.Abp.BlobStoring.Database.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +public class CmsKitHttpApiHostMigrationsDbContext : AbpDbContext { - public class CmsKitHttpApiHostMigrationsDbContext : AbpDbContext + public CmsKitHttpApiHostMigrationsDbContext(DbContextOptions options) + : base(options) { - public CmsKitHttpApiHostMigrationsDbContext(DbContextOptions options) - : base(options) - { - - } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); - modelBuilder.ConfigureCmsKit(); - modelBuilder.ConfigureBlobStoring(); - } + modelBuilder.ConfigureCmsKit(); + modelBuilder.ConfigureBlobStoring(); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs index dc19e09635..bdd01c16f7 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs @@ -3,29 +3,28 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +public class CmsKitHttpApiHostMigrationsDbContextFactory : IDesignTimeDbContextFactory { - public class CmsKitHttpApiHostMigrationsDbContextFactory : IDesignTimeDbContextFactory + public CmsKitHttpApiHostMigrationsDbContext CreateDbContext(string[] args) { - public CmsKitHttpApiHostMigrationsDbContext CreateDbContext(string[] args) - { - FeatureConfigurer.Configure(); + FeatureConfigurer.Configure(); - var configuration = BuildConfiguration(); + var configuration = BuildConfiguration(); - var builder = new DbContextOptionsBuilder() - .UseSqlServer(configuration.GetConnectionString("CmsKit")); + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("CmsKit")); - return new CmsKitHttpApiHostMigrationsDbContext(builder.Options); - } + return new CmsKitHttpApiHostMigrationsDbContext(builder.Options); + } - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false); + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false); - return builder.Build(); - } + return builder.Build(); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Migrations/20210609081519_Initial.cs b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Migrations/20210609081519_Initial.cs index 362c3700f7..2703785947 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Migrations/20210609081519_Initial.cs +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Migrations/20210609081519_Initial.cs @@ -1,472 +1,456 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace Volo.CmsKit.Migrations +namespace Volo.CmsKit.Migrations; + +public partial class Initial : Migration { - public partial class Initial : Migration + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AbpBlobContainers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpBlobContainers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsBlogFeatures", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + BlogId = table.Column(type: "uniqueidentifier", nullable: false), + FeatureName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + IsEnabled = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsBlogFeatures", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsBlogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Slug = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsBlogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsComments", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Text = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: false), + RepliedCommentId = table.Column(type: "uniqueidentifier", nullable: true), + CreatorId = table.Column(type: "uniqueidentifier", nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsComments", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsEntityTags", + columns: table => new { + TagId = table.Column(type: "uniqueidentifier", nullable: false), + EntityId = table.Column(type: "nvarchar(450)", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsEntityTags", x => new { x.EntityId, x.TagId }); + }); + + migrationBuilder.CreateTable( + name: "CmsMediaDescriptors", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + MimeType = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Size = table.Column(type: "bigint", maxLength: 2147483647, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsMediaDescriptors", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsMenus", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: true), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsMenus", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsPages", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Title = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Slug = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Content = table.Column(type: "nvarchar(max)", maxLength: 2147483647, nullable: true), + Script = table.Column(type: "nvarchar(max)", nullable: true), + Style = table.Column(type: "nvarchar(max)", nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsPages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsRatings", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + StarCount = table.Column(type: "smallint", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsRatings", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsTags", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Name = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsTags", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsUserReactions", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ReactionName = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsUserReactions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpBlobs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ContainerId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Content = table.Column(type: "varbinary(max)", maxLength: 2147483647, nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpBlobs", x => x.Id); + table.ForeignKey( + name: "FK_AbpBlobs_AbpBlobContainers_ContainerId", + column: x => x.ContainerId, + principalTable: "AbpBlobContainers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CmsMenuItems", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + MenuId = table.Column(type: "uniqueidentifier", nullable: false), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + DisplayName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + IsActive = table.Column(type: "bit", nullable: false), + Url = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: false), + Icon = table.Column(type: "nvarchar(max)", nullable: true), + Order = table.Column(type: "int", nullable: false), + Target = table.Column(type: "nvarchar(max)", nullable: true), + ElementId = table.Column(type: "nvarchar(max)", nullable: true), + CssClass = table.Column(type: "nvarchar(max)", nullable: true), + RequiredPermissionName = table.Column(type: "nvarchar(max)", nullable: true), + PageId = table.Column(type: "uniqueidentifier", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsMenuItems", x => x.Id); + table.ForeignKey( + name: "FK_CmsMenuItems_CmsMenus_MenuId", + column: x => x.MenuId, + principalTable: "CmsMenus", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CmsBlogPosts", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + BlogId = table.Column(type: "uniqueidentifier", nullable: false), + Title = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Slug = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ShortDescription = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Content = table.Column(type: "nvarchar(max)", maxLength: 2147483647, nullable: true), + CoverImageMediaId = table.Column(type: "uniqueidentifier", nullable: true), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + AuthorId = table.Column(type: "uniqueidentifier", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsBlogPosts", x => x.Id); + table.ForeignKey( + name: "FK_CmsBlogPosts_CmsUsers_AuthorId", + column: x => x.AuthorId, + principalTable: "CmsUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AbpBlobContainers_TenantId_Name", + table: "AbpBlobContainers", + columns: new[] { "TenantId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpBlobs_ContainerId", + table: "AbpBlobs", + column: "ContainerId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpBlobs_TenantId_ContainerId_Name", + table: "AbpBlobs", + columns: new[] { "TenantId", "ContainerId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsBlogPosts_AuthorId", + table: "CmsBlogPosts", + column: "AuthorId"); + + migrationBuilder.CreateIndex( + name: "IX_CmsBlogPosts_Slug_BlogId", + table: "CmsBlogPosts", + columns: new[] { "Slug", "BlogId" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsComments_TenantId_EntityType_EntityId", + table: "CmsComments", + columns: new[] { "TenantId", "EntityType", "EntityId" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsComments_TenantId_RepliedCommentId", + table: "CmsComments", + columns: new[] { "TenantId", "RepliedCommentId" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsEntityTags_TenantId_EntityId_TagId", + table: "CmsEntityTags", + columns: new[] { "TenantId", "EntityId", "TagId" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsMenuItems_MenuId", + table: "CmsMenuItems", + column: "MenuId"); + + migrationBuilder.CreateIndex( + name: "IX_CmsPages_TenantId_Slug", + table: "CmsPages", + columns: new[] { "TenantId", "Slug" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsRatings_TenantId_EntityType_EntityId_CreatorId", + table: "CmsRatings", + columns: new[] { "TenantId", "EntityType", "EntityId", "CreatorId" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsTags_TenantId_Name", + table: "CmsTags", + columns: new[] { "TenantId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsUserReactions_TenantId_CreatorId_EntityType_EntityId_ReactionName", + table: "CmsUserReactions", + columns: new[] { "TenantId", "CreatorId", "EntityType", "EntityId", "ReactionName" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsUserReactions_TenantId_EntityType_EntityId_ReactionName", + table: "CmsUserReactions", + columns: new[] { "TenantId", "EntityType", "EntityId", "ReactionName" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsUsers_TenantId_Email", + table: "CmsUsers", + columns: new[] { "TenantId", "Email" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsUsers_TenantId_UserName", + table: "CmsUsers", + columns: new[] { "TenantId", "UserName" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AbpBlobContainers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpBlobContainers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsBlogFeatures", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - BlogId = table.Column(type: "uniqueidentifier", nullable: false), - FeatureName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - IsEnabled = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsBlogFeatures", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsBlogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Slug = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsBlogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsComments", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Text = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: false), - RepliedCommentId = table.Column(type: "uniqueidentifier", nullable: true), - CreatorId = table.Column(type: "uniqueidentifier", nullable: false), - CreationTime = table.Column(type: "datetime2", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsComments", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsEntityTags", - columns: table => new - { - TagId = table.Column(type: "uniqueidentifier", nullable: false), - EntityId = table.Column(type: "nvarchar(450)", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsEntityTags", x => new { x.EntityId, x.TagId }); - }); - - migrationBuilder.CreateTable( - name: "CmsMediaDescriptors", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), - MimeType = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Size = table.Column(type: "bigint", maxLength: 2147483647, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsMediaDescriptors", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsMenus", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: true), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsMenus", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsPages", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Title = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Slug = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Content = table.Column(type: "nvarchar(max)", maxLength: 2147483647, nullable: true), - Script = table.Column(type: "nvarchar(max)", nullable: true), - Style = table.Column(type: "nvarchar(max)", nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsPages", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsRatings", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - StarCount = table.Column(type: "smallint", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: false), - CreationTime = table.Column(type: "datetime2", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsRatings", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsTags", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Name = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsTags", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsUserReactions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ReactionName = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: false), - CreationTime = table.Column(type: "datetime2", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsUserReactions", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpBlobs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ContainerId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Content = table.Column(type: "varbinary(max)", maxLength: 2147483647, nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpBlobs", x => x.Id); - table.ForeignKey( - name: "FK_AbpBlobs_AbpBlobContainers_ContainerId", - column: x => x.ContainerId, - principalTable: "AbpBlobContainers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "CmsMenuItems", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - MenuId = table.Column(type: "uniqueidentifier", nullable: false), - ParentId = table.Column(type: "uniqueidentifier", nullable: true), - DisplayName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - IsActive = table.Column(type: "bit", nullable: false), - Url = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: false), - Icon = table.Column(type: "nvarchar(max)", nullable: true), - Order = table.Column(type: "int", nullable: false), - Target = table.Column(type: "nvarchar(max)", nullable: true), - ElementId = table.Column(type: "nvarchar(max)", nullable: true), - CssClass = table.Column(type: "nvarchar(max)", nullable: true), - RequiredPermissionName = table.Column(type: "nvarchar(max)", nullable: true), - PageId = table.Column(type: "uniqueidentifier", nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsMenuItems", x => x.Id); - table.ForeignKey( - name: "FK_CmsMenuItems_CmsMenus_MenuId", - column: x => x.MenuId, - principalTable: "CmsMenus", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "CmsBlogPosts", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - BlogId = table.Column(type: "uniqueidentifier", nullable: false), - Title = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Slug = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ShortDescription = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - Content = table.Column(type: "nvarchar(max)", maxLength: 2147483647, nullable: true), - CoverImageMediaId = table.Column(type: "uniqueidentifier", nullable: true), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - AuthorId = table.Column(type: "uniqueidentifier", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsBlogPosts", x => x.Id); - table.ForeignKey( - name: "FK_CmsBlogPosts_CmsUsers_AuthorId", - column: x => x.AuthorId, - principalTable: "CmsUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_AbpBlobContainers_TenantId_Name", - table: "AbpBlobContainers", - columns: new[] { "TenantId", "Name" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpBlobs_ContainerId", - table: "AbpBlobs", - column: "ContainerId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpBlobs_TenantId_ContainerId_Name", - table: "AbpBlobs", - columns: new[] { "TenantId", "ContainerId", "Name" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsBlogPosts_AuthorId", - table: "CmsBlogPosts", - column: "AuthorId"); - - migrationBuilder.CreateIndex( - name: "IX_CmsBlogPosts_Slug_BlogId", - table: "CmsBlogPosts", - columns: new[] { "Slug", "BlogId" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsComments_TenantId_EntityType_EntityId", - table: "CmsComments", - columns: new[] { "TenantId", "EntityType", "EntityId" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsComments_TenantId_RepliedCommentId", - table: "CmsComments", - columns: new[] { "TenantId", "RepliedCommentId" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsEntityTags_TenantId_EntityId_TagId", - table: "CmsEntityTags", - columns: new[] { "TenantId", "EntityId", "TagId" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsMenuItems_MenuId", - table: "CmsMenuItems", - column: "MenuId"); - - migrationBuilder.CreateIndex( - name: "IX_CmsPages_TenantId_Slug", - table: "CmsPages", - columns: new[] { "TenantId", "Slug" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsRatings_TenantId_EntityType_EntityId_CreatorId", - table: "CmsRatings", - columns: new[] { "TenantId", "EntityType", "EntityId", "CreatorId" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsTags_TenantId_Name", - table: "CmsTags", - columns: new[] { "TenantId", "Name" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsUserReactions_TenantId_CreatorId_EntityType_EntityId_ReactionName", - table: "CmsUserReactions", - columns: new[] { "TenantId", "CreatorId", "EntityType", "EntityId", "ReactionName" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsUserReactions_TenantId_EntityType_EntityId_ReactionName", - table: "CmsUserReactions", - columns: new[] { "TenantId", "EntityType", "EntityId", "ReactionName" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsUsers_TenantId_Email", - table: "CmsUsers", - columns: new[] { "TenantId", "Email" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsUsers_TenantId_UserName", - table: "CmsUsers", - columns: new[] { "TenantId", "UserName" }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AbpBlobs"); - - migrationBuilder.DropTable( - name: "CmsBlogFeatures"); - - migrationBuilder.DropTable( - name: "CmsBlogPosts"); - - migrationBuilder.DropTable( - name: "CmsBlogs"); - - migrationBuilder.DropTable( - name: "CmsComments"); - - migrationBuilder.DropTable( - name: "CmsEntityTags"); - - migrationBuilder.DropTable( - name: "CmsMediaDescriptors"); - - migrationBuilder.DropTable( - name: "CmsMenuItems"); - - migrationBuilder.DropTable( - name: "CmsPages"); + migrationBuilder.DropTable( + name: "AbpBlobs"); + + migrationBuilder.DropTable( + name: "CmsBlogFeatures"); + + migrationBuilder.DropTable( + name: "CmsBlogPosts"); + + migrationBuilder.DropTable( + name: "CmsBlogs"); + + migrationBuilder.DropTable( + name: "CmsComments"); + + migrationBuilder.DropTable( + name: "CmsEntityTags"); + + migrationBuilder.DropTable( + name: "CmsMediaDescriptors"); + + migrationBuilder.DropTable( + name: "CmsMenuItems"); + + migrationBuilder.DropTable( + name: "CmsPages"); + + migrationBuilder.DropTable( + name: "CmsRatings"); + + migrationBuilder.DropTable( + name: "CmsTags"); - migrationBuilder.DropTable( - name: "CmsRatings"); - - migrationBuilder.DropTable( - name: "CmsTags"); - - migrationBuilder.DropTable( - name: "CmsUserReactions"); + migrationBuilder.DropTable( + name: "CmsUserReactions"); - migrationBuilder.DropTable( - name: "AbpBlobContainers"); + migrationBuilder.DropTable( + name: "AbpBlobContainers"); - migrationBuilder.DropTable( - name: "CmsUsers"); + migrationBuilder.DropTable( + name: "CmsUsers"); - migrationBuilder.DropTable( - name: "CmsMenus"); - } + migrationBuilder.DropTable( + name: "CmsMenus"); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Program.cs b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Program.cs index 7349f8eb0c..1df7011979 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Program.cs +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Program.cs @@ -5,47 +5,46 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class Program { - public class Program + public static int Main(string[] args) { - public static int Main(string[] args) - { - Log.Logger = new LoggerConfiguration() + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() #else .MinimumLevel.Information() #endif .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - .Enrich.FromLogContext() - .WriteTo.File("Logs/logs.txt") - .CreateLogger(); + .Enrich.FromLogContext() + .WriteTo.File("Logs/logs.txt") + .CreateLogger(); - try - { - Log.Information("Starting web host."); - CreateHostBuilder(args).Build().Run(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Host terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } + try + { + Log.Information("Starting web host."); + CreateHostBuilder(args).Build().Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Startup.cs b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Startup.cs index bfbaaadfa4..5d12783c4f 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Startup.cs +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Startup.cs @@ -4,18 +4,17 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs index b1a441bed5..62637998be 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs @@ -44,193 +44,192 @@ using Volo.Abp.TenantManagement.EntityFrameworkCore; using Volo.Abp.Threading; using Volo.Abp.UI.Navigation.Urls; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(AbpAccountWebIdentityServerModule), + typeof(AbpAccountApplicationModule), + typeof(AbpAccountHttpApiModule), + typeof(AbpAspNetCoreMvcUiMultiTenancyModule), + typeof(AbpAspNetCoreMvcModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAuditLoggingEntityFrameworkCoreModule), + typeof(AbpAutofacModule), + typeof(AbpCachingStackExchangeRedisModule), + typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpIdentityApplicationModule), + typeof(AbpIdentityHttpApiModule), + typeof(AbpIdentityServerEntityFrameworkCoreModule), + typeof(AbpPermissionManagementDomainIdentityModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementApplicationModule), + typeof(AbpPermissionManagementHttpApiModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpFeatureManagementApplicationModule), + typeof(AbpTenantManagementEntityFrameworkCoreModule), + typeof(AbpTenantManagementApplicationModule), + typeof(AbpTenantManagementHttpApiModule), + typeof(AbpAspNetCoreAuthenticationJwtBearerModule), + typeof(CmsKitApplicationContractsModule), + typeof(AbpAspNetCoreSerilogModule) + )] +public class CmsKitIdentityServerModule : AbpModule { - [DependsOn( - typeof(AbpAccountWebIdentityServerModule), - typeof(AbpAccountApplicationModule), - typeof(AbpAccountHttpApiModule), - typeof(AbpAspNetCoreMvcUiMultiTenancyModule), - typeof(AbpAspNetCoreMvcModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAuditLoggingEntityFrameworkCoreModule), - typeof(AbpAutofacModule), - typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpEntityFrameworkCoreSqlServerModule), - typeof(AbpIdentityEntityFrameworkCoreModule), - typeof(AbpIdentityApplicationModule), - typeof(AbpIdentityHttpApiModule), - typeof(AbpIdentityServerEntityFrameworkCoreModule), - typeof(AbpPermissionManagementDomainIdentityModule), - typeof(AbpPermissionManagementEntityFrameworkCoreModule), - typeof(AbpPermissionManagementApplicationModule), - typeof(AbpPermissionManagementHttpApiModule), - typeof(AbpSettingManagementEntityFrameworkCoreModule), - typeof(AbpFeatureManagementApplicationModule), - typeof(AbpTenantManagementEntityFrameworkCoreModule), - typeof(AbpTenantManagementApplicationModule), - typeof(AbpTenantManagementHttpApiModule), - typeof(AbpAspNetCoreAuthenticationJwtBearerModule), - typeof(CmsKitApplicationContractsModule), - typeof(AbpAspNetCoreSerilogModule) - )] - public class CmsKitIdentityServerModule : AbpModule + private const string DefaultCorsPolicyName = "Default"; + + public override void PreConfigureServices(ServiceConfigurationContext context) { - private const string DefaultCorsPolicyName = "Default"; + FeatureConfigurer.Configure(); + } - public override void PreConfigureServices(ServiceConfigurationContext context) - { - FeatureConfigurer.Configure(); - } + public override void ConfigureServices(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - var hostingEnvironment = context.Services.GetHostingEnvironment(); - var configuration = context.Services.GetConfiguration(); + options.UseSqlServer(); + }); - Configure(options => + context.Services.AddSwaggerGen( + options => { - options.UseSqlServer(); + options.SwaggerDoc("v1", new OpenApiInfo { Title = "CmsKit API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); }); - context.Services.AddSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "CmsKit API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - }); - - Configure(options => - { - options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); - options.Languages.Add(new LanguageInfo("en", "en", "English")); - options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); - options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); - options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); - options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); - options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); - options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); - options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); - options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); - options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); - options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); - options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); - options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); - }); - - Configure(options => - { + Configure(options => + { + options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); + options.Languages.Add(new LanguageInfo("en", "en", "English")); + options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); + options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); + options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); + options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); + options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); + options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); + options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); + options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); + options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); + options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); + options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); + options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); + options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); + }); + + Configure(options => + { //options.IsEnabledForGetRequests = true; options.ApplicationName = "AuthServer"; - }); + }); - Configure(options => - { - options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; - }); - - context.Services.AddAuthentication() - .AddJwtBearer(options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = false; - options.Audience = configuration["AuthServer:ApiName"]; - }); + Configure(options => + { + options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; + }); - Configure(options => + context.Services.AddAuthentication() + .AddJwtBearer(options => { - options.KeyPrefix = "CmsKit:"; + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = false; + options.Audience = configuration["AuthServer:ApiName"]; }); - Configure(options => - { - options.IsEnabled = MultiTenancyConsts.IsEnabled; - }); + Configure(options => + { + options.KeyPrefix = "CmsKit:"; + }); - if (!hostingEnvironment.IsDevelopment()) - { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - context.Services - .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "CmsKit-Protection-Keys"); - } + Configure(options => + { + options.IsEnabled = MultiTenancyConsts.IsEnabled; + }); - context.Services.AddCors(options => - { - options.AddPolicy(DefaultCorsPolicyName, builder => - { - builder - .WithOrigins( - configuration["App:CorsOrigins"] - .Split(",", StringSplitOptions.RemoveEmptyEntries) - .Select(o => o.RemovePostFix("/")) - .ToArray() - ) - .WithAbpExposedHeaders() - .SetIsOriginAllowedToAllowWildcardSubdomains() - .AllowAnyHeader() - .AllowAnyMethod() - .AllowCredentials(); - }); - }); + if (!hostingEnvironment.IsDevelopment()) + { + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services + .AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "CmsKit-Protection-Keys"); } - public override void OnApplicationInitialization(ApplicationInitializationContext context) + context.Services.AddCors(options => { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else + options.AddPolicy(DefaultCorsPolicyName, builder => { - app.UseErrorPage(); - app.UseHsts(); - } + builder + .WithOrigins( + configuration["App:CorsOrigins"] + .Split(",", StringSplitOptions.RemoveEmptyEntries) + .Select(o => o.RemovePostFix("/")) + .ToArray() + ) + .WithAbpExposedHeaders() + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials(); + }); + }); + } - app.UseHttpsRedirection(); - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseCors(DefaultCorsPolicyName); - app.UseAuthentication(); - app.UseJwtTokenMiddleware(); + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseErrorPage(); + app.UseHsts(); + } - app.UseAbpRequestLocalization(); - app.UseIdentityServer(); - app.UseAuthorization(); - app.UseSwagger(); - app.UseSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); - }); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); + app.UseHttpsRedirection(); + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseCors(DefaultCorsPolicyName); + app.UseAuthentication(); + app.UseJwtTokenMiddleware(); - SeedData(context); + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); } - private void SeedData(ApplicationInitializationContext context) + app.UseAbpRequestLocalization(); + app.UseIdentityServer(); + app.UseAuthorization(); + app.UseSwagger(); + app.UseSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); + }); + app.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); + + SeedData(context); + } + + private void SeedData(ApplicationInitializationContext context) + { + AsyncHelper.RunSync(async () => { - AsyncHelper.RunSync(async () => + using (var scope = context.ServiceProvider.CreateScope()) { - using (var scope = context.ServiceProvider.CreateScope()) - { - await scope.ServiceProvider - .GetRequiredService() - .SeedAsync(); - } - }); - } + await scope.ServiceProvider + .GetRequiredService() + .SeedAsync(); + } + }); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContext.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContext.cs index b0bd516dee..ecddf9aa78 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContext.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContext.cs @@ -7,26 +7,25 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement.EntityFrameworkCore; -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +public class IdentityServerHostMigrationsDbContext : AbpDbContext { - public class IdentityServerHostMigrationsDbContext : AbpDbContext + public IdentityServerHostMigrationsDbContext(DbContextOptions options) + : base(options) { - public IdentityServerHostMigrationsDbContext(DbContextOptions options) - : base(options) - { - } + } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); - modelBuilder.ConfigurePermissionManagement(); - modelBuilder.ConfigureSettingManagement(); - modelBuilder.ConfigureAuditLogging(); - modelBuilder.ConfigureIdentity(); - modelBuilder.ConfigureIdentityServer(); - modelBuilder.ConfigureTenantManagement(); - } + modelBuilder.ConfigurePermissionManagement(); + modelBuilder.ConfigureSettingManagement(); + modelBuilder.ConfigureAuditLogging(); + modelBuilder.ConfigureIdentity(); + modelBuilder.ConfigureIdentityServer(); + modelBuilder.ConfigureTenantManagement(); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs index 19402b80c1..68deb4782c 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs @@ -3,29 +3,28 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +public class IdentityServerHostMigrationsDbContextFactory : IDesignTimeDbContextFactory { - public class IdentityServerHostMigrationsDbContextFactory : IDesignTimeDbContextFactory + public IdentityServerHostMigrationsDbContext CreateDbContext(string[] args) { - public IdentityServerHostMigrationsDbContext CreateDbContext(string[] args) - { - FeatureConfigurer.Configure(); + FeatureConfigurer.Configure(); - var configuration = BuildConfiguration(); + var configuration = BuildConfiguration(); - var builder = new DbContextOptionsBuilder() - .UseSqlServer(configuration.GetConnectionString("Default")); + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); - return new IdentityServerHostMigrationsDbContext(builder.Options); - } + return new IdentityServerHostMigrationsDbContext(builder.Options); + } - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false); + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false); - return builder.Build(); - } + return builder.Build(); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs index 9eee928e53..15d60db308 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs @@ -12,45 +12,45 @@ using Volo.Abp.IdentityServer.IdentityResources; using Volo.Abp.PermissionManagement; using Volo.Abp.Uow; -namespace Volo.CmsKit.IdentityServer +namespace Volo.CmsKit.IdentityServer; + +public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency { - public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency + private readonly IApiResourceRepository _apiResourceRepository; + private readonly IClientRepository _clientRepository; + private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; + private readonly IGuidGenerator _guidGenerator; + private readonly IPermissionDataSeeder _permissionDataSeeder; + private readonly IConfiguration _configuration; + + public IdentityServerDataSeedContributor( + IClientRepository clientRepository, + IApiResourceRepository apiResourceRepository, + IIdentityResourceDataSeeder identityResourceDataSeeder, + IGuidGenerator guidGenerator, + IPermissionDataSeeder permissionDataSeeder, + IConfiguration configuration) { - private readonly IApiResourceRepository _apiResourceRepository; - private readonly IClientRepository _clientRepository; - private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; - private readonly IGuidGenerator _guidGenerator; - private readonly IPermissionDataSeeder _permissionDataSeeder; - private readonly IConfiguration _configuration; - - public IdentityServerDataSeedContributor( - IClientRepository clientRepository, - IApiResourceRepository apiResourceRepository, - IIdentityResourceDataSeeder identityResourceDataSeeder, - IGuidGenerator guidGenerator, - IPermissionDataSeeder permissionDataSeeder, - IConfiguration configuration) - { - _clientRepository = clientRepository; - _apiResourceRepository = apiResourceRepository; - _identityResourceDataSeeder = identityResourceDataSeeder; - _guidGenerator = guidGenerator; - _permissionDataSeeder = permissionDataSeeder; - _configuration = configuration; - } + _clientRepository = clientRepository; + _apiResourceRepository = apiResourceRepository; + _identityResourceDataSeeder = identityResourceDataSeeder; + _guidGenerator = guidGenerator; + _permissionDataSeeder = permissionDataSeeder; + _configuration = configuration; + } - [UnitOfWork] - public virtual async Task SeedAsync(DataSeedContext context) - { - await _identityResourceDataSeeder.CreateStandardResourcesAsync(); - await CreateApiResourcesAsync(); - await CreateClientsAsync(); - } + [UnitOfWork] + public virtual async Task SeedAsync(DataSeedContext context) + { + await _identityResourceDataSeeder.CreateStandardResourcesAsync(); + await CreateApiResourcesAsync(); + await CreateClientsAsync(); + } - private async Task CreateApiResourcesAsync() + private async Task CreateApiResourcesAsync() + { + var commonApiUserClaims = new[] { - var commonApiUserClaims = new[] - { "email", "email_verified", "name", @@ -59,41 +59,41 @@ namespace Volo.CmsKit.IdentityServer "role" }; - await CreateApiResourceAsync("CmsKit", commonApiUserClaims); + await CreateApiResourceAsync("CmsKit", commonApiUserClaims); + } + + private async Task CreateApiResourceAsync(string name, IEnumerable claims) + { + var apiResource = await _apiResourceRepository.FindByNameAsync(name); + if (apiResource == null) + { + apiResource = await _apiResourceRepository.InsertAsync( + new ApiResource( + _guidGenerator.Create(), + name, + name + " API" + ), + autoSave: true + ); } - private async Task CreateApiResourceAsync(string name, IEnumerable claims) + foreach (var claim in claims) { - var apiResource = await _apiResourceRepository.FindByNameAsync(name); - if (apiResource == null) + if (apiResource.FindClaim(claim) == null) { - apiResource = await _apiResourceRepository.InsertAsync( - new ApiResource( - _guidGenerator.Create(), - name, - name + " API" - ), - autoSave: true - ); + apiResource.AddUserClaim(claim); } + } - foreach (var claim in claims) - { - if (apiResource.FindClaim(claim) == null) - { - apiResource.AddUserClaim(claim); - } - } + return await _apiResourceRepository.UpdateAsync(apiResource); + } - return await _apiResourceRepository.UpdateAsync(apiResource); - } + private async Task CreateClientsAsync() + { + const string commonSecret = "E5Xd4yMqjP5kjWFKrYgySBju6JVfCzMyFp7n2QmMrME="; - private async Task CreateClientsAsync() + var commonScopes = new[] { - const string commonSecret = "E5Xd4yMqjP5kjWFKrYgySBju6JVfCzMyFp7n2QmMrME="; - - var commonScopes = new[] - { "email", "openid", "profile", @@ -103,117 +103,116 @@ namespace Volo.CmsKit.IdentityServer "CmsKit" }; - var configurationSection = _configuration.GetSection("IdentityServer:Clients"); + var configurationSection = _configuration.GetSection("IdentityServer:Clients"); - //Web Client - var webClientId = configurationSection["CmsKit_Web:ClientId"]; - if (!webClientId.IsNullOrWhiteSpace()) - { - var webClientRootUrl = configurationSection["CmsKit_Web:RootUrl"].EnsureEndsWith('/'); - await CreateClientAsync( - webClientId, - commonScopes, - new[] { "hybrid" }, - commonSecret, - redirectUri: $"{webClientRootUrl}signin-oidc", - postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc" - ); - } + //Web Client + var webClientId = configurationSection["CmsKit_Web:ClientId"]; + if (!webClientId.IsNullOrWhiteSpace()) + { + var webClientRootUrl = configurationSection["CmsKit_Web:RootUrl"].EnsureEndsWith('/'); + await CreateClientAsync( + webClientId, + commonScopes, + new[] { "hybrid" }, + commonSecret, + redirectUri: $"{webClientRootUrl}signin-oidc", + postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc" + ); + } - //Console Test Client - var consoleClientId = configurationSection["CmsKit_ConsoleTestApp:ClientId"]; - if (!consoleClientId.IsNullOrWhiteSpace()) - { - await CreateClientAsync( - consoleClientId, - commonScopes, - new[] { "password", "client_credentials" }, - commonSecret - ); - } + //Console Test Client + var consoleClientId = configurationSection["CmsKit_ConsoleTestApp:ClientId"]; + if (!consoleClientId.IsNullOrWhiteSpace()) + { + await CreateClientAsync( + consoleClientId, + commonScopes, + new[] { "password", "client_credentials" }, + commonSecret + ); } + } - private async Task CreateClientAsync( - string name, - IEnumerable scopes, - IEnumerable grantTypes, - string secret, - string redirectUri = null, - string postLogoutRedirectUri = null, - IEnumerable permissions = null) + private async Task CreateClientAsync( + string name, + IEnumerable scopes, + IEnumerable grantTypes, + string secret, + string redirectUri = null, + string postLogoutRedirectUri = null, + IEnumerable permissions = null) + { + var client = await _clientRepository.FindByClientIdAsync(name); + if (client == null) { - var client = await _clientRepository.FindByClientIdAsync(name); - if (client == null) - { - client = await _clientRepository.InsertAsync( - new Client( - _guidGenerator.Create(), - name - ) - { - ClientName = name, - ProtocolType = "oidc", - Description = name, - AlwaysIncludeUserClaimsInIdToken = true, - AllowOfflineAccess = true, - AbsoluteRefreshTokenLifetime = 31536000, //365 days + client = await _clientRepository.InsertAsync( + new Client( + _guidGenerator.Create(), + name + ) + { + ClientName = name, + ProtocolType = "oidc", + Description = name, + AlwaysIncludeUserClaimsInIdToken = true, + AllowOfflineAccess = true, + AbsoluteRefreshTokenLifetime = 31536000, //365 days AccessTokenLifetime = 31536000, //365 days AuthorizationCodeLifetime = 300, - IdentityTokenLifetime = 300, - RequireConsent = false - }, - autoSave: true - ); - } - - foreach (var scope in scopes) - { - if (client.FindScope(scope) == null) - { - client.AddScope(scope); - } - } + IdentityTokenLifetime = 300, + RequireConsent = false + }, + autoSave: true + ); + } - foreach (var grantType in grantTypes) + foreach (var scope in scopes) + { + if (client.FindScope(scope) == null) { - if (client.FindGrantType(grantType) == null) - { - client.AddGrantType(grantType); - } + client.AddScope(scope); } + } - if (client.FindSecret(secret) == null) + foreach (var grantType in grantTypes) + { + if (client.FindGrantType(grantType) == null) { - client.AddSecret(secret); + client.AddGrantType(grantType); } + } - if (redirectUri != null) - { - if (client.FindRedirectUri(redirectUri) == null) - { - client.AddRedirectUri(redirectUri); - } - } + if (client.FindSecret(secret) == null) + { + client.AddSecret(secret); + } - if (postLogoutRedirectUri != null) + if (redirectUri != null) + { + if (client.FindRedirectUri(redirectUri) == null) { - if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) - { - client.AddPostLogoutRedirectUri(postLogoutRedirectUri); - } + client.AddRedirectUri(redirectUri); } + } - if (permissions != null) + if (postLogoutRedirectUri != null) + { + if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) { - await _permissionDataSeeder.SeedAsync( - ClientPermissionValueProvider.ProviderName, - name, - permissions, - null - ); + client.AddPostLogoutRedirectUri(postLogoutRedirectUri); } + } - return await _clientRepository.UpdateAsync(client); + if (permissions != null) + { + await _permissionDataSeeder.SeedAsync( + ClientPermissionValueProvider.ProviderName, + name, + permissions, + null + ); } + + return await _clientRepository.UpdateAsync(client); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Migrations/20201013055450_Initial.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Migrations/20201013055450_Initial.cs index 573c52149b..9674fc20d9 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Migrations/20201013055450_Initial.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Migrations/20201013055450_Initial.cs @@ -1,1135 +1,1096 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace Volo.CmsKit.Migrations +namespace Volo.CmsKit.Migrations; + +public partial class Initial : Migration { - public partial class Initial : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AbpAuditLogs", - columns: table => new - { - Id = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true), - ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), - ApplicationName = table.Column(maxLength: 96, nullable: true), - UserId = table.Column(nullable: true), - UserName = table.Column(maxLength: 256, nullable: true), - TenantId = table.Column(nullable: true), - TenantName = table.Column(nullable: true), - ImpersonatorUserId = table.Column(nullable: true), - ImpersonatorTenantId = table.Column(nullable: true), - ExecutionTime = table.Column(nullable: false), - ExecutionDuration = table.Column(nullable: false), - ClientIpAddress = table.Column(maxLength: 64, nullable: true), - ClientName = table.Column(maxLength: 128, nullable: true), - ClientId = table.Column(maxLength: 64, nullable: true), - CorrelationId = table.Column(maxLength: 64, nullable: true), - BrowserInfo = table.Column(maxLength: 512, nullable: true), - HttpMethod = table.Column(maxLength: 16, nullable: true), - Url = table.Column(maxLength: 256, nullable: true), - Exceptions = table.Column(maxLength: 4000, nullable: true), - Comments = table.Column(maxLength: 256, nullable: true), - HttpStatusCode = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpClaimTypes", - columns: table => new - { - Id = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true), - ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), - Name = table.Column(maxLength: 256, nullable: false), - Required = table.Column(nullable: false), - IsStatic = table.Column(nullable: false), - Regex = table.Column(maxLength: 512, nullable: true), - RegexDescription = table.Column(maxLength: 128, nullable: true), - Description = table.Column(maxLength: 256, nullable: true), - ValueType = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnits", - columns: table => new - { - Id = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true), - ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), - CreationTime = table.Column(nullable: false), - CreatorId = table.Column(nullable: true), - LastModificationTime = table.Column(nullable: true), - LastModifierId = table.Column(nullable: true), - IsDeleted = table.Column(nullable: false, defaultValue: false), - DeleterId = table.Column(nullable: true), - DeletionTime = table.Column(nullable: true), - TenantId = table.Column(nullable: true), - ParentId = table.Column(nullable: true), - Code = table.Column(maxLength: 95, nullable: false), - DisplayName = table.Column(maxLength: 128, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); - table.ForeignKey( - name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", - column: x => x.ParentId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "AbpPermissionGrants", - columns: table => new - { - Id = table.Column(nullable: false), - TenantId = table.Column(nullable: true), - Name = table.Column(maxLength: 128, nullable: false), - ProviderName = table.Column(maxLength: 64, nullable: false), - ProviderKey = table.Column(maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpRoles", - columns: table => new - { - Id = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true), - ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), - TenantId = table.Column(nullable: true), - Name = table.Column(maxLength: 256, nullable: false), - NormalizedName = table.Column(maxLength: 256, nullable: false), - IsDefault = table.Column(nullable: false), - IsStatic = table.Column(nullable: false), - IsPublic = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpSettings", - columns: table => new - { - Id = table.Column(nullable: false), - Name = table.Column(maxLength: 128, nullable: false), - Value = table.Column(maxLength: 2048, nullable: false), - ProviderName = table.Column(maxLength: 64, nullable: true), - ProviderKey = table.Column(maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpSettings", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpTenants", - columns: table => new - { - Id = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true), - ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), - CreationTime = table.Column(nullable: false), - CreatorId = table.Column(nullable: true), - LastModificationTime = table.Column(nullable: true), - LastModifierId = table.Column(nullable: true), - IsDeleted = table.Column(nullable: false, defaultValue: false), - DeleterId = table.Column(nullable: true), - DeletionTime = table.Column(nullable: true), - Name = table.Column(maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpTenants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpUsers", - columns: table => new - { - Id = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true), - ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), - CreationTime = table.Column(nullable: false), - CreatorId = table.Column(nullable: true), - LastModificationTime = table.Column(nullable: true), - LastModifierId = table.Column(nullable: true), - IsDeleted = table.Column(nullable: false, defaultValue: false), - DeleterId = table.Column(nullable: true), - DeletionTime = table.Column(nullable: true), - TenantId = table.Column(nullable: true), - UserName = table.Column(maxLength: 256, nullable: false), - NormalizedUserName = table.Column(maxLength: 256, nullable: false), - Name = table.Column(maxLength: 64, nullable: true), - Surname = table.Column(maxLength: 64, nullable: true), - Email = table.Column(maxLength: 256, nullable: false), - NormalizedEmail = table.Column(maxLength: 256, nullable: false), - EmailConfirmed = table.Column(nullable: false, defaultValue: false), - PasswordHash = table.Column(maxLength: 256, nullable: true), - SecurityStamp = table.Column(maxLength: 256, nullable: false), - PhoneNumber = table.Column(maxLength: 16, nullable: true), - PhoneNumberConfirmed = table.Column(nullable: false, defaultValue: false), - TwoFactorEnabled = table.Column(nullable: false, defaultValue: false), - LockoutEnd = table.Column(nullable: true), - LockoutEnabled = table.Column(nullable: false, defaultValue: false), - AccessFailedCount = table.Column(nullable: false, defaultValue: 0) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiResources", - columns: table => new - { - Id = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true), - ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), - CreationTime = table.Column(nullable: false), - CreatorId = table.Column(nullable: true), - LastModificationTime = table.Column(nullable: true), - LastModifierId = table.Column(nullable: true), - IsDeleted = table.Column(nullable: false, defaultValue: false), - DeleterId = table.Column(nullable: true), - DeletionTime = table.Column(nullable: true), - Name = table.Column(maxLength: 200, nullable: false), - DisplayName = table.Column(maxLength: 200, nullable: true), - Description = table.Column(maxLength: 1000, nullable: true), - Enabled = table.Column(nullable: false), - Properties = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiResources", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClients", - columns: table => new - { - Id = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true), - ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), - CreationTime = table.Column(nullable: false), - CreatorId = table.Column(nullable: true), - LastModificationTime = table.Column(nullable: true), - LastModifierId = table.Column(nullable: true), - IsDeleted = table.Column(nullable: false, defaultValue: false), - DeleterId = table.Column(nullable: true), - DeletionTime = table.Column(nullable: true), - ClientId = table.Column(maxLength: 200, nullable: false), - ClientName = table.Column(maxLength: 200, nullable: true), - Description = table.Column(maxLength: 1000, nullable: true), - ClientUri = table.Column(maxLength: 2000, nullable: true), - LogoUri = table.Column(maxLength: 2000, nullable: true), - Enabled = table.Column(nullable: false), - ProtocolType = table.Column(maxLength: 200, nullable: false), - RequireClientSecret = table.Column(nullable: false), - RequireConsent = table.Column(nullable: false), - AllowRememberConsent = table.Column(nullable: false), - AlwaysIncludeUserClaimsInIdToken = table.Column(nullable: false), - RequirePkce = table.Column(nullable: false), - AllowPlainTextPkce = table.Column(nullable: false), - AllowAccessTokensViaBrowser = table.Column(nullable: false), - FrontChannelLogoutUri = table.Column(maxLength: 2000, nullable: true), - FrontChannelLogoutSessionRequired = table.Column(nullable: false), - BackChannelLogoutUri = table.Column(maxLength: 2000, nullable: true), - BackChannelLogoutSessionRequired = table.Column(nullable: false), - AllowOfflineAccess = table.Column(nullable: false), - IdentityTokenLifetime = table.Column(nullable: false), - AccessTokenLifetime = table.Column(nullable: false), - AuthorizationCodeLifetime = table.Column(nullable: false), - ConsentLifetime = table.Column(nullable: true), - AbsoluteRefreshTokenLifetime = table.Column(nullable: false), - SlidingRefreshTokenLifetime = table.Column(nullable: false), - RefreshTokenUsage = table.Column(nullable: false), - UpdateAccessTokenClaimsOnRefresh = table.Column(nullable: false), - RefreshTokenExpiration = table.Column(nullable: false), - AccessTokenType = table.Column(nullable: false), - EnableLocalLogin = table.Column(nullable: false), - IncludeJwtId = table.Column(nullable: false), - AlwaysSendClientClaims = table.Column(nullable: false), - ClientClaimsPrefix = table.Column(maxLength: 200, nullable: true), - PairWiseSubjectSalt = table.Column(maxLength: 200, nullable: true), - UserSsoLifetime = table.Column(nullable: true), - UserCodeType = table.Column(maxLength: 100, nullable: true), - DeviceCodeLifetime = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClients", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerDeviceFlowCodes", - columns: table => new - { - Id = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true), - ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), - CreationTime = table.Column(nullable: false), - CreatorId = table.Column(nullable: true), - DeviceCode = table.Column(maxLength: 200, nullable: false), - UserCode = table.Column(maxLength: 200, nullable: false), - SubjectId = table.Column(maxLength: 200, nullable: true), - ClientId = table.Column(maxLength: 200, nullable: false), - Expiration = table.Column(nullable: false), - Data = table.Column(maxLength: 50000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerDeviceFlowCodes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerIdentityResources", - columns: table => new - { - Id = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true), - ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), - CreationTime = table.Column(nullable: false), - CreatorId = table.Column(nullable: true), - LastModificationTime = table.Column(nullable: true), - LastModifierId = table.Column(nullable: true), - IsDeleted = table.Column(nullable: false, defaultValue: false), - DeleterId = table.Column(nullable: true), - DeletionTime = table.Column(nullable: true), - Name = table.Column(maxLength: 200, nullable: false), - DisplayName = table.Column(maxLength: 200, nullable: true), - Description = table.Column(maxLength: 1000, nullable: true), - Enabled = table.Column(nullable: false), - Required = table.Column(nullable: false), - Emphasize = table.Column(nullable: false), - ShowInDiscoveryDocument = table.Column(nullable: false), - Properties = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerIdentityResources", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerPersistedGrants", - columns: table => new - { - Key = table.Column(maxLength: 200, nullable: false), - Id = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true), - ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), - Type = table.Column(maxLength: 50, nullable: false), - SubjectId = table.Column(maxLength: 200, nullable: true), - ClientId = table.Column(maxLength: 200, nullable: false), - CreationTime = table.Column(nullable: false), - Expiration = table.Column(nullable: true), - Data = table.Column(maxLength: 50000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key); - }); - - migrationBuilder.CreateTable( - name: "AbpAuditLogActions", - columns: table => new - { - Id = table.Column(nullable: false), - TenantId = table.Column(nullable: true), - AuditLogId = table.Column(nullable: false), - ServiceName = table.Column(maxLength: 256, nullable: true), - MethodName = table.Column(maxLength: 128, nullable: true), - Parameters = table.Column(maxLength: 2000, nullable: true), - ExecutionTime = table.Column(nullable: false), - ExecutionDuration = table.Column(nullable: false), - ExtraProperties = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); - table.ForeignKey( - name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpEntityChanges", - columns: table => new - { - Id = table.Column(nullable: false), - AuditLogId = table.Column(nullable: false), - TenantId = table.Column(nullable: true), - ChangeTime = table.Column(nullable: false), - ChangeType = table.Column(nullable: false), - EntityTenantId = table.Column(nullable: true), - EntityId = table.Column(maxLength: 128, nullable: false), - EntityTypeFullName = table.Column(maxLength: 128, nullable: false), - ExtraProperties = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnitRoles", - columns: table => new - { - RoleId = table.Column(nullable: false), - OrganizationUnitId = table.Column(nullable: false), - CreationTime = table.Column(nullable: false), - CreatorId = table.Column(nullable: true), - TenantId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpRoleClaims", - columns: table => new - { - Id = table.Column(nullable: false), - TenantId = table.Column(nullable: true), - ClaimType = table.Column(maxLength: 256, nullable: false), - ClaimValue = table.Column(maxLength: 1024, nullable: true), - RoleId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AbpRoleClaims_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpTenantConnectionStrings", - columns: table => new - { - TenantId = table.Column(nullable: false), - Name = table.Column(maxLength: 64, nullable: false), - Value = table.Column(maxLength: 1024, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpTenantConnectionStrings", x => new { x.TenantId, x.Name }); - table.ForeignKey( - name: "FK_AbpTenantConnectionStrings_AbpTenants_TenantId", - column: x => x.TenantId, - principalTable: "AbpTenants", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserClaims", - columns: table => new - { - Id = table.Column(nullable: false), - TenantId = table.Column(nullable: true), - ClaimType = table.Column(maxLength: 256, nullable: false), - ClaimValue = table.Column(maxLength: 1024, nullable: true), - UserId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AbpUserClaims_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserLogins", - columns: table => new - { - UserId = table.Column(nullable: false), - LoginProvider = table.Column(maxLength: 64, nullable: false), - TenantId = table.Column(nullable: true), - ProviderKey = table.Column(maxLength: 196, nullable: false), - ProviderDisplayName = table.Column(maxLength: 128, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); - table.ForeignKey( - name: "FK_AbpUserLogins_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserOrganizationUnits", - columns: table => new - { - UserId = table.Column(nullable: false), - OrganizationUnitId = table.Column(nullable: false), - CreationTime = table.Column(nullable: false), - CreatorId = table.Column(nullable: true), - TenantId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserRoles", - columns: table => new - { - UserId = table.Column(nullable: false), - RoleId = table.Column(nullable: false), - TenantId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AbpUserRoles_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpUserRoles_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserTokens", - columns: table => new - { - UserId = table.Column(nullable: false), - LoginProvider = table.Column(maxLength: 64, nullable: false), - Name = table.Column(maxLength: 128, nullable: false), - TenantId = table.Column(nullable: true), - Value = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AbpUserTokens_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiClaims", - columns: table => new - { - Type = table.Column(maxLength: 200, nullable: false), - ApiResourceId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiClaims", x => new { x.ApiResourceId, x.Type }); - table.ForeignKey( - name: "FK_IdentityServerApiClaims_IdentityServerApiResources_ApiResourceId", - column: x => x.ApiResourceId, - principalTable: "IdentityServerApiResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiScopes", - columns: table => new - { - ApiResourceId = table.Column(nullable: false), - Name = table.Column(maxLength: 200, nullable: false), - DisplayName = table.Column(maxLength: 200, nullable: true), - Description = table.Column(maxLength: 1000, nullable: true), - Required = table.Column(nullable: false), - Emphasize = table.Column(nullable: false), - ShowInDiscoveryDocument = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiScopes", x => new { x.ApiResourceId, x.Name }); - table.ForeignKey( - name: "FK_IdentityServerApiScopes_IdentityServerApiResources_ApiResourceId", - column: x => x.ApiResourceId, - principalTable: "IdentityServerApiResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiSecrets", - columns: table => new - { - Type = table.Column(maxLength: 250, nullable: false), - Value = table.Column(maxLength: 4000, nullable: false), - ApiResourceId = table.Column(nullable: false), - Description = table.Column(maxLength: 2000, nullable: true), - Expiration = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiSecrets", x => new { x.ApiResourceId, x.Type, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerApiSecrets_IdentityServerApiResources_ApiResourceId", - column: x => x.ApiResourceId, - principalTable: "IdentityServerApiResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientClaims", - columns: table => new - { - ClientId = table.Column(nullable: false), - Type = table.Column(maxLength: 250, nullable: false), - Value = table.Column(maxLength: 250, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientClaims", x => new { x.ClientId, x.Type, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerClientClaims_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientCorsOrigins", - columns: table => new - { - ClientId = table.Column(nullable: false), - Origin = table.Column(maxLength: 150, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientCorsOrigins", x => new { x.ClientId, x.Origin }); - table.ForeignKey( - name: "FK_IdentityServerClientCorsOrigins_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientGrantTypes", - columns: table => new - { - ClientId = table.Column(nullable: false), - GrantType = table.Column(maxLength: 250, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientGrantTypes", x => new { x.ClientId, x.GrantType }); - table.ForeignKey( - name: "FK_IdentityServerClientGrantTypes_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientIdPRestrictions", - columns: table => new - { - ClientId = table.Column(nullable: false), - Provider = table.Column(maxLength: 200, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientIdPRestrictions", x => new { x.ClientId, x.Provider }); - table.ForeignKey( - name: "FK_IdentityServerClientIdPRestrictions_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientPostLogoutRedirectUris", - columns: table => new - { - ClientId = table.Column(nullable: false), - PostLogoutRedirectUri = table.Column(maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientPostLogoutRedirectUris", x => new { x.ClientId, x.PostLogoutRedirectUri }); - table.ForeignKey( - name: "FK_IdentityServerClientPostLogoutRedirectUris_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientProperties", - columns: table => new - { - ClientId = table.Column(nullable: false), - Key = table.Column(maxLength: 250, nullable: false), - Value = table.Column(maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientProperties", x => new { x.ClientId, x.Key }); - table.ForeignKey( - name: "FK_IdentityServerClientProperties_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientRedirectUris", - columns: table => new - { - ClientId = table.Column(nullable: false), - RedirectUri = table.Column(maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientRedirectUris", x => new { x.ClientId, x.RedirectUri }); - table.ForeignKey( - name: "FK_IdentityServerClientRedirectUris_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientScopes", - columns: table => new - { - ClientId = table.Column(nullable: false), - Scope = table.Column(maxLength: 200, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientScopes", x => new { x.ClientId, x.Scope }); - table.ForeignKey( - name: "FK_IdentityServerClientScopes_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientSecrets", - columns: table => new - { - Type = table.Column(maxLength: 250, nullable: false), - Value = table.Column(maxLength: 4000, nullable: false), - ClientId = table.Column(nullable: false), - Description = table.Column(maxLength: 2000, nullable: true), - Expiration = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientSecrets", x => new { x.ClientId, x.Type, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerClientSecrets_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerIdentityClaims", - columns: table => new - { - Type = table.Column(maxLength: 200, nullable: false), - IdentityResourceId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerIdentityClaims", x => new { x.IdentityResourceId, x.Type }); - table.ForeignKey( - name: "FK_IdentityServerIdentityClaims_IdentityServerIdentityResources_IdentityResourceId", - column: x => x.IdentityResourceId, - principalTable: "IdentityServerIdentityResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpEntityPropertyChanges", - columns: table => new - { - Id = table.Column(nullable: false), - TenantId = table.Column(nullable: true), - EntityChangeId = table.Column(nullable: false), - NewValue = table.Column(maxLength: 512, nullable: true), - OriginalValue = table.Column(maxLength: 512, nullable: true), - PropertyName = table.Column(maxLength: 128, nullable: false), - PropertyTypeFullName = table.Column(maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", - column: x => x.EntityChangeId, - principalTable: "AbpEntityChanges", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiScopeClaims", - columns: table => new - { - Type = table.Column(maxLength: 200, nullable: false), - ApiResourceId = table.Column(nullable: false), - Name = table.Column(maxLength: 200, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiScopeClaims", x => new { x.ApiResourceId, x.Name, x.Type }); - table.ForeignKey( - name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiResourceId_Name", - columns: x => new { x.ApiResourceId, x.Name }, - principalTable: "IdentityServerApiScopes", - principalColumns: new[] { "ApiResourceId", "Name" }, - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_AuditLogId", - table: "AbpAuditLogActions", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", - table: "AbpAuditLogActions", - columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "UserId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_AuditLogId", - table: "AbpEntityChanges", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", - table: "AbpEntityChanges", - columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityPropertyChanges_EntityChangeId", - table: "AbpEntityPropertyChanges", - column: "EntityChangeId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", - table: "AbpOrganizationUnitRoles", - columns: new[] { "RoleId", "OrganizationUnitId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_Code", - table: "AbpOrganizationUnits", - column: "Code"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_ParentId", - table: "AbpOrganizationUnits", - column: "ParentId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpPermissionGrants_Name_ProviderName_ProviderKey", - table: "AbpPermissionGrants", - columns: new[] { "Name", "ProviderName", "ProviderKey" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoleClaims_RoleId", - table: "AbpRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoles_NormalizedName", - table: "AbpRoles", - column: "NormalizedName"); - - migrationBuilder.CreateIndex( - name: "IX_AbpSettings_Name_ProviderName_ProviderKey", - table: "AbpSettings", - columns: new[] { "Name", "ProviderName", "ProviderKey" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpTenants_Name", - table: "AbpTenants", - column: "Name"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserClaims_UserId", - table: "AbpUserClaims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserLogins_LoginProvider_ProviderKey", - table: "AbpUserLogins", - columns: new[] { "LoginProvider", "ProviderKey" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId", - table: "AbpUserOrganizationUnits", - columns: new[] { "UserId", "OrganizationUnitId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserRoles_RoleId_UserId", - table: "AbpUserRoles", - columns: new[] { "RoleId", "UserId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_Email", - table: "AbpUsers", - column: "Email"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_NormalizedEmail", - table: "AbpUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_NormalizedUserName", - table: "AbpUsers", - column: "NormalizedUserName"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_UserName", - table: "AbpUsers", - column: "UserName"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerClients_ClientId", - table: "IdentityServerClients", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerDeviceFlowCodes_DeviceCode", - table: "IdentityServerDeviceFlowCodes", - column: "DeviceCode", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerDeviceFlowCodes_Expiration", - table: "IdentityServerDeviceFlowCodes", - column: "Expiration"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerDeviceFlowCodes_UserCode", - table: "IdentityServerDeviceFlowCodes", - column: "UserCode", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerPersistedGrants_Expiration", - table: "IdentityServerPersistedGrants", - column: "Expiration"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerPersistedGrants_SubjectId_ClientId_Type", - table: "IdentityServerPersistedGrants", - columns: new[] { "SubjectId", "ClientId", "Type" }); - } + migrationBuilder.CreateTable( + name: "AbpAuditLogs", + columns: table => new { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + ApplicationName = table.Column(maxLength: 96, nullable: true), + UserId = table.Column(nullable: true), + UserName = table.Column(maxLength: 256, nullable: true), + TenantId = table.Column(nullable: true), + TenantName = table.Column(nullable: true), + ImpersonatorUserId = table.Column(nullable: true), + ImpersonatorTenantId = table.Column(nullable: true), + ExecutionTime = table.Column(nullable: false), + ExecutionDuration = table.Column(nullable: false), + ClientIpAddress = table.Column(maxLength: 64, nullable: true), + ClientName = table.Column(maxLength: 128, nullable: true), + ClientId = table.Column(maxLength: 64, nullable: true), + CorrelationId = table.Column(maxLength: 64, nullable: true), + BrowserInfo = table.Column(maxLength: 512, nullable: true), + HttpMethod = table.Column(maxLength: 16, nullable: true), + Url = table.Column(maxLength: 256, nullable: true), + Exceptions = table.Column(maxLength: 4000, nullable: true), + Comments = table.Column(maxLength: 256, nullable: true), + HttpStatusCode = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpClaimTypes", + columns: table => new { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + Name = table.Column(maxLength: 256, nullable: false), + Required = table.Column(nullable: false), + IsStatic = table.Column(nullable: false), + Regex = table.Column(maxLength: 512, nullable: true), + RegexDescription = table.Column(maxLength: 128, nullable: true), + Description = table.Column(maxLength: 256, nullable: true), + ValueType = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnits", + columns: table => new { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false, defaultValue: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + TenantId = table.Column(nullable: true), + ParentId = table.Column(nullable: true), + Code = table.Column(maxLength: 95, nullable: false), + DisplayName = table.Column(maxLength: 128, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); + table.ForeignKey( + name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", + column: x => x.ParentId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "AbpPermissionGrants", + columns: table => new { + Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + Name = table.Column(maxLength: 128, nullable: false), + ProviderName = table.Column(maxLength: 64, nullable: false), + ProviderKey = table.Column(maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpRoles", + columns: table => new { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + TenantId = table.Column(nullable: true), + Name = table.Column(maxLength: 256, nullable: false), + NormalizedName = table.Column(maxLength: 256, nullable: false), + IsDefault = table.Column(nullable: false), + IsStatic = table.Column(nullable: false), + IsPublic = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpSettings", + columns: table => new { + Id = table.Column(nullable: false), + Name = table.Column(maxLength: 128, nullable: false), + Value = table.Column(maxLength: 2048, nullable: false), + ProviderName = table.Column(maxLength: 64, nullable: true), + ProviderKey = table.Column(maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSettings", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpTenants", + columns: table => new { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false, defaultValue: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + Name = table.Column(maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpUsers", + columns: table => new { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false, defaultValue: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + TenantId = table.Column(nullable: true), + UserName = table.Column(maxLength: 256, nullable: false), + NormalizedUserName = table.Column(maxLength: 256, nullable: false), + Name = table.Column(maxLength: 64, nullable: true), + Surname = table.Column(maxLength: 64, nullable: true), + Email = table.Column(maxLength: 256, nullable: false), + NormalizedEmail = table.Column(maxLength: 256, nullable: false), + EmailConfirmed = table.Column(nullable: false, defaultValue: false), + PasswordHash = table.Column(maxLength: 256, nullable: true), + SecurityStamp = table.Column(maxLength: 256, nullable: false), + PhoneNumber = table.Column(maxLength: 16, nullable: true), + PhoneNumberConfirmed = table.Column(nullable: false, defaultValue: false), + TwoFactorEnabled = table.Column(nullable: false, defaultValue: false), + LockoutEnd = table.Column(nullable: true), + LockoutEnabled = table.Column(nullable: false, defaultValue: false), + AccessFailedCount = table.Column(nullable: false, defaultValue: 0) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResources", + columns: table => new { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false, defaultValue: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + Name = table.Column(maxLength: 200, nullable: false), + DisplayName = table.Column(maxLength: 200, nullable: true), + Description = table.Column(maxLength: 1000, nullable: true), + Enabled = table.Column(nullable: false), + Properties = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResources", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClients", + columns: table => new { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false, defaultValue: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + ClientId = table.Column(maxLength: 200, nullable: false), + ClientName = table.Column(maxLength: 200, nullable: true), + Description = table.Column(maxLength: 1000, nullable: true), + ClientUri = table.Column(maxLength: 2000, nullable: true), + LogoUri = table.Column(maxLength: 2000, nullable: true), + Enabled = table.Column(nullable: false), + ProtocolType = table.Column(maxLength: 200, nullable: false), + RequireClientSecret = table.Column(nullable: false), + RequireConsent = table.Column(nullable: false), + AllowRememberConsent = table.Column(nullable: false), + AlwaysIncludeUserClaimsInIdToken = table.Column(nullable: false), + RequirePkce = table.Column(nullable: false), + AllowPlainTextPkce = table.Column(nullable: false), + AllowAccessTokensViaBrowser = table.Column(nullable: false), + FrontChannelLogoutUri = table.Column(maxLength: 2000, nullable: true), + FrontChannelLogoutSessionRequired = table.Column(nullable: false), + BackChannelLogoutUri = table.Column(maxLength: 2000, nullable: true), + BackChannelLogoutSessionRequired = table.Column(nullable: false), + AllowOfflineAccess = table.Column(nullable: false), + IdentityTokenLifetime = table.Column(nullable: false), + AccessTokenLifetime = table.Column(nullable: false), + AuthorizationCodeLifetime = table.Column(nullable: false), + ConsentLifetime = table.Column(nullable: true), + AbsoluteRefreshTokenLifetime = table.Column(nullable: false), + SlidingRefreshTokenLifetime = table.Column(nullable: false), + RefreshTokenUsage = table.Column(nullable: false), + UpdateAccessTokenClaimsOnRefresh = table.Column(nullable: false), + RefreshTokenExpiration = table.Column(nullable: false), + AccessTokenType = table.Column(nullable: false), + EnableLocalLogin = table.Column(nullable: false), + IncludeJwtId = table.Column(nullable: false), + AlwaysSendClientClaims = table.Column(nullable: false), + ClientClaimsPrefix = table.Column(maxLength: 200, nullable: true), + PairWiseSubjectSalt = table.Column(maxLength: 200, nullable: true), + UserSsoLifetime = table.Column(nullable: true), + UserCodeType = table.Column(maxLength: 100, nullable: true), + DeviceCodeLifetime = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClients", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerDeviceFlowCodes", + columns: table => new { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + DeviceCode = table.Column(maxLength: 200, nullable: false), + UserCode = table.Column(maxLength: 200, nullable: false), + SubjectId = table.Column(maxLength: 200, nullable: true), + ClientId = table.Column(maxLength: 200, nullable: false), + Expiration = table.Column(nullable: false), + Data = table.Column(maxLength: 50000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerDeviceFlowCodes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerIdentityResources", + columns: table => new { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false, defaultValue: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + Name = table.Column(maxLength: 200, nullable: false), + DisplayName = table.Column(maxLength: 200, nullable: true), + Description = table.Column(maxLength: 1000, nullable: true), + Enabled = table.Column(nullable: false), + Required = table.Column(nullable: false), + Emphasize = table.Column(nullable: false), + ShowInDiscoveryDocument = table.Column(nullable: false), + Properties = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerIdentityResources", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerPersistedGrants", + columns: table => new { + Key = table.Column(maxLength: 200, nullable: false), + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + Type = table.Column(maxLength: 50, nullable: false), + SubjectId = table.Column(maxLength: 200, nullable: true), + ClientId = table.Column(maxLength: 200, nullable: false), + CreationTime = table.Column(nullable: false), + Expiration = table.Column(nullable: true), + Data = table.Column(maxLength: 50000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key); + }); + + migrationBuilder.CreateTable( + name: "AbpAuditLogActions", + columns: table => new { + Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + AuditLogId = table.Column(nullable: false), + ServiceName = table.Column(maxLength: 256, nullable: true), + MethodName = table.Column(maxLength: 128, nullable: true), + Parameters = table.Column(maxLength: 2000, nullable: true), + ExecutionTime = table.Column(nullable: false), + ExecutionDuration = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); + table.ForeignKey( + name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpEntityChanges", + columns: table => new { + Id = table.Column(nullable: false), + AuditLogId = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + ChangeTime = table.Column(nullable: false), + ChangeType = table.Column(nullable: false), + EntityTenantId = table.Column(nullable: true), + EntityId = table.Column(maxLength: 128, nullable: false), + EntityTypeFullName = table.Column(maxLength: 128, nullable: false), + ExtraProperties = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnitRoles", + columns: table => new { + RoleId = table.Column(nullable: false), + OrganizationUnitId = table.Column(nullable: false), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + TenantId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpRoleClaims", + columns: table => new { + Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + ClaimType = table.Column(maxLength: 256, nullable: false), + ClaimValue = table.Column(maxLength: 1024, nullable: true), + RoleId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpRoleClaims_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpTenantConnectionStrings", + columns: table => new { + TenantId = table.Column(nullable: false), + Name = table.Column(maxLength: 64, nullable: false), + Value = table.Column(maxLength: 1024, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenantConnectionStrings", x => new { x.TenantId, x.Name }); + table.ForeignKey( + name: "FK_AbpTenantConnectionStrings_AbpTenants_TenantId", + column: x => x.TenantId, + principalTable: "AbpTenants", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserClaims", + columns: table => new { + Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + ClaimType = table.Column(maxLength: 256, nullable: false), + ClaimValue = table.Column(maxLength: 1024, nullable: true), + UserId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpUserClaims_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserLogins", + columns: table => new { + UserId = table.Column(nullable: false), + LoginProvider = table.Column(maxLength: 64, nullable: false), + TenantId = table.Column(nullable: true), + ProviderKey = table.Column(maxLength: 196, nullable: false), + ProviderDisplayName = table.Column(maxLength: 128, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); + table.ForeignKey( + name: "FK_AbpUserLogins_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserOrganizationUnits", + columns: table => new { + UserId = table.Column(nullable: false), + OrganizationUnitId = table.Column(nullable: false), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + TenantId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserRoles", + columns: table => new { + UserId = table.Column(nullable: false), + RoleId = table.Column(nullable: false), + TenantId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserTokens", + columns: table => new { + UserId = table.Column(nullable: false), + LoginProvider = table.Column(maxLength: 64, nullable: false), + Name = table.Column(maxLength: 128, nullable: false), + TenantId = table.Column(nullable: true), + Value = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AbpUserTokens_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiClaims", + columns: table => new { + Type = table.Column(maxLength: 200, nullable: false), + ApiResourceId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiClaims", x => new { x.ApiResourceId, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerApiClaims_IdentityServerApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiScopes", + columns: table => new { + ApiResourceId = table.Column(nullable: false), + Name = table.Column(maxLength: 200, nullable: false), + DisplayName = table.Column(maxLength: 200, nullable: true), + Description = table.Column(maxLength: 1000, nullable: true), + Required = table.Column(nullable: false), + Emphasize = table.Column(nullable: false), + ShowInDiscoveryDocument = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiScopes", x => new { x.ApiResourceId, x.Name }); + table.ForeignKey( + name: "FK_IdentityServerApiScopes_IdentityServerApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiSecrets", + columns: table => new { + Type = table.Column(maxLength: 250, nullable: false), + Value = table.Column(maxLength: 4000, nullable: false), + ApiResourceId = table.Column(nullable: false), + Description = table.Column(maxLength: 2000, nullable: true), + Expiration = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiSecrets", x => new { x.ApiResourceId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerApiSecrets_IdentityServerApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientClaims", + columns: table => new { + ClientId = table.Column(nullable: false), + Type = table.Column(maxLength: 250, nullable: false), + Value = table.Column(maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientClaims", x => new { x.ClientId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerClientClaims_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientCorsOrigins", + columns: table => new { + ClientId = table.Column(nullable: false), + Origin = table.Column(maxLength: 150, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientCorsOrigins", x => new { x.ClientId, x.Origin }); + table.ForeignKey( + name: "FK_IdentityServerClientCorsOrigins_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientGrantTypes", + columns: table => new { + ClientId = table.Column(nullable: false), + GrantType = table.Column(maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientGrantTypes", x => new { x.ClientId, x.GrantType }); + table.ForeignKey( + name: "FK_IdentityServerClientGrantTypes_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientIdPRestrictions", + columns: table => new { + ClientId = table.Column(nullable: false), + Provider = table.Column(maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientIdPRestrictions", x => new { x.ClientId, x.Provider }); + table.ForeignKey( + name: "FK_IdentityServerClientIdPRestrictions_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientPostLogoutRedirectUris", + columns: table => new { + ClientId = table.Column(nullable: false), + PostLogoutRedirectUri = table.Column(maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientPostLogoutRedirectUris", x => new { x.ClientId, x.PostLogoutRedirectUri }); + table.ForeignKey( + name: "FK_IdentityServerClientPostLogoutRedirectUris_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientProperties", + columns: table => new { + ClientId = table.Column(nullable: false), + Key = table.Column(maxLength: 250, nullable: false), + Value = table.Column(maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientProperties", x => new { x.ClientId, x.Key }); + table.ForeignKey( + name: "FK_IdentityServerClientProperties_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientRedirectUris", + columns: table => new { + ClientId = table.Column(nullable: false), + RedirectUri = table.Column(maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientRedirectUris", x => new { x.ClientId, x.RedirectUri }); + table.ForeignKey( + name: "FK_IdentityServerClientRedirectUris_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientScopes", + columns: table => new { + ClientId = table.Column(nullable: false), + Scope = table.Column(maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientScopes", x => new { x.ClientId, x.Scope }); + table.ForeignKey( + name: "FK_IdentityServerClientScopes_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientSecrets", + columns: table => new { + Type = table.Column(maxLength: 250, nullable: false), + Value = table.Column(maxLength: 4000, nullable: false), + ClientId = table.Column(nullable: false), + Description = table.Column(maxLength: 2000, nullable: true), + Expiration = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientSecrets", x => new { x.ClientId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerClientSecrets_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerIdentityClaims", + columns: table => new { + Type = table.Column(maxLength: 200, nullable: false), + IdentityResourceId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerIdentityClaims", x => new { x.IdentityResourceId, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerIdentityClaims_IdentityServerIdentityResources_IdentityResourceId", + column: x => x.IdentityResourceId, + principalTable: "IdentityServerIdentityResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpEntityPropertyChanges", + columns: table => new { + Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + EntityChangeId = table.Column(nullable: false), + NewValue = table.Column(maxLength: 512, nullable: true), + OriginalValue = table.Column(maxLength: 512, nullable: true), + PropertyName = table.Column(maxLength: 128, nullable: false), + PropertyTypeFullName = table.Column(maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", + column: x => x.EntityChangeId, + principalTable: "AbpEntityChanges", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiScopeClaims", + columns: table => new { + Type = table.Column(maxLength: 200, nullable: false), + ApiResourceId = table.Column(nullable: false), + Name = table.Column(maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiScopeClaims", x => new { x.ApiResourceId, x.Name, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiResourceId_Name", + columns: x => new { x.ApiResourceId, x.Name }, + principalTable: "IdentityServerApiScopes", + principalColumns: new[] { "ApiResourceId", "Name" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_AuditLogId", + table: "AbpAuditLogActions", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", + table: "AbpAuditLogActions", + columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "UserId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_AuditLogId", + table: "AbpEntityChanges", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", + table: "AbpEntityChanges", + columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityPropertyChanges_EntityChangeId", + table: "AbpEntityPropertyChanges", + column: "EntityChangeId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", + table: "AbpOrganizationUnitRoles", + columns: new[] { "RoleId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_Code", + table: "AbpOrganizationUnits", + column: "Code"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_ParentId", + table: "AbpOrganizationUnits", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissionGrants_Name_ProviderName_ProviderKey", + table: "AbpPermissionGrants", + columns: new[] { "Name", "ProviderName", "ProviderKey" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoleClaims_RoleId", + table: "AbpRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoles_NormalizedName", + table: "AbpRoles", + column: "NormalizedName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpSettings_Name_ProviderName_ProviderKey", + table: "AbpSettings", + columns: new[] { "Name", "ProviderName", "ProviderKey" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpTenants_Name", + table: "AbpTenants", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserClaims_UserId", + table: "AbpUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserLogins_LoginProvider_ProviderKey", + table: "AbpUserLogins", + columns: new[] { "LoginProvider", "ProviderKey" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId", + table: "AbpUserOrganizationUnits", + columns: new[] { "UserId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserRoles_RoleId_UserId", + table: "AbpUserRoles", + columns: new[] { "RoleId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_Email", + table: "AbpUsers", + column: "Email"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedEmail", + table: "AbpUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedUserName", + table: "AbpUsers", + column: "NormalizedUserName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_UserName", + table: "AbpUsers", + column: "UserName"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerClients_ClientId", + table: "IdentityServerClients", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_DeviceCode", + table: "IdentityServerDeviceFlowCodes", + column: "DeviceCode", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_Expiration", + table: "IdentityServerDeviceFlowCodes", + column: "Expiration"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_UserCode", + table: "IdentityServerDeviceFlowCodes", + column: "UserCode", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerPersistedGrants_Expiration", + table: "IdentityServerPersistedGrants", + column: "Expiration"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerPersistedGrants_SubjectId_ClientId_Type", + table: "IdentityServerPersistedGrants", + columns: new[] { "SubjectId", "ClientId", "Type" }); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AbpAuditLogActions"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpAuditLogActions"); - migrationBuilder.DropTable( - name: "AbpClaimTypes"); + migrationBuilder.DropTable( + name: "AbpClaimTypes"); - migrationBuilder.DropTable( - name: "AbpEntityPropertyChanges"); + migrationBuilder.DropTable( + name: "AbpEntityPropertyChanges"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnitRoles"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnitRoles"); - migrationBuilder.DropTable( - name: "AbpPermissionGrants"); + migrationBuilder.DropTable( + name: "AbpPermissionGrants"); - migrationBuilder.DropTable( - name: "AbpRoleClaims"); + migrationBuilder.DropTable( + name: "AbpRoleClaims"); - migrationBuilder.DropTable( - name: "AbpSettings"); + migrationBuilder.DropTable( + name: "AbpSettings"); - migrationBuilder.DropTable( - name: "AbpTenantConnectionStrings"); + migrationBuilder.DropTable( + name: "AbpTenantConnectionStrings"); - migrationBuilder.DropTable( - name: "AbpUserClaims"); + migrationBuilder.DropTable( + name: "AbpUserClaims"); - migrationBuilder.DropTable( - name: "AbpUserLogins"); + migrationBuilder.DropTable( + name: "AbpUserLogins"); - migrationBuilder.DropTable( - name: "AbpUserOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpUserOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpUserRoles"); + migrationBuilder.DropTable( + name: "AbpUserRoles"); - migrationBuilder.DropTable( - name: "AbpUserTokens"); + migrationBuilder.DropTable( + name: "AbpUserTokens"); - migrationBuilder.DropTable( - name: "IdentityServerApiClaims"); + migrationBuilder.DropTable( + name: "IdentityServerApiClaims"); - migrationBuilder.DropTable( - name: "IdentityServerApiScopeClaims"); + migrationBuilder.DropTable( + name: "IdentityServerApiScopeClaims"); - migrationBuilder.DropTable( - name: "IdentityServerApiSecrets"); + migrationBuilder.DropTable( + name: "IdentityServerApiSecrets"); - migrationBuilder.DropTable( - name: "IdentityServerClientClaims"); + migrationBuilder.DropTable( + name: "IdentityServerClientClaims"); - migrationBuilder.DropTable( - name: "IdentityServerClientCorsOrigins"); + migrationBuilder.DropTable( + name: "IdentityServerClientCorsOrigins"); - migrationBuilder.DropTable( - name: "IdentityServerClientGrantTypes"); + migrationBuilder.DropTable( + name: "IdentityServerClientGrantTypes"); - migrationBuilder.DropTable( - name: "IdentityServerClientIdPRestrictions"); + migrationBuilder.DropTable( + name: "IdentityServerClientIdPRestrictions"); - migrationBuilder.DropTable( - name: "IdentityServerClientPostLogoutRedirectUris"); + migrationBuilder.DropTable( + name: "IdentityServerClientPostLogoutRedirectUris"); - migrationBuilder.DropTable( - name: "IdentityServerClientProperties"); + migrationBuilder.DropTable( + name: "IdentityServerClientProperties"); - migrationBuilder.DropTable( - name: "IdentityServerClientRedirectUris"); + migrationBuilder.DropTable( + name: "IdentityServerClientRedirectUris"); - migrationBuilder.DropTable( - name: "IdentityServerClientScopes"); + migrationBuilder.DropTable( + name: "IdentityServerClientScopes"); - migrationBuilder.DropTable( - name: "IdentityServerClientSecrets"); + migrationBuilder.DropTable( + name: "IdentityServerClientSecrets"); - migrationBuilder.DropTable( - name: "IdentityServerDeviceFlowCodes"); + migrationBuilder.DropTable( + name: "IdentityServerDeviceFlowCodes"); - migrationBuilder.DropTable( - name: "IdentityServerIdentityClaims"); + migrationBuilder.DropTable( + name: "IdentityServerIdentityClaims"); - migrationBuilder.DropTable( - name: "IdentityServerPersistedGrants"); + migrationBuilder.DropTable( + name: "IdentityServerPersistedGrants"); - migrationBuilder.DropTable( - name: "AbpEntityChanges"); + migrationBuilder.DropTable( + name: "AbpEntityChanges"); - migrationBuilder.DropTable( - name: "AbpTenants"); + migrationBuilder.DropTable( + name: "AbpTenants"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpRoles"); + migrationBuilder.DropTable( + name: "AbpRoles"); - migrationBuilder.DropTable( - name: "AbpUsers"); + migrationBuilder.DropTable( + name: "AbpUsers"); - migrationBuilder.DropTable( - name: "IdentityServerApiScopes"); + migrationBuilder.DropTable( + name: "IdentityServerApiScopes"); - migrationBuilder.DropTable( - name: "IdentityServerClients"); + migrationBuilder.DropTable( + name: "IdentityServerClients"); - migrationBuilder.DropTable( - name: "IdentityServerIdentityResources"); + migrationBuilder.DropTable( + name: "IdentityServerIdentityResources"); - migrationBuilder.DropTable( - name: "AbpAuditLogs"); + migrationBuilder.DropTable( + name: "AbpAuditLogs"); - migrationBuilder.DropTable( - name: "IdentityServerApiResources"); - } + migrationBuilder.DropTable( + name: "IdentityServerApiResources"); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Pages/Index.cshtml.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Pages/Index.cshtml.cs index 77ead3d91a..909afb3080 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Pages/Index.cshtml.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Pages/Index.cshtml.cs @@ -1,11 +1,10 @@ using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public class IndexModel : AbpPageModel { - public class IndexModel : AbpPageModel + public void OnGet() { - public void OnGet() - { - } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Program.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Program.cs index 7349f8eb0c..1df7011979 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Program.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Program.cs @@ -5,47 +5,46 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class Program { - public class Program + public static int Main(string[] args) { - public static int Main(string[] args) - { - Log.Logger = new LoggerConfiguration() + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() #else .MinimumLevel.Information() #endif .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - .Enrich.FromLogContext() - .WriteTo.File("Logs/logs.txt") - .CreateLogger(); + .Enrich.FromLogContext() + .WriteTo.File("Logs/logs.txt") + .CreateLogger(); - try - { - Log.Information("Starting web host."); - CreateHostBuilder(args).Build().Run(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Host terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } + try + { + Log.Information("Starting web host."); + CreateHostBuilder(args).Build().Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Startup.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Startup.cs index 3ae2eec7c7..d961c19377 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Startup.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Startup.cs @@ -4,18 +4,17 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitBrandingProvider.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitBrandingProvider.cs index c776e1063b..57e6935ccf 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitBrandingProvider.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitBrandingProvider.cs @@ -1,11 +1,10 @@ using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[Dependency(ReplaceServices = true)] +public class CmsKitBrandingProvider : DefaultBrandingProvider { - [Dependency(ReplaceServices = true)] - public class CmsKitBrandingProvider : DefaultBrandingProvider - { - public override string AppName => "CmsKit"; - } + public override string AppName => "CmsKit"; } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebAutoMapperProfile.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebAutoMapperProfile.cs index 3fbe710a8c..bea413f2bc 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebAutoMapperProfile.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebAutoMapperProfile.cs @@ -1,12 +1,11 @@ using AutoMapper; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class CmsKitWebAutoMapperProfile : Profile { - public class CmsKitWebAutoMapperProfile : Profile + public CmsKitWebAutoMapperProfile() { - public CmsKitWebAutoMapperProfile() - { - //Define your AutoMapper configuration here for the Web project. - } + //Define your AutoMapper configuration here for the Web project. } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostMenuContributor.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostMenuContributor.cs index 62fccac5e6..46178addc9 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostMenuContributor.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostMenuContributor.cs @@ -9,49 +9,48 @@ using Volo.CmsKit.Localization; using Volo.Abp.UI.Navigation; using Volo.Abp.Users; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class CmsKitWebHostMenuContributor : IMenuContributor { - public class CmsKitWebHostMenuContributor : IMenuContributor + private readonly IConfiguration _configuration; + + public CmsKitWebHostMenuContributor(IConfiguration configuration) { - private readonly IConfiguration _configuration; + _configuration = configuration; + } - public CmsKitWebHostMenuContributor(IConfiguration configuration) + public Task ConfigureMenuAsync(MenuConfigurationContext context) + { + if (context.Menu.Name == StandardMenus.User) { - _configuration = configuration; + AddLogoutItemToMenu(context); } - public Task ConfigureMenuAsync(MenuConfigurationContext context) - { - if (context.Menu.Name == StandardMenus.User) - { - AddLogoutItemToMenu(context); - } - - return Task.CompletedTask; - } + return Task.CompletedTask; + } - private void AddLogoutItemToMenu(MenuConfigurationContext context) - { - var l = context.GetLocalizer(); - - context.Menu.Items.Add(new ApplicationMenuItem( - "Account.Manage", - l["MyAccount"], - $"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage", - icon: "fa fa-cog", - order: int.MaxValue - 1001, - null, - "_blank" - ).RequireAuthenticated()); - - - context.Menu.Items.Add(new ApplicationMenuItem( - "Account.Logout", - l["Logout"], - "~/Account/Logout", - "fas fa-power-off", - order: int.MaxValue - 1000 - ).RequireAuthenticated()); - } + private void AddLogoutItemToMenu(MenuConfigurationContext context) + { + var l = context.GetLocalizer(); + + context.Menu.Items.Add(new ApplicationMenuItem( + "Account.Manage", + l["MyAccount"], + $"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage", + icon: "fa fa-cog", + order: int.MaxValue - 1001, + null, + "_blank" + ).RequireAuthenticated()); + + + context.Menu.Items.Add(new ApplicationMenuItem( + "Account.Logout", + l["Logout"], + "~/Account/Logout", + "fas fa-power-off", + order: int.MaxValue - 1000 + ).RequireAuthenticated()); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs index 8ef91e4f94..4ca31dc44a 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs @@ -42,207 +42,206 @@ using Volo.Abp.UI; using Volo.Abp.UI.Navigation; using Volo.Abp.VirtualFileSystem; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitWebModule), + typeof(CmsKitHttpApiClientModule), + typeof(AbpAspNetCoreAuthenticationOAuthModule), + typeof(AbpAspNetCoreMvcClientModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAutofacModule), + typeof(AbpCachingStackExchangeRedisModule), + typeof(AbpHttpClientIdentityModelWebModule), + typeof(AbpIdentityWebModule), + typeof(AbpIdentityHttpApiClientModule), + typeof(AbpTenantManagementWebModule), + typeof(AbpTenantManagementHttpApiClientModule), + typeof(AbpFeatureManagementHttpApiClientModule), + typeof(AbpPermissionManagementHttpApiClientModule), + typeof(AbpAspNetCoreSerilogModule) + )] +public class CmsKitWebHostModule : AbpModule { - [DependsOn( - typeof(CmsKitWebModule), - typeof(CmsKitHttpApiClientModule), - typeof(AbpAspNetCoreAuthenticationOAuthModule), - typeof(AbpAspNetCoreMvcClientModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAutofacModule), - typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpHttpClientIdentityModelWebModule), - typeof(AbpIdentityWebModule), - typeof(AbpIdentityHttpApiClientModule), - typeof(AbpTenantManagementWebModule), - typeof(AbpTenantManagementHttpApiClientModule), - typeof(AbpFeatureManagementHttpApiClientModule), - typeof(AbpPermissionManagementHttpApiClientModule), - typeof(AbpAspNetCoreSerilogModule) - )] - public class CmsKitWebHostModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + FeatureConfigurer.Configure(); + + context.Services.PreConfigure(options => { - FeatureConfigurer.Configure(); + options.AddAssemblyResource( + typeof(CmsKitResource), + typeof(CmsKitDomainSharedModule).Assembly, + typeof(CmsKitApplicationContractsModule).Assembly, + typeof(CmsKitWebHostModule).Assembly + ); + }); + } - context.Services.PreConfigure(options => - { - options.AddAssemblyResource( - typeof(CmsKitResource), - typeof(CmsKitDomainSharedModule).Assembly, - typeof(CmsKitApplicationContractsModule).Assembly, - typeof(CmsKitWebHostModule).Assembly - ); - }); - } + public override void ConfigureServices(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); + + ConfigureMenu(configuration); + ConfigureCache(configuration); + ConfigureUrls(configuration); + ConfigureAuthentication(context, configuration); + ConfigureAutoMapper(); + ConfigureVirtualFileSystem(hostingEnvironment); + ConfigureSwaggerServices(context.Services); + ConfigureMultiTenancy(); + ConfigureRedis(context, configuration, hostingEnvironment); + } - public override void ConfigureServices(ServiceConfigurationContext context) + private void ConfigureMenu(IConfiguration configuration) + { + Configure(options => { - var hostingEnvironment = context.Services.GetHostingEnvironment(); - var configuration = context.Services.GetConfiguration(); - - ConfigureMenu(configuration); - ConfigureCache(configuration); - ConfigureUrls(configuration); - ConfigureAuthentication(context, configuration); - ConfigureAutoMapper(); - ConfigureVirtualFileSystem(hostingEnvironment); - ConfigureSwaggerServices(context.Services); - ConfigureMultiTenancy(); - ConfigureRedis(context, configuration, hostingEnvironment); - } + options.MenuContributors.Add(new CmsKitWebHostMenuContributor(configuration)); + }); + } - private void ConfigureMenu(IConfiguration configuration) + private void ConfigureCache(IConfiguration configuration) + { + Configure(options => { - Configure(options => - { - options.MenuContributors.Add(new CmsKitWebHostMenuContributor(configuration)); - }); - } + options.KeyPrefix = "CmsKit:"; + }); + } - private void ConfigureCache(IConfiguration configuration) + private void ConfigureUrls(IConfiguration configuration) + { + Configure(options => { - Configure(options => - { - options.KeyPrefix = "CmsKit:"; - }); - } + options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; + }); + } - private void ConfigureUrls(IConfiguration configuration) + private void ConfigureMultiTenancy() + { + Configure(options => { - Configure(options => - { - options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; - }); - } + options.IsEnabled = MultiTenancyConsts.IsEnabled; + }); + } - private void ConfigureMultiTenancy() - { - Configure(options => + private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + { + context.Services.AddAuthentication(options => + { + options.DefaultScheme = "Cookies"; + options.DefaultChallengeScheme = "oidc"; + }) + .AddCookie("Cookies", options => + { + options.ExpireTimeSpan = TimeSpan.FromDays(365); + }) + .AddOpenIdConnect("oidc", options => { - options.IsEnabled = MultiTenancyConsts.IsEnabled; + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = false; + options.ResponseType = OpenIdConnectResponseType.CodeIdToken; + + options.ClientId = configuration["AuthServer:ClientId"]; + options.ClientSecret = configuration["AuthServer:ClientSecret"]; + + options.SaveTokens = true; + options.GetClaimsFromUserInfoEndpoint = true; + + options.Scope.Add("role"); + options.Scope.Add("email"); + options.Scope.Add("phone"); + options.Scope.Add("CmsKit"); + + options.ClaimActions.MapJsonKey(AbpClaimTypes.UserName, "name"); + options.ClaimActions.DeleteClaim("name"); }); - } + } - private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + private void ConfigureAutoMapper() + { + Configure(options => { - context.Services.AddAuthentication(options => - { - options.DefaultScheme = "Cookies"; - options.DefaultChallengeScheme = "oidc"; - }) - .AddCookie("Cookies", options => - { - options.ExpireTimeSpan = TimeSpan.FromDays(365); - }) - .AddOpenIdConnect("oidc", options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = false; - options.ResponseType = OpenIdConnectResponseType.CodeIdToken; - - options.ClientId = configuration["AuthServer:ClientId"]; - options.ClientSecret = configuration["AuthServer:ClientSecret"]; - - options.SaveTokens = true; - options.GetClaimsFromUserInfoEndpoint = true; - - options.Scope.Add("role"); - options.Scope.Add("email"); - options.Scope.Add("phone"); - options.Scope.Add("CmsKit"); - - options.ClaimActions.MapJsonKey(AbpClaimTypes.UserName, "name"); - options.ClaimActions.DeleteClaim("name"); - }); - } + options.AddMaps(); + }); + } - private void ConfigureAutoMapper() + private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) + { + if (hostingEnvironment.IsDevelopment()) { - Configure(options => + Configure(options => { - options.AddMaps(); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application.Contracts", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Web", Path.DirectorySeparatorChar))); }); } + } - private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) - { - if (hostingEnvironment.IsDevelopment()) + private void ConfigureSwaggerServices(IServiceCollection services) + { + services.AddSwaggerGen( + options => { - Configure(options => - { - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application.Contracts", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Web", Path.DirectorySeparatorChar))); - }); + options.SwaggerDoc("v1", new OpenApiInfo { Title = "CmsKit API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); } - } + ); + } - private void ConfigureSwaggerServices(IServiceCollection services) + private void ConfigureRedis( + ServiceConfigurationContext context, + IConfiguration configuration, + IWebHostEnvironment hostingEnvironment) + { + if (!hostingEnvironment.IsDevelopment()) { - services.AddSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "CmsKit API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - } - ); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services + .AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "CmsKit-Protection-Keys"); } + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); - private void ConfigureRedis( - ServiceConfigurationContext context, - IConfiguration configuration, - IWebHostEnvironment hostingEnvironment) + if (env.IsDevelopment()) { - if (!hostingEnvironment.IsDevelopment()) - { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - context.Services - .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "CmsKit-Protection-Keys"); - } + app.UseDeveloperExceptionPage(); } - - public override void OnApplicationInitialization(ApplicationInitializationContext context) + else { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseErrorPage(); - app.UseHsts(); - } + app.UseErrorPage(); + app.UseHsts(); + } - app.UseHttpsRedirection(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthentication(); + app.UseHttpsRedirection(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseAuthentication(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); + } - app.UseAbpRequestLocalization(); - app.UseAuthorization(); + app.UseAbpRequestLocalization(); + app.UseAuthorization(); - app.UseSwagger(); - app.UseSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "CmsKit API"); - }); + app.UseSwagger(); + app.UseSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "CmsKit API"); + }); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); - } + app.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Controllers/AccountController.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Controllers/AccountController.cs index 99853fda6f..ef6c5c4e9a 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Controllers/AccountController.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Controllers/AccountController.cs @@ -1,9 +1,8 @@ using Volo.Abp.AspNetCore.Mvc.Authentication; -namespace Volo.CmsKit.Controllers +namespace Volo.CmsKit.Controllers; + +public class AccountController : ChallengeAccountController { - public class AccountController : ChallengeAccountController - { - } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Pages/CmsKitPageModel.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Pages/CmsKitPageModel.cs index de96012de0..aa3ec05d05 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Pages/CmsKitPageModel.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Pages/CmsKitPageModel.cs @@ -1,13 +1,12 @@ using Volo.CmsKit.Localization; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public abstract class CmsKitPageModel : AbpPageModel { - public abstract class CmsKitPageModel : AbpPageModel + protected CmsKitPageModel() { - protected CmsKitPageModel() - { - LocalizationResourceType = typeof(CmsKitResource); - } + LocalizationResourceType = typeof(CmsKitResource); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Pages/Index.cshtml.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Pages/Index.cshtml.cs index 2571bddec4..ff542f0ea3 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Pages/Index.cshtml.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Pages/Index.cshtml.cs @@ -1,18 +1,17 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public class IndexModel : CmsKitPageModel { - public class IndexModel : CmsKitPageModel + public void OnGet() { - public void OnGet() - { - - } - public async Task OnPostLoginAsync() - { - await HttpContext.ChallengeAsync("oidc"); - } } -} \ No newline at end of file + + public async Task OnPostLoginAsync() + { + await HttpContext.ChallengeAsync("oidc"); + } +} diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Program.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Program.cs index 7349f8eb0c..1df7011979 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Program.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Program.cs @@ -5,47 +5,46 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class Program { - public class Program + public static int Main(string[] args) { - public static int Main(string[] args) - { - Log.Logger = new LoggerConfiguration() + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() #else .MinimumLevel.Information() #endif .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - .Enrich.FromLogContext() - .WriteTo.File("Logs/logs.txt") - .CreateLogger(); + .Enrich.FromLogContext() + .WriteTo.File("Logs/logs.txt") + .CreateLogger(); - try - { - Log.Information("Starting web host."); - CreateHostBuilder(args).Build().Run(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Host terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } + try + { + Log.Information("Starting web host."); + CreateHostBuilder(args).Build().Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Startup.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Startup.cs index 277c6b07c3..e40f013bc2 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Startup.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Startup.cs @@ -2,18 +2,17 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs index 69fe7fd8d2..3a14141c01 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs @@ -47,193 +47,192 @@ using Volo.CmsKit.MediaDescriptors; using Volo.CmsKit.Reactions; using Volo.CmsKit.Ratings; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitWebModule), + typeof(CmsKitApplicationModule), + typeof(CmsKitHttpApiModule), + typeof(CmsKitEntityFrameworkCoreModule), + typeof(AbpAuditLoggingEntityFrameworkCoreModule), + typeof(AbpAutofacModule), + typeof(AbpAccountWebModule), + typeof(AbpAccountApplicationModule), + typeof(AbpAccountHttpApiModule), + typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementApplicationModule), + typeof(AbpPermissionManagementHttpApiModule), + typeof(AbpIdentityWebModule), + typeof(AbpIdentityApplicationModule), + typeof(AbpIdentityHttpApiModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpPermissionManagementDomainIdentityModule), + typeof(AbpFeatureManagementApplicationModule), + typeof(AbpFeatureManagementHttpApiModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), + typeof(AbpFeatureManagementWebModule), + typeof(AbpTenantManagementWebModule), + typeof(AbpTenantManagementApplicationModule), + typeof(AbpTenantManagementHttpApiModule), + typeof(AbpTenantManagementEntityFrameworkCoreModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(BlobStoringDatabaseEntityFrameworkCoreModule), + typeof(AbpSwashbuckleModule) +)] +public class CmsKitWebUnifiedModule : AbpModule { - [DependsOn( - typeof(CmsKitWebModule), - typeof(CmsKitApplicationModule), - typeof(CmsKitHttpApiModule), - typeof(CmsKitEntityFrameworkCoreModule), - typeof(AbpAuditLoggingEntityFrameworkCoreModule), - typeof(AbpAutofacModule), - typeof(AbpAccountWebModule), - typeof(AbpAccountApplicationModule), - typeof(AbpAccountHttpApiModule), - typeof(AbpEntityFrameworkCoreSqlServerModule), - typeof(AbpSettingManagementEntityFrameworkCoreModule), - typeof(AbpPermissionManagementEntityFrameworkCoreModule), - typeof(AbpPermissionManagementApplicationModule), - typeof(AbpPermissionManagementHttpApiModule), - typeof(AbpIdentityWebModule), - typeof(AbpIdentityApplicationModule), - typeof(AbpIdentityHttpApiModule), - typeof(AbpIdentityEntityFrameworkCoreModule), - typeof(AbpPermissionManagementDomainIdentityModule), - typeof(AbpFeatureManagementApplicationModule), - typeof(AbpFeatureManagementHttpApiModule), - typeof(AbpFeatureManagementEntityFrameworkCoreModule), - typeof(AbpFeatureManagementWebModule), - typeof(AbpTenantManagementWebModule), - typeof(AbpTenantManagementApplicationModule), - typeof(AbpTenantManagementHttpApiModule), - typeof(AbpTenantManagementEntityFrameworkCoreModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(BlobStoringDatabaseEntityFrameworkCoreModule), - typeof(AbpSwashbuckleModule) - )] - public class CmsKitWebUnifiedModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - FeatureConfigurer.Configure(); - } + FeatureConfigurer.Configure(); + } - public override void ConfigureServices(ServiceConfigurationContext context) - { - var hostingEnvironment = context.Services.GetHostingEnvironment(); - var configuration = context.Services.GetConfiguration(); + public override void ConfigureServices(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); - ConfigureCmsKit(context); + ConfigureCmsKit(context); - Configure(options => - { - options.UseSqlServer(); - }); + Configure(options => + { + options.UseSqlServer(); + }); - if (hostingEnvironment.IsDevelopment()) + if (hostingEnvironment.IsDevelopment()) + { + Configure(options => { - Configure(options => - { - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}framework/src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar))); - - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain.Shared", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}framework/src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Common.Web", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Public.Web", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Admin.Web", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain.Shared", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application.Contracts", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Web", Path.DirectorySeparatorChar))); - }); - } + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Common.Web", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Public.Web", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Admin.Web", Path.DirectorySeparatorChar))); - context.Services.AddSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "CmsKit API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - }); - - Configure(options => - { - options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); - options.Languages.Add(new LanguageInfo("en", "en", "English")); - options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); - options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); - options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); - options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); - options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); - options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); - options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)")); - options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); - options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); - options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); - options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); - options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application.Contracts", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Web", Path.DirectorySeparatorChar))); }); + } - Configure(options => + context.Services.AddSwaggerGen( + options => { - options.IsEnabled = MultiTenancyConsts.IsEnabled; + options.SwaggerDoc("v1", new OpenApiInfo { Title = "CmsKit API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); }); - } - private void ConfigureCmsKit(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.EntityTypes.Add(new TagEntityTypeDefiniton("quote")); - }); + options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); + options.Languages.Add(new LanguageInfo("en", "en", "English")); + options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); + options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); + options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); + options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); + options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); + options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); + options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)")); + options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); + options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); + options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); + options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); + options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); + options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); + }); + + Configure(options => + { + options.IsEnabled = MultiTenancyConsts.IsEnabled; + }); + } - Configure(options => - { - options.EntityTypes.Add(new CommentEntityTypeDefinition("quote")); - }); + private void ConfigureCmsKit(ServiceConfigurationContext context) + { + Configure(options => + { + options.EntityTypes.Add(new TagEntityTypeDefiniton("quote")); + }); - Configure(options => - { - options.EntityTypes.Add(new MediaDescriptorDefinition("quote")); - }); + Configure(options => + { + options.EntityTypes.Add(new CommentEntityTypeDefinition("quote")); + }); - Configure(options => - { - options.EntityTypes.Add( - new ReactionEntityTypeDefinition("quote", - reactions: new[] - { + Configure(options => + { + options.EntityTypes.Add(new MediaDescriptorDefinition("quote")); + }); + + Configure(options => + { + options.EntityTypes.Add( + new ReactionEntityTypeDefinition("quote", + reactions: new[] + { new ReactionDefinition(StandardReactions.ThumbsUp), new ReactionDefinition(StandardReactions.ThumbsDown), - })); - }); - - Configure(options => - { - options.EntityTypes.Add(new RatingEntityTypeDefinition("quote")); - }); - } + })); + }); - public override void OnApplicationInitialization(ApplicationInitializationContext context) + Configure(options => { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); + options.EntityTypes.Add(new RatingEntityTypeDefinition("quote")); + }); + } - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseErrorPage(); - app.UseHsts(); - } + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); - app.UseHttpsRedirection(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthentication(); + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseErrorPage(); + app.UseHsts(); + } - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + app.UseHttpsRedirection(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseAuthentication(); - app.UseAbpRequestLocalization(); - app.UseAuthorization(); + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); + } - app.UseSwagger(); - app.UseAbpSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); - }); + app.UseAbpRequestLocalization(); + app.UseAuthorization(); + + app.UseSwagger(); + app.UseAbpSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); + }); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); + app.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); - using (var scope = context.ServiceProvider.CreateScope()) + using (var scope = context.ServiceProvider.CreateScope()) + { + AsyncHelper.RunSync(async () => { - AsyncHelper.RunSync(async () => - { - await scope.ServiceProvider - .GetRequiredService() - .SeedAsync(); - }); - } + await scope.ServiceProvider + .GetRequiredService() + .SeedAsync(); + }); } } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContext.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContext.cs index fe6c11b300..9109a772ed 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContext.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContext.cs @@ -8,28 +8,27 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement.EntityFrameworkCore; -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +public class UnifiedDbContext : AbpDbContext { - public class UnifiedDbContext : AbpDbContext + public UnifiedDbContext(DbContextOptions options) + : base(options) { - public UnifiedDbContext(DbContextOptions options) - : base(options) - { - } + } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); - modelBuilder.ConfigurePermissionManagement(); - modelBuilder.ConfigureSettingManagement(); - modelBuilder.ConfigureAuditLogging(); - modelBuilder.ConfigureIdentity(); - modelBuilder.ConfigureTenantManagement(); - modelBuilder.ConfigureFeatureManagement(); - modelBuilder.ConfigureCmsKit(); - modelBuilder.ConfigureBlobStoring(); - } + modelBuilder.ConfigurePermissionManagement(); + modelBuilder.ConfigureSettingManagement(); + modelBuilder.ConfigureAuditLogging(); + modelBuilder.ConfigureIdentity(); + modelBuilder.ConfigureTenantManagement(); + modelBuilder.ConfigureFeatureManagement(); + modelBuilder.ConfigureCmsKit(); + modelBuilder.ConfigureBlobStoring(); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs index 170e4dc688..156a6f8ba9 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs @@ -3,29 +3,28 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +public class UnifiedDbContextFactory : IDesignTimeDbContextFactory { - public class UnifiedDbContextFactory : IDesignTimeDbContextFactory + public UnifiedDbContext CreateDbContext(string[] args) { - public UnifiedDbContext CreateDbContext(string[] args) - { - FeatureConfigurer.Configure(); + FeatureConfigurer.Configure(); - var configuration = BuildConfiguration(); + var configuration = BuildConfiguration(); - var builder = new DbContextOptionsBuilder() - .UseSqlServer(configuration.GetConnectionString("Default")); + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); - return new UnifiedDbContext(builder.Options); - } + return new UnifiedDbContext(builder.Options); + } - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false); + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false); - return builder.Build(); - } + return builder.Build(); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20211110134400_Initial.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20211110134400_Initial.cs index 2a60d586a1..29dad798d9 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20211110134400_Initial.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20211110134400_Initial.cs @@ -3,1157 +3,1120 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace Volo.CmsKit.Migrations +namespace Volo.CmsKit.Migrations; + +public partial class Initial : Migration { - public partial class Initial : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AbpAuditLogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - TenantName = table.Column(type: "nvarchar(max)", nullable: true), - ImpersonatorUserId = table.Column(type: "uniqueidentifier", nullable: true), - ImpersonatorTenantId = table.Column(type: "uniqueidentifier", nullable: true), - ExecutionTime = table.Column(type: "datetime2", nullable: false), - ExecutionDuration = table.Column(type: "int", nullable: false), - ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - HttpMethod = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - Url = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - Exceptions = table.Column(type: "nvarchar(max)", nullable: true), - Comments = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - HttpStatusCode = table.Column(type: "int", nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpBlobContainers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpBlobContainers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpClaimTypes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Required = table.Column(type: "bit", nullable: false), - IsStatic = table.Column(type: "bit", nullable: false), - Regex = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - RegexDescription = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - Description = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - ValueType = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpFeatureValues", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Value = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpLinkUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - SourceUserId = table.Column(type: "uniqueidentifier", nullable: false), - SourceTenantId = table.Column(type: "uniqueidentifier", nullable: true), - TargetUserId = table.Column(type: "uniqueidentifier", nullable: false), - TargetTenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnits", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ParentId = table.Column(type: "uniqueidentifier", nullable: true), - Code = table.Column(type: "nvarchar(95)", maxLength: 95, nullable: false), - DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); - table.ForeignKey( - name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", - column: x => x.ParentId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "AbpPermissionGrants", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpRoles", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - IsDefault = table.Column(type: "bit", nullable: false), - IsStatic = table.Column(type: "bit", nullable: false), - IsPublic = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpSecurityLogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - Identity = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - Action = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - TenantName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpSettings", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Value = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpSettings", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpTenants", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpTenants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - PasswordHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - SecurityStamp = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - IsExternal = table.Column(type: "bit", nullable: false, defaultValue: false), - PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - IsActive = table.Column(type: "bit", nullable: false), - TwoFactorEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), - LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), - LockoutEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), - AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsBlogFeatures", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - BlogId = table.Column(type: "uniqueidentifier", nullable: false), - FeatureName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - IsEnabled = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsBlogFeatures", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsBlogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Slug = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsBlogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsComments", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Text = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: false), - RepliedCommentId = table.Column(type: "uniqueidentifier", nullable: true), - CreatorId = table.Column(type: "uniqueidentifier", nullable: false), - CreationTime = table.Column(type: "datetime2", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsComments", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsEntityTags", - columns: table => new - { - TagId = table.Column(type: "uniqueidentifier", nullable: false), - EntityId = table.Column(type: "nvarchar(450)", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsEntityTags", x => new { x.EntityId, x.TagId }); - }); - - migrationBuilder.CreateTable( - name: "CmsMediaDescriptors", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), - MimeType = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Size = table.Column(type: "bigint", maxLength: 2147483647, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsMediaDescriptors", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsMenuItems", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ParentId = table.Column(type: "uniqueidentifier", nullable: true), - DisplayName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - IsActive = table.Column(type: "bit", nullable: false), - Url = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: false), - Icon = table.Column(type: "nvarchar(max)", nullable: true), - Order = table.Column(type: "int", nullable: false), - Target = table.Column(type: "nvarchar(max)", nullable: true), - ElementId = table.Column(type: "nvarchar(max)", nullable: true), - CssClass = table.Column(type: "nvarchar(max)", nullable: true), - PageId = table.Column(type: "uniqueidentifier", nullable: true), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsMenuItems", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsPages", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Title = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Slug = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Content = table.Column(type: "nvarchar(max)", maxLength: 2147483647, nullable: true), - Script = table.Column(type: "nvarchar(max)", nullable: true), - Style = table.Column(type: "nvarchar(max)", nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsPages", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsRatings", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - StarCount = table.Column(type: "smallint", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: false), - CreationTime = table.Column(type: "datetime2", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsRatings", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsTags", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Name = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsTags", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsUserReactions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ReactionName = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: false), - CreationTime = table.Column(type: "datetime2", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsUserReactions", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "CmsUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpAuditLogActions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), - ServiceName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - MethodName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - Parameters = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - ExecutionTime = table.Column(type: "datetime2", nullable: false), - ExecutionDuration = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); - table.ForeignKey( - name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpEntityChanges", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ChangeTime = table.Column(type: "datetime2", nullable: false), - ChangeType = table.Column(type: "tinyint", nullable: false), - EntityTenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - EntityTypeFullName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpBlobs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ContainerId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Content = table.Column(type: "varbinary(max)", maxLength: 2147483647, nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpBlobs", x => x.Id); - table.ForeignKey( - name: "FK_AbpBlobs_AbpBlobContainers_ContainerId", - column: x => x.ContainerId, - principalTable: "AbpBlobContainers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnitRoles", - columns: table => new - { - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpRoleClaims", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AbpRoleClaims_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpTenantConnectionStrings", - columns: table => new - { - TenantId = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Value = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpTenantConnectionStrings", x => new { x.TenantId, x.Name }); - table.ForeignKey( - name: "FK_AbpTenantConnectionStrings_AbpTenants_TenantId", - column: x => x.TenantId, - principalTable: "AbpTenants", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserClaims", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AbpUserClaims_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserLogins", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ProviderKey = table.Column(type: "nvarchar(196)", maxLength: 196, nullable: false), - ProviderDisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); - table.ForeignKey( - name: "FK_AbpUserLogins_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserOrganizationUnits", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserRoles", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AbpUserRoles_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpUserRoles_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserTokens", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Value = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AbpUserTokens_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "CmsBlogPosts", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - BlogId = table.Column(type: "uniqueidentifier", nullable: false), - Title = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Slug = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ShortDescription = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - Content = table.Column(type: "nvarchar(max)", maxLength: 2147483647, nullable: true), - CoverImageMediaId = table.Column(type: "uniqueidentifier", nullable: true), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - AuthorId = table.Column(type: "uniqueidentifier", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CmsBlogPosts", x => x.Id); - table.ForeignKey( - name: "FK_CmsBlogPosts_CmsUsers_AuthorId", - column: x => x.AuthorId, - principalTable: "CmsUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpEntityPropertyChanges", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityChangeId = table.Column(type: "uniqueidentifier", nullable: false), - NewValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - OriginalValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - PropertyName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - PropertyTypeFullName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", - column: x => x.EntityChangeId, - principalTable: "AbpEntityChanges", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_AuditLogId", - table: "AbpAuditLogActions", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", - table: "AbpAuditLogActions", - columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "UserId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpBlobContainers_TenantId_Name", - table: "AbpBlobContainers", - columns: new[] { "TenantId", "Name" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpBlobs_ContainerId", - table: "AbpBlobs", - column: "ContainerId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpBlobs_TenantId_ContainerId_Name", - table: "AbpBlobs", - columns: new[] { "TenantId", "ContainerId", "Name" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_AuditLogId", - table: "AbpEntityChanges", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", - table: "AbpEntityChanges", - columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityPropertyChanges_EntityChangeId", - table: "AbpEntityPropertyChanges", - column: "EntityChangeId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", - table: "AbpFeatureValues", - columns: new[] { "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId", - table: "AbpLinkUsers", - columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, - unique: true, - filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", - table: "AbpOrganizationUnitRoles", - columns: new[] { "RoleId", "OrganizationUnitId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_Code", - table: "AbpOrganizationUnits", - column: "Code"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_ParentId", - table: "AbpOrganizationUnits", - column: "ParentId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", - table: "AbpPermissionGrants", - columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[TenantId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoleClaims_RoleId", - table: "AbpRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoles_NormalizedName", - table: "AbpRoles", - column: "NormalizedName"); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_Action", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "Action" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_ApplicationName", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "ApplicationName" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_Identity", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "Identity" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_UserId", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "UserId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSettings_Name_ProviderName_ProviderKey", - table: "AbpSettings", - columns: new[] { "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpTenants_Name", - table: "AbpTenants", - column: "Name"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserClaims_UserId", - table: "AbpUserClaims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserLogins_LoginProvider_ProviderKey", - table: "AbpUserLogins", - columns: new[] { "LoginProvider", "ProviderKey" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId", - table: "AbpUserOrganizationUnits", - columns: new[] { "UserId", "OrganizationUnitId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserRoles_RoleId_UserId", - table: "AbpUserRoles", - columns: new[] { "RoleId", "UserId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_Email", - table: "AbpUsers", - column: "Email"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_NormalizedEmail", - table: "AbpUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_NormalizedUserName", - table: "AbpUsers", - column: "NormalizedUserName"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_UserName", - table: "AbpUsers", - column: "UserName"); - - migrationBuilder.CreateIndex( - name: "IX_CmsBlogPosts_AuthorId", - table: "CmsBlogPosts", - column: "AuthorId"); - - migrationBuilder.CreateIndex( - name: "IX_CmsBlogPosts_Slug_BlogId", - table: "CmsBlogPosts", - columns: new[] { "Slug", "BlogId" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsComments_TenantId_EntityType_EntityId", - table: "CmsComments", - columns: new[] { "TenantId", "EntityType", "EntityId" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsComments_TenantId_RepliedCommentId", - table: "CmsComments", - columns: new[] { "TenantId", "RepliedCommentId" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsEntityTags_TenantId_EntityId_TagId", - table: "CmsEntityTags", - columns: new[] { "TenantId", "EntityId", "TagId" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsPages_TenantId_Slug", - table: "CmsPages", - columns: new[] { "TenantId", "Slug" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsRatings_TenantId_EntityType_EntityId_CreatorId", - table: "CmsRatings", - columns: new[] { "TenantId", "EntityType", "EntityId", "CreatorId" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsTags_TenantId_Name", - table: "CmsTags", - columns: new[] { "TenantId", "Name" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsUserReactions_TenantId_CreatorId_EntityType_EntityId_ReactionName", - table: "CmsUserReactions", - columns: new[] { "TenantId", "CreatorId", "EntityType", "EntityId", "ReactionName" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsUserReactions_TenantId_EntityType_EntityId_ReactionName", - table: "CmsUserReactions", - columns: new[] { "TenantId", "EntityType", "EntityId", "ReactionName" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsUsers_TenantId_Email", - table: "CmsUsers", - columns: new[] { "TenantId", "Email" }); - - migrationBuilder.CreateIndex( - name: "IX_CmsUsers_TenantId_UserName", - table: "CmsUsers", - columns: new[] { "TenantId", "UserName" }); - } + migrationBuilder.CreateTable( + name: "AbpAuditLogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + TenantName = table.Column(type: "nvarchar(max)", nullable: true), + ImpersonatorUserId = table.Column(type: "uniqueidentifier", nullable: true), + ImpersonatorTenantId = table.Column(type: "uniqueidentifier", nullable: true), + ExecutionTime = table.Column(type: "datetime2", nullable: false), + ExecutionDuration = table.Column(type: "int", nullable: false), + ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + HttpMethod = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + Url = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Exceptions = table.Column(type: "nvarchar(max)", nullable: true), + Comments = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + HttpStatusCode = table.Column(type: "int", nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpBlobContainers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpBlobContainers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpClaimTypes", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Required = table.Column(type: "bit", nullable: false), + IsStatic = table.Column(type: "bit", nullable: false), + Regex = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + RegexDescription = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Description = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + ValueType = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpFeatureValues", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpLinkUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + SourceUserId = table.Column(type: "uniqueidentifier", nullable: false), + SourceTenantId = table.Column(type: "uniqueidentifier", nullable: true), + TargetUserId = table.Column(type: "uniqueidentifier", nullable: false), + TargetTenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnits", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + Code = table.Column(type: "nvarchar(95)", maxLength: 95, nullable: false), + DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); + table.ForeignKey( + name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", + column: x => x.ParentId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "AbpPermissionGrants", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpRoles", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + IsDefault = table.Column(type: "bit", nullable: false), + IsStatic = table.Column(type: "bit", nullable: false), + IsPublic = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpSecurityLogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + Identity = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + Action = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + TenantName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpSettings", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSettings", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpTenants", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + PasswordHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + SecurityStamp = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + IsExternal = table.Column(type: "bit", nullable: false, defaultValue: false), + PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + IsActive = table.Column(type: "bit", nullable: false), + TwoFactorEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), + LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), + LockoutEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), + AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsBlogFeatures", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + BlogId = table.Column(type: "uniqueidentifier", nullable: false), + FeatureName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + IsEnabled = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsBlogFeatures", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsBlogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Slug = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsBlogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsComments", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Text = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: false), + RepliedCommentId = table.Column(type: "uniqueidentifier", nullable: true), + CreatorId = table.Column(type: "uniqueidentifier", nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsComments", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsEntityTags", + columns: table => new { + TagId = table.Column(type: "uniqueidentifier", nullable: false), + EntityId = table.Column(type: "nvarchar(450)", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsEntityTags", x => new { x.EntityId, x.TagId }); + }); + + migrationBuilder.CreateTable( + name: "CmsMediaDescriptors", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + MimeType = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Size = table.Column(type: "bigint", maxLength: 2147483647, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsMediaDescriptors", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsMenuItems", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + DisplayName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + IsActive = table.Column(type: "bit", nullable: false), + Url = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: false), + Icon = table.Column(type: "nvarchar(max)", nullable: true), + Order = table.Column(type: "int", nullable: false), + Target = table.Column(type: "nvarchar(max)", nullable: true), + ElementId = table.Column(type: "nvarchar(max)", nullable: true), + CssClass = table.Column(type: "nvarchar(max)", nullable: true), + PageId = table.Column(type: "uniqueidentifier", nullable: true), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsMenuItems", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsPages", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Title = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Slug = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Content = table.Column(type: "nvarchar(max)", maxLength: 2147483647, nullable: true), + Script = table.Column(type: "nvarchar(max)", nullable: true), + Style = table.Column(type: "nvarchar(max)", nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsPages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsRatings", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + StarCount = table.Column(type: "smallint", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsRatings", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsTags", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Name = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsTags", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsUserReactions", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + EntityId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ReactionName = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsUserReactions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CmsUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpAuditLogActions", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), + ServiceName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + MethodName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Parameters = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + ExecutionTime = table.Column(type: "datetime2", nullable: false), + ExecutionDuration = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); + table.ForeignKey( + name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpEntityChanges", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ChangeTime = table.Column(type: "datetime2", nullable: false), + ChangeType = table.Column(type: "tinyint", nullable: false), + EntityTenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + EntityTypeFullName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpBlobs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ContainerId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Content = table.Column(type: "varbinary(max)", maxLength: 2147483647, nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpBlobs", x => x.Id); + table.ForeignKey( + name: "FK_AbpBlobs_AbpBlobContainers_ContainerId", + column: x => x.ContainerId, + principalTable: "AbpBlobContainers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnitRoles", + columns: table => new { + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpRoleClaims", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpRoleClaims_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpTenantConnectionStrings", + columns: table => new { + TenantId = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Value = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenantConnectionStrings", x => new { x.TenantId, x.Name }); + table.ForeignKey( + name: "FK_AbpTenantConnectionStrings_AbpTenants_TenantId", + column: x => x.TenantId, + principalTable: "AbpTenants", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserClaims", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpUserClaims_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserLogins", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ProviderKey = table.Column(type: "nvarchar(196)", maxLength: 196, nullable: false), + ProviderDisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); + table.ForeignKey( + name: "FK_AbpUserLogins_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserOrganizationUnits", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserRoles", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserTokens", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Value = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AbpUserTokens_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CmsBlogPosts", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + BlogId = table.Column(type: "uniqueidentifier", nullable: false), + Title = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Slug = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ShortDescription = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Content = table.Column(type: "nvarchar(max)", maxLength: 2147483647, nullable: true), + CoverImageMediaId = table.Column(type: "uniqueidentifier", nullable: true), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + AuthorId = table.Column(type: "uniqueidentifier", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CmsBlogPosts", x => x.Id); + table.ForeignKey( + name: "FK_CmsBlogPosts_CmsUsers_AuthorId", + column: x => x.AuthorId, + principalTable: "CmsUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpEntityPropertyChanges", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityChangeId = table.Column(type: "uniqueidentifier", nullable: false), + NewValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + OriginalValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + PropertyName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + PropertyTypeFullName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", + column: x => x.EntityChangeId, + principalTable: "AbpEntityChanges", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_AuditLogId", + table: "AbpAuditLogActions", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", + table: "AbpAuditLogActions", + columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "UserId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpBlobContainers_TenantId_Name", + table: "AbpBlobContainers", + columns: new[] { "TenantId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpBlobs_ContainerId", + table: "AbpBlobs", + column: "ContainerId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpBlobs_TenantId_ContainerId_Name", + table: "AbpBlobs", + columns: new[] { "TenantId", "ContainerId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_AuditLogId", + table: "AbpEntityChanges", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", + table: "AbpEntityChanges", + columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityPropertyChanges_EntityChangeId", + table: "AbpEntityPropertyChanges", + column: "EntityChangeId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", + table: "AbpFeatureValues", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId", + table: "AbpLinkUsers", + columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, + unique: true, + filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", + table: "AbpOrganizationUnitRoles", + columns: new[] { "RoleId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_Code", + table: "AbpOrganizationUnits", + column: "Code"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_ParentId", + table: "AbpOrganizationUnits", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", + table: "AbpPermissionGrants", + columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[TenantId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoleClaims_RoleId", + table: "AbpRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoles_NormalizedName", + table: "AbpRoles", + column: "NormalizedName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Action", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Action" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_ApplicationName", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "ApplicationName" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Identity", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Identity" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_UserId", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSettings_Name_ProviderName_ProviderKey", + table: "AbpSettings", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpTenants_Name", + table: "AbpTenants", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserClaims_UserId", + table: "AbpUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserLogins_LoginProvider_ProviderKey", + table: "AbpUserLogins", + columns: new[] { "LoginProvider", "ProviderKey" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId", + table: "AbpUserOrganizationUnits", + columns: new[] { "UserId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserRoles_RoleId_UserId", + table: "AbpUserRoles", + columns: new[] { "RoleId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_Email", + table: "AbpUsers", + column: "Email"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedEmail", + table: "AbpUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedUserName", + table: "AbpUsers", + column: "NormalizedUserName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_UserName", + table: "AbpUsers", + column: "UserName"); + + migrationBuilder.CreateIndex( + name: "IX_CmsBlogPosts_AuthorId", + table: "CmsBlogPosts", + column: "AuthorId"); + + migrationBuilder.CreateIndex( + name: "IX_CmsBlogPosts_Slug_BlogId", + table: "CmsBlogPosts", + columns: new[] { "Slug", "BlogId" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsComments_TenantId_EntityType_EntityId", + table: "CmsComments", + columns: new[] { "TenantId", "EntityType", "EntityId" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsComments_TenantId_RepliedCommentId", + table: "CmsComments", + columns: new[] { "TenantId", "RepliedCommentId" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsEntityTags_TenantId_EntityId_TagId", + table: "CmsEntityTags", + columns: new[] { "TenantId", "EntityId", "TagId" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsPages_TenantId_Slug", + table: "CmsPages", + columns: new[] { "TenantId", "Slug" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsRatings_TenantId_EntityType_EntityId_CreatorId", + table: "CmsRatings", + columns: new[] { "TenantId", "EntityType", "EntityId", "CreatorId" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsTags_TenantId_Name", + table: "CmsTags", + columns: new[] { "TenantId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsUserReactions_TenantId_CreatorId_EntityType_EntityId_ReactionName", + table: "CmsUserReactions", + columns: new[] { "TenantId", "CreatorId", "EntityType", "EntityId", "ReactionName" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsUserReactions_TenantId_EntityType_EntityId_ReactionName", + table: "CmsUserReactions", + columns: new[] { "TenantId", "EntityType", "EntityId", "ReactionName" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsUsers_TenantId_Email", + table: "CmsUsers", + columns: new[] { "TenantId", "Email" }); + + migrationBuilder.CreateIndex( + name: "IX_CmsUsers_TenantId_UserName", + table: "CmsUsers", + columns: new[] { "TenantId", "UserName" }); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AbpAuditLogActions"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpAuditLogActions"); - migrationBuilder.DropTable( - name: "AbpBlobs"); + migrationBuilder.DropTable( + name: "AbpBlobs"); - migrationBuilder.DropTable( - name: "AbpClaimTypes"); + migrationBuilder.DropTable( + name: "AbpClaimTypes"); - migrationBuilder.DropTable( - name: "AbpEntityPropertyChanges"); + migrationBuilder.DropTable( + name: "AbpEntityPropertyChanges"); - migrationBuilder.DropTable( - name: "AbpFeatureValues"); + migrationBuilder.DropTable( + name: "AbpFeatureValues"); - migrationBuilder.DropTable( - name: "AbpLinkUsers"); + migrationBuilder.DropTable( + name: "AbpLinkUsers"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnitRoles"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnitRoles"); - migrationBuilder.DropTable( - name: "AbpPermissionGrants"); + migrationBuilder.DropTable( + name: "AbpPermissionGrants"); - migrationBuilder.DropTable( - name: "AbpRoleClaims"); + migrationBuilder.DropTable( + name: "AbpRoleClaims"); - migrationBuilder.DropTable( - name: "AbpSecurityLogs"); + migrationBuilder.DropTable( + name: "AbpSecurityLogs"); - migrationBuilder.DropTable( - name: "AbpSettings"); + migrationBuilder.DropTable( + name: "AbpSettings"); - migrationBuilder.DropTable( - name: "AbpTenantConnectionStrings"); + migrationBuilder.DropTable( + name: "AbpTenantConnectionStrings"); - migrationBuilder.DropTable( - name: "AbpUserClaims"); + migrationBuilder.DropTable( + name: "AbpUserClaims"); - migrationBuilder.DropTable( - name: "AbpUserLogins"); + migrationBuilder.DropTable( + name: "AbpUserLogins"); - migrationBuilder.DropTable( - name: "AbpUserOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpUserOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpUserRoles"); + migrationBuilder.DropTable( + name: "AbpUserRoles"); - migrationBuilder.DropTable( - name: "AbpUserTokens"); + migrationBuilder.DropTable( + name: "AbpUserTokens"); - migrationBuilder.DropTable( - name: "CmsBlogFeatures"); + migrationBuilder.DropTable( + name: "CmsBlogFeatures"); - migrationBuilder.DropTable( - name: "CmsBlogPosts"); + migrationBuilder.DropTable( + name: "CmsBlogPosts"); - migrationBuilder.DropTable( - name: "CmsBlogs"); + migrationBuilder.DropTable( + name: "CmsBlogs"); - migrationBuilder.DropTable( - name: "CmsComments"); + migrationBuilder.DropTable( + name: "CmsComments"); - migrationBuilder.DropTable( - name: "CmsEntityTags"); + migrationBuilder.DropTable( + name: "CmsEntityTags"); - migrationBuilder.DropTable( - name: "CmsMediaDescriptors"); + migrationBuilder.DropTable( + name: "CmsMediaDescriptors"); - migrationBuilder.DropTable( - name: "CmsMenuItems"); + migrationBuilder.DropTable( + name: "CmsMenuItems"); - migrationBuilder.DropTable( - name: "CmsPages"); + migrationBuilder.DropTable( + name: "CmsPages"); - migrationBuilder.DropTable( - name: "CmsRatings"); + migrationBuilder.DropTable( + name: "CmsRatings"); - migrationBuilder.DropTable( - name: "CmsTags"); + migrationBuilder.DropTable( + name: "CmsTags"); - migrationBuilder.DropTable( - name: "CmsUserReactions"); + migrationBuilder.DropTable( + name: "CmsUserReactions"); - migrationBuilder.DropTable( - name: "AbpBlobContainers"); + migrationBuilder.DropTable( + name: "AbpBlobContainers"); - migrationBuilder.DropTable( - name: "AbpEntityChanges"); + migrationBuilder.DropTable( + name: "AbpEntityChanges"); - migrationBuilder.DropTable( - name: "AbpTenants"); + migrationBuilder.DropTable( + name: "AbpTenants"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpRoles"); + migrationBuilder.DropTable( + name: "AbpRoles"); - migrationBuilder.DropTable( - name: "AbpUsers"); + migrationBuilder.DropTable( + name: "AbpUsers"); - migrationBuilder.DropTable( - name: "CmsUsers"); + migrationBuilder.DropTable( + name: "CmsUsers"); - migrationBuilder.DropTable( - name: "AbpAuditLogs"); - } + migrationBuilder.DropTable( + name: "AbpAuditLogs"); } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml.cs index 1b9f50993f..e35f15635c 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml.cs @@ -1,9 +1,8 @@ using Microsoft.AspNetCore.Mvc.RazorPages; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public class IndexModel : PageModel { - public class IndexModel : PageModel - { - } } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Program.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Program.cs index d3ec2f10e4..0c1ab52b43 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Program.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Program.cs @@ -5,44 +5,43 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class Program { - public class Program + public static int Main(string[] args) { - public static int Main(string[] args) - { - Log.Logger = new LoggerConfiguration() - .MinimumLevel.Debug() - .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - .Enrich.FromLogContext() - .WriteTo.Console() - .WriteTo.File("Logs/logs.txt") - .CreateLogger(); + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .MinimumLevel.Override("Microsoft", LogEventLevel.Information) + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.File("Logs/logs.txt") + .CreateLogger(); - try - { - Log.Information("Starting web host."); - CreateHostBuilder(args).Build().Run(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Host terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } + try + { + Log.Information("Starting web host."); + CreateHostBuilder(args).Build().Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Startup.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Startup.cs index 522c383586..7eebea28f0 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Startup.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Startup.cs @@ -3,18 +3,17 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogDto.cs index 42383d8b83..1b72979b7f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogDto.cs @@ -2,14 +2,13 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Entities; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[Serializable] +public class BlogDto : EntityDto, IHasConcurrencyStamp { - [Serializable] - public class BlogDto : EntityDto, IHasConcurrencyStamp - { - public string Name { get; set; } + public string Name { get; set; } - public string Slug { get; set; } - public string ConcurrencyStamp { get; set; } - } + public string Slug { get; set; } + public string ConcurrencyStamp { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureInputDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureInputDto.cs index 91437d5532..7a02c69c7d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureInputDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureInputDto.cs @@ -1,14 +1,13 @@ using System; using System.ComponentModel.DataAnnotations; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[Serializable] +public class BlogFeatureInputDto { - [Serializable] - public class BlogFeatureInputDto - { - [Required] - public string FeatureName { get; set; } - - public bool IsEnabled { get; set; } - } + [Required] + public string FeatureName { get; set; } + + public bool IsEnabled { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogGetListInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogGetListInput.cs index ddca65f8c0..348719fd4d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogGetListInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogGetListInput.cs @@ -1,11 +1,10 @@ using System; using Volo.Abp.Application.Dtos; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[Serializable] +public class BlogGetListInput : PagedAndSortedResultRequestDto { - [Serializable] - public class BlogGetListInput : PagedAndSortedResultRequestDto - { - public string Filter { get; set; } - } + public string Filter { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostDto.cs index 02e1c5810d..6ea2fddd90 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostDto.cs @@ -3,27 +3,26 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.Auditing; using Volo.Abp.Domain.Entities; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[Serializable] +public class BlogPostDto : EntityDto, IHasCreationTime, IHasModificationTime, IHasConcurrencyStamp { - [Serializable] - public class BlogPostDto : EntityDto, IHasCreationTime, IHasModificationTime, IHasConcurrencyStamp - { - public Guid BlogId { get; set; } + public Guid BlogId { get; set; } + + public string Title { get; set; } + + public string Slug { get; set; } - public string Title { get; set; } + public string ShortDescription { get; set; } - public string Slug { get; set; } - - public string ShortDescription { get; set; } - - public string Content { get; set; } + public string Content { get; set; } - public Guid? CoverImageMediaId { get; set; } + public Guid? CoverImageMediaId { get; set; } - public DateTime CreationTime { get; set; } + public DateTime CreationTime { get; set; } - public DateTime? LastModificationTime { get; set; } + public DateTime? LastModificationTime { get; set; } - public string ConcurrencyStamp { get; set; } - } + public string ConcurrencyStamp { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostGetListInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostGetListInput.cs index 96e4d2dfe8..e8fa497e15 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostGetListInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostGetListInput.cs @@ -1,12 +1,11 @@ using System; using Volo.Abp.Application.Dtos; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +public class BlogPostGetListInput : PagedAndSortedResultRequestDto { - public class BlogPostGetListInput : PagedAndSortedResultRequestDto - { - public string Filter { get; set; } + public string Filter { get; set; } - public Guid? BlogId { get; set; } - } -} \ No newline at end of file + public Guid? BlogId { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostListDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostListDto.cs index d3e3b5126c..0953bf2c00 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostListDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostListDto.cs @@ -2,27 +2,26 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.Auditing; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[Serializable] +public class BlogPostListDto : EntityDto, IHasCreationTime, IHasModificationTime { - [Serializable] - public class BlogPostListDto : EntityDto, IHasCreationTime, IHasModificationTime - { - public Guid BlogId { get; set; } + public Guid BlogId { get; set; } + + public string BlogName { get; set; } + + public string Title { get; set; } - public string BlogName { get; set; } + public string Slug { get; set; } - public string Title { get; set; } + public string ShortDescription { get; set; } - public string Slug { get; set; } - - public string ShortDescription { get; set; } - - public string Content { get; set; } + public string Content { get; set; } - public Guid? CoverImageMediaId { get; set; } + public Guid? CoverImageMediaId { get; set; } - public DateTime CreationTime { get; set; } + public DateTime CreationTime { get; set; } - public DateTime? LastModificationTime { get; set; } - } -} \ No newline at end of file + public DateTime? LastModificationTime { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogDto.cs index 985567b48e..317846e511 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogDto.cs @@ -2,16 +2,15 @@ using Volo.Abp.Validation; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +public class CreateBlogDto { - public class CreateBlogDto - { - [Required] - [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxNameLength))] - public string Name { get; set; } + [Required] + [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxNameLength))] + public string Name { get; set; } - [Required] - [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxSlugLength))] - public string Slug { get; set; } - } -} \ No newline at end of file + [Required] + [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxSlugLength))] + public string Slug { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogPostDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogPostDto.cs index 1cae41512c..115239f47c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogPostDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogPostDto.cs @@ -3,28 +3,27 @@ using System.ComponentModel.DataAnnotations; using Volo.Abp.Validation; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[Serializable] +public class CreateBlogPostDto { - [Serializable] - public class CreateBlogPostDto - { - [Required] - public Guid BlogId { get; set; } + [Required] + public Guid BlogId { get; set; } + + [Required] + [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxTitleLength))] + public string Title { get; set; } - [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; } - [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; } - [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxShortDescriptionLength))] - public string ShortDescription { get; set; } - - [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))] - public string Content { get; set; } + [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))] + public string Content { get; set; } - public Guid? CoverImageMediaId { get; set; } - } + public Guid? CoverImageMediaId { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogAdminAppService.cs index 6d82e6117c..647c2bde15 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogAdminAppService.cs @@ -1,9 +1,8 @@ using System; using Volo.Abp.Application.Services; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +public interface IBlogAdminAppService : ICrudAppService { - public interface IBlogAdminAppService : ICrudAppService - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogFeatureAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogFeatureAdminAppService.cs index b6be3b3a47..d9f33f9942 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogFeatureAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogFeatureAdminAppService.cs @@ -6,12 +6,11 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +public interface IBlogFeatureAdminAppService : IApplicationService { - public interface IBlogFeatureAdminAppService : IApplicationService - { - Task SetAsync(Guid blogId, BlogFeatureInputDto dto); + Task SetAsync(Guid blogId, BlogFeatureInputDto dto); - Task> GetListAsync(Guid blogId); - } + Task> GetListAsync(Guid blogId); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogPostAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogPostAdminAppService.cs index 32cfa36f32..314b7a1def 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogPostAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogPostAdminAppService.cs @@ -1,16 +1,15 @@ using System; using Volo.Abp.Application.Services; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +public interface IBlogPostAdminAppService + : ICrudAppService< + BlogPostDto, + BlogPostListDto, + Guid, + BlogPostGetListInput, + CreateBlogPostDto, + UpdateBlogPostDto> { - public interface IBlogPostAdminAppService - : ICrudAppService< - BlogPostDto, - BlogPostListDto, - Guid, - BlogPostGetListInput, - CreateBlogPostDto, - UpdateBlogPostDto> - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogDto.cs index da4601503c..4c46ace0c6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogDto.cs @@ -3,18 +3,17 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Validation; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +public class UpdateBlogDto : IHasConcurrencyStamp { - public class UpdateBlogDto : IHasConcurrencyStamp - { - [Required] - [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxNameLength))] - public string Name { get; set; } + [Required] + [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxNameLength))] + public string Name { get; set; } - [Required] - [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxSlugLength))] - public string Slug { get; set; } + [Required] + [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxSlugLength))] + public string Slug { get; set; } - public string ConcurrencyStamp { get; set; } - } -} \ No newline at end of file + public string ConcurrencyStamp { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogPostDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogPostDto.cs index aadf648a25..b19e3ec0e0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogPostDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogPostDto.cs @@ -4,27 +4,26 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Validation; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[Serializable] +public class UpdateBlogPostDto : IHasConcurrencyStamp { - [Serializable] - public class UpdateBlogPostDto : IHasConcurrencyStamp - { - [Required] - [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxTitleLength))] - public string Title { get; set; } + [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; } - [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; } - [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxShortDescriptionLength))] - public string ShortDescription { get; set; } - - [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))] - public string Content { get; set; } + [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))] + public string Content { get; set; } - public Guid? CoverImageMediaId { get; set; } + public Guid? CoverImageMediaId { get; set; } - public string ConcurrencyStamp { get; set; } - } + public string ConcurrencyStamp { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/CmsKitAdminApplicationContractsModule.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/CmsKitAdminApplicationContractsModule.cs index 13c053c756..89ffdec62a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/CmsKitAdminApplicationContractsModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/CmsKitAdminApplicationContractsModule.cs @@ -1,12 +1,11 @@ using Volo.Abp.Modularity; -namespace Volo.CmsKit.Admin +namespace Volo.CmsKit.Admin; + +[DependsOn( + typeof(CmsKitCommonApplicationContractsModule) + )] +public class CmsKitAdminApplicationContractsModule : AbpModule { - [DependsOn( - typeof(CmsKitCommonApplicationContractsModule) - )] - public class CmsKitAdminApplicationContractsModule : AbpModule - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/CmsKitAdminRemoteServiceConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/CmsKitAdminRemoteServiceConsts.cs index 53dfe77fbb..12948b25f7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/CmsKitAdminRemoteServiceConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/CmsKitAdminRemoteServiceConsts.cs @@ -1,9 +1,8 @@ -namespace Volo.CmsKit.Admin +namespace Volo.CmsKit.Admin; + +public class CmsKitAdminRemoteServiceConsts { - public class CmsKitAdminRemoteServiceConsts - { - public const string RemoteServiceName = "CmsKitAdmin"; + public const string RemoteServiceName = "CmsKitAdmin"; - public const string ModuleName = "cms-kit-admin"; - } + public const string ModuleName = "cms-kit-admin"; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CmsUserDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CmsUserDto.cs index 2fc4109047..1c4f7b23bd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CmsUserDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CmsUserDto.cs @@ -1,16 +1,15 @@ using System; -namespace Volo.CmsKit.Admin.Comments +namespace Volo.CmsKit.Admin.Comments; + +[Serializable] +public class CmsUserDto { - [Serializable] - public class CmsUserDto - { - public Guid Id { get; set; } + public Guid Id { get; set; } - public string UserName { get; set; } + public string UserName { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public string Surname { get; set; } - } -} \ No newline at end of file + public string Surname { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentDto.cs index da09d88b8b..6b147d76aa 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentDto.cs @@ -1,22 +1,21 @@ using System; -namespace Volo.CmsKit.Admin.Comments +namespace Volo.CmsKit.Admin.Comments; + +[Serializable] +public class CommentDto { - [Serializable] - public class CommentDto - { - public Guid Id { get; set; } + public Guid Id { get; set; } - public string EntityType { get; set; } + public string EntityType { get; set; } - public string EntityId { get; set; } + public string EntityId { get; set; } - public string Text { get; set; } + public string Text { get; set; } - public Guid? RepliedCommentId { get; set; } + public Guid? RepliedCommentId { get; set; } - public Guid CreatorId { get; set; } + public Guid CreatorId { get; set; } - public DateTime CreationTime { get; set; } - } -} \ No newline at end of file + public DateTime CreationTime { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs index f4ffe68d42..399674e520 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs @@ -1,21 +1,20 @@ using System; using Volo.Abp.Application.Dtos; -namespace Volo.CmsKit.Admin.Comments +namespace Volo.CmsKit.Admin.Comments; + +[Serializable] +public class CommentGetListInput : PagedAndSortedResultRequestDto { - [Serializable] - public class CommentGetListInput : PagedAndSortedResultRequestDto - { - public string EntityType { get; set; } + public string EntityType { get; set; } + + public string Text { get; set; } - public string Text { get; set; } + public Guid? RepliedCommentId { get; set; } - public Guid? RepliedCommentId { get; set; } + public string Author { get; set; } - public string Author { get; set; } + public DateTime? CreationStartDate { get; set; } - public DateTime? CreationStartDate { get; set; } - - public DateTime? CreationEndDate { get; set; } - } -} \ No newline at end of file + public DateTime? CreationEndDate { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithAuthorDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithAuthorDto.cs index d60b836d89..18eaa9a4c6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithAuthorDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithAuthorDto.cs @@ -2,25 +2,24 @@ using System.Collections.Generic; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Admin.Comments +namespace Volo.CmsKit.Admin.Comments; + +[Serializable] +public class CommentWithAuthorDto { - [Serializable] - public class CommentWithAuthorDto - { - public Guid Id { get; set; } + public Guid Id { get; set; } + + public string EntityType { get; set; } - public string EntityType { get; set; } + public string EntityId { get; set; } - public string EntityId { get; set; } + public string Text { get; set; } - public string Text { get; set; } + public Guid? RepliedCommentId { get; set; } - public Guid? RepliedCommentId { get; set; } + public Guid CreatorId { get; set; } - public Guid CreatorId { get; set; } + public DateTime CreationTime { get; set; } - public DateTime CreationTime { get; set; } - - public CmsUserDto Author { get; set; } - } -} \ No newline at end of file + public CmsUserDto Author { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs index 2bddc35a25..5ea8d64d1d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs @@ -3,14 +3,13 @@ using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; -namespace Volo.CmsKit.Admin.Comments +namespace Volo.CmsKit.Admin.Comments; + +public interface ICommentAdminAppService : IApplicationService { - public interface ICommentAdminAppService : IApplicationService - { - Task> GetListAsync(CommentGetListInput input); + Task> GetListAsync(CommentGetListInput input); - Task GetAsync(Guid id); + Task GetAsync(Guid id); - Task DeleteAsync(Guid id); - } -} \ No newline at end of file + Task DeleteAsync(Guid id); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/CreateMediaInputWithStream.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/CreateMediaInputWithStream.cs index a8a13b2ed2..9cb05154db 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/CreateMediaInputWithStream.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/CreateMediaInputWithStream.cs @@ -3,14 +3,13 @@ using Volo.Abp.Content; using Volo.Abp.Validation; using Volo.CmsKit.MediaDescriptors; -namespace Volo.CmsKit.Admin.MediaDescriptors +namespace Volo.CmsKit.Admin.MediaDescriptors; + +public class CreateMediaInputWithStream { - public class CreateMediaInputWithStream - { - [Required] - [DynamicStringLength(typeof(MediaDescriptorConsts), nameof(MediaDescriptorConsts.MaxNameLength))] - public string Name { get; set; } + [Required] + [DynamicStringLength(typeof(MediaDescriptorConsts), nameof(MediaDescriptorConsts.MaxNameLength))] + public string Name { get; set; } - public IRemoteStreamContent File { get; set; } - } -} \ No newline at end of file + public IRemoteStreamContent File { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/IMediaDescriptorAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/IMediaDescriptorAdminAppService.cs index 83cd14e90c..c9b25009ea 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/IMediaDescriptorAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/IMediaDescriptorAdminAppService.cs @@ -2,12 +2,11 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; -namespace Volo.CmsKit.Admin.MediaDescriptors +namespace Volo.CmsKit.Admin.MediaDescriptors; + +public interface IMediaDescriptorAdminAppService : IApplicationService { - public interface IMediaDescriptorAdminAppService : IApplicationService - { - Task CreateAsync(string entityType, CreateMediaInputWithStream inputStream); - - Task DeleteAsync(Guid id); - } -} \ No newline at end of file + Task CreateAsync(string entityType, CreateMediaInputWithStream inputStream); + + Task DeleteAsync(Guid id); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorDto.cs index d6ee63c523..c34358ef9d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorDto.cs @@ -1,15 +1,14 @@ using System; using Volo.Abp.Application.Dtos; -namespace Volo.CmsKit.Admin.MediaDescriptors +namespace Volo.CmsKit.Admin.MediaDescriptors; + +[Serializable] +public class MediaDescriptorDto : EntityDto { - [Serializable] - public class MediaDescriptorDto : EntityDto - { - public string Name { get; set; } - - public string MimeType { get; set; } - - public int Size { get; set; } - } -} \ No newline at end of file + public string Name { get; set; } + + public string MimeType { get; set; } + + public int Size { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/IMenuItemAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/IMenuItemAdminAppService.cs index e36d4a5caf..74aac7b814 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/IMenuItemAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/IMenuItemAdminAppService.cs @@ -4,22 +4,21 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.CmsKit.Menus; -namespace Volo.CmsKit.Admin.Menus +namespace Volo.CmsKit.Admin.Menus; + +public interface IMenuItemAdminAppService : IApplicationService { - public interface IMenuItemAdminAppService : IApplicationService - { - Task> GetListAsync(); + Task> GetListAsync(); + + Task GetAsync(Guid id); + + Task CreateAsync(MenuItemCreateInput input); - Task GetAsync(Guid id); - - Task CreateAsync(MenuItemCreateInput input); + Task UpdateAsync(Guid id, MenuItemUpdateInput input); - Task UpdateAsync(Guid id, MenuItemUpdateInput input); + Task DeleteAsync(Guid id); - Task DeleteAsync(Guid id); + Task MoveMenuItemAsync(Guid id, MenuItemMoveInput input); - Task MoveMenuItemAsync(Guid id, MenuItemMoveInput input); - - Task> GetPageLookupAsync(PageLookupInputDto input); - } + Task> GetPageLookupAsync(PageLookupInputDto input); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuCreateInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuCreateInput.cs index 80cb3ada61..06323ebb42 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuCreateInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuCreateInput.cs @@ -4,11 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Volo.CmsKit.Admin.Menus +namespace Volo.CmsKit.Admin.Menus; + +[Serializable] +public class MenuCreateInput { - [Serializable] - public class MenuCreateInput - { - public string Name { get; set; } - } + public string Name { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemCreateInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemCreateInput.cs index c57b689c95..cb2f3129ce 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemCreateInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemCreateInput.cs @@ -1,30 +1,29 @@ using System; using System.ComponentModel.DataAnnotations; -namespace Volo.CmsKit.Admin.Menus +namespace Volo.CmsKit.Admin.Menus; + +[Serializable] +public class MenuItemCreateInput { - [Serializable] - public class MenuItemCreateInput - { - public Guid? ParentId { get; set; } + public Guid? ParentId { get; set; } - [Required] - public string DisplayName { get; set; } + [Required] + public string DisplayName { get; set; } - public bool IsActive { get; set; } + public bool IsActive { get; set; } - public string Url { get; set; } + public string Url { get; set; } - public string Icon { get; set; } + public string Icon { get; set; } - public int Order { get; set; } + public int Order { get; set; } - public string Target { get; set; } + public string Target { get; set; } - public string ElementId { get; set; } + public string ElementId { get; set; } - public string CssClass { get; set; } + public string CssClass { get; set; } - public Guid? PageId { get; set; } - } + public Guid? PageId { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemMoveInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemMoveInput.cs index 4d2d31d70c..9b9c4cbc15 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemMoveInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemMoveInput.cs @@ -4,13 +4,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Volo.CmsKit.Admin.Menus +namespace Volo.CmsKit.Admin.Menus; + +[Serializable] +public class MenuItemMoveInput { - [Serializable] - public class MenuItemMoveInput - { - public Guid? NewParentId { get; set; } + public Guid? NewParentId { get; set; } - public int Position { get; set; } - } + public int Position { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemUpdateInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemUpdateInput.cs index d9a7b17a92..5d9c0e9c02 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemUpdateInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuItemUpdateInput.cs @@ -2,28 +2,27 @@ using System.ComponentModel.DataAnnotations; using Volo.Abp.Domain.Entities; -namespace Volo.CmsKit.Admin.Menus +namespace Volo.CmsKit.Admin.Menus; + +[Serializable] +public class MenuItemUpdateInput : IHasConcurrencyStamp { - [Serializable] - public class MenuItemUpdateInput : IHasConcurrencyStamp - { - [Required] - public string DisplayName { get; set; } + [Required] + public string DisplayName { get; set; } - public bool IsActive { get; set; } + public bool IsActive { get; set; } - public string Url { get; set; } + public string Url { get; set; } - public string Icon { get; set; } + public string Icon { get; set; } - public string Target { get; set; } + public string Target { get; set; } - public string ElementId { get; set; } + public string ElementId { get; set; } - public string CssClass { get; set; } + public string CssClass { get; set; } - public Guid? PageId { get; set; } + public Guid? PageId { get; set; } - public string ConcurrencyStamp { get; set; } - } -} \ No newline at end of file + public string ConcurrencyStamp { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuUpdateInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuUpdateInput.cs index cd41ca427a..defa2558fe 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuUpdateInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/MenuUpdateInput.cs @@ -4,11 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Volo.CmsKit.Admin.Menus +namespace Volo.CmsKit.Admin.Menus; + +[Serializable] +public class MenuUpdateInput { - [Serializable] - public class MenuUpdateInput - { - public string Name { get; set; } - } + public string Name { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/PageLookupDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/PageLookupDto.cs index ee9fb17f2b..ee9992bee1 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/PageLookupDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/PageLookupDto.cs @@ -1,12 +1,11 @@ using System; using Volo.Abp.Application.Dtos; -namespace Volo.CmsKit.Admin.Menus +namespace Volo.CmsKit.Admin.Menus; + +public class PageLookupDto : EntityDto { - public class PageLookupDto : EntityDto - { - public string Title { get; set; } + public string Title { get; set; } - public string Slug { get; set; } - } -} \ No newline at end of file + public string Slug { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/PageLookupInputDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/PageLookupInputDto.cs index 19523ac14e..12fc847917 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/PageLookupInputDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/PageLookupInputDto.cs @@ -1,11 +1,10 @@ using System; using Volo.Abp.Application.Dtos; -namespace Volo.CmsKit.Admin.Menus +namespace Volo.CmsKit.Admin.Menus; + +[Serializable] +public class PageLookupInputDto : PagedAndSortedResultRequestDto { - [Serializable] - public class PageLookupInputDto: PagedAndSortedResultRequestDto - { - public string Filter { get; set; } - } -} \ No newline at end of file + public string Filter { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/UpdateMainMenuInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/UpdateMainMenuInput.cs index 3fbc3de080..d5cf9566ad 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/UpdateMainMenuInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Menus/UpdateMainMenuInput.cs @@ -1,10 +1,9 @@ using System; -namespace Volo.CmsKit.Admin.Menus +namespace Volo.CmsKit.Admin.Menus; + +[Serializable] +public class UpdateMainMenuInput { - [Serializable] - public class UpdateMainMenuInput - { - public bool IsMainMenu { get; set; } - } -} \ No newline at end of file + public bool IsMainMenu { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CreatePageInputDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CreatePageInputDto.cs index fae53e429a..1ee4550941 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CreatePageInputDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CreatePageInputDto.cs @@ -3,26 +3,25 @@ using System.ComponentModel.DataAnnotations; using Volo.Abp.Validation; using Volo.CmsKit.Pages; -namespace Volo.CmsKit.Admin.Pages +namespace Volo.CmsKit.Admin.Pages; + +[Serializable] +public class CreatePageInputDto { - [Serializable] - public class CreatePageInputDto - { - [Required] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))] - public string Title { get; set; } + [Required] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))] + public string Title { get; set; } + + [Required] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] + public string Slug { get; set; } - [Required] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] - public string Slug { get; set; } - - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxContentLength))] - public string Content { get; set; } + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxContentLength))] + public string Content { get; set; } - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxScriptLength))] - public string Script { get; set; } + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxScriptLength))] + public string Script { get; set; } - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxStyleLength))] - public string Style { get; set; } - } -} \ No newline at end of file + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxStyleLength))] + public string Style { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/GetPagesInputDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/GetPagesInputDto.cs index 132921ac0c..7275db931e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/GetPagesInputDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/GetPagesInputDto.cs @@ -1,11 +1,10 @@ using System; using Volo.Abp.Application.Dtos; -namespace Volo.CmsKit.Admin.Pages +namespace Volo.CmsKit.Admin.Pages; + +[Serializable] +public class GetPagesInputDto : PagedAndSortedResultRequestDto { - [Serializable] - public class GetPagesInputDto : PagedAndSortedResultRequestDto - { - public string Filter { get; set; } - } -} \ No newline at end of file + public string Filter { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/IPageAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/IPageAdminAppService.cs index f01dc07c5c..ec7cb919f9 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/IPageAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/IPageAdminAppService.cs @@ -4,9 +4,8 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.Content; -namespace Volo.CmsKit.Admin.Pages +namespace Volo.CmsKit.Admin.Pages; + +public interface IPageAdminAppService : ICrudAppService { - public interface IPageAdminAppService : ICrudAppService - { - } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/PageDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/PageDto.cs index 8ffbc4791c..20a76bf43e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/PageDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/PageDto.cs @@ -2,21 +2,20 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Entities; -namespace Volo.CmsKit.Admin.Pages +namespace Volo.CmsKit.Admin.Pages; + +[Serializable] +public class PageDto : AuditedEntityDto, IHasConcurrencyStamp { - [Serializable] - public class PageDto : AuditedEntityDto, IHasConcurrencyStamp - { - public string Title { get; set; } + public string Title { get; set; } + + public string Slug { get; set; } - public string Slug { get; set; } - - public string Content { get; set; } + public string Content { get; set; } - public string Script { get; set; } + public string Script { get; set; } - public string Style { get; set; } + public string Style { get; set; } - public string ConcurrencyStamp { get; set; } - } -} \ No newline at end of file + public string ConcurrencyStamp { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/UpdatePageInputDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/UpdatePageInputDto.cs index 615485e418..3cf2e53fcb 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/UpdatePageInputDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/UpdatePageInputDto.cs @@ -4,28 +4,27 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Validation; using Volo.CmsKit.Pages; -namespace Volo.CmsKit.Admin.Pages +namespace Volo.CmsKit.Admin.Pages; + +[Serializable] +public class UpdatePageInputDto : IHasConcurrencyStamp { - [Serializable] - public class UpdatePageInputDto : IHasConcurrencyStamp - { - [Required] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))] - public string Title { get; set; } + [Required] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))] + public string Title { get; set; } - [Required] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] - public string Slug { get; set; } + [Required] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] + public string Slug { get; set; } - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxContentLength))] - public string Content { get; set; } + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxContentLength))] + public string Content { get; set; } - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxScriptLength))] - public string Script { get; set; } + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxScriptLength))] + public string Script { get; set; } - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxStyleLength))] - public string Style { get; set; } + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxStyleLength))] + public string Style { get; set; } - public string ConcurrencyStamp { get; set; } - } -} \ No newline at end of file + public string ConcurrencyStamp { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagCreateDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagCreateDto.cs index da4b52fe49..69f3ebe473 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagCreateDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagCreateDto.cs @@ -1,18 +1,17 @@ using System; using System.ComponentModel.DataAnnotations; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +[Serializable] +public class EntityTagCreateDto { - [Serializable] - public class EntityTagCreateDto - { - [Required] - public string TagName { get; set; } + [Required] + public string TagName { get; set; } - [Required] - public string EntityType { get; set; } + [Required] + public string EntityType { get; set; } - [Required] - public string EntityId { get; set; } - } + [Required] + public string EntityId { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagRemoveDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagRemoveDto.cs index 67e54be54d..8254022af7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagRemoveDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagRemoveDto.cs @@ -1,18 +1,17 @@ using System; using System.ComponentModel.DataAnnotations; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +[Serializable] +public class EntityTagRemoveDto { - [Serializable] - public class EntityTagRemoveDto - { - [Required] - public Guid TagId { get; set; } + [Required] + public Guid TagId { get; set; } - [Required] - public string EntityType { get; set; } + [Required] + public string EntityType { get; set; } - [Required] - public string EntityId { get; set; } - } + [Required] + public string EntityId { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs index 052b63a596..245526cfc2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/EntityTagSetDto.cs @@ -4,13 +4,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +[Serializable] +public class EntityTagSetDto { - [Serializable] - public class EntityTagSetDto - { - public string EntityId { get; set; } - public string EntityType { get; set; } - public List Tags { get; set; } - } + public string EntityId { get; set; } + public string EntityType { get; set; } + public List Tags { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/IEntityTagAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/IEntityTagAdminAppService.cs index 1c42d3cf92..fb55d37e37 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/IEntityTagAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/IEntityTagAdminAppService.cs @@ -1,14 +1,13 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +public interface IEntityTagAdminAppService : IApplicationService { - public interface IEntityTagAdminAppService : IApplicationService - { - Task AddTagToEntityAsync(EntityTagCreateDto input); + Task AddTagToEntityAsync(EntityTagCreateDto input); - Task RemoveTagFromEntityAsync(EntityTagRemoveDto input); + Task RemoveTagFromEntityAsync(EntityTagRemoveDto input); - Task SetEntityTagsAsync(EntityTagSetDto input); - } + Task SetEntityTagsAsync(EntityTagSetDto input); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/ITagAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/ITagAdminAppService.cs index a5ae9d85d4..590eb58f6e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/ITagAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/ITagAdminAppService.cs @@ -4,10 +4,9 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +public interface ITagAdminAppService : ICrudAppService { - public interface ITagAdminAppService : ICrudAppService - { - Task> GetTagDefinitionsAsync(); - } + Task> GetTagDefinitionsAsync(); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagCreateDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagCreateDto.cs index bb831918c5..e992f0ac76 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagCreateDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagCreateDto.cs @@ -3,17 +3,16 @@ using System.ComponentModel.DataAnnotations; using Volo.Abp.Validation; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +[Serializable] +public class TagCreateDto { - [Serializable] - public class TagCreateDto - { - [Required] - [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxEntityTypeLength))] - public string EntityType { get; set; } + [Required] + [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxEntityTypeLength))] + public string EntityType { get; set; } - [Required] - [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxNameLength))] - public string Name { get; set; } - } + [Required] + [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxNameLength))] + public string Name { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagDefinitionDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagDefinitionDto.cs index c44180c02b..0a7dbb1b42 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagDefinitionDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagDefinitionDto.cs @@ -1,12 +1,11 @@ using System; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +[Serializable] +public class TagDefinitionDto { - [Serializable] - public class TagDefinitionDto - { - public string EntityType { get; set; } + public string EntityType { get; set; } - public string DisplayName { get; set; } - } + public string DisplayName { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagGetListInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagGetListInput.cs index 71a5b692bf..eb2ae580a1 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagGetListInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagGetListInput.cs @@ -1,11 +1,10 @@ using System; using Volo.Abp.Application.Dtos; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +[Serializable] +public class TagGetListInput : PagedAndSortedResultRequestDto { - [Serializable] - public class TagGetListInput : PagedAndSortedResultRequestDto - { - public string Filter { get; set; } - } + public string Filter { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagUpdateDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagUpdateDto.cs index 4785c9fac2..e8ab16e7e1 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagUpdateDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Tags/TagUpdateDto.cs @@ -4,15 +4,14 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Validation; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +[Serializable] +public class TagUpdateDto : IHasConcurrencyStamp { - [Serializable] - public class TagUpdateDto : IHasConcurrencyStamp - { - [Required] - [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxNameLength))] - public string Name { get; set; } + [Required] + [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxNameLength))] + public string Name { get; set; } - public string ConcurrencyStamp { get; set; } - } + public string ConcurrencyStamp { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissionDefinitionProvider.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissionDefinitionProvider.cs index 91ab3310a2..d1b5556306 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissionDefinitionProvider.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissionDefinitionProvider.cs @@ -5,71 +5,70 @@ using Volo.Abp.Localization; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Localization; -namespace Volo.CmsKit.Permissions +namespace Volo.CmsKit.Permissions; + +public class CmsKitAdminPermissionDefinitionProvider : PermissionDefinitionProvider { - public class CmsKitAdminPermissionDefinitionProvider : PermissionDefinitionProvider + public override void Define(IPermissionDefinitionContext context) { - public override void Define(IPermissionDefinitionContext context) - { - var cmsGroup = context.GetGroupOrNull(CmsKitAdminPermissions.GroupName) ?? context.AddGroup(CmsKitAdminPermissions.GroupName, L("Permission:CmsKit")); + var cmsGroup = context.GetGroupOrNull(CmsKitAdminPermissions.GroupName) ?? context.AddGroup(CmsKitAdminPermissions.GroupName, L("Permission:CmsKit")); - var contentGroup = cmsGroup.AddPermission(CmsKitAdminPermissions.Comments.Default, L("Permission:Comments")) - .RequireGlobalFeatures(typeof(CommentsFeature)); - contentGroup.AddChild(CmsKitAdminPermissions.Comments.Delete, L("Permission:Comments.Delete")) - .RequireGlobalFeatures(typeof(CommentsFeature)); + var contentGroup = cmsGroup.AddPermission(CmsKitAdminPermissions.Comments.Default, L("Permission:Comments")) + .RequireGlobalFeatures(typeof(CommentsFeature)); + contentGroup.AddChild(CmsKitAdminPermissions.Comments.Delete, L("Permission:Comments.Delete")) + .RequireGlobalFeatures(typeof(CommentsFeature)); - var tagGroup = cmsGroup.AddPermission(CmsKitAdminPermissions.Tags.Default, L("Permission:TagManagement")) - .RequireGlobalFeatures(typeof(TagsFeature)); - tagGroup.AddChild(CmsKitAdminPermissions.Tags.Create, L("Permission:TagManagement.Create")) - .RequireGlobalFeatures(typeof(TagsFeature)); - tagGroup.AddChild(CmsKitAdminPermissions.Tags.Update, L("Permission:TagManagement.Update")) - .RequireGlobalFeatures(typeof(TagsFeature)); - tagGroup.AddChild(CmsKitAdminPermissions.Tags.Delete, L("Permission:TagManagement.Delete")) - .RequireGlobalFeatures(typeof(TagsFeature)); + var tagGroup = cmsGroup.AddPermission(CmsKitAdminPermissions.Tags.Default, L("Permission:TagManagement")) + .RequireGlobalFeatures(typeof(TagsFeature)); + tagGroup.AddChild(CmsKitAdminPermissions.Tags.Create, L("Permission:TagManagement.Create")) + .RequireGlobalFeatures(typeof(TagsFeature)); + tagGroup.AddChild(CmsKitAdminPermissions.Tags.Update, L("Permission:TagManagement.Update")) + .RequireGlobalFeatures(typeof(TagsFeature)); + tagGroup.AddChild(CmsKitAdminPermissions.Tags.Delete, L("Permission:TagManagement.Delete")) + .RequireGlobalFeatures(typeof(TagsFeature)); - var pageManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.Pages.Default, L("Permission:PageManagement")) - .RequireGlobalFeatures(typeof(PagesFeature)); - pageManagement.AddChild(CmsKitAdminPermissions.Pages.Create, L("Permission:PageManagement:Create")) - .RequireGlobalFeatures(typeof(PagesFeature)); - pageManagement.AddChild(CmsKitAdminPermissions.Pages.Update, L("Permission:PageManagement:Update")) - .RequireGlobalFeatures(typeof(PagesFeature)); - pageManagement.AddChild(CmsKitAdminPermissions.Pages.Delete, L("Permission:PageManagement:Delete")) - .RequireGlobalFeatures(typeof(PagesFeature)); + var pageManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.Pages.Default, L("Permission:PageManagement")) + .RequireGlobalFeatures(typeof(PagesFeature)); + pageManagement.AddChild(CmsKitAdminPermissions.Pages.Create, L("Permission:PageManagement:Create")) + .RequireGlobalFeatures(typeof(PagesFeature)); + pageManagement.AddChild(CmsKitAdminPermissions.Pages.Update, L("Permission:PageManagement:Update")) + .RequireGlobalFeatures(typeof(PagesFeature)); + pageManagement.AddChild(CmsKitAdminPermissions.Pages.Delete, L("Permission:PageManagement:Delete")) + .RequireGlobalFeatures(typeof(PagesFeature)); - var blogManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.Blogs.Default, L("Permission:BlogManagement")) - .RequireGlobalFeatures(typeof(BlogsFeature)); - blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Create, L("Permission:BlogManagement.Create")) - .RequireGlobalFeatures(typeof(BlogsFeature)); - blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Update, L("Permission:BlogManagement.Update")) - .RequireGlobalFeatures(typeof(BlogsFeature)); - blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Delete, L("Permission:BlogManagement.Delete")) - .RequireGlobalFeatures(typeof(BlogsFeature)); - blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Features, L("Permission:BlogManagement.Features")) - .RequireGlobalFeatures(typeof(BlogsFeature)); + var blogManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.Blogs.Default, L("Permission:BlogManagement")) + .RequireGlobalFeatures(typeof(BlogsFeature)); + blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Create, L("Permission:BlogManagement.Create")) + .RequireGlobalFeatures(typeof(BlogsFeature)); + blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Update, L("Permission:BlogManagement.Update")) + .RequireGlobalFeatures(typeof(BlogsFeature)); + blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Delete, L("Permission:BlogManagement.Delete")) + .RequireGlobalFeatures(typeof(BlogsFeature)); + blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Features, L("Permission:BlogManagement.Features")) + .RequireGlobalFeatures(typeof(BlogsFeature)); - var blogPostManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.BlogPosts.Default, L("Permission:BlogPostManagement")) - .RequireGlobalFeatures(typeof(BlogsFeature)); - blogPostManagement.AddChild(CmsKitAdminPermissions.BlogPosts.Create, L("Permission:BlogPostManagement.Create")) - .RequireGlobalFeatures(typeof(BlogsFeature)); - blogPostManagement.AddChild(CmsKitAdminPermissions.BlogPosts.Update, L("Permission:BlogPostManagement.Update")) - .RequireGlobalFeatures(typeof(BlogsFeature)); - blogPostManagement.AddChild(CmsKitAdminPermissions.BlogPosts.Delete, L("Permission:BlogPostManagement.Delete")) - .RequireGlobalFeatures(typeof(BlogsFeature)); + var blogPostManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.BlogPosts.Default, L("Permission:BlogPostManagement")) + .RequireGlobalFeatures(typeof(BlogsFeature)); + blogPostManagement.AddChild(CmsKitAdminPermissions.BlogPosts.Create, L("Permission:BlogPostManagement.Create")) + .RequireGlobalFeatures(typeof(BlogsFeature)); + blogPostManagement.AddChild(CmsKitAdminPermissions.BlogPosts.Update, L("Permission:BlogPostManagement.Update")) + .RequireGlobalFeatures(typeof(BlogsFeature)); + blogPostManagement.AddChild(CmsKitAdminPermissions.BlogPosts.Delete, L("Permission:BlogPostManagement.Delete")) + .RequireGlobalFeatures(typeof(BlogsFeature)); - var menuManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.Menus.Default, L("Permission:MenuManagement")) - .RequireGlobalFeatures(typeof(MenuFeature)); + var menuManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.Menus.Default, L("Permission:MenuManagement")) + .RequireGlobalFeatures(typeof(MenuFeature)); - menuManagement.AddChild(CmsKitAdminPermissions.Menus.Create, L("Permission:MenuManagement.Create")) - .RequireGlobalFeatures(typeof(MenuFeature)); - menuManagement.AddChild(CmsKitAdminPermissions.Menus.Update, L("Permission:MenuManagement.Update")) - .RequireGlobalFeatures(typeof(MenuFeature)); - menuManagement.AddChild(CmsKitAdminPermissions.Menus.Delete, L("Permission:MenuManagement.Delete")) - .RequireGlobalFeatures(typeof(MenuFeature)); - } + menuManagement.AddChild(CmsKitAdminPermissions.Menus.Create, L("Permission:MenuManagement.Create")) + .RequireGlobalFeatures(typeof(MenuFeature)); + menuManagement.AddChild(CmsKitAdminPermissions.Menus.Update, L("Permission:MenuManagement.Update")) + .RequireGlobalFeatures(typeof(MenuFeature)); + menuManagement.AddChild(CmsKitAdminPermissions.Menus.Delete, L("Permission:MenuManagement.Delete")) + .RequireGlobalFeatures(typeof(MenuFeature)); + } - private static LocalizableString L(string name) - { - return LocalizableString.Create(name); - } + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissions.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissions.cs index 0ecc97362f..010df13ac8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissions.cs @@ -1,64 +1,63 @@ using Volo.Abp.Reflection; -namespace Volo.CmsKit.Permissions +namespace Volo.CmsKit.Permissions; + +public class CmsKitAdminPermissions { - public class CmsKitAdminPermissions - { - public const string GroupName = "CmsKit"; + public const string GroupName = "CmsKit"; - public static class Comments - { - public const string Default = GroupName + ".Comments"; - public const string Delete = Default + ".Delete"; - } + public static class Comments + { + public const string Default = GroupName + ".Comments"; + public const string Delete = Default + ".Delete"; + } - public static class Tags - { - public const string Default = GroupName + ".Tags"; - public const string Create = Default + ".Create"; - public const string Update = Default + ".Update"; - public const string Delete = Default + ".Delete"; - } + public static class Tags + { + public const string Default = GroupName + ".Tags"; + public const string Create = Default + ".Create"; + public const string Update = Default + ".Update"; + public const string Delete = Default + ".Delete"; + } - public static class Contents - { - public const string Default = GroupName + ".Contents"; - public const string Create = Default + ".Create"; - public const string Update = Default + ".Update"; - public const string Delete = Default + ".Delete"; - } + public static class Contents + { + public const string Default = GroupName + ".Contents"; + public const string Create = Default + ".Create"; + public const string Update = Default + ".Update"; + public const string Delete = Default + ".Delete"; + } - public static class Pages - { - public const string Default = GroupName + ".Pages"; - public const string Create = Default + ".Create"; - public const string Update = Default + ".Update"; - public const string Delete = Default + ".Delete"; - } + public static class Pages + { + public const string Default = GroupName + ".Pages"; + public const string Create = Default + ".Create"; + public const string Update = Default + ".Update"; + public const string Delete = Default + ".Delete"; + } - public static class Blogs - { - public const string Default = GroupName + ".Blogs"; - public const string Create = Default + ".Create"; - public const string Update = Default + ".Update"; - public const string Delete = Default + ".Delete"; - public const string Features = Default + ".Features"; - } + public static class Blogs + { + public const string Default = GroupName + ".Blogs"; + public const string Create = Default + ".Create"; + public const string Update = Default + ".Update"; + public const string Delete = Default + ".Delete"; + public const string Features = Default + ".Features"; + } - public static class BlogPosts - { - public const string Default = GroupName + ".BlogPosts"; - public const string Create = Default + ".Create"; - public const string Update = Default + ".Update"; - public const string Delete = Default + ".Delete"; - } + public static class BlogPosts + { + public const string Default = GroupName + ".BlogPosts"; + public const string Create = Default + ".Create"; + public const string Update = Default + ".Update"; + public const string Delete = Default + ".Delete"; + } - public static class Menus - { - public const string Default = GroupName + ".Menus"; - public const string Create = Default + ".Create"; - public const string Update = Default + ".Update"; - public const string Delete = Default + ".Delete"; - } + public static class Menus + { + public const string Default = GroupName + ".Menus"; + public const string Create = Default + ".Create"; + public const string Update = Default + ".Update"; + public const string Delete = Default + ".Delete"; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogAdminAppService.cs index d278086fab..7cd17b7696 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogAdminAppService.cs @@ -9,76 +9,75 @@ using Volo.CmsKit.Blogs; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[RequiresGlobalFeature(typeof(BlogsFeature))] +[Authorize(CmsKitAdminPermissions.Blogs.Default)] +public class BlogAdminAppService : CmsKitAdminAppServiceBase, IBlogAdminAppService { - [RequiresGlobalFeature(typeof(BlogsFeature))] - [Authorize(CmsKitAdminPermissions.Blogs.Default)] - public class BlogAdminAppService : CmsKitAdminAppServiceBase, IBlogAdminAppService + protected IBlogRepository BlogRepository { get; } + protected BlogManager BlogManager { get; } + protected BlogFeatureManager BlogFeatureManager { get; } + + public BlogAdminAppService( + IBlogRepository blogRepository, + BlogManager blogManager, + BlogFeatureManager blogFeatureManager = null) { - protected IBlogRepository BlogRepository { get; } - protected BlogManager BlogManager { get; } - protected BlogFeatureManager BlogFeatureManager{ get; } - - public BlogAdminAppService( - IBlogRepository blogRepository, - BlogManager blogManager, - BlogFeatureManager blogFeatureManager = null) - { - BlogRepository = blogRepository; - BlogManager = blogManager; - BlogFeatureManager = blogFeatureManager; - } + BlogRepository = blogRepository; + BlogManager = blogManager; + BlogFeatureManager = blogFeatureManager; + } - public virtual async Task GetAsync(Guid id) - { - var blog = await BlogRepository.GetAsync(id); + public virtual async Task GetAsync(Guid id) + { + var blog = await BlogRepository.GetAsync(id); - return ObjectMapper.Map(blog); - } + return ObjectMapper.Map(blog); + } - public virtual async Task> GetListAsync(BlogGetListInput input) - { - var totalCount = await BlogRepository.GetCountAsync(input.Filter); + public virtual async Task> GetListAsync(BlogGetListInput input) + { + var totalCount = await BlogRepository.GetCountAsync(input.Filter); - var blogs = await BlogRepository.GetListAsync( - input.Filter, - input.Sorting, - input.MaxResultCount, - input.SkipCount); + var blogs = await BlogRepository.GetListAsync( + input.Filter, + input.Sorting, + input.MaxResultCount, + input.SkipCount); - return new PagedResultDto(totalCount, ObjectMapper.Map, List>(blogs)); - } + return new PagedResultDto(totalCount, ObjectMapper.Map, List>(blogs)); + } - [Authorize(CmsKitAdminPermissions.Blogs.Create)] - public virtual async Task CreateAsync(CreateBlogDto input) - { - var blog = await BlogManager.CreateAsync(input.Name, input.Slug); + [Authorize(CmsKitAdminPermissions.Blogs.Create)] + public virtual async Task CreateAsync(CreateBlogDto input) + { + var blog = await BlogManager.CreateAsync(input.Name, input.Slug); - await BlogRepository.InsertAsync(blog, autoSave: true); + await BlogRepository.InsertAsync(blog, autoSave: true); - await BlogFeatureManager.SetDefaultsAsync(blog.Id); + await BlogFeatureManager.SetDefaultsAsync(blog.Id); - return ObjectMapper.Map(blog); - } + return ObjectMapper.Map(blog); + } - [Authorize(CmsKitAdminPermissions.Blogs.Update)] - public virtual async Task UpdateAsync(Guid id, UpdateBlogDto input) - { - var blog = await BlogRepository.GetAsync(id); + [Authorize(CmsKitAdminPermissions.Blogs.Update)] + public virtual async Task UpdateAsync(Guid id, UpdateBlogDto input) + { + var blog = await BlogRepository.GetAsync(id); - blog = await BlogManager.UpdateAsync(blog, input.Name, input.Slug); + blog = await BlogManager.UpdateAsync(blog, input.Name, input.Slug); - blog.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); + blog.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); - await BlogRepository.UpdateAsync(blog); + await BlogRepository.UpdateAsync(blog); - return ObjectMapper.Map(blog); - } + return ObjectMapper.Map(blog); + } - [Authorize(CmsKitAdminPermissions.Blogs.Delete)] - public virtual Task DeleteAsync(Guid id) - { - return BlogRepository.DeleteAsync(id); - } + [Authorize(CmsKitAdminPermissions.Blogs.Delete)] + public virtual Task DeleteAsync(Guid id) + { + return BlogRepository.DeleteAsync(id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminAppService.cs index a0ba1c460e..823f569bed 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminAppService.cs @@ -8,38 +8,37 @@ using Volo.CmsKit.Blogs; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[RequiresGlobalFeature(typeof(BlogsFeature))] +[Authorize(CmsKitAdminPermissions.Blogs.Features)] +public class BlogFeatureAdminAppService : CmsKitAdminAppServiceBase, IBlogFeatureAdminAppService { - [RequiresGlobalFeature(typeof(BlogsFeature))] - [Authorize(CmsKitAdminPermissions.Blogs.Features)] - public class BlogFeatureAdminAppService : CmsKitAdminAppServiceBase, IBlogFeatureAdminAppService - { - protected IBlogFeatureRepository BlogFeatureRepository { get; } + protected IBlogFeatureRepository BlogFeatureRepository { get; } - protected BlogFeatureManager BlogFeatureManager { get; } + protected BlogFeatureManager BlogFeatureManager { get; } - protected IDistributedEventBus EventBus { get; } + protected IDistributedEventBus EventBus { get; } - public BlogFeatureAdminAppService( - IBlogFeatureRepository blogFeatureRepository, - BlogFeatureManager blogFeatureManager, - IDistributedEventBus eventBus) - { - BlogFeatureRepository = blogFeatureRepository; - BlogFeatureManager = blogFeatureManager; - EventBus = eventBus; - } + public BlogFeatureAdminAppService( + IBlogFeatureRepository blogFeatureRepository, + BlogFeatureManager blogFeatureManager, + IDistributedEventBus eventBus) + { + BlogFeatureRepository = blogFeatureRepository; + BlogFeatureManager = blogFeatureManager; + EventBus = eventBus; + } - public virtual async Task> GetListAsync(Guid blogId) - { - var blogFeatures = await BlogFeatureRepository.GetListAsync(blogId); + public virtual async Task> GetListAsync(Guid blogId) + { + var blogFeatures = await BlogFeatureRepository.GetListAsync(blogId); - return ObjectMapper.Map, List>(blogFeatures); - } + return ObjectMapper.Map, List>(blogFeatures); + } - public virtual Task SetAsync(Guid blogId, BlogFeatureInputDto dto) - { - return BlogFeatureManager.SetAsync(blogId, dto.FeatureName, dto.IsEnabled); - } + public virtual Task SetAsync(Guid blogId, BlogFeatureInputDto dto) + { + return BlogFeatureManager.SetAsync(blogId, dto.FeatureName, dto.IsEnabled); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs index 1b0a8b1d2e..83899199f0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs @@ -11,103 +11,102 @@ using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[RequiresGlobalFeature(typeof(BlogsFeature))] +[Authorize(CmsKitAdminPermissions.BlogPosts.Default)] +public class BlogPostAdminAppService : CmsKitAppServiceBase, IBlogPostAdminAppService { - [RequiresGlobalFeature(typeof(BlogsFeature))] - [Authorize(CmsKitAdminPermissions.BlogPosts.Default)] - public class BlogPostAdminAppService : CmsKitAppServiceBase, IBlogPostAdminAppService + protected BlogPostManager BlogPostManager { get; } + protected IBlogPostRepository BlogPostRepository { get; } + protected IBlogRepository BlogRepository { get; } + protected ICmsUserLookupService UserLookupService { get; } + + public BlogPostAdminAppService( + BlogPostManager blogPostManager, + IBlogPostRepository blogPostRepository, + IBlogRepository blogRepository, + ICmsUserLookupService userLookupService) { - protected BlogPostManager BlogPostManager { get; } - protected IBlogPostRepository BlogPostRepository { get; } - protected IBlogRepository BlogRepository { get; } - protected ICmsUserLookupService UserLookupService { get; } - - public BlogPostAdminAppService( - BlogPostManager blogPostManager, - IBlogPostRepository blogPostRepository, - IBlogRepository blogRepository, - ICmsUserLookupService userLookupService) - { - BlogPostManager = blogPostManager; - BlogPostRepository = blogPostRepository; - BlogRepository = blogRepository; - UserLookupService = userLookupService; - } + BlogPostManager = blogPostManager; + BlogPostRepository = blogPostRepository; + BlogRepository = blogRepository; + UserLookupService = userLookupService; + } - [Authorize(CmsKitAdminPermissions.BlogPosts.Create)] - public virtual async Task CreateAsync(CreateBlogPostDto input) - { - var author = await UserLookupService.GetByIdAsync(CurrentUser.GetId()); + [Authorize(CmsKitAdminPermissions.BlogPosts.Create)] + public virtual async Task CreateAsync(CreateBlogPostDto input) + { + var author = await UserLookupService.GetByIdAsync(CurrentUser.GetId()); - var blog = await BlogRepository.GetAsync(input.BlogId); + var blog = await BlogRepository.GetAsync(input.BlogId); - var blogPost = await BlogPostManager.CreateAsync( - author, - blog, - input.Title, - input.Slug, - input.ShortDescription, - input.Content, - input.CoverImageMediaId); + var blogPost = await BlogPostManager.CreateAsync( + author, + blog, + input.Title, + input.Slug, + input.ShortDescription, + input.Content, + input.CoverImageMediaId); - await BlogPostRepository.InsertAsync(blogPost); + await BlogPostRepository.InsertAsync(blogPost); - return ObjectMapper.Map(blogPost); - } + return ObjectMapper.Map(blogPost); + } + + [Authorize(CmsKitAdminPermissions.BlogPosts.Update)] + public virtual async Task UpdateAsync(Guid id, UpdateBlogPostDto input) + { + var blogPost = await BlogPostRepository.GetAsync(id); + + blogPost.SetTitle(input.Title); + blogPost.SetShortDescription(input.ShortDescription); + blogPost.SetContent(input.Content); + blogPost.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); + blogPost.CoverImageMediaId = input.CoverImageMediaId; - [Authorize(CmsKitAdminPermissions.BlogPosts.Update)] - public virtual async Task UpdateAsync(Guid id, UpdateBlogPostDto input) + if (blogPost.Slug != input.Slug) { - var blogPost = await BlogPostRepository.GetAsync(id); + await BlogPostManager.SetSlugUrlAsync(blogPost, input.Slug); + } - blogPost.SetTitle(input.Title); - blogPost.SetShortDescription(input.ShortDescription); - blogPost.SetContent(input.Content); - blogPost.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); - blogPost.CoverImageMediaId = input.CoverImageMediaId; + await BlogPostRepository.UpdateAsync(blogPost); - if (blogPost.Slug != input.Slug) - { - await BlogPostManager.SetSlugUrlAsync(blogPost, input.Slug); - } + return ObjectMapper.Map(blogPost); + } - await BlogPostRepository.UpdateAsync(blogPost); + [Authorize(CmsKitAdminPermissions.BlogPosts.Default)] + public virtual async Task GetAsync(Guid id) + { + var blogPost = await BlogPostRepository.GetAsync(id); - return ObjectMapper.Map(blogPost); - } + return ObjectMapper.Map(blogPost); + } - [Authorize(CmsKitAdminPermissions.BlogPosts.Default)] - public virtual async Task GetAsync(Guid id) - { - var blogPost = await BlogPostRepository.GetAsync(id); + [Authorize(CmsKitAdminPermissions.BlogPosts.Default)] + public virtual async Task> GetListAsync(BlogPostGetListInput input) + { + var blogs = (await BlogRepository.GetListAsync()).ToDictionary(x => x.Id); - return ObjectMapper.Map(blogPost); - } + var blogPosts = await BlogPostRepository.GetListAsync(input.Filter, input.BlogId, input.MaxResultCount, input.SkipCount, input.Sorting); - [Authorize(CmsKitAdminPermissions.BlogPosts.Default)] - public virtual async Task> GetListAsync(BlogPostGetListInput input) - { - var blogs = (await BlogRepository.GetListAsync()).ToDictionary(x => x.Id); - - var blogPosts = await BlogPostRepository.GetListAsync(input.Filter, input.BlogId, input.MaxResultCount, input.SkipCount, input.Sorting); + var count = await BlogPostRepository.GetCountAsync(input.Filter); - var count = await BlogPostRepository.GetCountAsync(input.Filter); + var dtoList = blogPosts.Select(x => + { + var dto = ObjectMapper.Map(x); + dto.BlogName = blogs[x.BlogId].Name; - var dtoList = blogPosts.Select(x => - { - var dto = ObjectMapper.Map(x); - dto.BlogName = blogs[x.BlogId].Name; + return dto; + }).ToList(); - return dto; - }).ToList(); - - return new PagedResultDto(count, dtoList); - } + return new PagedResultDto(count, dtoList); + } - [Authorize(CmsKitAdminPermissions.BlogPosts.Delete)] - public virtual async Task DeleteAsync(Guid id) - { - await BlogPostRepository.DeleteAsync(id); - } + [Authorize(CmsKitAdminPermissions.BlogPosts.Delete)] + public virtual async Task DeleteAsync(Guid id) + { + await BlogPostRepository.DeleteAsync(id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminAppServiceBase.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminAppServiceBase.cs index 9d4c109698..eea94d3ac8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminAppServiceBase.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminAppServiceBase.cs @@ -7,33 +7,32 @@ using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Authorization; -namespace Volo.CmsKit.Admin +namespace Volo.CmsKit.Admin; + +public abstract class CmsKitAdminAppServiceBase : CmsKitAppServiceBase { - public abstract class CmsKitAdminAppServiceBase : CmsKitAppServiceBase + protected CmsKitAdminAppServiceBase() { - protected CmsKitAdminAppServiceBase() - { - ObjectMapperContext = typeof(CmsKitAdminApplicationModule); - } + ObjectMapperContext = typeof(CmsKitAdminApplicationModule); + } - /// - /// Checks given policies until finding granted policy. If none of them is granted, throws - /// - /// Policies to be checked. - /// Thrown when none of policies is granted. - protected async Task CheckAnyOfPoliciesAsync([NotNull] IEnumerable policies) - { - Check.NotNull(policies, nameof(policies)); + /// + /// Checks given policies until finding granted policy. If none of them is granted, throws + /// + /// Policies to be checked. + /// Thrown when none of policies is granted. + protected async Task CheckAnyOfPoliciesAsync([NotNull] IEnumerable policies) + { + Check.NotNull(policies, nameof(policies)); - foreach (var policy in policies) + foreach (var policy in policies) + { + if (await AuthorizationService.IsGrantedAsync(policy)) { - if (await AuthorizationService.IsGrantedAsync(policy)) - { - return; - } + return; } - - throw new AbpAuthorizationException(); } + + throw new AbpAuthorizationException(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs index 30ed1041a4..120e704575 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs @@ -14,36 +14,35 @@ using Volo.CmsKit.Users; using Volo.CmsKit.Menus; using Volo.CmsKit.Admin.Menus; -namespace Volo.CmsKit.Admin +namespace Volo.CmsKit.Admin; + +public class CmsKitAdminApplicationAutoMapperProfile : Profile { - public class CmsKitAdminApplicationAutoMapperProfile : Profile + public CmsKitAdminApplicationAutoMapperProfile() { - public CmsKitAdminApplicationAutoMapperProfile() - { - CreateMap(); + CreateMap(); - CreateMap(); - CreateMap() - .Ignore(x => x.Author); + CreateMap(); + CreateMap() + .Ignore(x => x.Author); - CreateMap(); - CreateMap(); + CreateMap(); + CreateMap(); - CreateMap(MemberList.Destination); - CreateMap() - .Ignore(d => d.BlogName); - CreateMap(MemberList.Source); - CreateMap(MemberList.Source); + CreateMap(MemberList.Destination); + CreateMap() + .Ignore(d => d.BlogName); + CreateMap(MemberList.Source); + CreateMap(MemberList.Source); - CreateMap(); + CreateMap(); - CreateMap(MemberList.Destination); + CreateMap(MemberList.Destination); - CreateMap(); + CreateMap(); - CreateMap(); + CreateMap(); - CreateMap(); - } + CreateMap(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationModule.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationModule.cs index 5eaf3dae28..2a9765dd5a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationModule.cs @@ -13,114 +13,113 @@ using Volo.CmsKit.Pages; using Volo.CmsKit.Permissions; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Admin +namespace Volo.CmsKit.Admin; + +[DependsOn( + typeof(CmsKitAdminApplicationContractsModule), + typeof(AbpAutoMapperModule), + typeof(CmsKitCommonApplicationModule) + )] +public class CmsKitAdminApplicationModule : AbpModule { - [DependsOn( - typeof(CmsKitAdminApplicationContractsModule), - typeof(AbpAutoMapperModule), - typeof(CmsKitCommonApplicationModule) - )] - public class CmsKitAdminApplicationModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddAutoMapperObjectMapper(); + context.Services.AddAutoMapperObjectMapper(); - ConfigureTagOptions(); + ConfigureTagOptions(); - ConfigureCommentOptions(); + ConfigureCommentOptions(); - Configure(options => - { - options.AddMaps(validate: true); - }); - } + Configure(options => + { + options.AddMaps(validate: true); + }); + } - private void ConfigureTagOptions() + private void ConfigureTagOptions() + { + Configure(opts => { - Configure(opts => + if (GlobalFeatureManager.Instance.IsEnabled()) { - if (GlobalFeatureManager.Instance.IsEnabled()) - { - opts.EntityTypes.AddIfNotContains( - new TagEntityTypeDefiniton( - BlogPostConsts.EntityType, - LocalizableString.Create("BlogPost"), - createPolicies: new[] - { + opts.EntityTypes.AddIfNotContains( + new TagEntityTypeDefiniton( + BlogPostConsts.EntityType, + LocalizableString.Create("BlogPost"), + createPolicies: new[] + { CmsKitAdminPermissions.BlogPosts.Create, CmsKitAdminPermissions.BlogPosts.Update - }, - updatePolicies: new[] - { + }, + updatePolicies: new[] + { CmsKitAdminPermissions.BlogPosts.Create, CmsKitAdminPermissions.BlogPosts.Update - }, - deletePolicies: new[] - { + }, + deletePolicies: new[] + { CmsKitAdminPermissions.BlogPosts.Create, CmsKitAdminPermissions.BlogPosts.Update - })); - } - }); + })); + } + }); - if (GlobalFeatureManager.Instance.IsEnabled()) + if (GlobalFeatureManager.Instance.IsEnabled()) + { + Configure(options => { - Configure(options => + if (GlobalFeatureManager.Instance.IsEnabled()) { - if (GlobalFeatureManager.Instance.IsEnabled()) - { - options.EntityTypes.AddIfNotContains( - new MediaDescriptorDefinition( - BlogPostConsts.EntityType, - createPolicies: new[] - { + options.EntityTypes.AddIfNotContains( + new MediaDescriptorDefinition( + BlogPostConsts.EntityType, + createPolicies: new[] + { CmsKitAdminPermissions.BlogPosts.Create, CmsKitAdminPermissions.BlogPosts.Update - }, - deletePolicies: new[] - { + }, + deletePolicies: new[] + { CmsKitAdminPermissions.BlogPosts.Create, CmsKitAdminPermissions.BlogPosts.Update, CmsKitAdminPermissions.BlogPosts.Delete - })); - } + })); + } - if (GlobalFeatureManager.Instance.IsEnabled()) - { - options.EntityTypes.AddIfNotContains( - new MediaDescriptorDefinition( - PageConsts.EntityType, - createPolicies: new[] - { + if (GlobalFeatureManager.Instance.IsEnabled()) + { + options.EntityTypes.AddIfNotContains( + new MediaDescriptorDefinition( + PageConsts.EntityType, + createPolicies: new[] + { CmsKitAdminPermissions.Pages.Create, CmsKitAdminPermissions.Pages.Update - }, - deletePolicies: new[] - { + }, + deletePolicies: new[] + { CmsKitAdminPermissions.Pages.Create, CmsKitAdminPermissions.Pages.Update, CmsKitAdminPermissions.Pages.Delete - })); - } - }); - } + })); + } + }); } + } - private void ConfigureCommentOptions() + private void ConfigureCommentOptions() + { + if (GlobalFeatureManager.Instance.IsEnabled()) { - if (GlobalFeatureManager.Instance.IsEnabled()) + Configure(options => { - Configure(options => + if (GlobalFeatureManager.Instance.IsEnabled()) { - if (GlobalFeatureManager.Instance.IsEnabled()) - { - options.EntityTypes.AddIfNotContains( - new CommentEntityTypeDefinition(BlogPostConsts.EntityType)); + options.EntityTypes.AddIfNotContains( + new CommentEntityTypeDefinition(BlogPostConsts.EntityType)); - } - }); - } + } + }); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs index a9469bcca8..5295557860 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs @@ -9,67 +9,66 @@ using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Admin.Comments +namespace Volo.CmsKit.Admin.Comments; + +[RequiresGlobalFeature(typeof(CommentsFeature))] +[Authorize(CmsKitAdminPermissions.Comments.Default)] +public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAppService { - [RequiresGlobalFeature(typeof(CommentsFeature))] - [Authorize(CmsKitAdminPermissions.Comments.Default)] - public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAppService - { - protected ICommentRepository CommentRepository { get; } + protected ICommentRepository CommentRepository { get; } - public CommentAdminAppService(ICommentRepository commentRepository) - { - CommentRepository = commentRepository; - } + public CommentAdminAppService(ICommentRepository commentRepository) + { + CommentRepository = commentRepository; + } - public virtual async Task> GetListAsync(CommentGetListInput input) - { - var totalCount = await CommentRepository.GetCountAsync( - input.Text, - input.EntityType, - input.RepliedCommentId, - input.Author, - input.CreationStartDate, - input.CreationEndDate); + public virtual async Task> GetListAsync(CommentGetListInput input) + { + var totalCount = await CommentRepository.GetCountAsync( + input.Text, + input.EntityType, + input.RepliedCommentId, + input.Author, + input.CreationStartDate, + input.CreationEndDate); - var comments = await CommentRepository.GetListAsync( - input.Text, - input.EntityType, - input.RepliedCommentId, - input.Author, - input.CreationStartDate, - input.CreationEndDate, - input.Sorting, - input.MaxResultCount, - input.SkipCount - ); + var comments = await CommentRepository.GetListAsync( + input.Text, + input.EntityType, + input.RepliedCommentId, + input.Author, + input.CreationStartDate, + input.CreationEndDate, + input.Sorting, + input.MaxResultCount, + input.SkipCount + ); - var dtos = comments.Select(queryResultItem => - { - var dto = ObjectMapper.Map(queryResultItem.Comment); - dto.Author = ObjectMapper.Map(queryResultItem.Author); + var dtos = comments.Select(queryResultItem => + { + var dto = ObjectMapper.Map(queryResultItem.Comment); + dto.Author = ObjectMapper.Map(queryResultItem.Author); - return dto; - }).ToList(); + return dto; + }).ToList(); - return new PagedResultDto(totalCount, dtos); - } + return new PagedResultDto(totalCount, dtos); + } - public virtual async Task GetAsync(Guid id) - { - var comment = await CommentRepository.GetWithAuthorAsync(id); + public virtual async Task GetAsync(Guid id) + { + var comment = await CommentRepository.GetWithAuthorAsync(id); - var dto = ObjectMapper.Map(comment.Comment); - dto.Author = ObjectMapper.Map(comment.Author); + var dto = ObjectMapper.Map(comment.Comment); + dto.Author = ObjectMapper.Map(comment.Author); - return dto; - } + return dto; + } - [Authorize(CmsKitAdminPermissions.Comments.Delete)] - public virtual async Task DeleteAsync(Guid id) - { - var comment = await CommentRepository.GetAsync(id); - await CommentRepository.DeleteWithRepliesAsync(comment); - } + [Authorize(CmsKitAdminPermissions.Comments.Delete)] + public virtual async Task DeleteAsync(Guid id) + { + var comment = await CommentRepository.GetAsync(id); + await CommentRepository.DeleteWithRepliesAsync(comment); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorAdminAppService.cs index bab338e503..cc785adac0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorAdminAppService.cs @@ -5,54 +5,53 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.MediaDescriptors; -namespace Volo.CmsKit.Admin.MediaDescriptors +namespace Volo.CmsKit.Admin.MediaDescriptors; + +[RequiresGlobalFeature(typeof(MediaFeature))] +public class MediaDescriptorAdminAppService : CmsKitAdminAppServiceBase, IMediaDescriptorAdminAppService { - [RequiresGlobalFeature(typeof(MediaFeature))] - public class MediaDescriptorAdminAppService : CmsKitAdminAppServiceBase, IMediaDescriptorAdminAppService + protected IBlobContainer MediaContainer { get; } + protected IMediaDescriptorRepository MediaDescriptorRepository { get; } + protected MediaDescriptorManager MediaDescriptorManager { get; } + protected IMediaDescriptorDefinitionStore MediaDescriptorDefinitionStore { get; } + + public MediaDescriptorAdminAppService( + IBlobContainer mediaContainer, + IMediaDescriptorRepository mediaDescriptorRepository, + MediaDescriptorManager mediaDescriptorManager, + IMediaDescriptorDefinitionStore mediaDescriptorDefinitionStore) + { + MediaContainer = mediaContainer; + MediaDescriptorRepository = mediaDescriptorRepository; + MediaDescriptorManager = mediaDescriptorManager; + MediaDescriptorDefinitionStore = mediaDescriptorDefinitionStore; + } + + public virtual async Task CreateAsync(string entityType, CreateMediaInputWithStream inputStream) + { + var definition = await MediaDescriptorDefinitionStore.GetAsync(entityType); + + /* TODO: Shouldn't CreatePolicies be a dictionary and we check for inputStream.EntityType? */ + await CheckAnyOfPoliciesAsync(definition.CreatePolicies); + + var newEntity = await MediaDescriptorManager.CreateAsync(entityType, inputStream.Name, inputStream.File.ContentType, inputStream.File.ContentLength ?? 0); + + await MediaContainer.SaveAsync(newEntity.Id.ToString(), inputStream.File.GetStream()); + await MediaDescriptorRepository.InsertAsync(newEntity); + + return ObjectMapper.Map(newEntity); + } + + public virtual async Task DeleteAsync(Guid id) { - protected IBlobContainer MediaContainer { get; } - protected IMediaDescriptorRepository MediaDescriptorRepository { get; } - protected MediaDescriptorManager MediaDescriptorManager { get; } - protected IMediaDescriptorDefinitionStore MediaDescriptorDefinitionStore { get; } - - public MediaDescriptorAdminAppService( - IBlobContainer mediaContainer, - IMediaDescriptorRepository mediaDescriptorRepository, - MediaDescriptorManager mediaDescriptorManager, - IMediaDescriptorDefinitionStore mediaDescriptorDefinitionStore) - { - MediaContainer = mediaContainer; - MediaDescriptorRepository = mediaDescriptorRepository; - MediaDescriptorManager = mediaDescriptorManager; - MediaDescriptorDefinitionStore = mediaDescriptorDefinitionStore; - } - - public virtual async Task CreateAsync(string entityType, CreateMediaInputWithStream inputStream) - { - var definition = await MediaDescriptorDefinitionStore.GetAsync(entityType); - - /* TODO: Shouldn't CreatePolicies be a dictionary and we check for inputStream.EntityType? */ - await CheckAnyOfPoliciesAsync(definition.CreatePolicies); - - var newEntity = await MediaDescriptorManager.CreateAsync(entityType, inputStream.Name, inputStream.File.ContentType, inputStream.File.ContentLength ?? 0); - - await MediaContainer.SaveAsync(newEntity.Id.ToString(), inputStream.File.GetStream()); - await MediaDescriptorRepository.InsertAsync(newEntity); - - return ObjectMapper.Map(newEntity); - } - - public virtual async Task DeleteAsync(Guid id) - { - var mediaDescriptor = await MediaDescriptorRepository.GetAsync(id); - - var definition = await MediaDescriptorDefinitionStore.GetAsync(mediaDescriptor.EntityType); - - /* TODO: Shouldn't DeletePolicies be a dictionary and we check for inputStream.EntityType? */ - await CheckAnyOfPoliciesAsync(definition.DeletePolicies); - - await MediaContainer.DeleteAsync(id.ToString()); - await MediaDescriptorRepository.DeleteAsync(id); - } + var mediaDescriptor = await MediaDescriptorRepository.GetAsync(id); + + var definition = await MediaDescriptorDefinitionStore.GetAsync(mediaDescriptor.EntityType); + + /* TODO: Shouldn't DeletePolicies be a dictionary and we check for inputStream.EntityType? */ + await CheckAnyOfPoliciesAsync(definition.DeletePolicies); + + await MediaContainer.DeleteAsync(id.ToString()); + await MediaDescriptorRepository.DeleteAsync(id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Menus/MenuItemAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Menus/MenuItemAdminAppService.cs index 7fb783cdc1..8ef6ce0346 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Menus/MenuItemAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Menus/MenuItemAdminAppService.cs @@ -12,122 +12,121 @@ using Volo.CmsKit.Menus; using Volo.CmsKit.Pages; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Menus +namespace Volo.CmsKit.Admin.Menus; + +[RequiresGlobalFeature(typeof(MenuFeature))] +[Authorize(CmsKitAdminPermissions.Menus.Default)] +public class MenuItemAdminAppService : CmsKitAdminAppServiceBase, IMenuItemAdminAppService { - [RequiresGlobalFeature(typeof(MenuFeature))] - [Authorize(CmsKitAdminPermissions.Menus.Default)] - public class MenuItemAdminAppService : CmsKitAdminAppServiceBase, IMenuItemAdminAppService + protected MenuItemManager MenuManager { get; } + protected IMenuItemRepository MenuItemRepository { get; } + protected IPageRepository PageRepository { get; } + + public MenuItemAdminAppService( + MenuItemManager menuManager, + IMenuItemRepository menuRepository, + IPageRepository pageRepository) { - protected MenuItemManager MenuManager { get; } - protected IMenuItemRepository MenuItemRepository { get; } - protected IPageRepository PageRepository { get; } - - public MenuItemAdminAppService( - MenuItemManager menuManager, - IMenuItemRepository menuRepository, - IPageRepository pageRepository) - { - MenuManager = menuManager; - MenuItemRepository = menuRepository; - PageRepository = pageRepository; - } + MenuManager = menuManager; + MenuItemRepository = menuRepository; + PageRepository = pageRepository; + } - public virtual async Task> GetListAsync() - { - var menuItems = await MenuItemRepository.GetListAsync(); + public virtual async Task> GetListAsync() + { + var menuItems = await MenuItemRepository.GetListAsync(); + + return new ListResultDto( + ObjectMapper.Map, List>(menuItems) + ); + } - return new ListResultDto( - ObjectMapper.Map, List>(menuItems) + public virtual async Task GetAsync(Guid id) + { + var menu = await MenuItemRepository.GetAsync(id); + return ObjectMapper.Map(menu); + } + + [Authorize(CmsKitAdminPermissions.Menus.Create)] + public virtual async Task CreateAsync(MenuItemCreateInput input) + { + var menuItem = new MenuItem( + GuidGenerator.Create(), + input.DisplayName, + input.Url.IsNullOrEmpty() ? "#" : input.Url, + input.IsActive, + input.ParentId, + input.Icon, + input.Order, + input.Target, + input.ElementId, + input.CssClass, + CurrentTenant.Id ); - } - public virtual async Task GetAsync(Guid id) + if (input.PageId.HasValue) { - var menu = await MenuItemRepository.GetAsync(id); - return ObjectMapper.Map(menu); + MenuManager.SetPageUrl(menuItem, await PageRepository.GetAsync(input.PageId.Value)); } - [Authorize(CmsKitAdminPermissions.Menus.Create)] - public virtual async Task CreateAsync(MenuItemCreateInput input) - { - var menuItem = new MenuItem( - GuidGenerator.Create(), - input.DisplayName, - input.Url.IsNullOrEmpty() ? "#" : input.Url, - input.IsActive, - input.ParentId, - input.Icon, - input.Order, - input.Target, - input.ElementId, - input.CssClass, - CurrentTenant.Id - ); - - if (input.PageId.HasValue) - { - MenuManager.SetPageUrl(menuItem, await PageRepository.GetAsync(input.PageId.Value)); - } - - await MenuItemRepository.InsertAsync(menuItem); - - return ObjectMapper.Map(menuItem); - } + await MenuItemRepository.InsertAsync(menuItem); - [Authorize(CmsKitAdminPermissions.Menus.Update)] - public virtual async Task UpdateAsync(Guid id, MenuItemUpdateInput input) - { - var menuItem = await MenuItemRepository.GetAsync(id); - - if (input.PageId.HasValue) - { - MenuManager.SetPageUrl(menuItem, await PageRepository.GetAsync(input.PageId.Value)); - } - else - { - menuItem.SetUrl(input.Url); - } - - menuItem.SetDisplayName(input.DisplayName); - menuItem.IsActive = input.IsActive; - menuItem.Icon = input.Icon; - menuItem.Target = input.Target; - menuItem.ElementId = input.ElementId; - menuItem.CssClass = input.CssClass; - menuItem.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); - - await MenuItemRepository.UpdateAsync(menuItem); - - return ObjectMapper.Map(menuItem); - } + return ObjectMapper.Map(menuItem); + } + + [Authorize(CmsKitAdminPermissions.Menus.Update)] + public virtual async Task UpdateAsync(Guid id, MenuItemUpdateInput input) + { + var menuItem = await MenuItemRepository.GetAsync(id); - [Authorize(CmsKitAdminPermissions.Menus.Delete)] - public virtual Task DeleteAsync(Guid id) + if (input.PageId.HasValue) { - return MenuItemRepository.DeleteAsync(id); + MenuManager.SetPageUrl(menuItem, await PageRepository.GetAsync(input.PageId.Value)); } - - [Authorize(CmsKitAdminPermissions.Menus.Update)] - public virtual Task MoveMenuItemAsync(Guid id, MenuItemMoveInput input) + else { - return MenuManager.MoveAsync(id, input.NewParentId, input.Position); + menuItem.SetUrl(input.Url); } - public virtual async Task> GetPageLookupAsync(PageLookupInputDto input) - { - var count = await PageRepository.GetCountAsync(input.Filter); + menuItem.SetDisplayName(input.DisplayName); + menuItem.IsActive = input.IsActive; + menuItem.Icon = input.Icon; + menuItem.Target = input.Target; + menuItem.ElementId = input.ElementId; + menuItem.CssClass = input.CssClass; + menuItem.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); - var pages = await PageRepository.GetListAsync( - input.Filter, - input.MaxResultCount, - input.SkipCount, - input.Sorting - ); + await MenuItemRepository.UpdateAsync(menuItem); - return new PagedResultDto( - count, - ObjectMapper.Map, List>(pages) - ); - } + return ObjectMapper.Map(menuItem); + } + + [Authorize(CmsKitAdminPermissions.Menus.Delete)] + public virtual Task DeleteAsync(Guid id) + { + return MenuItemRepository.DeleteAsync(id); + } + + [Authorize(CmsKitAdminPermissions.Menus.Update)] + public virtual Task MoveMenuItemAsync(Guid id, MenuItemMoveInput input) + { + return MenuManager.MoveAsync(id, input.NewParentId, input.Position); + } + + public virtual async Task> GetPageLookupAsync(PageLookupInputDto input) + { + var count = await PageRepository.GetCountAsync(input.Filter); + + var pages = await PageRepository.GetListAsync( + input.Filter, + input.MaxResultCount, + input.SkipCount, + input.Sorting + ); + + return new PagedResultDto( + count, + ObjectMapper.Map, List>(pages) + ); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Pages/PageAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Pages/PageAdminAppService.cs index f04f2bc9b6..68f0690555 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Pages/PageAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Pages/PageAdminAppService.cs @@ -11,79 +11,78 @@ using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Pages; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Pages +namespace Volo.CmsKit.Admin.Pages; + +[RequiresGlobalFeature(typeof(PagesFeature))] +[Authorize(CmsKitAdminPermissions.Pages.Default)] +public class PageAdminAppService : CmsKitAdminAppServiceBase, IPageAdminAppService { - [RequiresGlobalFeature(typeof(PagesFeature))] - [Authorize(CmsKitAdminPermissions.Pages.Default)] - public class PageAdminAppService : CmsKitAdminAppServiceBase, IPageAdminAppService + protected IPageRepository PageRepository { get; } + + protected PageManager PageManager { get; } + + public PageAdminAppService( + IPageRepository pageRepository, + PageManager pageManager) + { + PageRepository = pageRepository; + PageManager = pageManager; + } + + public virtual async Task GetAsync(Guid id) + { + var page = await PageRepository.GetAsync(id); + return ObjectMapper.Map(page); + } + + public virtual async Task> GetListAsync(GetPagesInputDto input) + { + var count = await PageRepository.GetCountAsync(input.Filter); + + var pages = await PageRepository.GetListAsync( + input.Filter, + input.MaxResultCount, + input.SkipCount, + input.Sorting + ); + + return new PagedResultDto( + count, + ObjectMapper.Map, List>(pages) + ); + } + + [Authorize(CmsKitAdminPermissions.Pages.Create)] + public virtual async Task CreateAsync(CreatePageInputDto input) + { + var page = await PageManager.CreateAsync(input.Title, input.Slug, input.Content, input.Script, input.Style); + + await PageRepository.InsertAsync(page); + + return ObjectMapper.Map(page); + } + + [Authorize(CmsKitAdminPermissions.Pages.Update)] + public virtual async Task UpdateAsync(Guid id, UpdatePageInputDto input) + { + var page = await PageRepository.GetAsync(id); + + await PageManager.SetSlugAsync(page, input.Slug); + + page.SetTitle(input.Title); + page.SetContent(input.Content); + page.SetScript(input.Script); + page.SetStyle(input.Style); + page.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); + + await PageRepository.UpdateAsync(page); + + return ObjectMapper.Map(page); + } + + [Authorize(CmsKitAdminPermissions.Pages.Delete)] + public virtual async Task DeleteAsync(Guid id) { - protected IPageRepository PageRepository { get; } - - protected PageManager PageManager { get; } - - public PageAdminAppService( - IPageRepository pageRepository, - PageManager pageManager) - { - PageRepository = pageRepository; - PageManager = pageManager; - } - - public virtual async Task GetAsync(Guid id) - { - var page = await PageRepository.GetAsync(id); - return ObjectMapper.Map(page); - } - - public virtual async Task> GetListAsync(GetPagesInputDto input) - { - var count = await PageRepository.GetCountAsync(input.Filter); - - var pages = await PageRepository.GetListAsync( - input.Filter, - input.MaxResultCount, - input.SkipCount, - input.Sorting - ); - - return new PagedResultDto( - count, - ObjectMapper.Map, List>(pages) - ); - } - - [Authorize(CmsKitAdminPermissions.Pages.Create)] - public virtual async Task CreateAsync(CreatePageInputDto input) - { - var page = await PageManager.CreateAsync(input.Title, input.Slug, input.Content, input.Script, input.Style); - - await PageRepository.InsertAsync(page); - - return ObjectMapper.Map(page); - } - - [Authorize(CmsKitAdminPermissions.Pages.Update)] - public virtual async Task UpdateAsync(Guid id, UpdatePageInputDto input) - { - var page = await PageRepository.GetAsync(id); - - await PageManager.SetSlugAsync(page, input.Slug); - - page.SetTitle(input.Title); - page.SetContent(input.Content); - page.SetScript(input.Script); - page.SetStyle(input.Style); - page.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); - - await PageRepository.UpdateAsync(page); - - return ObjectMapper.Map(page); - } - - [Authorize(CmsKitAdminPermissions.Pages.Delete)] - public virtual async Task DeleteAsync(Guid id) - { - await PageRepository.DeleteAsync(id); - } + await PageRepository.DeleteAsync(id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/EntityTagAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/EntityTagAdminAppService.cs index 221b32a245..8d106b70e0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/EntityTagAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/EntityTagAdminAppService.cs @@ -3,66 +3,65 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +[RequiresGlobalFeature(typeof(TagsFeature))] +public class EntityTagAdminAppService : CmsKitAdminAppServiceBase, IEntityTagAdminAppService { - [RequiresGlobalFeature(typeof(TagsFeature))] - public class EntityTagAdminAppService : CmsKitAdminAppServiceBase, IEntityTagAdminAppService - { - protected ITagDefinitionStore TagDefinitionStore { get; } - protected EntityTagManager EntityTagManager { get; } - protected TagManager TagManager { get; } - protected ITagRepository TagRepository { get; } - protected IEntityTagRepository EntityTagRepository { get; } + protected ITagDefinitionStore TagDefinitionStore { get; } + protected EntityTagManager EntityTagManager { get; } + protected TagManager TagManager { get; } + protected ITagRepository TagRepository { get; } + protected IEntityTagRepository EntityTagRepository { get; } - public EntityTagAdminAppService( - ITagDefinitionStore tagDefinitionStore, - EntityTagManager entityTagManager, - TagManager tagManager, - ITagRepository tagRepository, - IEntityTagRepository entityTagRepository) - { - TagDefinitionStore = tagDefinitionStore; - EntityTagManager = entityTagManager; - TagManager = tagManager; - TagRepository = tagRepository; - EntityTagRepository = entityTagRepository; - } + public EntityTagAdminAppService( + ITagDefinitionStore tagDefinitionStore, + EntityTagManager entityTagManager, + TagManager tagManager, + ITagRepository tagRepository, + IEntityTagRepository entityTagRepository) + { + TagDefinitionStore = tagDefinitionStore; + EntityTagManager = entityTagManager; + TagManager = tagManager; + TagRepository = tagRepository; + EntityTagRepository = entityTagRepository; + } - public virtual async Task AddTagToEntityAsync(EntityTagCreateDto input) - { - var definition = await TagDefinitionStore.GetAsync(input.EntityType); + public virtual async Task AddTagToEntityAsync(EntityTagCreateDto input) + { + var definition = await TagDefinitionStore.GetAsync(input.EntityType); - await CheckAnyOfPoliciesAsync(definition.CreatePolicies); + await CheckAnyOfPoliciesAsync(definition.CreatePolicies); - var tag = await TagManager.GetOrAddAsync(input.EntityType, input.TagName); + var tag = await TagManager.GetOrAddAsync(input.EntityType, input.TagName); - await EntityTagManager.AddTagToEntityAsync( - tag.Id, - input.EntityType, - input.EntityId, - CurrentTenant?.Id); - } + await EntityTagManager.AddTagToEntityAsync( + tag.Id, + input.EntityType, + input.EntityId, + CurrentTenant?.Id); + } - public virtual async Task RemoveTagFromEntityAsync(EntityTagRemoveDto input) - { - var definition = await TagDefinitionStore.GetAsync(input.EntityType); + public virtual async Task RemoveTagFromEntityAsync(EntityTagRemoveDto input) + { + var definition = await TagDefinitionStore.GetAsync(input.EntityType); - await CheckAnyOfPoliciesAsync(definition.DeletePolicies); + await CheckAnyOfPoliciesAsync(definition.DeletePolicies); - await EntityTagManager.RemoveTagFromEntityAsync( - input.TagId, - input.EntityType, - input.EntityId, - CurrentTenant?.Id); - } + await EntityTagManager.RemoveTagFromEntityAsync( + input.TagId, + input.EntityType, + input.EntityId, + CurrentTenant?.Id); + } - public virtual async Task SetEntityTagsAsync(EntityTagSetDto input) - { - var definition = await TagDefinitionStore.GetAsync(input.EntityType); + public virtual async Task SetEntityTagsAsync(EntityTagSetDto input) + { + var definition = await TagDefinitionStore.GetAsync(input.EntityType); - await CheckAnyOfPoliciesAsync(definition.UpdatePolicies); + await CheckAnyOfPoliciesAsync(definition.UpdatePolicies); - await EntityTagManager.SetEntityTagsAsync(input.EntityType, input.EntityId, input.Tags); - } + await EntityTagManager.SetEntityTagsAsync(input.EntityType, input.EntityId, input.Tags); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/TagAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/TagAdminAppService.cs index f5e9e0f7dd..f6de1ac5b9 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/TagAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/TagAdminAppService.cs @@ -11,95 +11,94 @@ using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +[Authorize(CmsKitAdminPermissions.Tags.Default)] +[RequiresGlobalFeature(typeof(TagsFeature))] +public class TagAdminAppService : CmsKitAppServiceBase, ITagAdminAppService { + protected ITagRepository Repository { get; } + protected TagManager TagManager { get; } + protected ITagDefinitionStore TagDefinitionStore { get; } + protected IStringLocalizerFactory StringLocalizerFactory { get; } + + public TagAdminAppService( + ITagRepository repository, + TagManager tagManager, + ITagDefinitionStore tagDefinitionStore, + IStringLocalizerFactory stringLocalizerFactory) + { + Repository = repository; + TagManager = tagManager; + TagDefinitionStore = tagDefinitionStore; + StringLocalizerFactory = stringLocalizerFactory; + } + + [Authorize(CmsKitAdminPermissions.Tags.Create)] + public async Task CreateAsync(TagCreateDto input) + { + var tag = await TagManager.CreateAsync( + GuidGenerator.Create(), + input.EntityType, + input.Name); + + await Repository.InsertAsync(tag); + + return ObjectMapper.Map(tag); + } + + [Authorize(CmsKitAdminPermissions.Tags.Update)] + public async Task UpdateAsync(Guid id, TagUpdateDto input) + { + var tag = await TagManager.UpdateAsync( + id, + input.Name); + + tag.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); + + await Repository.UpdateAsync(tag); + + return ObjectMapper.Map(tag); + } + + [Authorize(CmsKitAdminPermissions.Tags.Default)] + public virtual async Task> GetTagDefinitionsAsync() + { + var definitions = await TagDefinitionStore.GetTagEntityTypeDefinitionListAsync(); + + return definitions + .Select(s => + new TagDefinitionDto + { + EntityType = s.EntityType, + DisplayName = s.DisplayName?.Localize(StringLocalizerFactory) ?? s.EntityType + }) + .ToList(); + } + + [Authorize(CmsKitAdminPermissions.Tags.Default)] + public async Task GetAsync(Guid id) + { + var tag = await Repository.GetAsync(id); + + return ObjectMapper.Map(tag); + } + [Authorize(CmsKitAdminPermissions.Tags.Default)] - [RequiresGlobalFeature(typeof(TagsFeature))] - public class TagAdminAppService : CmsKitAppServiceBase, ITagAdminAppService + public async Task> GetListAsync(TagGetListInput input) + { + var tags = await Repository.GetListAsync(input.Filter); + var count = await Repository.GetCountAsync(input.Filter); + + return new PagedResultDto( + count, + ObjectMapper.Map, List>(tags) + ); + } + + [Authorize(CmsKitAdminPermissions.Tags.Delete)] + public async Task DeleteAsync(Guid id) { - protected ITagRepository Repository { get; } - protected TagManager TagManager { get; } - protected ITagDefinitionStore TagDefinitionStore { get; } - protected IStringLocalizerFactory StringLocalizerFactory { get; } - - public TagAdminAppService( - ITagRepository repository, - TagManager tagManager, - ITagDefinitionStore tagDefinitionStore, - IStringLocalizerFactory stringLocalizerFactory) - { - Repository = repository; - TagManager = tagManager; - TagDefinitionStore = tagDefinitionStore; - StringLocalizerFactory = stringLocalizerFactory; - } - - [Authorize(CmsKitAdminPermissions.Tags.Create)] - public async Task CreateAsync(TagCreateDto input) - { - var tag = await TagManager.CreateAsync( - GuidGenerator.Create(), - input.EntityType, - input.Name); - - await Repository.InsertAsync(tag); - - return ObjectMapper.Map(tag); - } - - [Authorize(CmsKitAdminPermissions.Tags.Update)] - public async Task UpdateAsync(Guid id, TagUpdateDto input) - { - var tag = await TagManager.UpdateAsync( - id, - input.Name); - - tag.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); - - await Repository.UpdateAsync(tag); - - return ObjectMapper.Map(tag); - } - - [Authorize(CmsKitAdminPermissions.Tags.Default)] - public virtual async Task> GetTagDefinitionsAsync() - { - var definitions = await TagDefinitionStore.GetTagEntityTypeDefinitionListAsync(); - - return definitions - .Select(s => - new TagDefinitionDto - { - EntityType = s.EntityType, - DisplayName = s.DisplayName?.Localize(StringLocalizerFactory) ?? s.EntityType - }) - .ToList(); - } - - [Authorize(CmsKitAdminPermissions.Tags.Default)] - public async Task GetAsync(Guid id) - { - var tag = await Repository.GetAsync(id); - - return ObjectMapper.Map(tag); - } - - [Authorize(CmsKitAdminPermissions.Tags.Default)] - public async Task> GetListAsync(TagGetListInput input) - { - var tags = await Repository.GetListAsync(input.Filter); - var count = await Repository.GetCountAsync(input.Filter); - - return new PagedResultDto( - count, - ObjectMapper.Map, List>(tags) - ); - } - - [Authorize(CmsKitAdminPermissions.Tags.Delete)] - public async Task DeleteAsync(Guid id) - { - await Repository.DeleteAsync(id); - } + await Repository.DeleteAsync(id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogAdminClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogAdminClientProxy.cs index 011293a94c..35361cdfea 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogAdminClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogAdminClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of BlogAdminClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Admin.Blogs.ClientProxies +namespace Volo.CmsKit.Admin.Blogs.ClientProxies; + +public partial class BlogAdminClientProxy { - public partial class BlogAdminClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogFeatureAdminClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogFeatureAdminClientProxy.cs index df8ec24179..1d4a61cf8d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogFeatureAdminClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogFeatureAdminClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of BlogFeatureAdminClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Admin.Blogs.ClientProxies +namespace Volo.CmsKit.Admin.Blogs.ClientProxies; + +public partial class BlogFeatureAdminClientProxy { - public partial class BlogFeatureAdminClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogPostAdminClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogPostAdminClientProxy.cs index d6c0b35d15..e9edd5b710 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogPostAdminClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/BlogPostAdminClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of BlogPostAdminClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Admin.Blogs.ClientProxies +namespace Volo.CmsKit.Admin.Blogs.ClientProxies; + +public partial class BlogPostAdminClientProxy { - public partial class BlogPostAdminClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/CommentAdminClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/CommentAdminClientProxy.cs index 28575f6ed5..cc815bc052 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/CommentAdminClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/CommentAdminClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of CommentAdminClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Admin.Comments.ClientProxies +namespace Volo.CmsKit.Admin.Comments.ClientProxies; + +public partial class CommentAdminClientProxy { - public partial class CommentAdminClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/EntityTagAdminClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/EntityTagAdminClientProxy.cs index bf7f82fb70..08cf572c9d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/EntityTagAdminClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/EntityTagAdminClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of EntityTagAdminClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Admin.Tags.ClientProxies +namespace Volo.CmsKit.Admin.Tags.ClientProxies; + +public partial class EntityTagAdminClientProxy { - public partial class EntityTagAdminClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/MediaDescriptorAdminClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/MediaDescriptorAdminClientProxy.cs index ff80b86764..ebf76040da 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/MediaDescriptorAdminClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/MediaDescriptorAdminClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of MediaDescriptorAdminClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Admin.MediaDescriptors.ClientProxies +namespace Volo.CmsKit.Admin.MediaDescriptors.ClientProxies; + +public partial class MediaDescriptorAdminClientProxy { - public partial class MediaDescriptorAdminClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/MenuItemAdminClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/MenuItemAdminClientProxy.cs index d015dc2969..861b3f6082 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/MenuItemAdminClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/MenuItemAdminClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of MenuItemAdminClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Admin.Menus.ClientProxies +namespace Volo.CmsKit.Admin.Menus.ClientProxies; + +public partial class MenuItemAdminClientProxy { - public partial class MenuItemAdminClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/PageAdminClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/PageAdminClientProxy.cs index 8fed767228..c9d87b3ead 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/PageAdminClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/PageAdminClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of PageAdminClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Admin.Pages.ClientProxies +namespace Volo.CmsKit.Admin.Pages.ClientProxies; + +public partial class PageAdminClientProxy { - public partial class PageAdminClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/TagAdminClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/TagAdminClientProxy.cs index 49e3b72a04..fe63cfa72f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/TagAdminClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/ClientProxies/TagAdminClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of TagAdminClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Admin.Tags.ClientProxies +namespace Volo.CmsKit.Admin.Tags.ClientProxies; + +public partial class TagAdminClientProxy { - public partial class TagAdminClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/Volo/CmsKit/Admin/CmsKitAdminHttpApiClientModule.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/Volo/CmsKit/Admin/CmsKitAdminHttpApiClientModule.cs index 7cf32ec051..3d587dd2f0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/Volo/CmsKit/Admin/CmsKitAdminHttpApiClientModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi.Client/Volo/CmsKit/Admin/CmsKitAdminHttpApiClientModule.cs @@ -3,24 +3,23 @@ using Volo.Abp.Http.Client; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; -namespace Volo.CmsKit.Admin +namespace Volo.CmsKit.Admin; + +[DependsOn( + typeof(CmsKitAdminApplicationContractsModule), + typeof(CmsKitCommonHttpApiClientModule))] +public class CmsKitAdminHttpApiClientModule : AbpModule { - [DependsOn( - typeof(CmsKitAdminApplicationContractsModule), - typeof(CmsKitCommonHttpApiClientModule))] - public class CmsKitAdminHttpApiClientModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddStaticHttpClientProxies( - typeof(CmsKitAdminApplicationContractsModule).Assembly, - CmsKitAdminRemoteServiceConsts.RemoteServiceName - ); + context.Services.AddStaticHttpClientProxies( + typeof(CmsKitAdminApplicationContractsModule).Assembly, + CmsKitAdminRemoteServiceConsts.RemoteServiceName + ); - Configure(options => - { - options.FileSets.AddEmbedded(); - }); - } + Configure(options => + { + options.FileSets.AddEmbedded(); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogAdminController.cs index bf538276d0..094c1b1b5a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogAdminController.cs @@ -8,56 +8,55 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[RequiresGlobalFeature(typeof(BlogsFeature))] +[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitAdminRemoteServiceConsts.ModuleName)] +[Authorize(CmsKitAdminPermissions.Blogs.Default)] +[Route("api/cms-kit-admin/blogs")] +public class BlogAdminController : CmsKitAdminController, IBlogAdminAppService { - [RequiresGlobalFeature(typeof(BlogsFeature))] - [RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitAdminRemoteServiceConsts.ModuleName)] - [Authorize(CmsKitAdminPermissions.Blogs.Default)] - [Route("api/cms-kit-admin/blogs")] - public class BlogAdminController : CmsKitAdminController, IBlogAdminAppService + protected IBlogAdminAppService BlogAdminAppService { get; } + + public BlogAdminController(IBlogAdminAppService blogAdminAppService) + { + BlogAdminAppService = blogAdminAppService; + } + + [HttpGet] + [Route("{id}")] + public Task GetAsync(Guid id) + { + return BlogAdminAppService.GetAsync(id); + } + + [HttpGet] + public Task> GetListAsync(BlogGetListInput input) + { + return BlogAdminAppService.GetListAsync(input); + } + + [HttpPost] + [Authorize(CmsKitAdminPermissions.Blogs.Create)] + public Task CreateAsync(CreateBlogDto input) + { + return BlogAdminAppService.CreateAsync(input); + } + + [HttpPut] + [Route("{id}")] + [Authorize(CmsKitAdminPermissions.Blogs.Update)] + public Task UpdateAsync(Guid id, UpdateBlogDto input) + { + return BlogAdminAppService.UpdateAsync(id, input); + } + + [HttpDelete] + [Route("{id}")] + [Authorize(CmsKitAdminPermissions.Blogs.Delete)] + public Task DeleteAsync(Guid id) { - protected IBlogAdminAppService BlogAdminAppService { get; } - - public BlogAdminController(IBlogAdminAppService blogAdminAppService) - { - BlogAdminAppService = blogAdminAppService; - } - - [HttpGet] - [Route("{id}")] - public Task GetAsync(Guid id) - { - return BlogAdminAppService.GetAsync(id); - } - - [HttpGet] - public Task> GetListAsync(BlogGetListInput input) - { - return BlogAdminAppService.GetListAsync(input); - } - - [HttpPost] - [Authorize(CmsKitAdminPermissions.Blogs.Create)] - public Task CreateAsync(CreateBlogDto input) - { - return BlogAdminAppService.CreateAsync(input); - } - - [HttpPut] - [Route("{id}")] - [Authorize(CmsKitAdminPermissions.Blogs.Update)] - public Task UpdateAsync(Guid id, UpdateBlogDto input) - { - return BlogAdminAppService.UpdateAsync(id, input); - } - - [HttpDelete] - [Route("{id}")] - [Authorize(CmsKitAdminPermissions.Blogs.Delete)] - public Task DeleteAsync(Guid id) - { - return BlogAdminAppService.DeleteAsync(id); - } + return BlogAdminAppService.DeleteAsync(id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminController.cs index bb8dcd4fa6..e3cc3c5e73 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminController.cs @@ -9,32 +9,31 @@ using Volo.CmsKit.Blogs; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[RequiresGlobalFeature(typeof(BlogsFeature))] +[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitAdminRemoteServiceConsts.ModuleName)] +[Authorize(CmsKitAdminPermissions.Blogs.Features)] +[Route("api/cms-kit-admin/blogs/{blogId}/features")] +public class BlogFeatureAdminController : CmsKitAdminController, IBlogFeatureAdminAppService { - [RequiresGlobalFeature(typeof(BlogsFeature))] - [RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitAdminRemoteServiceConsts.ModuleName)] - [Authorize(CmsKitAdminPermissions.Blogs.Features)] - [Route("api/cms-kit-admin/blogs/{blogId}/features")] - public class BlogFeatureAdminController : CmsKitAdminController, IBlogFeatureAdminAppService - { - protected IBlogFeatureAdminAppService BlogFeatureAdminAppService { get; } + protected IBlogFeatureAdminAppService BlogFeatureAdminAppService { get; } - public BlogFeatureAdminController(IBlogFeatureAdminAppService blogFeatureAdminAppService) - { - BlogFeatureAdminAppService = blogFeatureAdminAppService; - } + public BlogFeatureAdminController(IBlogFeatureAdminAppService blogFeatureAdminAppService) + { + BlogFeatureAdminAppService = blogFeatureAdminAppService; + } - [HttpGet] - public Task> GetListAsync(Guid blogId) - { - return BlogFeatureAdminAppService.GetListAsync(blogId); - } + [HttpGet] + public Task> GetListAsync(Guid blogId) + { + return BlogFeatureAdminAppService.GetListAsync(blogId); + } - [HttpPut] - public Task SetAsync(Guid blogId, BlogFeatureInputDto dto) - { - return BlogFeatureAdminAppService.SetAsync(blogId, dto); - } + [HttpPut] + public Task SetAsync(Guid blogId, BlogFeatureInputDto dto) + { + return BlogFeatureAdminAppService.SetAsync(blogId, dto); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogPostAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogPostAdminController.cs index d8e442553f..51b201349a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogPostAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogPostAdminController.cs @@ -8,58 +8,57 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Blogs +namespace Volo.CmsKit.Admin.Blogs; + +[RequiresGlobalFeature(typeof(BlogsFeature))] +[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitAdminRemoteServiceConsts.ModuleName)] +[Authorize(CmsKitAdminPermissions.BlogPosts.Default)] +[Route("api/cms-kit-admin/blogs/blog-posts")] +public class BlogPostAdminController : CmsKitAdminController, IBlogPostAdminAppService { - [RequiresGlobalFeature(typeof(BlogsFeature))] - [RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitAdminRemoteServiceConsts.ModuleName)] - [Authorize(CmsKitAdminPermissions.BlogPosts.Default)] - [Route("api/cms-kit-admin/blogs/blog-posts")] - public class BlogPostAdminController : CmsKitAdminController, IBlogPostAdminAppService + protected readonly IBlogPostAdminAppService BlogPostAdminAppService; + + public BlogPostAdminController(IBlogPostAdminAppService blogPostAdminAppService) { - protected readonly IBlogPostAdminAppService BlogPostAdminAppService; + BlogPostAdminAppService = blogPostAdminAppService; + } - public BlogPostAdminController(IBlogPostAdminAppService blogPostAdminAppService) - { - BlogPostAdminAppService = blogPostAdminAppService; - } + [HttpPost] + [Authorize(CmsKitAdminPermissions.BlogPosts.Create)] + public virtual Task CreateAsync(CreateBlogPostDto input) + { + return BlogPostAdminAppService.CreateAsync(input); + } - [HttpPost] - [Authorize(CmsKitAdminPermissions.BlogPosts.Create)] - public virtual Task CreateAsync(CreateBlogPostDto input) - { - return BlogPostAdminAppService.CreateAsync(input); - } + [HttpDelete] + [Route("{id}")] + [Authorize(CmsKitAdminPermissions.BlogPosts.Delete)] + public virtual Task DeleteAsync(Guid id) + { + return BlogPostAdminAppService.DeleteAsync(id); + } - [HttpDelete] - [Route("{id}")] - [Authorize(CmsKitAdminPermissions.BlogPosts.Delete)] - public virtual Task DeleteAsync(Guid id) - { - return BlogPostAdminAppService.DeleteAsync(id); - } + [HttpGet] + [Route("{id:Guid}")] + [Authorize(CmsKitAdminPermissions.BlogPosts.Default)] + public virtual Task GetAsync(Guid id) + { + return BlogPostAdminAppService.GetAsync(id); + } - [HttpGet] - [Route("{id:Guid}")] - [Authorize(CmsKitAdminPermissions.BlogPosts.Default)] - public virtual Task GetAsync(Guid id) - { - return BlogPostAdminAppService.GetAsync(id); - } + [HttpGet] + [Authorize(CmsKitAdminPermissions.BlogPosts.Default)] + public virtual Task> GetListAsync(BlogPostGetListInput input) + { + return BlogPostAdminAppService.GetListAsync(input); + } - [HttpGet] - [Authorize(CmsKitAdminPermissions.BlogPosts.Default)] - public virtual Task> GetListAsync(BlogPostGetListInput input) - { - return BlogPostAdminAppService.GetListAsync(input); - } - - [HttpPut] - [Route("{id}")] - [Authorize(CmsKitAdminPermissions.BlogPosts.Update)] - public virtual Task UpdateAsync(Guid id, UpdateBlogPostDto input) - { - return BlogPostAdminAppService.UpdateAsync(id, input); - } + [HttpPut] + [Route("{id}")] + [Authorize(CmsKitAdminPermissions.BlogPosts.Update)] + public virtual Task UpdateAsync(Guid id, UpdateBlogPostDto input) + { + return BlogPostAdminAppService.UpdateAsync(id, input); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/CmsKitAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/CmsKitAdminController.cs index fc89a0c63b..4f174b1192 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/CmsKitAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/CmsKitAdminController.cs @@ -1,13 +1,12 @@ using Volo.Abp.AspNetCore.Mvc; using Volo.CmsKit.Localization; -namespace Volo.CmsKit.Admin +namespace Volo.CmsKit.Admin; + +public abstract class CmsKitAdminController : AbpControllerBase { - public abstract class CmsKitAdminController : AbpControllerBase + protected CmsKitAdminController() { - protected CmsKitAdminController() - { - LocalizationResource = typeof(CmsKitResource); - } + LocalizationResource = typeof(CmsKitResource); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/CmsKitAdminHttpApiModule.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/CmsKitAdminHttpApiModule.cs index bb573d55e6..5513a0bf99 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/CmsKitAdminHttpApiModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/CmsKitAdminHttpApiModule.cs @@ -3,28 +3,27 @@ using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Modularity; using Volo.CmsKit.Admin.MediaDescriptors; -namespace Volo.CmsKit.Admin +namespace Volo.CmsKit.Admin; + +[DependsOn( + typeof(CmsKitAdminApplicationContractsModule), + typeof(CmsKitCommonHttpApiModule) + )] +public class CmsKitAdminHttpApiModule : AbpModule { - [DependsOn( - typeof(CmsKitAdminApplicationContractsModule), - typeof(CmsKitCommonHttpApiModule) - )] - public class CmsKitAdminHttpApiModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + PreConfigure(mvcBuilder => { - PreConfigure(mvcBuilder => - { - mvcBuilder.AddApplicationPartIfNotExists(typeof(CmsKitAdminHttpApiModule).Assembly); - }); - } + mvcBuilder.AddApplicationPartIfNotExists(typeof(CmsKitAdminHttpApiModule).Assembly); + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.ConventionalControllers.FormBodyBindingIgnoredTypes.Add(typeof(CreateMediaInputWithStream)); - }); - } + options.ConventionalControllers.FormBodyBindingIgnoredTypes.Add(typeof(CreateMediaInputWithStream)); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs index efa9876f7d..6082ad3794 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs @@ -8,41 +8,40 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Comments +namespace Volo.CmsKit.Admin.Comments; + +[Authorize(CmsKitAdminPermissions.Comments.Default)] +[RequiresGlobalFeature(typeof(CommentsFeature))] +[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitAdminRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit-admin/comments")] +public class CommentAdminController : CmsKitAdminController, ICommentAdminAppService { - [Authorize(CmsKitAdminPermissions.Comments.Default)] - [RequiresGlobalFeature(typeof(CommentsFeature))] - [RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitAdminRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit-admin/comments")] - public class CommentAdminController : CmsKitAdminController, ICommentAdminAppService - { - protected ICommentAdminAppService CommentAdminAppService { get; } + protected ICommentAdminAppService CommentAdminAppService { get; } - public CommentAdminController(ICommentAdminAppService commentAdminAppService) - { - CommentAdminAppService = commentAdminAppService; - } + public CommentAdminController(ICommentAdminAppService commentAdminAppService) + { + CommentAdminAppService = commentAdminAppService; + } - [HttpGet] - public virtual Task> GetListAsync(CommentGetListInput input) - { - return CommentAdminAppService.GetListAsync(input); - } + [HttpGet] + public virtual Task> GetListAsync(CommentGetListInput input) + { + return CommentAdminAppService.GetListAsync(input); + } - [HttpGet] - [Route("{id}")] - public virtual Task GetAsync(Guid id) - { - return CommentAdminAppService.GetAsync(id); - } + [HttpGet] + [Route("{id}")] + public virtual Task GetAsync(Guid id) + { + return CommentAdminAppService.GetAsync(id); + } - [HttpDelete] - [Route("{id}")] - [Authorize(CmsKitAdminPermissions.Comments.Delete)] - public virtual Task DeleteAsync(Guid id) - { - return CommentAdminAppService.DeleteAsync(id); - } + [HttpDelete] + [Route("{id}")] + [Authorize(CmsKitAdminPermissions.Comments.Delete)] + public virtual Task DeleteAsync(Guid id) + { + return CommentAdminAppService.DeleteAsync(id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorAdminController.cs index 1495af2121..f95d2a86b2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorAdminController.cs @@ -9,33 +9,32 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.MediaDescriptors +namespace Volo.CmsKit.Admin.MediaDescriptors; + +[RequiresGlobalFeature(typeof(MediaFeature))] +[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitAdminRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit-admin/media")] +public class MediaDescriptorAdminController : CmsKitAdminController, IMediaDescriptorAdminAppService { - [RequiresGlobalFeature(typeof(MediaFeature))] - [RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitAdminRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit-admin/media")] - public class MediaDescriptorAdminController : CmsKitAdminController, IMediaDescriptorAdminAppService - { - protected readonly IMediaDescriptorAdminAppService MediaDescriptorAdminAppService; + protected readonly IMediaDescriptorAdminAppService MediaDescriptorAdminAppService; - public MediaDescriptorAdminController(IMediaDescriptorAdminAppService mediaDescriptorAdminAppService) - { - MediaDescriptorAdminAppService = mediaDescriptorAdminAppService; - } + public MediaDescriptorAdminController(IMediaDescriptorAdminAppService mediaDescriptorAdminAppService) + { + MediaDescriptorAdminAppService = mediaDescriptorAdminAppService; + } - [HttpPost] - [Route("{entityType}")] - public virtual Task CreateAsync(string entityType, CreateMediaInputWithStream inputStream) - { - return MediaDescriptorAdminAppService.CreateAsync(entityType, inputStream); - } + [HttpPost] + [Route("{entityType}")] + public virtual Task CreateAsync(string entityType, CreateMediaInputWithStream inputStream) + { + return MediaDescriptorAdminAppService.CreateAsync(entityType, inputStream); + } - [HttpDelete] - [Route("{id}")] - public virtual Task DeleteAsync(Guid id) - { - return MediaDescriptorAdminAppService.DeleteAsync(id); - } + [HttpDelete] + [Route("{id}")] + public virtual Task DeleteAsync(Guid id) + { + return MediaDescriptorAdminAppService.DeleteAsync(id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Menus/MenuItemAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Menus/MenuItemAdminController.cs index b83c5f962c..de36883ff7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Menus/MenuItemAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Menus/MenuItemAdminController.cs @@ -9,71 +9,70 @@ using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Menus; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Menus +namespace Volo.CmsKit.Admin.Menus; + +[RequiresGlobalFeature(typeof(MenuFeature))] +[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitAdminRemoteServiceConsts.ModuleName)] +[Authorize(CmsKitAdminPermissions.Menus.Default)] +[Route("api/cms-kit-admin/menu-items")] +public class MenuItemAdminController : CmsKitAdminController, IMenuItemAdminAppService { - [RequiresGlobalFeature(typeof(MenuFeature))] - [RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitAdminRemoteServiceConsts.ModuleName)] - [Authorize(CmsKitAdminPermissions.Menus.Default)] - [Route("api/cms-kit-admin/menu-items")] - public class MenuItemAdminController : CmsKitAdminController, IMenuItemAdminAppService - { - protected IMenuItemAdminAppService MenuItemAdminAppService { get; } + protected IMenuItemAdminAppService MenuItemAdminAppService { get; } - public MenuItemAdminController(IMenuItemAdminAppService menuAdminAppService) - { - MenuItemAdminAppService = menuAdminAppService; - } + public MenuItemAdminController(IMenuItemAdminAppService menuAdminAppService) + { + MenuItemAdminAppService = menuAdminAppService; + } - [HttpGet] - public virtual Task> GetListAsync() - { - return MenuItemAdminAppService.GetListAsync(); - } + [HttpGet] + public virtual Task> GetListAsync() + { + return MenuItemAdminAppService.GetListAsync(); + } - [HttpGet] - [Route("{id}")] - public virtual Task GetAsync(Guid id) - { - return MenuItemAdminAppService.GetAsync(id); - } + [HttpGet] + [Route("{id}")] + public virtual Task GetAsync(Guid id) + { + return MenuItemAdminAppService.GetAsync(id); + } - [HttpPost] - [Authorize(CmsKitAdminPermissions.Menus.Create)] - public virtual Task CreateAsync(MenuItemCreateInput input) - { - return MenuItemAdminAppService.CreateAsync(input); - } + [HttpPost] + [Authorize(CmsKitAdminPermissions.Menus.Create)] + public virtual Task CreateAsync(MenuItemCreateInput input) + { + return MenuItemAdminAppService.CreateAsync(input); + } - [HttpPut] - [Route("{id}")] - [Authorize(CmsKitAdminPermissions.Menus.Update)] - public virtual Task UpdateAsync(Guid id, MenuItemUpdateInput input) - { - return MenuItemAdminAppService.UpdateAsync(id, input); - } + [HttpPut] + [Route("{id}")] + [Authorize(CmsKitAdminPermissions.Menus.Update)] + public virtual Task UpdateAsync(Guid id, MenuItemUpdateInput input) + { + return MenuItemAdminAppService.UpdateAsync(id, input); + } - [HttpDelete] - [Route("{id}")] - [Authorize(CmsKitAdminPermissions.Menus.Delete)] - public virtual Task DeleteAsync(Guid id) - { - return MenuItemAdminAppService.DeleteAsync(id); - } + [HttpDelete] + [Route("{id}")] + [Authorize(CmsKitAdminPermissions.Menus.Delete)] + public virtual Task DeleteAsync(Guid id) + { + return MenuItemAdminAppService.DeleteAsync(id); + } - [HttpPut] - [Route("{id}/move")] - [Authorize(CmsKitAdminPermissions.Menus.Update)] - public virtual Task MoveMenuItemAsync(Guid id, MenuItemMoveInput input) - { - return MenuItemAdminAppService.MoveMenuItemAsync(id, input); - } + [HttpPut] + [Route("{id}/move")] + [Authorize(CmsKitAdminPermissions.Menus.Update)] + public virtual Task MoveMenuItemAsync(Guid id, MenuItemMoveInput input) + { + return MenuItemAdminAppService.MoveMenuItemAsync(id, input); + } - [HttpGet] - [Route("lookup/pages")] - public virtual Task> GetPageLookupAsync(PageLookupInputDto input) - { - return MenuItemAdminAppService.GetPageLookupAsync(input); - } + [HttpGet] + [Route("lookup/pages")] + public virtual Task> GetPageLookupAsync(PageLookupInputDto input) + { + return MenuItemAdminAppService.GetPageLookupAsync(input); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Pages/PageAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Pages/PageAdminController.cs index e502a6d61a..7936b206e6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Pages/PageAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Pages/PageAdminController.cs @@ -9,56 +9,55 @@ using Volo.CmsKit.Admin.Menus; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Pages +namespace Volo.CmsKit.Admin.Pages; + +[RequiresGlobalFeature(typeof(PagesFeature))] +[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitAdminRemoteServiceConsts.ModuleName)] +[Authorize(CmsKitAdminPermissions.Pages.Default)] +[Route("api/cms-kit-admin/pages")] +public class PageAdminController : CmsKitAdminController, IPageAdminAppService { - [RequiresGlobalFeature(typeof(PagesFeature))] - [RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitAdminRemoteServiceConsts.ModuleName)] - [Authorize(CmsKitAdminPermissions.Pages.Default)] - [Route("api/cms-kit-admin/pages")] - public class PageAdminController : CmsKitAdminController, IPageAdminAppService + protected readonly IPageAdminAppService PageAdminAppService; + + public PageAdminController(IPageAdminAppService pageAdminAppService) { - protected readonly IPageAdminAppService PageAdminAppService; + PageAdminAppService = pageAdminAppService; + } - public PageAdminController(IPageAdminAppService pageAdminAppService) - { - PageAdminAppService = pageAdminAppService; - } - - [HttpGet] - [Route("{id}")] - public virtual Task GetAsync(Guid id) - { - return PageAdminAppService.GetAsync(id); - } + [HttpGet] + [Route("{id}")] + public virtual Task GetAsync(Guid id) + { + return PageAdminAppService.GetAsync(id); + } - [HttpGet] - public virtual Task> GetListAsync(GetPagesInputDto input) - { - return PageAdminAppService.GetListAsync(input); - } + [HttpGet] + public virtual Task> GetListAsync(GetPagesInputDto input) + { + return PageAdminAppService.GetListAsync(input); + } - [HttpPost] - [Authorize(CmsKitAdminPermissions.Pages.Create)] - public virtual Task CreateAsync(CreatePageInputDto input) - { - return PageAdminAppService.CreateAsync(input); - } + [HttpPost] + [Authorize(CmsKitAdminPermissions.Pages.Create)] + public virtual Task CreateAsync(CreatePageInputDto input) + { + return PageAdminAppService.CreateAsync(input); + } - [HttpPut] - [Authorize(CmsKitAdminPermissions.Pages.Update)] - [Route("{id}")] - public virtual Task UpdateAsync(Guid id, UpdatePageInputDto input) - { - return PageAdminAppService.UpdateAsync(id, input); - } + [HttpPut] + [Authorize(CmsKitAdminPermissions.Pages.Update)] + [Route("{id}")] + public virtual Task UpdateAsync(Guid id, UpdatePageInputDto input) + { + return PageAdminAppService.UpdateAsync(id, input); + } - [HttpDelete] - [Authorize(CmsKitAdminPermissions.Pages.Delete)] - [Route("{id}")] - public virtual Task DeleteAsync(Guid id) - { - return PageAdminAppService.DeleteAsync(id); - } + [HttpDelete] + [Authorize(CmsKitAdminPermissions.Pages.Delete)] + [Route("{id}")] + public virtual Task DeleteAsync(Guid id) + { + return PageAdminAppService.DeleteAsync(id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/EntityTagAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/EntityTagAdminController.cs index 72c742a166..9df9394fdd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/EntityTagAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/EntityTagAdminController.cs @@ -6,37 +6,36 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +[RequiresGlobalFeature(typeof(TagsFeature))] +[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitAdminRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit-admin/entity-tags")] +public class EntityTagAdminController : CmsKitAdminController, IEntityTagAdminAppService { - [RequiresGlobalFeature(typeof(TagsFeature))] - [RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitAdminRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit-admin/entity-tags")] - public class EntityTagAdminController : CmsKitAdminController, IEntityTagAdminAppService - { - protected IEntityTagAdminAppService EntityTagAdminAppService { get; } + protected IEntityTagAdminAppService EntityTagAdminAppService { get; } - public EntityTagAdminController(IEntityTagAdminAppService entityTagAdminAppService) - { - EntityTagAdminAppService = entityTagAdminAppService; - } + public EntityTagAdminController(IEntityTagAdminAppService entityTagAdminAppService) + { + EntityTagAdminAppService = entityTagAdminAppService; + } - [HttpPost] - public Task AddTagToEntityAsync(EntityTagCreateDto input) - { - return EntityTagAdminAppService.AddTagToEntityAsync(input); - } + [HttpPost] + public Task AddTagToEntityAsync(EntityTagCreateDto input) + { + return EntityTagAdminAppService.AddTagToEntityAsync(input); + } - [HttpDelete] - public Task RemoveTagFromEntityAsync(EntityTagRemoveDto input) - { - return EntityTagAdminAppService.RemoveTagFromEntityAsync(input); - } + [HttpDelete] + public Task RemoveTagFromEntityAsync(EntityTagRemoveDto input) + { + return EntityTagAdminAppService.RemoveTagFromEntityAsync(input); + } - [HttpPut] - public Task SetEntityTagsAsync(EntityTagSetDto input) - { - return EntityTagAdminAppService.SetEntityTagsAsync(input); - } + [HttpPut] + public Task SetEntityTagsAsync(EntityTagSetDto input) + { + return EntityTagAdminAppService.SetEntityTagsAsync(input); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagAdminController.cs index 514e3a9bba..c34107b742 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagAdminController.cs @@ -11,62 +11,61 @@ using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Admin.Tags +namespace Volo.CmsKit.Admin.Tags; + +[RequiresGlobalFeature(typeof(TagsFeature))] +[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitAdminRemoteServiceConsts.ModuleName)] +[Authorize(CmsKitAdminPermissions.Tags.Default)] +[Route("api/cms-kit-admin/tags")] +public class TagAdminController : CmsKitAdminController, ITagAdminAppService { - [RequiresGlobalFeature(typeof(TagsFeature))] - [RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitAdminRemoteServiceConsts.ModuleName)] - [Authorize(CmsKitAdminPermissions.Tags.Default)] - [Route("api/cms-kit-admin/tags")] - public class TagAdminController : CmsKitAdminController, ITagAdminAppService - { - protected ITagAdminAppService TagAdminAppService { get; } + protected ITagAdminAppService TagAdminAppService { get; } - public TagAdminController(ITagAdminAppService tagAdminAppService) - { - TagAdminAppService = tagAdminAppService; - } + public TagAdminController(ITagAdminAppService tagAdminAppService) + { + TagAdminAppService = tagAdminAppService; + } - [HttpPost] - [Authorize(CmsKitAdminPermissions.Tags.Create)] - public Task CreateAsync(TagCreateDto input) - { - return TagAdminAppService.CreateAsync(input); - } + [HttpPost] + [Authorize(CmsKitAdminPermissions.Tags.Create)] + public Task CreateAsync(TagCreateDto input) + { + return TagAdminAppService.CreateAsync(input); + } - [HttpDelete("{id}")] - [Authorize(CmsKitAdminPermissions.Tags.Delete)] - public Task DeleteAsync(Guid id) - { - return TagAdminAppService.DeleteAsync(id); - } + [HttpDelete("{id}")] + [Authorize(CmsKitAdminPermissions.Tags.Delete)] + public Task DeleteAsync(Guid id) + { + return TagAdminAppService.DeleteAsync(id); + } - [HttpGet("{id}")] - [Authorize(CmsKitAdminPermissions.Tags.Default)] - public Task GetAsync(Guid id) - { - return TagAdminAppService.GetAsync(id); - } + [HttpGet("{id}")] + [Authorize(CmsKitAdminPermissions.Tags.Default)] + public Task GetAsync(Guid id) + { + return TagAdminAppService.GetAsync(id); + } - [HttpGet] - [Authorize(CmsKitAdminPermissions.Tags.Default)] - public Task> GetListAsync(TagGetListInput input) - { - return TagAdminAppService.GetListAsync(input); - } + [HttpGet] + [Authorize(CmsKitAdminPermissions.Tags.Default)] + public Task> GetListAsync(TagGetListInput input) + { + return TagAdminAppService.GetListAsync(input); + } - [HttpPut("{id}")] - [Authorize(CmsKitAdminPermissions.Tags.Update)] - public Task UpdateAsync(Guid id, [FromBody] TagUpdateDto input) - { - return TagAdminAppService.UpdateAsync(id, input); - } + [HttpPut("{id}")] + [Authorize(CmsKitAdminPermissions.Tags.Update)] + public Task UpdateAsync(Guid id, [FromBody] TagUpdateDto input) + { + return TagAdminAppService.UpdateAsync(id, input); + } - [HttpGet] - [Route("tag-definitions")] - public Task> GetTagDefinitionsAsync() - { - return TagAdminAppService.GetTagDefinitionsAsync(); - } + [HttpGet] + [Route("tag-definitions")] + public Task> GetTagDefinitionsAsync() + { + return TagAdminAppService.GetTagDefinitionsAsync(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/CmsKitAdminWebModule.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/CmsKitAdminWebModule.cs index 549e200aae..96773235eb 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/CmsKitAdminWebModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/CmsKitAdminWebModule.cs @@ -13,151 +13,150 @@ using Volo.Abp.Localization; using Volo.Abp.AutoMapper; using Volo.Abp.Http.ProxyScripting.Generators.JQuery; -namespace Volo.CmsKit.Admin.Web +namespace Volo.CmsKit.Admin.Web; + +[DependsOn( + typeof(CmsKitAdminApplicationContractsModule), + typeof(CmsKitCommonWebModule) + )] +public class CmsKitAdminWebModule : AbpModule { - [DependsOn( - typeof(CmsKitAdminApplicationContractsModule), - typeof(CmsKitCommonWebModule) - )] - public class CmsKitAdminWebModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + context.Services.PreConfigure(options => { - context.Services.PreConfigure(options => - { - options.AddAssemblyResource( - typeof(CmsKitResource), - typeof(CmsKitAdminWebModule).Assembly, - typeof(CmsKitAdminApplicationContractsModule).Assembly, - typeof(CmsKitCommonApplicationContractsModule).Assembly - ); - }); + options.AddAssemblyResource( + typeof(CmsKitResource), + typeof(CmsKitAdminWebModule).Assembly, + typeof(CmsKitAdminApplicationContractsModule).Assembly, + typeof(CmsKitCommonApplicationContractsModule).Assembly + ); + }); - PreConfigure(mvcBuilder => - { - mvcBuilder.AddApplicationPartIfNotExists(typeof(CmsKitAdminWebModule).Assembly); - }); - } + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(CmsKitAdminWebModule).Assembly); + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.MenuContributors.Add(new CmsKitAdminMenuContributor()); - }); + options.MenuContributors.Add(new CmsKitAdminMenuContributor()); + }); + + Configure(options => + { + options.FileSets.AddEmbedded("Volo.CmsKit.Admin.Web"); + }); + + context.Services.AddAutoMapperObjectMapper(); + Configure(options => { options.AddMaps(validate: true); }); - Configure(options => - { - options.FileSets.AddEmbedded("Volo.CmsKit.Admin.Web"); - }); + Configure(options => + { + options.Conventions.AuthorizeFolder("/CmsKit/Tags/", CmsKitAdminPermissions.Tags.Default); + options.Conventions.AuthorizeFolder("/CmsKit/Tags/CreateModal", CmsKitAdminPermissions.Tags.Create); + options.Conventions.AuthorizeFolder("/CmsKit/Tags/UpdateModal", CmsKitAdminPermissions.Tags.Update); + options.Conventions.AuthorizeFolder("/CmsKit/Pages", CmsKitAdminPermissions.Pages.Default); + options.Conventions.AuthorizeFolder("/CmsKit/Pages/Create", CmsKitAdminPermissions.Pages.Create); + options.Conventions.AuthorizeFolder("/CmsKit/Pages/Update", CmsKitAdminPermissions.Pages.Update); + options.Conventions.AuthorizeFolder("/CmsKit/Blogs", CmsKitAdminPermissions.Blogs.Default); + options.Conventions.AuthorizeFolder("/CmsKit/Blogs/Create", CmsKitAdminPermissions.Blogs.Create); + options.Conventions.AuthorizeFolder("/CmsKit/Blogs/Update", CmsKitAdminPermissions.Blogs.Update); + options.Conventions.AuthorizeFolder("/CmsKit/BlogPosts", CmsKitAdminPermissions.BlogPosts.Default); + options.Conventions.AuthorizeFolder("/CmsKit/BlogPosts/Create", CmsKitAdminPermissions.BlogPosts.Create); + options.Conventions.AuthorizeFolder("/CmsKit/BlogPosts/Update", CmsKitAdminPermissions.BlogPosts.Update); + options.Conventions.AuthorizeFolder("/CmsKit/Comments/", CmsKitAdminPermissions.Comments.Default); + options.Conventions.AuthorizeFolder("/CmsKit/Comments/Details", CmsKitAdminPermissions.Comments.Default); + options.Conventions.AuthorizeFolder("/CmsKit/Menus", CmsKitAdminPermissions.Menus.Default); + options.Conventions.AuthorizePage("/CmsKit/Menus/MenuItems/CreateModal", CmsKitAdminPermissions.Menus.Create); + options.Conventions.AuthorizePage("/CmsKit/Menus/MenuItems/UpdateModal", CmsKitAdminPermissions.Menus.Update); + options.Conventions.AuthorizeFolder("/CmsKit/Menus/MenuItems", CmsKitAdminPermissions.Menus.Update); + }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => { options.AddMaps(validate: true); }); + Configure(options => + { + options.Conventions.AddPageRoute("/CmsKit/Tags/Index", "/Cms/Tags"); + options.Conventions.AddPageRoute("/CmsKit/Pages/Index", "/Cms/Pages"); + options.Conventions.AddPageRoute("/CmsKit/Pages/Create", "/Cms/Pages/Create"); + options.Conventions.AddPageRoute("/CmsKit/Pages/Update", "/Cms/Pages/Update/{Id}"); + options.Conventions.AddPageRoute("/CmsKit/Blogs/Index", "/Cms/Blogs"); + options.Conventions.AddPageRoute("/CmsKit/BlogPosts/Index", "/Cms/BlogPosts"); + options.Conventions.AddPageRoute("/CmsKit/BlogPosts/Create", "/Cms/BlogPosts/Create"); + options.Conventions.AddPageRoute("/CmsKit/BlogPosts/Update", "/Cms/BlogPosts/Update/{Id}"); + options.Conventions.AddPageRoute("/CmsKit/Comments/Index", "/Cms/Comments"); + options.Conventions.AddPageRoute("/CmsKit/Comments/Details", "/Cms/Comments/{Id}"); + options.Conventions.AddPageRoute("/CmsKit/Menus/MenuItems/Index", "/Cms/Menus/Items"); + }); - Configure(options => - { - options.Conventions.AuthorizeFolder("/CmsKit/Tags/", CmsKitAdminPermissions.Tags.Default); - options.Conventions.AuthorizeFolder("/CmsKit/Tags/CreateModal", CmsKitAdminPermissions.Tags.Create); - options.Conventions.AuthorizeFolder("/CmsKit/Tags/UpdateModal", CmsKitAdminPermissions.Tags.Update); - options.Conventions.AuthorizeFolder("/CmsKit/Pages", CmsKitAdminPermissions.Pages.Default); - options.Conventions.AuthorizeFolder("/CmsKit/Pages/Create", CmsKitAdminPermissions.Pages.Create); - options.Conventions.AuthorizeFolder("/CmsKit/Pages/Update", CmsKitAdminPermissions.Pages.Update); - options.Conventions.AuthorizeFolder("/CmsKit/Blogs", CmsKitAdminPermissions.Blogs.Default); - options.Conventions.AuthorizeFolder("/CmsKit/Blogs/Create", CmsKitAdminPermissions.Blogs.Create); - options.Conventions.AuthorizeFolder("/CmsKit/Blogs/Update", CmsKitAdminPermissions.Blogs.Update); - options.Conventions.AuthorizeFolder("/CmsKit/BlogPosts", CmsKitAdminPermissions.BlogPosts.Default); - options.Conventions.AuthorizeFolder("/CmsKit/BlogPosts/Create", CmsKitAdminPermissions.BlogPosts.Create); - options.Conventions.AuthorizeFolder("/CmsKit/BlogPosts/Update", CmsKitAdminPermissions.BlogPosts.Update); - options.Conventions.AuthorizeFolder("/CmsKit/Comments/", CmsKitAdminPermissions.Comments.Default); - options.Conventions.AuthorizeFolder("/CmsKit/Comments/Details", CmsKitAdminPermissions.Comments.Default); - options.Conventions.AuthorizeFolder("/CmsKit/Menus", CmsKitAdminPermissions.Menus.Default); - options.Conventions.AuthorizePage("/CmsKit/Menus/MenuItems/CreateModal", CmsKitAdminPermissions.Menus.Create); - options.Conventions.AuthorizePage("/CmsKit/Menus/MenuItems/UpdateModal", CmsKitAdminPermissions.Menus.Update); - options.Conventions.AuthorizeFolder("/CmsKit/Menus/MenuItems", CmsKitAdminPermissions.Menus.Update); - }); + Configure(options => + { - Configure(options => - { - options.Conventions.AddPageRoute("/CmsKit/Tags/Index", "/Cms/Tags"); - options.Conventions.AddPageRoute("/CmsKit/Pages/Index", "/Cms/Pages"); - options.Conventions.AddPageRoute("/CmsKit/Pages/Create", "/Cms/Pages/Create"); - options.Conventions.AddPageRoute("/CmsKit/Pages/Update", "/Cms/Pages/Update/{Id}"); - options.Conventions.AddPageRoute("/CmsKit/Blogs/Index", "/Cms/Blogs"); - options.Conventions.AddPageRoute("/CmsKit/BlogPosts/Index", "/Cms/BlogPosts"); - options.Conventions.AddPageRoute("/CmsKit/BlogPosts/Create", "/Cms/BlogPosts/Create"); - options.Conventions.AddPageRoute("/CmsKit/BlogPosts/Update", "/Cms/BlogPosts/Update/{Id}"); - options.Conventions.AddPageRoute("/CmsKit/Comments/Index", "/Cms/Comments"); - options.Conventions.AddPageRoute("/CmsKit/Comments/Details", "/Cms/Comments/{Id}"); - options.Conventions.AddPageRoute("/CmsKit/Menus/MenuItems/Index", "/Cms/Menus/Items"); - }); + options.Configure( + toolbar => + { + toolbar.AddButton( + LocalizableString.Create("NewTag"), + icon: "plus", + name: "NewButton", + requiredPolicyName: CmsKitAdminPermissions.Tags.Create + ); + } + ); - Configure(options => - { + options.Configure( + toolbar => + { + toolbar.AddButton( + LocalizableString.Create("NewPage"), + icon: "plus", + name: "CreatePage", + requiredPolicyName: CmsKitAdminPermissions.Pages.Create + ); + }); - options.Configure( - toolbar => - { - toolbar.AddButton( - LocalizableString.Create("NewTag"), - icon: "plus", - name: "NewButton", - requiredPolicyName: CmsKitAdminPermissions.Tags.Create + options.Configure( + toolbar => + { + toolbar.AddButton( + LocalizableString.Create("NewBlog"), + icon: "plus", + name: "CreateBlog", + id: "CreateBlog", + requiredPolicyName: CmsKitAdminPermissions.Blogs.Create ); - } - ); + }); - options.Configure( - toolbar => - { - toolbar.AddButton( - LocalizableString.Create("NewPage"), - icon: "plus", - name: "CreatePage", - requiredPolicyName: CmsKitAdminPermissions.Pages.Create + options.Configure( + toolbar => + { + toolbar.AddButton( + LocalizableString.Create("NewBlogPost"), + icon: "plus", + name: "CreateBlogPost", + id: "CreateBlogPost", + requiredPolicyName: CmsKitAdminPermissions.BlogPosts.Create ); - }); - - options.Configure( - toolbar => - { - toolbar.AddButton( - LocalizableString.Create("NewBlog"), - icon: "plus", - name: "CreateBlog", - id: "CreateBlog", - requiredPolicyName: CmsKitAdminPermissions.Blogs.Create - ); - }); + }); - options.Configure( - toolbar => - { - toolbar.AddButton( - LocalizableString.Create("NewBlogPost"), - icon: "plus", - name: "CreateBlogPost", - id: "CreateBlogPost", - requiredPolicyName: CmsKitAdminPermissions.BlogPosts.Create - ); - }); - - options.Configure( - toolbar => - { - toolbar.AddButton( - LocalizableString.Create("NewMenuItem"), - icon: "plus", - name: "CreateMenuItem", - id: "CreateMenuItem", - requiredPolicyName: CmsKitAdminPermissions.Menus.Update - ); - }); - }); + options.Configure( + toolbar => + { + toolbar.AddButton( + LocalizableString.Create("NewMenuItem"), + icon: "plus", + name: "CreateMenuItem", + id: "CreateMenuItem", + requiredPolicyName: CmsKitAdminPermissions.Menus.Update + ); + }); + }); - Configure(options => - { - options.DisableModule(CmsKitAdminRemoteServiceConsts.ModuleName); - }); - } + Configure(options => + { + options.DisableModule(CmsKitAdminRemoteServiceConsts.ModuleName); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenuContributor.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenuContributor.cs index 43d4b823d0..82c55999ba 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenuContributor.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenuContributor.cs @@ -8,95 +8,94 @@ using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Localization; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit.Admin.Web.Menus +namespace Volo.CmsKit.Admin.Web.Menus; + +public class CmsKitAdminMenuContributor : IMenuContributor { - public class CmsKitAdminMenuContributor : IMenuContributor + public async Task ConfigureMenuAsync(MenuConfigurationContext context) { - public async Task ConfigureMenuAsync(MenuConfigurationContext context) + if (context.Menu.Name == StandardMenus.Main) { - if (context.Menu.Name == StandardMenus.Main) - { - await ConfigureMainMenuAsync(context); - } + await ConfigureMainMenuAsync(context); } + } - private async Task ConfigureMainMenuAsync(MenuConfigurationContext context) - { - await AddCmsMenuAsync(context); - } + private async Task ConfigureMainMenuAsync(MenuConfigurationContext context) + { + await AddCmsMenuAsync(context); + } - private async Task AddCmsMenuAsync(MenuConfigurationContext context) - { - var l = context.GetLocalizer(); + private async Task AddCmsMenuAsync(MenuConfigurationContext context) + { + var l = context.GetLocalizer(); - var cmsMenus = new List(); + var cmsMenus = new List(); - cmsMenus.Add(new ApplicationMenuItem( - CmsKitAdminMenus.Pages.PagesMenu, - l["Pages"].Value, - "/Cms/Pages", - "fa fa-file-alt") - .RequireGlobalFeatures(typeof(PagesFeature)) - .RequirePermissions(CmsKitAdminPermissions.Pages.Default)); + cmsMenus.Add(new ApplicationMenuItem( + CmsKitAdminMenus.Pages.PagesMenu, + l["Pages"].Value, + "/Cms/Pages", + "fa fa-file-alt") + .RequireGlobalFeatures(typeof(PagesFeature)) + .RequirePermissions(CmsKitAdminPermissions.Pages.Default)); - cmsMenus.Add(new ApplicationMenuItem( - CmsKitAdminMenus.Blogs.BlogsMenu, - l["Blogs"], - "/Cms/Blogs", - "fa fa-blog") - .RequireGlobalFeatures(typeof(BlogsFeature)) - .RequirePermissions(CmsKitAdminPermissions.Blogs.Default)); + cmsMenus.Add(new ApplicationMenuItem( + CmsKitAdminMenus.Blogs.BlogsMenu, + l["Blogs"], + "/Cms/Blogs", + "fa fa-blog") + .RequireGlobalFeatures(typeof(BlogsFeature)) + .RequirePermissions(CmsKitAdminPermissions.Blogs.Default)); - cmsMenus.Add(new ApplicationMenuItem( - CmsKitAdminMenus.BlogPosts.BlogPostsMenu, - l["BlogPosts"], - "/Cms/BlogPosts", - "fa fa-file-signature") - .RequireGlobalFeatures(typeof(BlogsFeature)) - .RequirePermissions(CmsKitAdminPermissions.BlogPosts.Default)); + cmsMenus.Add(new ApplicationMenuItem( + CmsKitAdminMenus.BlogPosts.BlogPostsMenu, + l["BlogPosts"], + "/Cms/BlogPosts", + "fa fa-file-signature") + .RequireGlobalFeatures(typeof(BlogsFeature)) + .RequirePermissions(CmsKitAdminPermissions.BlogPosts.Default)); - cmsMenus.Add(new ApplicationMenuItem( - CmsKitAdminMenus.Tags.TagsMenu, - l["Tags"].Value, - "/Cms/Tags", - "fa fa-tags") - .RequireGlobalFeatures(typeof(TagsFeature)) - .RequirePermissions(CmsKitAdminPermissions.Tags.Default)); + cmsMenus.Add(new ApplicationMenuItem( + CmsKitAdminMenus.Tags.TagsMenu, + l["Tags"].Value, + "/Cms/Tags", + "fa fa-tags") + .RequireGlobalFeatures(typeof(TagsFeature)) + .RequirePermissions(CmsKitAdminPermissions.Tags.Default)); - cmsMenus.Add(new ApplicationMenuItem( - CmsKitAdminMenus.Comments.CommentsMenu, - l["Comments"].Value, - "/Cms/Comments", - "fa fa-comments") - .RequireGlobalFeatures(typeof(CommentsFeature)) - .RequirePermissions(CmsKitAdminPermissions.Comments.Default)); + cmsMenus.Add(new ApplicationMenuItem( + CmsKitAdminMenus.Comments.CommentsMenu, + l["Comments"].Value, + "/Cms/Comments", + "fa fa-comments") + .RequireGlobalFeatures(typeof(CommentsFeature)) + .RequirePermissions(CmsKitAdminPermissions.Comments.Default)); - cmsMenus.Add(new ApplicationMenuItem( - CmsKitAdminMenus.Menus.MenusMenu, - l["Menus"], - "/Cms/Menus/Items", - "fa fa-stream") - .RequireGlobalFeatures(typeof(MenuFeature)) - .RequirePermissions(CmsKitAdminPermissions.Menus.Default)); + cmsMenus.Add(new ApplicationMenuItem( + CmsKitAdminMenus.Menus.MenusMenu, + l["Menus"], + "/Cms/Menus/Items", + "fa fa-stream") + .RequireGlobalFeatures(typeof(MenuFeature)) + .RequirePermissions(CmsKitAdminPermissions.Menus.Default)); - if (cmsMenus.Any()) - { - var cmsMenu = context.Menu.FindMenuItem(CmsKitAdminMenus.GroupName); + if (cmsMenus.Any()) + { + var cmsMenu = context.Menu.FindMenuItem(CmsKitAdminMenus.GroupName); - if (cmsMenu == null) - { - cmsMenu = new ApplicationMenuItem( - CmsKitAdminMenus.GroupName, - l["Cms"], - icon: "far fa-newspaper"); + if (cmsMenu == null) + { + cmsMenu = new ApplicationMenuItem( + CmsKitAdminMenus.GroupName, + l["Cms"], + icon: "far fa-newspaper"); - context.Menu.AddItem(cmsMenu); - } + context.Menu.AddItem(cmsMenu); + } - foreach (var menu in cmsMenus) - { - cmsMenu.AddItem(menu); - } + foreach (var menu in cmsMenus) + { + cmsMenu.AddItem(menu); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenus.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenus.cs index b92a6a4458..bcd52b9e5d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenus.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Menus/CmsKitAdminMenus.cs @@ -1,37 +1,36 @@ -namespace Volo.CmsKit.Admin.Web.Menus +namespace Volo.CmsKit.Admin.Web.Menus; + +public class CmsKitAdminMenus { - public class CmsKitAdminMenus - { - public const string GroupName = "Cms"; + public const string GroupName = "Cms"; - public static class Comments - { - public const string CommentsMenu = GroupName + ".Comments"; - } + public static class Comments + { + public const string CommentsMenu = GroupName + ".Comments"; + } - public static class Tags - { - public const string TagsMenu = GroupName + ".Tags"; - } + public static class Tags + { + public const string TagsMenu = GroupName + ".Tags"; + } - public static class Pages - { - public const string PagesMenu = GroupName + ".Pages"; - } + public static class Pages + { + public const string PagesMenu = GroupName + ".Pages"; + } - public static class Blogs - { - public const string BlogsMenu = GroupName + ".Blogs"; - } + public static class Blogs + { + public const string BlogsMenu = GroupName + ".Blogs"; + } - public static class BlogPosts - { - public const string BlogPostsMenu = GroupName + ".BlogPosts"; - } + public static class BlogPosts + { + public const string BlogPostsMenu = GroupName + ".BlogPosts"; + } - public static class Menus - { - public const string MenusMenu = GroupName + ".Menus"; - } + public static class Menus + { + public const string MenusMenu = GroupName + ".Menus"; } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Create.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Create.cshtml.cs index 7b6680c3c2..08d4d24b37 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Create.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Create.cshtml.cs @@ -12,59 +12,58 @@ using Volo.Abp.Validation; using Volo.CmsKit.Admin.Blogs; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.BlogPosts +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.BlogPosts; + +public class CreateModel : CmsKitAdminPageModel { - public class CreateModel : CmsKitAdminPageModel - { - protected IBlogPostAdminAppService BlogPostAdminAppService { get; } + protected IBlogPostAdminAppService BlogPostAdminAppService { get; } - [BindProperty] - public CreateBlogPostViewModel ViewModel { get; set; } + [BindProperty] + public CreateBlogPostViewModel ViewModel { get; set; } + + public CreateModel( + IBlogPostAdminAppService blogPostAdminAppService) + { + BlogPostAdminAppService = blogPostAdminAppService; + } - public CreateModel( - IBlogPostAdminAppService blogPostAdminAppService) - { - BlogPostAdminAppService = blogPostAdminAppService; - } + public async Task OnPostAsync() + { + var dto = ObjectMapper.Map(ViewModel); - public async Task OnPostAsync() - { - var dto = ObjectMapper.Map(ViewModel); + var created = await BlogPostAdminAppService.CreateAsync(dto); - var created = await BlogPostAdminAppService.CreateAsync(dto); + return new OkObjectResult(created); + } - return new OkObjectResult(created); - } + [AutoMap(typeof(CreateBlogPostDto), ReverseMap = true)] + public class CreateBlogPostViewModel + { + [Required] + [DynamicFormIgnore] + public Guid BlogId { get; set; } - [AutoMap(typeof(CreateBlogPostDto), ReverseMap = true)] - public class CreateBlogPostViewModel - { - [Required] - [DynamicFormIgnore] - public Guid BlogId { get; set; } + [Required] + [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxTitleLength))] + [DynamicFormIgnore] + public string Title { get; set; } - [Required] - [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxTitleLength))] - [DynamicFormIgnore] - public string Title { get; set; } + [Required] + [DynamicStringLength( + typeof(BlogPostConsts), + nameof(BlogPostConsts.MaxSlugLength), + nameof(BlogPostConsts.MinSlugLength))] + [DynamicFormIgnore] + public string Slug { get; set; } - [Required] - [DynamicStringLength( - typeof(BlogPostConsts), - nameof(BlogPostConsts.MaxSlugLength), - nameof(BlogPostConsts.MinSlugLength))] - [DynamicFormIgnore] - public string Slug { get; set; } + [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxShortDescriptionLength))] + public string ShortDescription { get; set; } - [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxShortDescriptionLength))] - public string ShortDescription { get; set; } - - [HiddenInput] - [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))] - public string Content { get; set; } + [HiddenInput] + [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))] + public string Content { get; set; } - [HiddenInput] - public Guid? CoverImageMediaId { get; set; } - } + [HiddenInput] + public Guid? CoverImageMediaId { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Index.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Index.cshtml.cs index 02afe21fc1..fce51fb69f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Index.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Index.cshtml.cs @@ -1,7 +1,6 @@ -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.BlogPosts +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.BlogPosts; + +public class IndexModel : CmsKitAdminPageModel { - public class IndexModel : CmsKitAdminPageModel - { - - } + } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Update.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Update.cshtml.cs index e49aa4d5a1..6f93cb2ed9 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Update.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Update.cshtml.cs @@ -13,75 +13,74 @@ using Volo.Abp.Validation; using Volo.CmsKit.Admin.Blogs; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.BlogPosts +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.BlogPosts; + +public class UpdateModel : CmsKitAdminPageModel { - public class UpdateModel : CmsKitAdminPageModel + protected IBlogPostAdminAppService BlogPostAdminAppService { get; } + protected IBlogFeatureAppService BlogFeatureAppService { get; } + + [BindProperty] + public virtual UpdateBlogPostViewModel ViewModel { get; set; } + + [HiddenInput] + [BindProperty(SupportsGet = true)] + public virtual Guid Id { get; set; } + + public virtual BlogFeatureDto TagsFeature { get; protected set; } + + public UpdateModel( + IBlogPostAdminAppService blogPostAdminAppService, + IBlogFeatureAppService blogFeatureAppService) + { + BlogPostAdminAppService = blogPostAdminAppService; + BlogFeatureAppService = blogFeatureAppService; + } + + public virtual async Task OnGetAsync() + { + var blogPost = await BlogPostAdminAppService.GetAsync(Id); + + ViewModel = ObjectMapper.Map(blogPost); + + TagsFeature = await BlogFeatureAppService.GetOrDefaultAsync(blogPost.BlogId, GlobalFeatures.TagsFeature.Name); + } + + public virtual async Task OnPostAsync() { - protected IBlogPostAdminAppService BlogPostAdminAppService { get; } - protected IBlogFeatureAppService BlogFeatureAppService { get; } + var dto = ObjectMapper.Map(ViewModel); + + await BlogPostAdminAppService.UpdateAsync(Id, dto); - [BindProperty] - public virtual UpdateBlogPostViewModel ViewModel { get; set; } + return NoContent(); + } + + [AutoMap(typeof(BlogPostDto))] + [AutoMap(typeof(UpdateBlogPostDto), ReverseMap = true)] + public class UpdateBlogPostViewModel : IHasConcurrencyStamp + { + [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxTitleLength))] + [Required] + [DynamicFormIgnore] + public string Title { get; set; } + + [DynamicStringLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxSlugLength), nameof(BlogPostConsts.MinSlugLength))] + [Required] + [DisplayOrder(10000)] + [DynamicFormIgnore] + public string Slug { get; set; } + + [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxShortDescriptionLength))] + [DisplayOrder(10001)] + public string ShortDescription { get; set; } [HiddenInput] - [BindProperty(SupportsGet = true)] - public virtual Guid Id { get; set; } - - public virtual BlogFeatureDto TagsFeature { get; protected set; } - - public UpdateModel( - IBlogPostAdminAppService blogPostAdminAppService, - IBlogFeatureAppService blogFeatureAppService) - { - BlogPostAdminAppService = blogPostAdminAppService; - BlogFeatureAppService = blogFeatureAppService; - } - - public virtual async Task OnGetAsync() - { - var blogPost = await BlogPostAdminAppService.GetAsync(Id); - - ViewModel = ObjectMapper.Map(blogPost); - - TagsFeature = await BlogFeatureAppService.GetOrDefaultAsync(blogPost.BlogId, GlobalFeatures.TagsFeature.Name); - } - - public virtual async Task OnPostAsync() - { - var dto = ObjectMapper.Map(ViewModel); - - await BlogPostAdminAppService.UpdateAsync(Id, dto); - - return NoContent(); - } - - [AutoMap(typeof(BlogPostDto))] - [AutoMap(typeof(UpdateBlogPostDto), ReverseMap = true)] - public class UpdateBlogPostViewModel : IHasConcurrencyStamp - { - [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxTitleLength))] - [Required] - [DynamicFormIgnore] - public string Title { get; set; } - - [DynamicStringLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxSlugLength), nameof(BlogPostConsts.MinSlugLength))] - [Required] - [DisplayOrder(10000)] - [DynamicFormIgnore] - public string Slug { get; set; } - - [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxShortDescriptionLength))] - [DisplayOrder(10001)] - public string ShortDescription { get; set; } - - [HiddenInput] - [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))] - public string Content { get; set; } - - [HiddenInput] - public Guid? CoverImageMediaId { get; set; } - - public string ConcurrencyStamp { get; set; } - } + [DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))] + public string Content { get; set; } + + [HiddenInput] + public Guid? CoverImageMediaId { get; set; } + + public string ConcurrencyStamp { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/CreateModal.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/CreateModal.cshtml.cs index 05996b6f87..738d3c2f63 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/CreateModal.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/CreateModal.cshtml.cs @@ -6,39 +6,38 @@ using Volo.Abp.Validation; using Volo.CmsKit.Admin.Blogs; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Blogs +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Blogs; + +public class CreateModalModel : CmsKitAdminPageModel { - public class CreateModalModel : CmsKitAdminPageModel - { - protected IBlogAdminAppService BlogAdminAppService { get; } + protected IBlogAdminAppService BlogAdminAppService { get; } - [BindProperty] - public CreateBlogViewModel ViewModel { get; set; } + [BindProperty] + public CreateBlogViewModel ViewModel { get; set; } - public CreateModalModel(IBlogAdminAppService blogAdminAppService) - { - BlogAdminAppService = blogAdminAppService; - } + public CreateModalModel(IBlogAdminAppService blogAdminAppService) + { + BlogAdminAppService = blogAdminAppService; + } - public async Task OnPostAsync() - { - var dto = ObjectMapper.Map(ViewModel); + public async Task OnPostAsync() + { + var dto = ObjectMapper.Map(ViewModel); - await BlogAdminAppService.CreateAsync(dto); + await BlogAdminAppService.CreateAsync(dto); - return NoContent(); - } + return NoContent(); + } - [AutoMap(typeof(CreateBlogDto), ReverseMap = true)] - public class CreateBlogViewModel - { - [Required] - [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxNameLength))] - public string Name { get; set; } + [AutoMap(typeof(CreateBlogDto), ReverseMap = true)] + public class CreateBlogViewModel + { + [Required] + [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxNameLength))] + public string Name { get; set; } - [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxSlugLength))] - [Required] - public string Slug { get; set; } - } + [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxSlugLength))] + [Required] + public string Slug { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/FeaturesModal.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/FeaturesModal.cshtml.cs index c788e2cf4a..a18d2e7d89 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/FeaturesModal.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/FeaturesModal.cshtml.cs @@ -10,67 +10,66 @@ using Volo.CmsKit.Admin.Blogs; using Volo.CmsKit.Admin.Web.Pages; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Blogs +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Blogs; + +public class FeaturesModalModel : CmsKitAdminPageModel { - public class FeaturesModalModel : CmsKitAdminPageModel + [BindProperty(SupportsGet = true)] + [HiddenInput] + public Guid BlogId { get; set; } + + [BindProperty] + public List Items { get; set; } + + protected IBlogFeatureAdminAppService BlogFeatureAdminAppService { get; } + + public FeaturesModalModel(IBlogFeatureAdminAppService blogFeatureAdminAppService) { - [BindProperty(SupportsGet = true)] - [HiddenInput] - public Guid BlogId { get; set; } + BlogFeatureAdminAppService = blogFeatureAdminAppService; + } - [BindProperty] - public List Items { get; set; } + public async Task OnGetAsync() + { + var blogFeatureDtos = await BlogFeatureAdminAppService.GetListAsync(BlogId); - protected IBlogFeatureAdminAppService BlogFeatureAdminAppService { get; } + Items = ObjectMapper.Map, List>(blogFeatureDtos); + } - public FeaturesModalModel(IBlogFeatureAdminAppService blogFeatureAdminAppService) - { - BlogFeatureAdminAppService = blogFeatureAdminAppService; - } + public async Task OnPostAsync() + { + var dtos = ObjectMapper.Map, List>(Items); - public async Task OnGetAsync() + foreach (var item in dtos) { - var blogFeatureDtos = await BlogFeatureAdminAppService.GetListAsync(BlogId); - - Items = ObjectMapper.Map, List>(blogFeatureDtos); + await BlogFeatureAdminAppService.SetAsync(BlogId, item); } - public async Task OnPostAsync() - { - var dtos = ObjectMapper.Map, List>(Items); + return NoContent(); + } - foreach (var item in dtos) - { - await BlogFeatureAdminAppService.SetAsync(BlogId, item); - } + [AutoMap(typeof(BlogFeatureDto), ReverseMap = true)] + [AutoMap(typeof(BlogFeatureInputDto), ReverseMap = true)] + public class BlogFeatureViewModel + { + private string featureName; + [HiddenInput] + public string FeatureName { get => featureName; set => SetFeatureName(value); } - return NoContent(); - } + public bool IsEnabled { get; set; } - [AutoMap(typeof(BlogFeatureDto), ReverseMap = true)] - [AutoMap(typeof(BlogFeatureInputDto), ReverseMap = true)] - public class BlogFeatureViewModel - { - private string featureName; - [HiddenInput] - public string FeatureName { get => featureName; set => SetFeatureName(value); } + public bool IsAvailable { get; private set; } - public bool IsEnabled { get; set; } + private void SetFeatureName(string value) + { + featureName = value; - public bool IsAvailable { get; private set; } + IsAvailable = GlobalFeatureManager.Instance.Modules.CmsKit().GetFeatures().Any(a => a.FeatureName == FeatureName) ? + GlobalFeatureManager.Instance.IsEnabled(FeatureName) : + true; - private void SetFeatureName(string value) + if (!IsAvailable) { - featureName = value; - - IsAvailable = GlobalFeatureManager.Instance.Modules.CmsKit().GetFeatures().Any(a => a.FeatureName == FeatureName) ? - GlobalFeatureManager.Instance.IsEnabled(FeatureName) : - true; - - if (!IsAvailable) - { - IsEnabled = false; - } + IsEnabled = false; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/Index.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/Index.cshtml.cs index 77ca47493b..5386d556e4 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/Index.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/Index.cshtml.cs @@ -1,7 +1,6 @@ -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Blogs +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Blogs; + +public class IndexModel : CmsKitAdminPageModel { - public class IndexModel : CmsKitAdminPageModel - { - - } + } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/UpdateModal.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/UpdateModal.cshtml.cs index 02bb9b7c0b..53840922b9 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/UpdateModal.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/UpdateModal.cshtml.cs @@ -8,54 +8,53 @@ using Volo.Abp.Validation; using Volo.CmsKit.Admin.Blogs; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Blogs +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Blogs; + +public class UpdateModalModel : CmsKitAdminPageModel { - public class UpdateModalModel : CmsKitAdminPageModel - { - protected IBlogAdminAppService BlogAdminAppService { get; } + protected IBlogAdminAppService BlogAdminAppService { get; } - [HiddenInput] - [BindProperty(SupportsGet = true)] - public Guid Id { get; set; } + [HiddenInput] + [BindProperty(SupportsGet = true)] + public Guid Id { get; set; } - [BindProperty] - public UpdateBlogViewModel ViewModel { get; set; } + [BindProperty] + public UpdateBlogViewModel ViewModel { get; set; } - public UpdateModalModel(IBlogAdminAppService blogAdminAppService) - { - BlogAdminAppService = blogAdminAppService; - } + public UpdateModalModel(IBlogAdminAppService blogAdminAppService) + { + BlogAdminAppService = blogAdminAppService; + } - public async Task OnGetAsync() - { - var blog = await BlogAdminAppService.GetAsync(Id); + public async Task OnGetAsync() + { + var blog = await BlogAdminAppService.GetAsync(Id); - ViewModel = ObjectMapper.Map(blog); - } + ViewModel = ObjectMapper.Map(blog); + } - public async Task OnPostAsync() - { - var dto = ObjectMapper.Map(ViewModel); + public async Task OnPostAsync() + { + var dto = ObjectMapper.Map(ViewModel); - await BlogAdminAppService.UpdateAsync(Id, dto); + await BlogAdminAppService.UpdateAsync(Id, dto); - return NoContent(); - } + return NoContent(); + } - [AutoMap(typeof(BlogDto))] - [AutoMap(typeof(UpdateBlogDto), ReverseMap = true)] - public class UpdateBlogViewModel : IHasConcurrencyStamp - { - [Required] - [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxNameLength))] - public string Name { get; set; } + [AutoMap(typeof(BlogDto))] + [AutoMap(typeof(UpdateBlogDto), ReverseMap = true)] + public class UpdateBlogViewModel : IHasConcurrencyStamp + { + [Required] + [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxNameLength))] + public string Name { get; set; } - [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxSlugLength))] - [Required] - public string Slug { get; set; } + [DynamicMaxLength(typeof(BlogConsts), nameof(BlogConsts.MaxSlugLength))] + [Required] + public string Slug { get; set; } - [HiddenInput] - public string ConcurrencyStamp { get; set; } - } + [HiddenInput] + public string ConcurrencyStamp { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Details.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Details.cshtml.cs index 7e8b757b1a..f1e793987f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Details.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Details.cshtml.cs @@ -3,31 +3,30 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.CmsKit.Admin.Comments; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Comments +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Comments; + +public class DetailsModel : CmsKitAdminPageModel { - public class DetailsModel : CmsKitAdminPageModel + [BindProperty(SupportsGet = true)] + public Guid Id { get; set; } + + public string Author { get; set; } + + public DateTime? CreationStartDate { get; set; } + + public DateTime? CreationEndDate { get; set; } + + public CommentWithAuthorDto CommentWithAuthorDto { get; protected set; } + + protected readonly ICommentAdminAppService CommentAdminAppService; + + public DetailsModel(ICommentAdminAppService commentAdminAppService) + { + CommentAdminAppService = commentAdminAppService; + } + + public async Task OnGetAsync() { - [BindProperty(SupportsGet = true)] - public Guid Id { get; set; } - - public string Author { get; set; } - - public DateTime? CreationStartDate { get; set; } - - public DateTime? CreationEndDate { get; set; } - - public CommentWithAuthorDto CommentWithAuthorDto { get; protected set; } - - protected readonly ICommentAdminAppService CommentAdminAppService; - - public DetailsModel(ICommentAdminAppService commentAdminAppService) - { - CommentAdminAppService = commentAdminAppService; - } - - public async Task OnGetAsync() - { - CommentWithAuthorDto = await CommentAdminAppService.GetAsync(Id); - } + CommentWithAuthorDto = await CommentAdminAppService.GetAsync(Id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml.cs index c6f51131ed..4502669669 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml.cs @@ -1,15 +1,14 @@ using System; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Comments +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Comments; + +public class IndexModel : CmsKitAdminPageModel { - public class IndexModel : CmsKitAdminPageModel - { - public string EntityType { get; set; } + public string EntityType { get; set; } + + public string Author { get; set; } - public string Author { get; set; } + public DateTime? CreationStartDate { get; set; } - public DateTime? CreationStartDate { get; set; } - - public DateTime? CreationEndDate { get; set; } - } + public DateTime? CreationEndDate { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/CreateModal.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/CreateModal.cshtml.cs index 063c35638c..bb65ec1873 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/CreateModal.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/CreateModal.cshtml.cs @@ -9,63 +9,62 @@ using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; using Volo.CmsKit.Admin.Menus; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems; + +public class CreateModalModel : CmsKitAdminPageModel { - public class CreateModalModel : CmsKitAdminPageModel + protected IMenuItemAdminAppService MenuAdminAppService { get; } + + [BindProperty] + public MenuItemCreateViewModel ViewModel { get; set; } + + public CreateModalModel(IMenuItemAdminAppService menuAdminAppService) { - protected IMenuItemAdminAppService MenuAdminAppService { get; } + MenuAdminAppService = menuAdminAppService; + ViewModel = new MenuItemCreateViewModel(); + } - [BindProperty] - public MenuItemCreateViewModel ViewModel { get; set; } + public virtual Task OnGetAsync(Guid? parentId) + { + ViewModel.ParentId = parentId; - public CreateModalModel(IMenuItemAdminAppService menuAdminAppService) - { - MenuAdminAppService = menuAdminAppService; - ViewModel = new MenuItemCreateViewModel(); - } + return Task.CompletedTask; + } - public virtual Task OnGetAsync(Guid? parentId) - { - ViewModel.ParentId = parentId; + public virtual async Task OnPostAsync() + { + var input = ObjectMapper.Map(ViewModel); - return Task.CompletedTask; - } + var dto = await MenuAdminAppService.CreateAsync(input); - public virtual async Task OnPostAsync() - { - var input = ObjectMapper.Map(ViewModel); + return new OkObjectResult(dto); + } - var dto = await MenuAdminAppService.CreateAsync(input); + [AutoMap(typeof(MenuItemCreateInput), ReverseMap = true)] + public class MenuItemCreateViewModel + { + [HiddenInput] + public Guid? ParentId { get; set; } - return new OkObjectResult(dto); - } + [Required] + public string DisplayName { get; set; } - [AutoMap(typeof(MenuItemCreateInput), ReverseMap = true)] - public class MenuItemCreateViewModel - { - [HiddenInput] - public Guid? ParentId { get; set; } + public bool IsActive { get; set; } = true; - [Required] - public string DisplayName { get; set; } + public string Url { get; set; } - public bool IsActive { get; set; } = true; - - public string Url { get; set; } - - public Guid? PageId { get; set; } + public Guid? PageId { get; set; } - public string Icon { get; set; } + public string Icon { get; set; } - [HiddenInput] - public int Order { get; set; } + [HiddenInput] + public int Order { get; set; } - public string Target { get; set; } + public string Target { get; set; } - public string ElementId { get; set; } + public string ElementId { get; set; } - public string CssClass { get; set; } + public string CssClass { get; set; } - } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/Index.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/Index.cshtml.cs index 380d88a945..5458130134 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/Index.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/Index.cshtml.cs @@ -7,9 +7,8 @@ using System.Threading.Tasks; using Volo.CmsKit.Admin.Menus; using Volo.CmsKit.Menus; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems; + +public class IndexModel : CmsKitAdminPageModel { - public class IndexModel : CmsKitAdminPageModel - { - } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/UpdateModal.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/UpdateModal.cshtml.cs index e2d171b0e4..ed707fb482 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/UpdateModal.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Menus/MenuItems/UpdateModal.cshtml.cs @@ -8,63 +8,62 @@ using Volo.Abp.Domain.Entities; using Volo.CmsKit.Admin.Menus; using Volo.CmsKit.Menus; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems; + +public class UpdateModalModel : CmsKitAdminPageModel { - public class UpdateModalModel : CmsKitAdminPageModel + protected IMenuItemAdminAppService MenuAdminAppService { get; } + + [BindProperty] + public MenuItemUpdateViewModel ViewModel { get; set; } + + [HiddenInput] + [BindProperty(SupportsGet = true)] + public Guid Id { get; set; } + + public UpdateModalModel(IMenuItemAdminAppService menuAdminAppService) + { + MenuAdminAppService = menuAdminAppService; + } + + public async Task OnGetAsync() + { + var menuItemDto = await MenuAdminAppService.GetAsync(Id); + + ViewModel = ObjectMapper.Map(menuItemDto); + } + + public async Task OnPostAsync() { - protected IMenuItemAdminAppService MenuAdminAppService { get; } + var input = ObjectMapper.Map(ViewModel); + + var result = await MenuAdminAppService.UpdateAsync(Id, input); + + return new OkObjectResult(result); + } + + [AutoMap(typeof(MenuItemDto))] + [AutoMap(typeof(MenuItemUpdateInput), ReverseMap = true)] + public class MenuItemUpdateViewModel : IHasConcurrencyStamp + { + [Required] + public string DisplayName { get; set; } + + public bool IsActive { get; set; } + + public string Url { get; set; } + + public string Icon { get; set; } + + public string Target { get; set; } + + public string ElementId { get; set; } + + public string CssClass { get; set; } - [BindProperty] - public MenuItemUpdateViewModel ViewModel { get; set; } + public Guid? PageId { get; set; } [HiddenInput] - [BindProperty(SupportsGet = true)] - public Guid Id { get; set; } - - public UpdateModalModel(IMenuItemAdminAppService menuAdminAppService) - { - MenuAdminAppService = menuAdminAppService; - } - - public async Task OnGetAsync() - { - var menuItemDto = await MenuAdminAppService.GetAsync(Id); - - ViewModel = ObjectMapper.Map(menuItemDto); - } - - public async Task OnPostAsync() - { - var input = ObjectMapper.Map(ViewModel); - - var result = await MenuAdminAppService.UpdateAsync(Id, input); - - return new OkObjectResult(result); - } - - [AutoMap(typeof(MenuItemDto))] - [AutoMap(typeof(MenuItemUpdateInput), ReverseMap = true)] - public class MenuItemUpdateViewModel : IHasConcurrencyStamp - { - [Required] - public string DisplayName { get; set; } - - public bool IsActive { get; set; } - - public string Url { get; set; } - - public string Icon { get; set; } - - public string Target { get; set; } - - public string ElementId { get; set; } - - public string CssClass { get; set; } - - public Guid? PageId { get; set; } - - [HiddenInput] - public string ConcurrencyStamp { get; set; } - } + public string ConcurrencyStamp { get; set; } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Create.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Create.cshtml.cs index 5be3d9b9ee..1a6e7c1b57 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Create.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Create.cshtml.cs @@ -7,51 +7,50 @@ using Volo.Abp.Validation; using Volo.CmsKit.Admin.Pages; using Volo.CmsKit.Pages; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Pages +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Pages; + +public class CreateModel : CmsKitAdminPageModel { - public class CreateModel : CmsKitAdminPageModel - { - protected readonly IPageAdminAppService pageAdminAppService; + protected readonly IPageAdminAppService pageAdminAppService; - [BindProperty] - public CreatePageViewModel ViewModel { get; set; } + [BindProperty] + public CreatePageViewModel ViewModel { get; set; } - public CreateModel(IPageAdminAppService pageAdminAppService) - { - this.pageAdminAppService = pageAdminAppService; - } + public CreateModel(IPageAdminAppService pageAdminAppService) + { + this.pageAdminAppService = pageAdminAppService; + } - public async Task OnPostAsync() - { - var createInput = ObjectMapper.Map(ViewModel); + public async Task OnPostAsync() + { + var createInput = ObjectMapper.Map(ViewModel); - var created = await pageAdminAppService.CreateAsync(createInput); + var created = await pageAdminAppService.CreateAsync(createInput); - return new OkObjectResult(created); - } + return new OkObjectResult(created); + } - [AutoMap(typeof(CreatePageInputDto), ReverseMap = true)] - public class CreatePageViewModel - { - [Required] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))] - public string Title { get; set; } + [AutoMap(typeof(CreatePageInputDto), ReverseMap = true)] + public class CreatePageViewModel + { + [Required] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))] + public string Title { get; set; } - [Required] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] - public string Slug { get; set; } + [Required] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] + public string Slug { get; set; } - [HiddenInput] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] - public string Content { get; set; } + [HiddenInput] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] + public string Content { get; set; } - [TextArea(Rows = 6)] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] - public string Script { get; set; } + [TextArea(Rows = 6)] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] + public string Script { get; set; } - [TextArea(Rows = 6)] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] - public string Style { get; set; } - } + [TextArea(Rows = 6)] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] + public string Style { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Index.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Index.cshtml.cs index 9c4eea078b..932e0bc493 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Index.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Index.cshtml.cs @@ -1,11 +1,10 @@  -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Pages +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Pages; + +public class IndexModel : CmsKitAdminPageModel { - public class IndexModel : CmsKitAdminPageModel + public void OnGet() { - public void OnGet() - { - - } + } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml.cs index 797c97eb64..3116144cc7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml.cs @@ -9,66 +9,65 @@ using Volo.Abp.Validation; using Volo.CmsKit.Admin.Pages; using Volo.CmsKit.Pages; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Pages +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Pages; + +public class UpdateModel : CmsKitAdminPageModel { - public class UpdateModel : CmsKitAdminPageModel + [BindProperty(SupportsGet = true)] + [HiddenInput] + public Guid Id { get; set; } + + [BindProperty] + public UpdatePageViewModel ViewModel { get; set; } + + protected readonly IPageAdminAppService pageAdminAppService; + + public UpdateModel(IPageAdminAppService pageAdminAppService) + { + this.pageAdminAppService = pageAdminAppService; + } + + public async Task OnGetAsync() + { + var dto = await pageAdminAppService.GetAsync(Id); + + ViewModel = ObjectMapper.Map(dto); + } + + public async Task OnPostAsync() { - [BindProperty(SupportsGet = true)] + var updateInput = ObjectMapper.Map(ViewModel); + + await pageAdminAppService.UpdateAsync(Id, updateInput); + + return NoContent(); + } + + [AutoMap(typeof(PageDto))] + [AutoMap(typeof(UpdatePageInputDto), ReverseMap = true)] + public class UpdatePageViewModel : IHasConcurrencyStamp + { + [Required] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))] + public string Title { get; set; } + + [Required] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] + public string Slug { get; set; } + + [HiddenInput] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] + public string Content { get; set; } + + [TextArea(Rows = 6)] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxScriptLength))] + public string Script { get; set; } + + [TextArea(Rows = 6)] + [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxStyleLength))] + public string Style { get; set; } + [HiddenInput] - public Guid Id { get; set; } - - [BindProperty] - public UpdatePageViewModel ViewModel { get; set; } - - protected readonly IPageAdminAppService pageAdminAppService; - - public UpdateModel(IPageAdminAppService pageAdminAppService) - { - this.pageAdminAppService = pageAdminAppService; - } - - public async Task OnGetAsync() - { - var dto = await pageAdminAppService.GetAsync(Id); - - ViewModel = ObjectMapper.Map(dto); - } - - public async Task OnPostAsync() - { - var updateInput = ObjectMapper.Map(ViewModel); - - await pageAdminAppService.UpdateAsync(Id, updateInput); - - return NoContent(); - } - - [AutoMap(typeof(PageDto))] - [AutoMap(typeof(UpdatePageInputDto), ReverseMap = true)] - public class UpdatePageViewModel : IHasConcurrencyStamp - { - [Required] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))] - public string Title { get; set; } - - [Required] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] - public string Slug { get; set; } - - [HiddenInput] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))] - public string Content { get; set; } - - [TextArea(Rows = 6)] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxScriptLength))] - public string Script { get; set; } - - [TextArea(Rows = 6)] - [DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxStyleLength))] - public string Style { get; set; } - - [HiddenInput] - public string ConcurrencyStamp { get; set; } - } + public string ConcurrencyStamp { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/Components/TagEditor/TagEditorViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/Components/TagEditor/TagEditorViewComponent.cs index 16f84e214b..c360f9130e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/Components/TagEditor/TagEditorViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/Components/TagEditor/TagEditorViewComponent.cs @@ -6,44 +6,43 @@ using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Tags.Components.TagEditor -{ - [Widget( - ScriptFiles = new[] - { +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Tags.Components.TagEditor; + +[Widget( + ScriptFiles = new[] + { "/Pages/CmsKit/Tags/Components/TagEditor/default.js" - })] - public class TagEditorViewComponent : AbpViewComponent + })] +public class TagEditorViewComponent : AbpViewComponent +{ + protected ITagAppService TagAppService { get; } + + public TagEditorViewComponent(ITagAppService tagAppService) { - protected ITagAppService TagAppService { get; } + TagAppService = tagAppService; + } - public TagEditorViewComponent(ITagAppService tagAppService) - { - TagAppService = tagAppService; - } + public virtual async Task InvokeAsync(string entityType, string entityId, bool displaySubmitButton = true) + { + var tags = + entityId.IsNullOrWhiteSpace() ? + new List() : + await TagAppService.GetAllRelatedTagsAsync(entityType, entityId); - public virtual async Task InvokeAsync(string entityType, string entityId, bool displaySubmitButton = true) + return View("~/Pages/CmsKit/Tags/Components/TagEditor/Default.cshtml", new TagEditorViewModel { - var tags = - entityId.IsNullOrWhiteSpace() ? - new List() : - await TagAppService.GetAllRelatedTagsAsync(entityType, entityId); - - return View("~/Pages/CmsKit/Tags/Components/TagEditor/Default.cshtml", new TagEditorViewModel - { - EntityId = entityId, - EntityType = entityType, - Tags = tags, - DisplaySubmitButton = displaySubmitButton - }); - } + EntityId = entityId, + EntityType = entityType, + Tags = tags, + DisplaySubmitButton = displaySubmitButton + }); + } - public class TagEditorViewModel - { - public string EntityType { get; set; } - public string EntityId { get; set; } - public List Tags { get; set; } - public bool DisplaySubmitButton { get; set; } - } + public class TagEditorViewModel + { + public string EntityType { get; set; } + public string EntityId { get; set; } + public List Tags { get; set; } + public bool DisplaySubmitButton { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/CreateModal.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/CreateModal.cshtml.cs index 5ce3d0cb1f..9dbbe18abc 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/CreateModal.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/CreateModal.cshtml.cs @@ -10,49 +10,48 @@ using Volo.Abp.Validation; using Volo.CmsKit.Admin.Tags; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Tags -{ - public class CreateModalModel : CmsKitAdminPageModel - { - protected ITagAdminAppService TagAdminAppService { get; } +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Tags; - [BindProperty] - public TagCreateViewModel ViewModel { get; set; } +public class CreateModalModel : CmsKitAdminPageModel +{ + protected ITagAdminAppService TagAdminAppService { get; } - public List TagDefinitions { get; set; } + [BindProperty] + public TagCreateViewModel ViewModel { get; set; } - public CreateModalModel(ITagAdminAppService tagAdminAppService) - { - TagAdminAppService = tagAdminAppService; - } + public List TagDefinitions { get; set; } - public async Task OnGetAsync() - { - var definitions = await TagAdminAppService.GetTagDefinitionsAsync(); + public CreateModalModel(ITagAdminAppService tagAdminAppService) + { + TagAdminAppService = tagAdminAppService; + } - TagDefinitions = definitions.Select(s => new SelectListItem(s.DisplayName, s.EntityType)).ToList(); - } + public async Task OnGetAsync() + { + var definitions = await TagAdminAppService.GetTagDefinitionsAsync(); - public async Task OnPostAsync() - { - var tagCreateDto = ObjectMapper.Map(ViewModel); + TagDefinitions = definitions.Select(s => new SelectListItem(s.DisplayName, s.EntityType)).ToList(); + } - await TagAdminAppService.CreateAsync(tagCreateDto); + public async Task OnPostAsync() + { + var tagCreateDto = ObjectMapper.Map(ViewModel); - return NoContent(); - } + await TagAdminAppService.CreateAsync(tagCreateDto); - [AutoMap(typeof(TagCreateDto), ReverseMap = true)] - public class TagCreateViewModel - { - [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxEntityTypeLength))] - [Required] - [SelectItems(nameof(TagDefinitions))] - public string EntityType { get; set; } + return NoContent(); + } - [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxNameLength))] - [Required] - public string Name { get; set; } - } + [AutoMap(typeof(TagCreateDto), ReverseMap = true)] + public class TagCreateViewModel + { + [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxEntityTypeLength))] + [Required] + [SelectItems(nameof(TagDefinitions))] + public string EntityType { get; set; } + + [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxNameLength))] + [Required] + public string Name { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/EditModal.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/EditModal.cshtml.cs index 05471b9a15..836d5103df 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/EditModal.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/EditModal.cshtml.cs @@ -11,48 +11,47 @@ using Volo.Abp.Validation; using Volo.CmsKit.Admin.Tags; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Tags +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Tags; + +public class EditModalModel : CmsKitAdminPageModel { - public class EditModalModel : CmsKitAdminPageModel + protected ITagAdminAppService TagAdminAppService { get; } + + [HiddenInput] + [BindProperty(SupportsGet = true)] + public Guid Id { get; set; } + + [BindProperty] + public TagEditViewModel ViewModel { get; set; } + + public EditModalModel(ITagAdminAppService tagAdminAppService) + { + this.TagAdminAppService = tagAdminAppService; + } + + public async Task OnGetAsync() + { + var dto = await TagAdminAppService.GetAsync(Id); + + ViewModel = ObjectMapper.Map(dto); + } + + public async Task OnPostAsync() + { + var tagDto = ObjectMapper.Map(ViewModel); + await TagAdminAppService.UpdateAsync(Id, tagDto); + return NoContent(); + } + + [AutoMap(typeof(TagDto))] + [AutoMap(typeof(TagUpdateDto), ReverseMap = true)] + public class TagEditViewModel : IHasConcurrencyStamp { - protected ITagAdminAppService TagAdminAppService { get; } + [Required] + [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxNameLength))] + public string Name { get; set; } [HiddenInput] - [BindProperty(SupportsGet = true)] - public Guid Id { get; set; } - - [BindProperty] - public TagEditViewModel ViewModel { get; set; } - - public EditModalModel(ITagAdminAppService tagAdminAppService) - { - this.TagAdminAppService = tagAdminAppService; - } - - public async Task OnGetAsync() - { - var dto = await TagAdminAppService.GetAsync(Id); - - ViewModel = ObjectMapper.Map(dto); - } - - public async Task OnPostAsync() - { - var tagDto = ObjectMapper.Map(ViewModel); - await TagAdminAppService.UpdateAsync(Id, tagDto); - return NoContent(); - } - - [AutoMap(typeof(TagDto))] - [AutoMap(typeof(TagUpdateDto), ReverseMap = true)] - public class TagEditViewModel : IHasConcurrencyStamp - { - [Required] - [DynamicMaxLength(typeof(TagConsts), nameof(TagConsts.MaxNameLength))] - public string Name { get; set; } - - [HiddenInput] - public string ConcurrencyStamp { get; set; } - } + public string ConcurrencyStamp { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/Index.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/Index.cshtml.cs index 268e61ab0e..9986fc956b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/Index.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/Index.cshtml.cs @@ -1,8 +1,7 @@ using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; -namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Tags +namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Tags; + +public class IndexModel : CmsKitAdminPageModel { - public class IndexModel : CmsKitAdminPageModel - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKitAdminPageBase.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKitAdminPageBase.cs index b45176453a..641d4266af 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKitAdminPageBase.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKitAdminPageBase.cs @@ -4,17 +4,16 @@ using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.Layout; using Volo.CmsKit.Localization; -namespace Volo.CmsKit.Admin.Web.Pages +namespace Volo.CmsKit.Admin.Web.Pages; + +public class CmsKitAdminPageBase : Microsoft.AspNetCore.Mvc.RazorPages.Page { - public class CmsKitAdminPageBase : Microsoft.AspNetCore.Mvc.RazorPages.Page - { - [RazorInject] public IStringLocalizer L { get; set; } + [RazorInject] public IStringLocalizer L { get; set; } - [RazorInject] public IPageLayout PageLayout { get; set; } + [RazorInject] public IPageLayout PageLayout { get; set; } - public override Task ExecuteAsync() - { - return Task.CompletedTask; // Will be overriden by razor pages. (.cshtml) - } + public override Task ExecuteAsync() + { + return Task.CompletedTask; // Will be overriden by razor pages. (.cshtml) } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKitAdminPageModel.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKitAdminPageModel.cs index 7a6fd8c9ae..ca2950f3ce 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKitAdminPageModel.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKitAdminPageModel.cs @@ -1,16 +1,15 @@ using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.CmsKit.Localization; -namespace Volo.CmsKit.Admin.Web.Pages +namespace Volo.CmsKit.Admin.Web.Pages; + +/* Inherit your PageModel classes from this class. + */ +public abstract class CmsKitAdminPageModel : AbpPageModel { - /* Inherit your PageModel classes from this class. - */ - public abstract class CmsKitAdminPageModel : AbpPageModel + protected CmsKitAdminPageModel() { - protected CmsKitAdminPageModel() - { - LocalizationResourceType = typeof(CmsKitResource); - ObjectMapperContext = typeof(CmsKitAdminWebModule); - } + LocalizationResourceType = typeof(CmsKitResource); + ObjectMapperContext = typeof(CmsKitAdminWebModule); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Properties/launchSettings.json b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Properties/launchSettings.json new file mode 100644 index 0000000000..705f30a4c6 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:50568/", + "sslPort": 44301 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Volo.CmsKit.Admin.Web": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:5000" + } + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Application.Contracts/Volo/CmsKit/CmsKitApplicationContractsModule.cs b/modules/cms-kit/src/Volo.CmsKit.Application.Contracts/Volo/CmsKit/CmsKitApplicationContractsModule.cs index e29c725b05..ad8358eec0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Application.Contracts/Volo/CmsKit/CmsKitApplicationContractsModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Application.Contracts/Volo/CmsKit/CmsKitApplicationContractsModule.cs @@ -2,14 +2,13 @@ using Volo.CmsKit.Admin; using Volo.CmsKit.Public; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitPublicApplicationContractsModule), + typeof(CmsKitAdminApplicationContractsModule) + )] +public class CmsKitApplicationContractsModule : AbpModule { - [DependsOn( - typeof(CmsKitPublicApplicationContractsModule), - typeof(CmsKitAdminApplicationContractsModule) - )] - public class CmsKitApplicationContractsModule : AbpModule - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Application/Volo/CmsKit/CmsKitApplicationModule.cs b/modules/cms-kit/src/Volo.CmsKit.Application/Volo/CmsKit/CmsKitApplicationModule.cs index 2b48e56716..6b525e4f99 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Application/Volo/CmsKit/CmsKitApplicationModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Application/Volo/CmsKit/CmsKitApplicationModule.cs @@ -2,15 +2,14 @@ using Volo.CmsKit.Admin; using Volo.CmsKit.Public; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitPublicApplicationModule), + typeof(CmsKitAdminApplicationModule), + typeof(CmsKitApplicationContractsModule) + )] +public class CmsKitApplicationModule : AbpModule { - [DependsOn( - typeof(CmsKitPublicApplicationModule), - typeof(CmsKitAdminApplicationModule), - typeof(CmsKitApplicationContractsModule) - )] - public class CmsKitApplicationModule : AbpModule - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureCacheItem.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureCacheItem.cs index 3ad4565aed..ef3f79b3df 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureCacheItem.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureCacheItem.cs @@ -1,12 +1,11 @@ using System; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +[Serializable] +public class BlogFeatureCacheItem { - [Serializable] - public class BlogFeatureCacheItem - { - public Guid Id { get; set; } - public string FeatureName { get; set; } - public bool IsEnabled { get; set; } - } + public Guid Id { get; set; } + public string FeatureName { get; set; } + public bool IsEnabled { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureCacheKey.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureCacheKey.cs index f3e9579c0c..b49bfb83d0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureCacheKey.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureCacheKey.cs @@ -2,23 +2,22 @@ using System; using Volo.Abp; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogFeatureCacheKey { - public class BlogFeatureCacheKey + public BlogFeatureCacheKey(Guid id, [NotNull] string featureName) { - public BlogFeatureCacheKey(Guid id, [NotNull] string featureName) - { - Id = id; - FeatureName = Check.NotNullOrEmpty(featureName, nameof(featureName)); - } + Id = id; + FeatureName = Check.NotNullOrEmpty(featureName, nameof(featureName)); + } - public Guid Id { get; set; } + public Guid Id { get; set; } - public string FeatureName { get; set; } + public string FeatureName { get; set; } - public override string ToString() - { - return $"BlogFeature_{Id}_{FeatureName}"; - } + public override string ToString() + { + return $"BlogFeature_{Id}_{FeatureName}"; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureDto.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureDto.cs index 6d6188c985..b2ca7eea17 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureDto.cs @@ -1,12 +1,11 @@ using System; using Volo.Abp.Application.Dtos; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +[Serializable] +public class BlogFeatureDto : EntityDto { - [Serializable] - public class BlogFeatureDto : EntityDto - { - public string FeatureName { get; set; } - public bool IsEnabled { get; set; } - } + public string FeatureName { get; set; } + public bool IsEnabled { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/IBlogFeatureAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/IBlogFeatureAppService.cs index 52a1dbd71a..9f754d8183 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/IBlogFeatureAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/IBlogFeatureAppService.cs @@ -2,10 +2,9 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public interface IBlogFeatureAppService : IApplicationService { - public interface IBlogFeatureAppService : IApplicationService - { - Task GetOrDefaultAsync(Guid blogId, string featureName); - } + Task GetOrDefaultAsync(Guid blogId, string featureName); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/CmsKitCommonApplicationContractsModule.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/CmsKitCommonApplicationContractsModule.cs index 12e25acc76..e675de2267 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/CmsKitCommonApplicationContractsModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/CmsKitCommonApplicationContractsModule.cs @@ -2,15 +2,14 @@ using Volo.Abp.Authorization; using Volo.Abp.Modularity; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitDomainSharedModule), + typeof(AbpDddApplicationContractsModule), + typeof(AbpAuthorizationModule) +)] +public class CmsKitCommonApplicationContractsModule : AbpModule { - [DependsOn( - typeof(CmsKitDomainSharedModule), - typeof(AbpDddApplicationContractsModule), - typeof(AbpAuthorizationModule) - )] - public class CmsKitCommonApplicationContractsModule : AbpModule - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/CmsKitCommonRemoteServiceConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/CmsKitCommonRemoteServiceConsts.cs index 2fdb413fc9..5a652c1b3d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/CmsKitCommonRemoteServiceConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/CmsKitCommonRemoteServiceConsts.cs @@ -1,9 +1,8 @@ -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class CmsKitCommonRemoteServiceConsts { - public class CmsKitCommonRemoteServiceConsts - { - public const string RemoteServiceName = "CmsKitCommon"; + public const string RemoteServiceName = "CmsKitCommon"; - public const string ModuleName = "cms-kit-common"; - } + public const string ModuleName = "cms-kit-common"; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/MediaDescriptors/IMediaDescriptorAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/MediaDescriptors/IMediaDescriptorAppService.cs index b50103ef0c..569a76a691 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/MediaDescriptors/IMediaDescriptorAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/MediaDescriptors/IMediaDescriptorAppService.cs @@ -3,10 +3,9 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.Abp.Content; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public interface IMediaDescriptorAppService : IApplicationService { - public interface IMediaDescriptorAppService : IApplicationService - { - Task DownloadAsync(Guid id); - } -} \ No newline at end of file + Task DownloadAsync(Guid id); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Menus/MenuItemDto.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Menus/MenuItemDto.cs index f40a1ad344..0f39ff131e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Menus/MenuItemDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Menus/MenuItemDto.cs @@ -2,31 +2,30 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Entities; -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +[Serializable] +public class MenuItemDto : AuditedEntityDto, IHasConcurrencyStamp { - [Serializable] - public class MenuItemDto : AuditedEntityDto, IHasConcurrencyStamp - { - public Guid? ParentId { get; set; } + public Guid? ParentId { get; set; } - public string DisplayName { get; set; } + public string DisplayName { get; set; } - public bool IsActive { get; set; } + public bool IsActive { get; set; } - public string Url { get; set; } + public string Url { get; set; } - public string Icon { get; set; } + public string Icon { get; set; } - public int Order { get; set; } + public int Order { get; set; } - public string Target { get; set; } + public string Target { get; set; } - public string ElementId { get; set; } + public string ElementId { get; set; } - public string CssClass { get; set; } + public string CssClass { get; set; } - public Guid? PageId { get; set; } + public Guid? PageId { get; set; } - public string ConcurrencyStamp { get; set; } - } + public string ConcurrencyStamp { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Permissions/CmsKitPermissionDefinitionProvider.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Permissions/CmsKitPermissionDefinitionProvider.cs index c0f7775ba8..52a84a55b3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Permissions/CmsKitPermissionDefinitionProvider.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Permissions/CmsKitPermissionDefinitionProvider.cs @@ -2,21 +2,20 @@ using Volo.Abp.Localization; using Volo.CmsKit.Localization; -namespace Volo.CmsKit.Permissions +namespace Volo.CmsKit.Permissions; + +public class CmsKitPermissionDefinitionProvider : PermissionDefinitionProvider { - public class CmsKitPermissionDefinitionProvider : PermissionDefinitionProvider + public override void Define(IPermissionDefinitionContext context) { - public override void Define(IPermissionDefinitionContext context) - { - var myGroup = context.AddGroup( - CmsKitPermissions.GroupName, - L("Permission:CmsKit.Public") - ); - } + var myGroup = context.AddGroup( + CmsKitPermissions.GroupName, + L("Permission:CmsKit.Public") + ); + } - private static LocalizableString L(string name) - { - return LocalizableString.Create(name); - } + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Permissions/CmsKitPermissions.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Permissions/CmsKitPermissions.cs index 08557bb3ca..7bdf38dc68 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Permissions/CmsKitPermissions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Permissions/CmsKitPermissions.cs @@ -1,14 +1,13 @@ using Volo.Abp.Reflection; -namespace Volo.CmsKit.Permissions +namespace Volo.CmsKit.Permissions; + +public class CmsKitPermissions { - public class CmsKitPermissions - { - public const string GroupName = "CmsKit.Public"; + public const string GroupName = "CmsKit.Public"; - public static string[] GetAll() - { - return ReflectionHelper.GetPublicConstantsRecursively(typeof(CmsKitPermissions)); - } + public static string[] GetAll() + { + return ReflectionHelper.GetPublicConstantsRecursively(typeof(CmsKitPermissions)); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/ITagAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/ITagAppService.cs index 5ab01940e1..b984d76dc2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/ITagAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/ITagAppService.cs @@ -3,10 +3,9 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public interface ITagAppService : IApplicationService { - public interface ITagAppService : IApplicationService - { - Task> GetAllRelatedTagsAsync(string entityType, string entityId); - } -} \ No newline at end of file + Task> GetAllRelatedTagsAsync(string entityType, string entityId); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/TagDto.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/TagDto.cs index 38f89f61a3..7e36d1579b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/TagDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Tags/TagDto.cs @@ -2,15 +2,14 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Entities; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +[Serializable] +public class TagDto : EntityDto, IHasConcurrencyStamp { - [Serializable] - public class TagDto : EntityDto, IHasConcurrencyStamp - { - public string EntityType { get; set; } + public string EntityType { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public string ConcurrencyStamp { get; set; } - } + public string ConcurrencyStamp { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Users/CmsUserDto.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Users/CmsUserDto.cs index 3bd54fec03..bd6a6c374e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Users/CmsUserDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Users/CmsUserDto.cs @@ -5,17 +5,16 @@ using System.Text; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; -namespace Volo.CmsKit.Users +namespace Volo.CmsKit.Users; + +[Serializable] +public class CmsUserDto : EntityDto { - [Serializable] - public class CmsUserDto : EntityDto - { - public virtual Guid? TenantId { get; protected set; } + public virtual Guid? TenantId { get; protected set; } - public virtual string UserName { get; protected set; } + public virtual string UserName { get; protected set; } - public virtual string Name { get; set; } + public virtual string Name { get; set; } - public virtual string Surname { get; set; } - } + public virtual string Surname { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs index 5f6a38c95c..c03f8e3a28 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs @@ -5,38 +5,37 @@ using Volo.Abp.Caching; using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +[RequiresGlobalFeature(typeof(BlogsFeature))] +public class BlogFeatureAppService : CmsKitAppServiceBase, IBlogFeatureAppService { - [RequiresGlobalFeature(typeof(BlogsFeature))] - public class BlogFeatureAppService : CmsKitAppServiceBase, IBlogFeatureAppService + protected virtual IBlogFeatureRepository BlogFeatureRepository { get; } + + protected virtual IDistributedCache Cache { get; } + + public BlogFeatureAppService( + IBlogFeatureRepository blogFeatureRepository, + IDistributedCache blogFeatureCacheManager) + { + BlogFeatureRepository = blogFeatureRepository; + Cache = blogFeatureCacheManager; + } + + public virtual async Task GetOrDefaultAsync(Guid blogId, string featureName) { - protected virtual IBlogFeatureRepository BlogFeatureRepository { get; } - - protected virtual IDistributedCache Cache { get; } - - public BlogFeatureAppService( - IBlogFeatureRepository blogFeatureRepository, - IDistributedCache blogFeatureCacheManager) - { - BlogFeatureRepository = blogFeatureRepository; - Cache = blogFeatureCacheManager; - } - - public virtual async Task GetOrDefaultAsync(Guid blogId, string featureName) - { - var cacheItem = await Cache.GetOrAddAsync( - new BlogFeatureCacheKey(blogId, featureName), - ()=> GetOrDefaultFroRepositoryAsync(blogId, featureName)); - - return ObjectMapper.Map(cacheItem); - } - - protected virtual async Task GetOrDefaultFroRepositoryAsync(Guid blogId, string featureName) - { - var feature = await BlogFeatureRepository.FindAsync(blogId, featureName); - var blogFeature = feature ?? new BlogFeature(blogId, featureName); - - return ObjectMapper.Map(blogFeature); - } + var cacheItem = await Cache.GetOrAddAsync( + new BlogFeatureCacheKey(blogId, featureName), + () => GetOrDefaultFroRepositoryAsync(blogId, featureName)); + + return ObjectMapper.Map(cacheItem); + } + + protected virtual async Task GetOrDefaultFroRepositoryAsync(Guid blogId, string featureName) + { + var feature = await BlogFeatureRepository.FindAsync(blogId, featureName); + var blogFeature = feature ?? new BlogFeature(blogId, featureName); + + return ObjectMapper.Map(blogFeature); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs index 6e5ee46a79..d4451fec61 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs @@ -5,34 +5,33 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Entities.Events; using Volo.Abp.EventBus; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogFeatureChangedHandler : + ILocalEventHandler>, + ILocalEventHandler>, + ITransientDependency { - public class BlogFeatureChangedHandler : - ILocalEventHandler>, - ILocalEventHandler>, - ITransientDependency - { - protected IDistributedCache Cache { get; } + protected IDistributedCache Cache { get; } - public BlogFeatureChangedHandler( - IDistributedCache cache) - { - Cache = cache; - } + public BlogFeatureChangedHandler( + IDistributedCache cache) + { + Cache = cache; + } - public Task RemoveFromCacheAsync(Guid blogId, string featureName) - { - return Cache.RemoveAsync(new BlogFeatureCacheKey(blogId, featureName)); - } + public Task RemoveFromCacheAsync(Guid blogId, string featureName) + { + return Cache.RemoveAsync(new BlogFeatureCacheKey(blogId, featureName)); + } - public Task HandleEventAsync(EntityCreatedEventData eventData) - { - return RemoveFromCacheAsync(eventData.Entity.BlogId, eventData.Entity.FeatureName); - } + public Task HandleEventAsync(EntityCreatedEventData eventData) + { + return RemoveFromCacheAsync(eventData.Entity.BlogId, eventData.Entity.FeatureName); + } - public Task HandleEventAsync(EntityUpdatedEventData eventData) - { - return RemoveFromCacheAsync(eventData.Entity.BlogId, eventData.Entity.FeatureName); - } + public Task HandleEventAsync(EntityUpdatedEventData eventData) + { + return RemoveFromCacheAsync(eventData.Entity.BlogId, eventData.Entity.FeatureName); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitAppServiceBase.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitAppServiceBase.cs index ffb2a8b197..99efcb92b8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitAppServiceBase.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitAppServiceBase.cs @@ -1,13 +1,12 @@ using Volo.Abp.Application.Services; using Volo.CmsKit.Localization; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public abstract class CmsKitAppServiceBase : ApplicationService { - public abstract class CmsKitAppServiceBase : ApplicationService + protected CmsKitAppServiceBase() { - protected CmsKitAppServiceBase() - { - LocalizationResource = typeof(CmsKitResource); - } + LocalizationResource = typeof(CmsKitResource); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitCommonApplicationAutoMapperProfile.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitCommonApplicationAutoMapperProfile.cs index aff12d05c1..e323ab3551 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitCommonApplicationAutoMapperProfile.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitCommonApplicationAutoMapperProfile.cs @@ -3,19 +3,18 @@ using Volo.CmsKit.Blogs; using Volo.CmsKit.Tags; using Volo.CmsKit.Users; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class CmsKitCommonApplicationAutoMapperProfile : Profile { - public class CmsKitCommonApplicationAutoMapperProfile : Profile + public CmsKitCommonApplicationAutoMapperProfile() { - public CmsKitCommonApplicationAutoMapperProfile() - { - CreateMap(); + CreateMap(); - CreateMap(); + CreateMap(); - CreateMap(); - CreateMap(); - CreateMap().ReverseMap(); - } + CreateMap(); + CreateMap(); + CreateMap().ReverseMap(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitCommonApplicationModule.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitCommonApplicationModule.cs index 1778e7e234..44125bd4bf 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitCommonApplicationModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitCommonApplicationModule.cs @@ -7,22 +7,21 @@ using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.MediaDescriptors; using Volo.CmsKit.Permissions; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitCommonApplicationContractsModule), + typeof(CmsKitDomainModule), + typeof(AbpDddApplicationModule), + typeof(AbpAutoMapperModule) +)] +public class CmsKitCommonApplicationModule : AbpModule { - [DependsOn( - typeof(CmsKitCommonApplicationContractsModule), - typeof(CmsKitDomainModule), - typeof(AbpDddApplicationModule), - typeof(AbpAutoMapperModule) - )] - public class CmsKitCommonApplicationModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.AddMaps(validate: true); - }); - } + options.AddMaps(validate: true); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/MediaDescriptors/MediaDescriptorAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/MediaDescriptors/MediaDescriptorAppService.cs index 99700630e7..414c15cca6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/MediaDescriptors/MediaDescriptorAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/MediaDescriptors/MediaDescriptorAppService.cs @@ -5,26 +5,25 @@ using Volo.Abp.Content; using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +[RequiresGlobalFeature(typeof(MediaFeature))] +public class MediaDescriptorAppService : CmsKitAppServiceBase, IMediaDescriptorAppService { - [RequiresGlobalFeature(typeof(MediaFeature))] - public class MediaDescriptorAppService : CmsKitAppServiceBase, IMediaDescriptorAppService - { - protected IMediaDescriptorRepository MediaDescriptorRepository { get; } - protected IBlobContainer MediaContainer { get; } + protected IMediaDescriptorRepository MediaDescriptorRepository { get; } + protected IBlobContainer MediaContainer { get; } - public MediaDescriptorAppService(IMediaDescriptorRepository mediaDescriptorRepository, IBlobContainer mediaContainer) - { - MediaDescriptorRepository = mediaDescriptorRepository; - MediaContainer = mediaContainer; - } + public MediaDescriptorAppService(IMediaDescriptorRepository mediaDescriptorRepository, IBlobContainer mediaContainer) + { + MediaDescriptorRepository = mediaDescriptorRepository; + MediaContainer = mediaContainer; + } - public virtual async Task DownloadAsync(Guid id) - { - var entity = await MediaDescriptorRepository.GetAsync(id); - var stream = await MediaContainer.GetAsync(id.ToString()); + public virtual async Task DownloadAsync(Guid id) + { + var entity = await MediaDescriptorRepository.GetAsync(id); + var stream = await MediaContainer.GetAsync(id.ToString()); - return new RemoteStreamContent(stream, entity.Name, entity.MimeType); - } + return new RemoteStreamContent(stream, entity.Name, entity.MimeType); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Menus/MenuApplicationConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Menus/MenuApplicationConsts.cs index 308680dd30..8e5fb9834f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Menus/MenuApplicationConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Menus/MenuApplicationConsts.cs @@ -1,7 +1,6 @@ -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +public static class MenuApplicationConsts { - public static class MenuApplicationConsts - { - public static string MainMenuCacheKey = "MainMenu"; - } -} \ No newline at end of file + public static string MainMenuCacheKey = "MainMenu"; +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Menus/MenuChangedHandler.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Menus/MenuChangedHandler.cs index a0c55ca641..3716edf567 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Menus/MenuChangedHandler.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Menus/MenuChangedHandler.cs @@ -5,34 +5,33 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Entities.Events; using Volo.Abp.EventBus; -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +public class MenuChangedHandler : + ILocalEventHandler>, + ILocalEventHandler>, + ILocalEventHandler>, + ITransientDependency { - public class MenuChangedHandler : - ILocalEventHandler>, - ILocalEventHandler>, - ILocalEventHandler>, - ITransientDependency + protected IDistributedCache> DistributedCache { get; } + + public MenuChangedHandler(IDistributedCache> distributedCache) { - protected IDistributedCache> DistributedCache { get; } - - public MenuChangedHandler(IDistributedCache> distributedCache) - { - DistributedCache = distributedCache; - } + DistributedCache = distributedCache; + } - public Task HandleEventAsync(EntityUpdatedEventData eventData) - { - return DistributedCache.RemoveAsync(MenuApplicationConsts.MainMenuCacheKey); - } + public Task HandleEventAsync(EntityUpdatedEventData eventData) + { + return DistributedCache.RemoveAsync(MenuApplicationConsts.MainMenuCacheKey); + } - public Task HandleEventAsync(EntityDeletedEventData eventData) - { - return DistributedCache.RemoveAsync(MenuApplicationConsts.MainMenuCacheKey); - } + public Task HandleEventAsync(EntityDeletedEventData eventData) + { + return DistributedCache.RemoveAsync(MenuApplicationConsts.MainMenuCacheKey); + } - public Task HandleEventAsync(EntityCreatedEventData eventData) - { - return DistributedCache.RemoveAsync(MenuApplicationConsts.MainMenuCacheKey); - } + public Task HandleEventAsync(EntityCreatedEventData eventData) + { + return DistributedCache.RemoveAsync(MenuApplicationConsts.MainMenuCacheKey); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Tags/TagAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Tags/TagAppService.cs index 191eeb4999..daa8bd5ec8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Tags/TagAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Tags/TagAppService.cs @@ -5,24 +5,23 @@ using System.Text; using System.Threading.Tasks; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class TagAppService : CmsKitAppServiceBase, ITagAppService { - public class TagAppService : CmsKitAppServiceBase, ITagAppService - { - protected ITagRepository TagRepository { get; } + protected ITagRepository TagRepository { get; } - public TagAppService(ITagRepository tagRepository) - { - TagRepository = tagRepository; - } + public TagAppService(ITagRepository tagRepository) + { + TagRepository = tagRepository; + } - public virtual async Task> GetAllRelatedTagsAsync(string entityType, string entityId) - { - var entities = await TagRepository.GetAllRelatedTagsAsync( - entityType, - entityId); + public virtual async Task> GetAllRelatedTagsAsync(string entityType, string entityId) + { + var entities = await TagRepository.GetAllRelatedTagsAsync( + entityType, + entityId); - return ObjectMapper.Map, List>(entities); - } + return ObjectMapper.Map, List>(entities); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/ClientProxies/BlogFeatureClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/ClientProxies/BlogFeatureClientProxy.cs index a16bc8a329..61650128a9 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/ClientProxies/BlogFeatureClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/ClientProxies/BlogFeatureClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of BlogFeatureClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Blogs.ClientProxies +namespace Volo.CmsKit.Blogs.ClientProxies; + +public partial class BlogFeatureClientProxy { - public partial class BlogFeatureClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/ClientProxies/MediaDescriptorClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/ClientProxies/MediaDescriptorClientProxy.cs index c3c90c23db..cf3e084ddc 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/ClientProxies/MediaDescriptorClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/ClientProxies/MediaDescriptorClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of MediaDescriptorClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.MediaDescriptors.ClientProxies +namespace Volo.CmsKit.MediaDescriptors.ClientProxies; + +public partial class MediaDescriptorClientProxy { - public partial class MediaDescriptorClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/Volo/CmsKit/CmsKitCommonHttpApiClientModule.cs b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/Volo/CmsKit/CmsKitCommonHttpApiClientModule.cs index bad9e9a844..96a2ffe792 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/Volo/CmsKit/CmsKitCommonHttpApiClientModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi.Client/Volo/CmsKit/CmsKitCommonHttpApiClientModule.cs @@ -4,25 +4,24 @@ using Volo.Abp.Http.Client; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(AbpHttpClientModule), + typeof(CmsKitCommonApplicationContractsModule) + )] +public class CmsKitCommonHttpApiClientModule : AbpModule { - [DependsOn( - typeof(AbpHttpClientModule), - typeof(CmsKitCommonApplicationContractsModule) - )] - public class CmsKitCommonHttpApiClientModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddStaticHttpClientProxies( - typeof(CmsKitCommonApplicationContractsModule).Assembly, - CmsKitCommonRemoteServiceConsts.RemoteServiceName - ); + context.Services.AddStaticHttpClientProxies( + typeof(CmsKitCommonApplicationContractsModule).Assembly, + CmsKitCommonRemoteServiceConsts.RemoteServiceName + ); - Configure(options => - { - options.FileSets.AddEmbedded(); - }); - } + Configure(options => + { + options.FileSets.AddEmbedded(); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Blogs/BlogFeatureController.cs b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Blogs/BlogFeatureController.cs index a282116ce5..340ae13db5 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Blogs/BlogFeatureController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Blogs/BlogFeatureController.cs @@ -6,26 +6,25 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.Blogs; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +[RequiresGlobalFeature(typeof(BlogsFeature))] +[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitCommonRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit/blogs/{blogId}/features")] +public class BlogFeatureController : CmsKitControllerBase, IBlogFeatureAppService { - [RequiresGlobalFeature(typeof(BlogsFeature))] - [RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitCommonRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit/blogs/{blogId}/features")] - public class BlogFeatureController : CmsKitControllerBase, IBlogFeatureAppService - { - protected IBlogFeatureAppService BlogFeatureAppService { get; } + protected IBlogFeatureAppService BlogFeatureAppService { get; } - public BlogFeatureController(IBlogFeatureAppService blogFeatureAppService) - { - BlogFeatureAppService = blogFeatureAppService; - } + public BlogFeatureController(IBlogFeatureAppService blogFeatureAppService) + { + BlogFeatureAppService = blogFeatureAppService; + } - [HttpGet] - [Route("{featureName}")] - public Task GetOrDefaultAsync(Guid blogId, string featureName) - { - return BlogFeatureAppService.GetOrDefaultAsync(blogId, featureName); - } + [HttpGet] + [Route("{featureName}")] + public Task GetOrDefaultAsync(Guid blogId, string featureName) + { + return BlogFeatureAppService.GetOrDefaultAsync(blogId, featureName); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/CmsKitCommonHttpApiModule.cs b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/CmsKitCommonHttpApiModule.cs index e94344d1a0..953651217c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/CmsKitCommonHttpApiModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/CmsKitCommonHttpApiModule.cs @@ -5,31 +5,30 @@ using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.CmsKit.Localization; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(AbpAspNetCoreMvcModule), + typeof(CmsKitCommonApplicationContractsModule) + )] +public class CmsKitCommonHttpApiModule : AbpModule { - [DependsOn( - typeof(AbpAspNetCoreMvcModule), - typeof(CmsKitCommonApplicationContractsModule) - )] - public class CmsKitCommonHttpApiModule : AbpModule - { - public override void PreConfigureServices(ServiceConfigurationContext context) + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(mvcBuilder => { - PreConfigure(mvcBuilder => - { - mvcBuilder.AddApplicationPartIfNotExists(typeof(CmsKitCommonHttpApiModule).Assembly); - }); - } + mvcBuilder.AddApplicationPartIfNotExists(typeof(CmsKitCommonHttpApiModule).Assembly); + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.Resources - .Get() - .AddBaseTypes(typeof(AbpUiResource)); - }); - } + options.Resources + .Get() + .AddBaseTypes(typeof(AbpUiResource)); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/CmsKitControllerBase.cs b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/CmsKitControllerBase.cs index 4ac5d5423b..02c4ecff37 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/CmsKitControllerBase.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/CmsKitControllerBase.cs @@ -1,13 +1,12 @@ using Volo.Abp.AspNetCore.Mvc; using Volo.CmsKit.Localization; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public abstract class CmsKitControllerBase : AbpControllerBase { - public abstract class CmsKitControllerBase : AbpControllerBase + protected CmsKitControllerBase() { - protected CmsKitControllerBase() - { - LocalizationResource = typeof(CmsKitResource); - } + LocalizationResource = typeof(CmsKitResource); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/MediaDescriptors/MediaDescriptorController.cs b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/MediaDescriptors/MediaDescriptorController.cs index 6dac329571..23233596a2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/MediaDescriptors/MediaDescriptorController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/MediaDescriptors/MediaDescriptorController.cs @@ -6,26 +6,25 @@ using Volo.Abp.Content; using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +[RequiresGlobalFeature(typeof(MediaFeature))] +[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitCommonRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit/media")] +public class MediaDescriptorController : CmsKitControllerBase, IMediaDescriptorAppService { - [RequiresGlobalFeature(typeof(MediaFeature))] - [RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitCommonRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit/media")] - public class MediaDescriptorController : CmsKitControllerBase, IMediaDescriptorAppService - { - protected readonly IMediaDescriptorAppService MediaDescriptorAppService; + protected readonly IMediaDescriptorAppService MediaDescriptorAppService; - public MediaDescriptorController(IMediaDescriptorAppService mediaDescriptorAppService) - { - MediaDescriptorAppService = mediaDescriptorAppService; - } + public MediaDescriptorController(IMediaDescriptorAppService mediaDescriptorAppService) + { + MediaDescriptorAppService = mediaDescriptorAppService; + } - [HttpGet] - [Route("{id}")] - public virtual Task DownloadAsync(Guid id) - { - return MediaDescriptorAppService.DownloadAsync(id); - } + [HttpGet] + [Route("{id}")] + public virtual Task DownloadAsync(Guid id) + { + return MediaDescriptorAppService.DownloadAsync(id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitCommonWebModule.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitCommonWebModule.cs index ea340d61e5..c80ab584dd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitCommonWebModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitCommonWebModule.cs @@ -6,43 +6,42 @@ using Volo.Abp.VirtualFileSystem; using Volo.CmsKit.Reactions; using Volo.CmsKit.Web.Icons; -namespace Volo.CmsKit.Web +namespace Volo.CmsKit.Web; + +[DependsOn( + typeof(AbpAspNetCoreMvcUiThemeSharedModule), + typeof(CmsKitCommonApplicationContractsModule), + typeof(AbpAutoMapperModule) + )] +public class CmsKitCommonWebModule : AbpModule { - [DependsOn( - typeof(AbpAspNetCoreMvcUiThemeSharedModule), - typeof(CmsKitCommonApplicationContractsModule), - typeof(AbpAutoMapperModule) - )] - public class CmsKitCommonWebModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.ReactionIcons[StandardReactions.Smile] = new LocalizableIconDictionary("fas fa-smile text-warning"); - options.ReactionIcons[StandardReactions.ThumbsUp] = new LocalizableIconDictionary("fa fa-thumbs-up text-primary"); - options.ReactionIcons[StandardReactions.Confused] = new LocalizableIconDictionary("fas fa-surprise text-warning"); - options.ReactionIcons[StandardReactions.Eyes] = new LocalizableIconDictionary("fas fa-meh-rolling-eyes text-warning"); - options.ReactionIcons[StandardReactions.Heart] = new LocalizableIconDictionary("fa fa-heart text-danger"); - options.ReactionIcons[StandardReactions.HeartBroken] = new LocalizableIconDictionary("fas fa-heart-broken text-danger"); - options.ReactionIcons[StandardReactions.Wink] = new LocalizableIconDictionary("fas fa-grin-wink text-warning"); - options.ReactionIcons[StandardReactions.Pray] = new LocalizableIconDictionary("fas fa-praying-hands text-info"); - options.ReactionIcons[StandardReactions.Rocket] = new LocalizableIconDictionary("fa fa-rocket text-success"); - options.ReactionIcons[StandardReactions.ThumbsDown] = new LocalizableIconDictionary("fa fa-thumbs-down text-secondary"); - options.ReactionIcons[StandardReactions.Victory] = new LocalizableIconDictionary("fas fa-hand-peace text-warning"); - options.ReactionIcons[StandardReactions.Rock] = new LocalizableIconDictionary("fas fa-hand-rock text-warning"); - }); + options.ReactionIcons[StandardReactions.Smile] = new LocalizableIconDictionary("fas fa-smile text-warning"); + options.ReactionIcons[StandardReactions.ThumbsUp] = new LocalizableIconDictionary("fa fa-thumbs-up text-primary"); + options.ReactionIcons[StandardReactions.Confused] = new LocalizableIconDictionary("fas fa-surprise text-warning"); + options.ReactionIcons[StandardReactions.Eyes] = new LocalizableIconDictionary("fas fa-meh-rolling-eyes text-warning"); + options.ReactionIcons[StandardReactions.Heart] = new LocalizableIconDictionary("fa fa-heart text-danger"); + options.ReactionIcons[StandardReactions.HeartBroken] = new LocalizableIconDictionary("fas fa-heart-broken text-danger"); + options.ReactionIcons[StandardReactions.Wink] = new LocalizableIconDictionary("fas fa-grin-wink text-warning"); + options.ReactionIcons[StandardReactions.Pray] = new LocalizableIconDictionary("fas fa-praying-hands text-info"); + options.ReactionIcons[StandardReactions.Rocket] = new LocalizableIconDictionary("fa fa-rocket text-success"); + options.ReactionIcons[StandardReactions.ThumbsDown] = new LocalizableIconDictionary("fa fa-thumbs-down text-secondary"); + options.ReactionIcons[StandardReactions.Victory] = new LocalizableIconDictionary("fas fa-hand-peace text-warning"); + options.ReactionIcons[StandardReactions.Rock] = new LocalizableIconDictionary("fas fa-hand-rock text-warning"); + }); - Configure(options => - { - options.FileSets.AddEmbedded(); - }); + Configure(options => + { + options.FileSets.AddEmbedded(); + }); - Configure(options => - { - options.DisableModule(CmsKitCommonRemoteServiceConsts.ModuleName); - }); - } + Configure(options => + { + options.DisableModule(CmsKitCommonRemoteServiceConsts.ModuleName); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiCommentOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiCommentOptions.cs index b1ac26a004..c9d955fa96 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiCommentOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiCommentOptions.cs @@ -1,12 +1,11 @@ -namespace Volo.CmsKit.Web +namespace Volo.CmsKit.Web; + +public class CmsKitUiCommentOptions { - public class CmsKitUiCommentOptions - { - public bool IsReactionsEnabled { get; set; } + public bool IsReactionsEnabled { get; set; } - public CmsKitUiCommentOptions() - { - IsReactionsEnabled = true; - } + public CmsKitUiCommentOptions() + { + IsReactionsEnabled = true; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiOptions.cs index 2b640b9696..ec89d40514 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/CmsKitUiOptions.cs @@ -1,19 +1,18 @@ using JetBrains.Annotations; using Volo.CmsKit.Web.Reactions; -namespace Volo.CmsKit.Web +namespace Volo.CmsKit.Web; + +public class CmsKitUiOptions { - public class CmsKitUiOptions - { - [NotNull] - public ReactionIconDictionary ReactionIcons { get; } + [NotNull] + public ReactionIconDictionary ReactionIcons { get; } - public CmsKitUiCommentOptions CommentsOptions { get; } + public CmsKitUiCommentOptions CommentsOptions { get; } - public CmsKitUiOptions() - { - ReactionIcons = new ReactionIconDictionary(); - CommentsOptions = new CmsKitUiCommentOptions(); - } + public CmsKitUiOptions() + { + ReactionIcons = new ReactionIconDictionary(); + CommentsOptions = new CmsKitUiCommentOptions(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/IContentRenderer.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/IContentRenderer.cs index af600d0382..879b27cda7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/IContentRenderer.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/IContentRenderer.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; -namespace Volo.CmsKit.Web.Contents +namespace Volo.CmsKit.Web.Contents; + +public interface IContentRenderer { - public interface IContentRenderer - { - Task RenderAsync(string value); - } -} \ No newline at end of file + Task RenderAsync(string value); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/PlainTextContentRenderer.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/PlainTextContentRenderer.cs index 3f839947e3..cf68e25e15 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/PlainTextContentRenderer.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/PlainTextContentRenderer.cs @@ -1,13 +1,12 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace Volo.CmsKit.Web.Contents +namespace Volo.CmsKit.Web.Contents; + +public class PlainTextContentRenderer : IContentRenderer, ITransientDependency { - public class PlainTextContentRenderer : IContentRenderer, ITransientDependency + public Task RenderAsync(string value) { - public Task RenderAsync(string value) - { - return Task.FromResult(value); - } + return Task.FromResult(value); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Icons/LocalizableIconDictionary.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Icons/LocalizableIconDictionary.cs index 881c751eab..778baa1543 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Icons/LocalizableIconDictionary.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Icons/LocalizableIconDictionary.cs @@ -3,34 +3,32 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using Volo.Abp; -namespace Volo.CmsKit.Web.Icons +namespace Volo.CmsKit.Web.Icons; + +public class LocalizableIconDictionary : Dictionary { - public class LocalizableIconDictionary : Dictionary + [NotNull] + public string Default { + get => _default; + set => _default = Check.NotNullOrWhiteSpace(value, nameof(value)); + } + private string _default; + + public LocalizableIconDictionary([NotNull] string defaultIcon) { - [NotNull] - public string Default - { - get => _default; - set => _default = Check.NotNullOrWhiteSpace(value, nameof(value)); - } - private string _default; + Default = defaultIcon; + } - public LocalizableIconDictionary([NotNull] string defaultIcon) - { - Default = defaultIcon; - } + public string GetLocalizedIconOrDefault(string cultureName = null) + { + cultureName ??= CultureInfo.CurrentUICulture.Name; - public string GetLocalizedIconOrDefault(string cultureName = null) + var localizedIcon = this.GetOrDefault(cultureName); + if (localizedIcon != null) { - cultureName ??= CultureInfo.CurrentUICulture.Name; - - var localizedIcon = this.GetOrDefault(cultureName); - if (localizedIcon != null) - { - return localizedIcon; - } - - return Default; + return localizedIcon; } + + return Default; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CommonPageModel.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CommonPageModel.cs index 1148bb0436..17e71ff40a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CommonPageModel.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CommonPageModel.cs @@ -1,13 +1,12 @@ using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.CmsKit.Localization; -namespace Volo.CmsKit.Web.Pages +namespace Volo.CmsKit.Web.Pages; + +public abstract class CommonPageModel : AbpPageModel { - public abstract class CommonPageModel : AbpPageModel + protected CommonPageModel() { - protected CommonPageModel() - { - LocalizationResourceType = typeof(CmsKitResource); - } + LocalizationResourceType = typeof(CmsKitResource); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Properties/launchSettings.json b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Properties/launchSettings.json new file mode 100644 index 0000000000..0b2d439c44 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:50570/", + "sslPort": 44373 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Volo.CmsKit.Common.Web": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:5000" + } + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Reactions/ReactionIconDictionary.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Reactions/ReactionIconDictionary.cs index 038302b25a..76fc85d8d6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Reactions/ReactionIconDictionary.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Reactions/ReactionIconDictionary.cs @@ -2,19 +2,18 @@ using Volo.Abp; using Volo.CmsKit.Web.Icons; -namespace Volo.CmsKit.Web.Reactions +namespace Volo.CmsKit.Web.Reactions; + +public class ReactionIconDictionary : Dictionary { - public class ReactionIconDictionary : Dictionary + public string GetLocalizedIcon(string name, string cultureName = null) { - public string GetLocalizedIcon(string name, string cultureName = null) + var icon = this.GetOrDefault(name); + if (icon == null) { - var icon = this.GetOrDefault(name); - if (icon == null) - { - throw new AbpException($"No icon defined for the reaction with name '{name}'"); - } - - return icon.GetLocalizedIconOrDefault(cultureName); + throw new AbpException($"No icon defined for the reaction with name '{name}'"); } + + return icon.GetLocalizedIconOrDefault(cultureName); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeaturesDictionaryCmsKitExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeaturesDictionaryCmsKitExtensions.cs index 72701d5e4d..4c20723c23 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeaturesDictionaryCmsKitExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeaturesDictionaryCmsKitExtensions.cs @@ -3,32 +3,31 @@ using System.Collections.Generic; using JetBrains.Annotations; using Volo.CmsKit.GlobalFeatures; -namespace Volo.Abp.GlobalFeatures +namespace Volo.Abp.GlobalFeatures; + +public static class GlobalModuleFeaturesDictionaryCmsKitExtensions { - public static class GlobalModuleFeaturesDictionaryCmsKitExtensions + public static GlobalCmsKitFeatures CmsKit( + [NotNull] this GlobalModuleFeaturesDictionary modules) { - public static GlobalCmsKitFeatures CmsKit( - [NotNull] this GlobalModuleFeaturesDictionary modules) - { - Check.NotNull(modules, nameof(modules)); + Check.NotNull(modules, nameof(modules)); - return modules - .GetOrAdd( - GlobalCmsKitFeatures.ModuleName, - _ => new GlobalCmsKitFeatures(modules.FeatureManager) - ) - as GlobalCmsKitFeatures; - } + return modules + .GetOrAdd( + GlobalCmsKitFeatures.ModuleName, + _ => new GlobalCmsKitFeatures(modules.FeatureManager) + ) + as GlobalCmsKitFeatures; + } - public static GlobalModuleFeaturesDictionary CmsKit( - [NotNull] this GlobalModuleFeaturesDictionary modules, - [NotNull] Action configureAction) - { - Check.NotNull(configureAction, nameof(configureAction)); + public static GlobalModuleFeaturesDictionary CmsKit( + [NotNull] this GlobalModuleFeaturesDictionary modules, + [NotNull] Action configureAction) + { + Check.NotNull(configureAction, nameof(configureAction)); - configureAction(modules.CmsKit()); + configureAction(modules.CmsKit()); - return modules; - } + return modules; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogConsts.cs index def370dca8..3c57836221 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogConsts.cs @@ -1,8 +1,7 @@ -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogConsts { - public class BlogConsts - { - public static int MaxNameLength { get; set; } = 64; - public static int MaxSlugLength { get; set; } = 64; - } + public static int MaxNameLength { get; set; } = 64; + public static int MaxSlugLength { get; set; } = 64; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureConsts.cs index b030d97ba5..9856477a29 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureConsts.cs @@ -1,7 +1,6 @@ -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public static class BlogFeatureConsts { - public static class BlogFeatureConsts - { - public const int MaxFeatureNameLenth = 64; - } + public const int MaxFeatureNameLenth = 64; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs index 91748dc1e3..94a0456c66 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs @@ -1,19 +1,18 @@ using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public static class BlogPostConsts { - public static class BlogPostConsts - { - public static int MaxTitleLength { get; set; } = 64; + public static int MaxTitleLength { get; set; } = 64; + + public static int MaxSlugLength { get; set; } = 256; - public static int MaxSlugLength { get; set; } = 256; + public static int MinSlugLength { get; set; } = 2; - public static int MinSlugLength { get; set; } = 2; + public static int MaxShortDescriptionLength { get; set; } = 256; - public static int MaxShortDescriptionLength { get; set; } = 256; - - public static int MaxContentLength { get; set; } = int.MaxValue; + public static int MaxContentLength { get; set; } = int.MaxValue; - public const string EntityType = "BlogPost"; - } + public const string EntityType = "BlogPost"; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs index d2490cfb37..81349734f0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs @@ -8,33 +8,32 @@ using Volo.Abp.Validation; using Volo.Abp.Validation.Localization; using Volo.Abp.VirtualFileSystem; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(AbpValidationModule), + typeof(AbpGlobalFeaturesModule) +)] +public class CmsKitDomainSharedModule : AbpModule { - [DependsOn( - typeof(AbpValidationModule), - typeof(AbpGlobalFeaturesModule) - )] - public class CmsKitDomainSharedModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.FileSets.AddEmbedded(); - }); + options.FileSets.AddEmbedded(); + }); - Configure(options => - { - options.Resources - .Add("en") - .AddBaseTypes(typeof(AbpValidationResource)) - .AddVirtualJson("Volo/CmsKit/Localization/Resources"); - }); + Configure(options => + { + options.Resources + .Add("en") + .AddBaseTypes(typeof(AbpValidationResource)) + .AddVirtualJson("Volo/CmsKit/Localization/Resources"); + }); - Configure(options => - { - options.MapCodeNamespace("CmsKit", typeof(CmsKitResource)); - }); - } + Configure(options => + { + options.MapCodeNamespace("CmsKit", typeof(CmsKitResource)); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitErrorCodes.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitErrorCodes.cs index 9ef2b9bb86..773ca621a2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitErrorCodes.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitErrorCodes.cs @@ -1,47 +1,46 @@ -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public static class CmsKitErrorCodes { - public static class CmsKitErrorCodes - { - public static class Tags - { - public const string TagAlreadyExist = "CmsKit:Tag:0001"; - public const string EntityNotTaggable = "CmsKit:Tag:0002"; - } - - public static class Pages - { - public const string SlugAlreadyExist = "CmsKit:Page:0001"; - } - - public static class Ratings - { - public const string EntityCantHaveRating = "CmsKit:Rating:0001"; - } - - public static class Reactions - { - public const string EntityCantHaveReaction = "CmsKit:Reaction:0001"; - } - - public static class Blogs - { - public const string SlugAlreadyExists = "CmsKit:Blog:0001"; - } - - public static class BlogPosts - { - public const string SlugAlreadyExist = "CmsKit:BlogPost:0001"; - } - - public static class Comments - { - public const string EntityNotCommentable = "CmsKit:Comments:0001"; - } - - public static class MediaDescriptors - { - public const string InvalidName = "CmsKit:Media:0001"; - public const string EntityTypeDoesntExist = "CmsKit:Media:0002"; - } + public static class Tags + { + public const string TagAlreadyExist = "CmsKit:Tag:0001"; + public const string EntityNotTaggable = "CmsKit:Tag:0002"; + } + + public static class Pages + { + public const string SlugAlreadyExist = "CmsKit:Page:0001"; + } + + public static class Ratings + { + public const string EntityCantHaveRating = "CmsKit:Rating:0001"; + } + + public static class Reactions + { + public const string EntityCantHaveReaction = "CmsKit:Reaction:0001"; + } + + public static class Blogs + { + public const string SlugAlreadyExists = "CmsKit:Blog:0001"; + } + + public static class BlogPosts + { + public const string SlugAlreadyExist = "CmsKit:BlogPost:0001"; + } + + public static class Comments + { + public const string EntityNotCommentable = "CmsKit:Comments:0001"; + } + + public static class MediaDescriptors + { + public const string InvalidName = "CmsKit:Media:0001"; + public const string EntityTypeDoesntExist = "CmsKit:Media:0002"; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs index 27298e3acf..c878b1cdb6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs @@ -1,14 +1,13 @@ using Volo.CmsKit.Entities; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public static class CommentConsts { - public static class CommentConsts - { - public const string EntityType = "Comment"; - public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; + public const string EntityType = "Comment"; + public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; - public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength; + public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength; - public static int MaxTextLength { get; set; } = 512; - } + public static int MaxTextLength { get; set; } = 512; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs index 7176240196..b3728bbbc8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs @@ -1,9 +1,8 @@ -namespace Volo.CmsKit.Entities +namespace Volo.CmsKit.Entities; + +public class CmsEntityConsts { - public class CmsEntityConsts - { - public static int MaxEntityTypeLength { get; set; } = 64; + public static int MaxEntityTypeLength { get; set; } = 64; - public static int MaxEntityIdLength { get; set; } = 64; - } + public static int MaxEntityIdLength { get; set; } = 64; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/BlogsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/BlogsFeature.cs index 1b094ecf2d..d302f8c490 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/BlogsFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/BlogsFeature.cs @@ -1,17 +1,16 @@ using JetBrains.Annotations; using Volo.Abp.GlobalFeatures; -namespace Volo.CmsKit.GlobalFeatures +namespace Volo.CmsKit.GlobalFeatures; + +[GlobalFeatureName(Name)] +public class BlogsFeature : GlobalFeature { - [GlobalFeatureName(Name)] - public class BlogsFeature : GlobalFeature - { - public const string Name = "CmsKit.Blogs"; + public const string Name = "CmsKit.Blogs"; - internal BlogsFeature( - [NotNull] GlobalCmsKitFeatures cmsKit - ) : base(cmsKit) - { - } + internal BlogsFeature( + [NotNull] GlobalCmsKitFeatures cmsKit + ) : base(cmsKit) + { } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CmsUserFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CmsUserFeature.cs index 67d7047a8b..335192475f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CmsUserFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CmsUserFeature.cs @@ -1,18 +1,17 @@ using JetBrains.Annotations; using Volo.Abp.GlobalFeatures; -namespace Volo.CmsKit.GlobalFeatures +namespace Volo.CmsKit.GlobalFeatures; + +/// +/// All CmsKit Features are dependent this feature. Do not disable this manually. +/// +[GlobalFeatureName(Name)] +public class CmsUserFeature : GlobalFeature { - /// - /// All CmsKit Features are dependent this feature. Do not disable this manually. - /// - [GlobalFeatureName(Name)] - public class CmsUserFeature : GlobalFeature - { - public const string Name = "CmsKit.User"; + public const string Name = "CmsKit.User"; - internal CmsUserFeature([NotNull] GlobalModuleFeatures module) : base(module) - { - } + internal CmsUserFeature([NotNull] GlobalModuleFeatures module) : base(module) + { } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs index 0d2499aa48..e7b0c2d98b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs @@ -1,29 +1,28 @@ using JetBrains.Annotations; using Volo.Abp.GlobalFeatures; -namespace Volo.CmsKit.GlobalFeatures +namespace Volo.CmsKit.GlobalFeatures; + +[GlobalFeatureName(Name)] +public class CommentsFeature : GlobalFeature { - [GlobalFeatureName(Name)] - public class CommentsFeature : GlobalFeature - { - public const string Name = "CmsKit.Comments"; + public const string Name = "CmsKit.Comments"; - internal CommentsFeature( - [NotNull] GlobalCmsKitFeatures cmsKit - ) : base(cmsKit) - { + internal CommentsFeature( + [NotNull] GlobalCmsKitFeatures cmsKit + ) : base(cmsKit) + { - } + } - public override void Enable() + public override void Enable() + { + var userFeature = FeatureManager.Modules.CmsKit().User; + if (!userFeature.IsEnabled) { - var userFeature = FeatureManager.Modules.CmsKit().User; - if (!userFeature.IsEnabled) - { - userFeature.Enable(); - } - - base.Enable(); + userFeature.Enable(); } + + base.Enable(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs index 1f090f8f17..ed454c1598 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs @@ -1,42 +1,41 @@ using JetBrains.Annotations; using Volo.Abp.GlobalFeatures; -namespace Volo.CmsKit.GlobalFeatures +namespace Volo.CmsKit.GlobalFeatures; + +public class GlobalCmsKitFeatures : GlobalModuleFeatures { - public class GlobalCmsKitFeatures : GlobalModuleFeatures - { - public const string ModuleName = "CmsKit"; + public const string ModuleName = "CmsKit"; - public ReactionsFeature Reactions => GetFeature(); + public ReactionsFeature Reactions => GetFeature(); - public CommentsFeature Comments => GetFeature(); + public CommentsFeature Comments => GetFeature(); - public MediaFeature Media => GetFeature(); + public MediaFeature Media => GetFeature(); - public RatingsFeature Ratings => GetFeature(); + public RatingsFeature Ratings => GetFeature(); - public TagsFeature Tags => GetFeature(); + public TagsFeature Tags => GetFeature(); - public PagesFeature Pages => GetFeature(); + public PagesFeature Pages => GetFeature(); - public BlogsFeature Blogs => GetFeature(); + public BlogsFeature Blogs => GetFeature(); - public CmsUserFeature User => GetFeature(); + public CmsUserFeature User => GetFeature(); - public MenuFeature Menu => GetFeature(); + public MenuFeature Menu => GetFeature(); - public GlobalCmsKitFeatures([NotNull] GlobalFeatureManager featureManager) - : base(featureManager) - { - AddFeature(new ReactionsFeature(this)); - AddFeature(new MediaFeature(this)); - AddFeature(new CommentsFeature(this)); - AddFeature(new RatingsFeature(this)); - AddFeature(new TagsFeature(this)); - AddFeature(new PagesFeature(this)); - AddFeature(new BlogsFeature(this)); - AddFeature(new CmsUserFeature(this)); - AddFeature(new MenuFeature(this)); - } + public GlobalCmsKitFeatures([NotNull] GlobalFeatureManager featureManager) + : base(featureManager) + { + AddFeature(new ReactionsFeature(this)); + AddFeature(new MediaFeature(this)); + AddFeature(new CommentsFeature(this)); + AddFeature(new RatingsFeature(this)); + AddFeature(new TagsFeature(this)); + AddFeature(new PagesFeature(this)); + AddFeature(new BlogsFeature(this)); + AddFeature(new CmsUserFeature(this)); + AddFeature(new MenuFeature(this)); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/MediaFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/MediaFeature.cs index 9714df8c73..a47eaebf1a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/MediaFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/MediaFeature.cs @@ -1,29 +1,28 @@ using JetBrains.Annotations; using Volo.Abp.GlobalFeatures; -namespace Volo.CmsKit.GlobalFeatures +namespace Volo.CmsKit.GlobalFeatures; + +[GlobalFeatureName(Name)] +public class MediaFeature : GlobalFeature { - [GlobalFeatureName(Name)] - public class MediaFeature : GlobalFeature + public const string Name = "CmsKit.Medias"; + + internal MediaFeature( + [NotNull] GlobalCmsKitFeatures cmsKit + ) : base(cmsKit) { - public const string Name = "CmsKit.Medias"; - - internal MediaFeature( - [NotNull] GlobalCmsKitFeatures cmsKit - ) : base(cmsKit) - { - - } - public override void Enable() - { - var userFeature = FeatureManager.Modules.CmsKit().User; - if (!userFeature.IsEnabled) - { - userFeature.Enable(); - } + } - base.Enable(); + public override void Enable() + { + var userFeature = FeatureManager.Modules.CmsKit().User; + if (!userFeature.IsEnabled) + { + userFeature.Enable(); } + + base.Enable(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/MenuFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/MenuFeature.cs index 5868f68b3e..abffac400b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/MenuFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/MenuFeature.cs @@ -1,17 +1,16 @@ using JetBrains.Annotations; using Volo.Abp.GlobalFeatures; -namespace Volo.CmsKit.GlobalFeatures +namespace Volo.CmsKit.GlobalFeatures; + +[GlobalFeatureName(Name)] +public class MenuFeature : GlobalFeature { - [GlobalFeatureName(Name)] - public class MenuFeature : GlobalFeature - { - public const string Name = "CmsKit.Menus"; + public const string Name = "CmsKit.Menus"; - internal MenuFeature( - [NotNull] GlobalCmsKitFeatures cmsKit) : base(cmsKit) - { + internal MenuFeature( + [NotNull] GlobalCmsKitFeatures cmsKit) : base(cmsKit) + { - } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/PagesFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/PagesFeature.cs index 86977590ee..5d4e553d5d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/PagesFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/PagesFeature.cs @@ -1,29 +1,28 @@ using JetBrains.Annotations; using Volo.Abp.GlobalFeatures; -namespace Volo.CmsKit.GlobalFeatures +namespace Volo.CmsKit.GlobalFeatures; + +[GlobalFeatureName(Name)] +public class PagesFeature : GlobalFeature { - [GlobalFeatureName(Name)] - public class PagesFeature:GlobalFeature + public const string Name = "CmsKit.Pages"; + + internal PagesFeature( + [NotNull] GlobalCmsKitFeatures cmsKit + ) : base(cmsKit) { - public const string Name = "CmsKit.Pages"; - internal PagesFeature( - [NotNull] GlobalCmsKitFeatures cmsKit - ) : base(cmsKit) - { - - } + } - public override void Enable() + public override void Enable() + { + var userFeature = FeatureManager.Modules.CmsKit().User; + if (!userFeature.IsEnabled) { - var userFeature = FeatureManager.Modules.CmsKit().User; - if (!userFeature.IsEnabled) - { - userFeature.Enable(); - } - - base.Enable(); + userFeature.Enable(); } + + base.Enable(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/RatingsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/RatingsFeature.cs index 56796c6422..01f5c66908 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/RatingsFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/RatingsFeature.cs @@ -1,29 +1,28 @@ using JetBrains.Annotations; using Volo.Abp.GlobalFeatures; -namespace Volo.CmsKit.GlobalFeatures +namespace Volo.CmsKit.GlobalFeatures; + +[GlobalFeatureName(Name)] +public class RatingsFeature : GlobalFeature { - [GlobalFeatureName(Name)] - public class RatingsFeature : GlobalFeature - { - public const string Name = "CmsKit.Ratings"; + public const string Name = "CmsKit.Ratings"; - internal RatingsFeature( - [NotNull] GlobalCmsKitFeatures cmsKit - ) : base(cmsKit) - { + internal RatingsFeature( + [NotNull] GlobalCmsKitFeatures cmsKit + ) : base(cmsKit) + { - } + } - public override void Enable() + public override void Enable() + { + var userFeature = FeatureManager.Modules.CmsKit().User; + if (!userFeature.IsEnabled) { - var userFeature = FeatureManager.Modules.CmsKit().User; - if (!userFeature.IsEnabled) - { - userFeature.Enable(); - } - - base.Enable(); + userFeature.Enable(); } + + base.Enable(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs index fce32d548e..e3e9b5dc58 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs @@ -1,28 +1,27 @@ using JetBrains.Annotations; using Volo.Abp.GlobalFeatures; -namespace Volo.CmsKit.GlobalFeatures +namespace Volo.CmsKit.GlobalFeatures; + +[GlobalFeatureName(Name)] +public class ReactionsFeature : GlobalFeature { - [GlobalFeatureName(Name)] - public class ReactionsFeature : GlobalFeature + public const string Name = "CmsKit.Reactions"; + + internal ReactionsFeature( + [NotNull] GlobalCmsKitFeatures cmsKit + ) : base(cmsKit) { - public const string Name = "CmsKit.Reactions"; + } - internal ReactionsFeature( - [NotNull] GlobalCmsKitFeatures cmsKit - ) : base(cmsKit) + public override void Enable() + { + var userFeature = FeatureManager.Modules.CmsKit().User; + if (!userFeature.IsEnabled) { + userFeature.Enable(); } - public override void Enable() - { - var userFeature = FeatureManager.Modules.CmsKit().User; - if (!userFeature.IsEnabled) - { - userFeature.Enable(); - } - - base.Enable(); - } + base.Enable(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/TagsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/TagsFeature.cs index 1e8fde3570..ae6d8930db 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/TagsFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/TagsFeature.cs @@ -1,28 +1,27 @@ using JetBrains.Annotations; using Volo.Abp.GlobalFeatures; -namespace Volo.CmsKit.GlobalFeatures +namespace Volo.CmsKit.GlobalFeatures; + +[GlobalFeatureName(Name)] +public class TagsFeature : GlobalFeature { - [GlobalFeatureName(Name)] - public class TagsFeature : GlobalFeature + public const string Name = "CmsKit.Tags"; + + internal TagsFeature( + [NotNull] GlobalCmsKitFeatures cmsKit + ) : base(cmsKit) { - public const string Name = "CmsKit.Tags"; + } - internal TagsFeature( - [NotNull] GlobalCmsKitFeatures cmsKit - ) : base(cmsKit) + public override void Enable() + { + var userFeature = FeatureManager.Modules.CmsKit().User; + if (!userFeature.IsEnabled) { + userFeature.Enable(); } - public override void Enable() - { - var userFeature = FeatureManager.Modules.CmsKit().User; - if (!userFeature.IsEnabled) - { - userFeature.Enable(); - } - - base.Enable(); - } + base.Enable(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/CmsKitResource.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/CmsKitResource.cs index 791217e6ff..7ce500e35f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/CmsKitResource.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/CmsKitResource.cs @@ -1,10 +1,9 @@ using Volo.Abp.Localization; -namespace Volo.CmsKit.Localization +namespace Volo.CmsKit.Localization; + +[LocalizationResourceName("CmsKit")] +public class CmsKitResource { - [LocalizationResourceName("CmsKit")] - public class CmsKitResource - { - - } + } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/MediaDescriptors/MediaDescriptorConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/MediaDescriptors/MediaDescriptorConsts.cs index 31737fa9fe..ddd7a81ff0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/MediaDescriptors/MediaDescriptorConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/MediaDescriptors/MediaDescriptorConsts.cs @@ -1,15 +1,14 @@ using Volo.CmsKit.Entities; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public class MediaDescriptorConsts { - public class MediaDescriptorConsts - { - public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; - - public static int MaxNameLength { get; set; } = 255; - - public static int MaxMimeTypeLength { get; set; } = 128; - - public static int MaxSizeLength = int.MaxValue; - } -} \ No newline at end of file + public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; + + public static int MaxNameLength { get; set; } = 255; + + public static int MaxMimeTypeLength { get; set; } = 128; + + public static int MaxSizeLength = int.MaxValue; +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Menus/MenuConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Menus/MenuConsts.cs index 4c75d14229..f8363615fd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Menus/MenuConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Menus/MenuConsts.cs @@ -4,10 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +public static class MenuConsts { - public static class MenuConsts - { - public static int MaxNameLength { get; set; } = 128; - } + public static int MaxNameLength { get; set; } = 128; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Menus/MenuItemConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Menus/MenuItemConsts.cs index 4ae1d494eb..6484d5280e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Menus/MenuItemConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Menus/MenuItemConsts.cs @@ -1,8 +1,7 @@ -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +public static class MenuItemConsts { - public static class MenuItemConsts - { - public const int MaxDisplayNameLength = 64; - public const int MaxUrlLength = 1024; - } + public const int MaxDisplayNameLength = 64; + public const int MaxUrlLength = 1024; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Pages/PageConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Pages/PageConsts.cs index d347de2328..9f03dc809f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Pages/PageConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Pages/PageConsts.cs @@ -1,26 +1,24 @@ using System; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public class PageConsts { - public class PageConsts - { - public const string EntityType = "Page"; - - public static int MaxTitleLength { get; set; } = 256; - - public static int MaxSlugLength { get; set; } = 256; - - public static int MaxContentLength { get; set; } = int.MaxValue; - - public static int MaxScriptLength { get; set; } = int.MaxValue; - - public static int MaxStyleLength { get; set; } = int.MaxValue; - - private static string _urlPrefix = "/pages/"; - public static string UrlPrefix - { - get => _urlPrefix; - set => _urlPrefix = value.EnsureEndsWith('/').EnsureStartsWith('/'); - } + public const string EntityType = "Page"; + + public static int MaxTitleLength { get; set; } = 256; + + public static int MaxSlugLength { get; set; } = 256; + + public static int MaxContentLength { get; set; } = int.MaxValue; + + public static int MaxScriptLength { get; set; } = int.MaxValue; + + public static int MaxStyleLength { get; set; } = int.MaxValue; + + private static string _urlPrefix = "/pages/"; + public static string UrlPrefix { + get => _urlPrefix; + set => _urlPrefix = value.EnsureEndsWith('/').EnsureStartsWith('/'); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Ratings/RatingConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Ratings/RatingConsts.cs index e3bf6c399d..2249623a0b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Ratings/RatingConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Ratings/RatingConsts.cs @@ -1,15 +1,14 @@ using Volo.CmsKit.Entities; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public static class RatingConsts { - public static class RatingConsts - { - public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; + public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; - public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength; + public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength; - public static int MaxStarCount { get; set; } = 5; + public static int MaxStarCount { get; set; } = 5; - public static int MinStarCount { get; set; } = 1; - } -} \ No newline at end of file + public static int MinStarCount { get; set; } = 1; +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/StandardReactions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/StandardReactions.cs index 532971502d..6da10ad6dd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/StandardReactions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/StandardReactions.cs @@ -1,18 +1,17 @@ -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public static class StandardReactions { - public static class StandardReactions - { - public const string Smile = "_SM"; - public const string ThumbsUp = "_TU"; - public const string ThumbsDown = "_TD"; - public const string Confused = "_CF"; - public const string Eyes = "_EY"; - public const string Heart = "_HE"; - public const string HeartBroken = "_HB"; - public const string Wink = "_WI"; - public const string Pray = "_PR"; - public const string Rocket = "_RO"; - public const string Victory = "_VI"; - public const string Rock = "_RC"; - } + public const string Smile = "_SM"; + public const string ThumbsUp = "_TU"; + public const string ThumbsDown = "_TD"; + public const string Confused = "_CF"; + public const string Eyes = "_EY"; + public const string Heart = "_HE"; + public const string HeartBroken = "_HB"; + public const string Wink = "_WI"; + public const string Pray = "_PR"; + public const string Rocket = "_RO"; + public const string Victory = "_VI"; + public const string Rock = "_RC"; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs index e89067f869..ad3560363e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs @@ -1,13 +1,12 @@ using Volo.CmsKit.Entities; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public static class UserReactionConsts { - public static class UserReactionConsts - { - public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; + public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; - public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength; + public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength; - public static int MaxReactionNameLength { get; set; } = 32; - } + public static int MaxReactionNameLength { get; set; } = 32; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Tags/TagConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Tags/TagConsts.cs index 4e6c0b38cc..c8ebcecf47 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Tags/TagConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Tags/TagConsts.cs @@ -1,11 +1,10 @@ using Volo.CmsKit.Entities; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public static class TagConsts { - public static class TagConsts - { - public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; - - public static int MaxNameLength { get; set; } = 32; - } + public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; + + public static int MaxNameLength { get; set; } = 32; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/Blog.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/Blog.cs index 9d800abbdb..32ce890ff0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/Blog.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/Blog.cs @@ -4,40 +4,39 @@ using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.MultiTenancy; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class Blog : FullAuditedAggregateRoot, IMultiTenant { - public class Blog : FullAuditedAggregateRoot, IMultiTenant + [NotNull] + public virtual string Name { get; protected set; } + + [NotNull] + public virtual string Slug { get; protected set; } + + public virtual Guid? TenantId { get; protected set; } + + protected internal Blog( + Guid id, + [NotNull] string name, + [NotNull] string slug, + [CanBeNull] Guid? tenantId = null + ) : base(id) { - [NotNull] - public virtual string Name { get; protected set; } - - [NotNull] - public virtual string Slug { get; protected set; } - - public virtual Guid? TenantId { get; protected set; } - - protected internal Blog( - Guid id, - [NotNull] string name, - [NotNull] string slug, - [CanBeNull] Guid? tenantId = null - ) : base(id) - { - SetName(name); - SetSlug(slug); - TenantId = tenantId; - } - - public virtual void SetName(string name) - { - Name = Check.NotNullOrWhiteSpace(name, nameof(name), BlogConsts.MaxNameLength); - } - - public virtual void SetSlug(string slug) - { - Check.NotNullOrWhiteSpace(slug, nameof(slug), BlogConsts.MaxNameLength); - - Slug = SlugNormalizer.Normalize(slug); - } + SetName(name); + SetSlug(slug); + TenantId = tenantId; + } + + public virtual void SetName(string name) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name), BlogConsts.MaxNameLength); + } + + public virtual void SetSlug(string slug) + { + Check.NotNullOrWhiteSpace(slug, nameof(slug), BlogConsts.MaxNameLength); + + Slug = SlugNormalizer.Normalize(slug); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeature.cs index e1bb05fa3f..39e2e2c65c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeature.cs @@ -3,21 +3,20 @@ using System; using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogFeature : FullAuditedAggregateRoot { - public class BlogFeature : FullAuditedAggregateRoot - { - public Guid BlogId { get; protected set; } + public Guid BlogId { get; protected set; } - public string FeatureName { get; protected set; } + public string FeatureName { get; protected set; } - public bool IsEnabled { get; protected internal set; } + public bool IsEnabled { get; protected internal set; } - public BlogFeature(Guid blogId, [NotNull] string featureName, bool isEnabled = true) - { - BlogId = blogId; - FeatureName = Check.NotNullOrWhiteSpace(featureName, nameof(featureName)); - IsEnabled = isEnabled; - } + public BlogFeature(Guid blogId, [NotNull] string featureName, bool isEnabled = true) + { + BlogId = blogId; + FeatureName = Check.NotNullOrWhiteSpace(featureName, nameof(featureName)); + IsEnabled = isEnabled; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeatureManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeatureManager.cs index cea6d894f0..77a519daf3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeatureManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeatureManager.cs @@ -4,45 +4,44 @@ using System.Linq; using System.Threading.Tasks; using Volo.Abp.Domain.Services; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogFeatureManager : DomainService { - public class BlogFeatureManager : DomainService - { - protected IBlogFeatureRepository BlogFeatureRepository { get; } + protected IBlogFeatureRepository BlogFeatureRepository { get; } + + protected IDefaultBlogFeatureProvider DefaultBlogFeatureProvider { get; } - protected IDefaultBlogFeatureProvider DefaultBlogFeatureProvider { get; } + public BlogFeatureManager( + IBlogFeatureRepository blogFeatureRepository, + IDefaultBlogFeatureProvider defaultBlogFeatureProvider) + { + BlogFeatureRepository = blogFeatureRepository; + DefaultBlogFeatureProvider = defaultBlogFeatureProvider; + } - public BlogFeatureManager( - IBlogFeatureRepository blogFeatureRepository, - IDefaultBlogFeatureProvider defaultBlogFeatureProvider) + public async Task SetAsync(Guid blogId, string featureName, bool isEnabled) + { + var blogFeature = await BlogFeatureRepository.FindAsync(blogId, featureName); + if (blogFeature == null) { - BlogFeatureRepository = blogFeatureRepository; - DefaultBlogFeatureProvider = defaultBlogFeatureProvider; + var newBlogFeature = new BlogFeature(blogId, featureName, isEnabled); + await BlogFeatureRepository.InsertAsync(newBlogFeature); } - - public async Task SetAsync(Guid blogId, string featureName, bool isEnabled) + else { - var blogFeature = await BlogFeatureRepository.FindAsync(blogId, featureName); - if (blogFeature == null) - { - var newBlogFeature = new BlogFeature(blogId, featureName, isEnabled); - await BlogFeatureRepository.InsertAsync(newBlogFeature); - } - else - { - blogFeature.IsEnabled = isEnabled; - await BlogFeatureRepository.UpdateAsync(blogFeature); - } + blogFeature.IsEnabled = isEnabled; + await BlogFeatureRepository.UpdateAsync(blogFeature); } + } - public async Task SetDefaultsAsync(Guid blogId) - { - var defaultFeatures = await DefaultBlogFeatureProvider.GetDefaultFeaturesAsync(blogId); + public async Task SetDefaultsAsync(Guid blogId) + { + var defaultFeatures = await DefaultBlogFeatureProvider.GetDefaultFeaturesAsync(blogId); - foreach (var feature in defaultFeatures) - { - await SetAsync(blogId, feature.FeatureName, isEnabled: true); - } + foreach (var feature in defaultFeatures) + { + await SetAsync(blogId, feature.FeatureName, isEnabled: true); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogManager.cs index 1d2e2f5b07..8329f4c205 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogManager.cs @@ -2,43 +2,42 @@ using JetBrains.Annotations; using Volo.Abp.Domain.Services; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogManager : DomainService { - public class BlogManager : DomainService + protected IBlogRepository BlogRepository { get; } + + public BlogManager(IBlogRepository blogRepository) { - protected IBlogRepository BlogRepository { get; } - - public BlogManager(IBlogRepository blogRepository) - { - BlogRepository = blogRepository; - } + BlogRepository = blogRepository; + } - public virtual async Task CreateAsync([NotNull] string name, [NotNull] string slug) - { - await CheckSlugAsync(slug); + public virtual async Task CreateAsync([NotNull] string name, [NotNull] string slug) + { + await CheckSlugAsync(slug); - return new Blog(GuidGenerator.Create(), name, slug, CurrentTenant.Id); - } + return new Blog(GuidGenerator.Create(), name, slug, CurrentTenant.Id); + } - public virtual async Task UpdateAsync([NotNull] Blog blog, [NotNull] string name, [NotNull] string slug) + public virtual async Task UpdateAsync([NotNull] Blog blog, [NotNull] string name, [NotNull] string slug) + { + if (slug != blog.Slug) { - if (slug != blog.Slug) - { - await CheckSlugAsync(slug); - } - - blog.SetName(name); - blog.SetSlug(slug); - - return blog; + await CheckSlugAsync(slug); } - protected virtual async Task CheckSlugAsync([NotNull] string slug) + blog.SetName(name); + blog.SetSlug(slug); + + return blog; + } + + protected virtual async Task CheckSlugAsync([NotNull] string slug) + { + if (await BlogRepository.SlugExistsAsync(slug)) { - if (await BlogRepository.SlugExistsAsync(slug)) - { - throw new BlogSlugAlreadyExistException(slug); - } + throw new BlogSlugAlreadyExistException(slug); } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs index 4d81a322be..faf6c4bcb6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs @@ -5,76 +5,75 @@ using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.MultiTenancy; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogPost : FullAuditedAggregateRoot, IMultiTenant { - public class BlogPost : FullAuditedAggregateRoot, IMultiTenant + public virtual Guid BlogId { get; protected set; } + + [NotNull] + public virtual string Title { get; protected set; } + + [NotNull] + public virtual string Slug { get; protected set; } + + [NotNull] + public virtual string ShortDescription { get; protected set; } + + public virtual string Content { get; protected set; } + + public Guid? CoverImageMediaId { get; set; } + + public virtual Guid? TenantId { get; protected set; } + + public Guid AuthorId { get; set; } + + public virtual CmsUser Author { get; set; } + + protected BlogPost() + { + } + + internal BlogPost( + Guid id, + Guid blogId, + Guid authorId, + [NotNull] string title, + [NotNull] string slug, + [CanBeNull] string shortDescription = null, + [CanBeNull] string content = null, + [CanBeNull] Guid? coverImageMediaId = null, + [CanBeNull] Guid? tenantId = null) : base(id) + { + TenantId = tenantId; + BlogId = blogId; + AuthorId = authorId; + SetTitle(title); + SetSlug(slug); + SetShortDescription(shortDescription); + SetContent(content); + CoverImageMediaId = coverImageMediaId; + } + + public virtual void SetTitle(string title) + { + Title = Check.NotNullOrWhiteSpace(title, nameof(title), BlogPostConsts.MaxTitleLength); + } + + internal void SetSlug(string slug) + { + Check.NotNullOrWhiteSpace(slug, nameof(slug), BlogPostConsts.MaxSlugLength, BlogPostConsts.MinSlugLength); + + Slug = SlugNormalizer.Normalize(slug); + } + + public virtual void SetShortDescription(string shortDescription) + { + ShortDescription = Check.Length(shortDescription, nameof(shortDescription), BlogPostConsts.MaxShortDescriptionLength); + } + + public virtual void SetContent(string content) { - public virtual Guid BlogId { get; protected set; } - - [NotNull] - public virtual string Title { get; protected set; } - - [NotNull] - public virtual string Slug { get; protected set; } - - [NotNull] - public virtual string ShortDescription { get; protected set; } - - public virtual string Content { get; protected set; } - - public Guid? CoverImageMediaId { get; set; } - - public virtual Guid? TenantId { get; protected set; } - - public Guid AuthorId { get; set; } - - public virtual CmsUser Author { get; set; } - - protected BlogPost() - { - } - - internal BlogPost( - Guid id, - Guid blogId, - Guid authorId, - [NotNull] string title, - [NotNull] string slug, - [CanBeNull] string shortDescription = null, - [CanBeNull] string content = null, - [CanBeNull] Guid? coverImageMediaId = null, - [CanBeNull] Guid? tenantId = null) : base(id) - { - TenantId = tenantId; - BlogId = blogId; - AuthorId = authorId; - SetTitle(title); - SetSlug(slug); - SetShortDescription(shortDescription); - SetContent(content); - CoverImageMediaId = coverImageMediaId; - } - - public virtual void SetTitle(string title) - { - Title = Check.NotNullOrWhiteSpace(title, nameof(title), BlogPostConsts.MaxTitleLength); - } - - internal void SetSlug(string slug) - { - Check.NotNullOrWhiteSpace(slug, nameof(slug), BlogPostConsts.MaxSlugLength, BlogPostConsts.MinSlugLength); - - Slug = SlugNormalizer.Normalize(slug); - } - - public virtual void SetShortDescription(string shortDescription) - { - ShortDescription = Check.Length(shortDescription, nameof(shortDescription), BlogPostConsts.MaxShortDescriptionLength); - } - - public virtual void SetContent(string content) - { - Content = Check.Length(content, nameof(content), BlogPostConsts.MaxContentLength); - } + Content = Check.Length(content, nameof(content), BlogPostConsts.MaxContentLength); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs index e51108fc9a..a19643308d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs @@ -6,79 +6,78 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Services; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogPostManager : DomainService { - public class BlogPostManager : DomainService - { - protected IBlogPostRepository BlogPostRepository { get; } - protected IBlogRepository BlogRepository { get; } - protected IDefaultBlogFeatureProvider BlogFeatureProvider { get; } + protected IBlogPostRepository BlogPostRepository { get; } + protected IBlogRepository BlogRepository { get; } + protected IDefaultBlogFeatureProvider BlogFeatureProvider { get; } - public BlogPostManager( - IBlogPostRepository blogPostRepository, - IBlogRepository blogRepository, - IDefaultBlogFeatureProvider blogFeatureProvider) - { - BlogPostRepository = blogPostRepository; - BlogRepository = blogRepository; - BlogFeatureProvider = blogFeatureProvider; - } + public BlogPostManager( + IBlogPostRepository blogPostRepository, + IBlogRepository blogRepository, + IDefaultBlogFeatureProvider blogFeatureProvider) + { + BlogPostRepository = blogPostRepository; + BlogRepository = blogRepository; + BlogFeatureProvider = blogFeatureProvider; + } - public virtual async Task CreateAsync( - [NotNull] CmsUser author, - [NotNull] Blog blog, - [NotNull] string title, - [NotNull] string slug, - [CanBeNull] string shortDescription = null, - [CanBeNull] string content = null, - [CanBeNull] Guid? coverImageMediaId = null) - { - Check.NotNull(author, nameof(author)); - Check.NotNull(blog, nameof(blog)); - Check.NotNullOrEmpty(title, nameof(title)); - Check.NotNullOrEmpty(slug, nameof(slug)); + public virtual async Task CreateAsync( + [NotNull] CmsUser author, + [NotNull] Blog blog, + [NotNull] string title, + [NotNull] string slug, + [CanBeNull] string shortDescription = null, + [CanBeNull] string content = null, + [CanBeNull] Guid? coverImageMediaId = null) + { + Check.NotNull(author, nameof(author)); + Check.NotNull(blog, nameof(blog)); + Check.NotNullOrEmpty(title, nameof(title)); + Check.NotNullOrEmpty(slug, nameof(slug)); - var blogPost = new BlogPost( - GuidGenerator.Create(), - blog.Id, - author.Id, - title, - slug, - shortDescription, - content, - coverImageMediaId, - CurrentTenant.Id - ); + var blogPost = new BlogPost( + GuidGenerator.Create(), + blog.Id, + author.Id, + title, + slug, + shortDescription, + content, + coverImageMediaId, + CurrentTenant.Id + ); - await CheckSlugExistenceAsync(blog.Id, blogPost.Slug); + await CheckSlugExistenceAsync(blog.Id, blogPost.Slug); - return blogPost; - } + return blogPost; + } - public virtual async Task SetSlugUrlAsync(BlogPost blogPost, [NotNull] string newSlug) - { - Check.NotNullOrWhiteSpace(newSlug, nameof(newSlug)); + public virtual async Task SetSlugUrlAsync(BlogPost blogPost, [NotNull] string newSlug) + { + Check.NotNullOrWhiteSpace(newSlug, nameof(newSlug)); - await CheckSlugExistenceAsync(blogPost.BlogId, newSlug); + await CheckSlugExistenceAsync(blogPost.BlogId, newSlug); - blogPost.SetSlug(newSlug); - } + blogPost.SetSlug(newSlug); + } - protected virtual async Task CheckSlugExistenceAsync(Guid blogId, string slug) + protected virtual async Task CheckSlugExistenceAsync(Guid blogId, string slug) + { + if (await BlogPostRepository.SlugExistsAsync(blogId, slug)) { - if (await BlogPostRepository.SlugExistsAsync(blogId, slug)) - { - throw new BlogPostSlugAlreadyExistException(blogId, slug); - } + throw new BlogPostSlugAlreadyExistException(blogId, slug); } + } - protected virtual async Task CheckBlogExistenceAsync(Guid blogId) + protected virtual async Task CheckBlogExistenceAsync(Guid blogId) + { + if (!await BlogRepository.ExistsAsync(blogId)) { - if (!await BlogRepository.ExistsAsync(blogId)) - { - throw new EntityNotFoundException(typeof(Blog), blogId); - } + throw new EntityNotFoundException(typeof(Blog), blogId); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostSlugAlreadyExistException.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostSlugAlreadyExistException.cs index 16fae16735..8e7cacc28c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostSlugAlreadyExistException.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostSlugAlreadyExistException.cs @@ -2,28 +2,27 @@ using System.Runtime.Serialization; using Volo.Abp; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogPostSlugAlreadyExistException : BusinessException { - public class BlogPostSlugAlreadyExistException : BusinessException + public BlogPostSlugAlreadyExistException(SerializationInfo serializationInfo, StreamingContext context) + : base(serializationInfo, context) { - public BlogPostSlugAlreadyExistException(SerializationInfo serializationInfo, StreamingContext context) - : base(serializationInfo, context) - { - } + } - public BlogPostSlugAlreadyExistException(Guid blogId, string slug) - { - Slug = slug; - BlogId = blogId; + public BlogPostSlugAlreadyExistException(Guid blogId, string slug) + { + Slug = slug; + BlogId = blogId; - Code = CmsKitErrorCodes.BlogPosts.SlugAlreadyExist; + Code = CmsKitErrorCodes.BlogPosts.SlugAlreadyExist; - WithData(nameof(Slug), Slug); - WithData(nameof(BlogId), BlogId); - } + WithData(nameof(Slug), Slug); + WithData(nameof(BlogId), BlogId); + } - public virtual string Slug { get; } + public virtual string Slug { get; } - public virtual Guid BlogId { get; } - } + public virtual Guid BlogId { get; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogSlugAlreadyExistException.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogSlugAlreadyExistException.cs index 1adb95ac33..8d14cf469f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogSlugAlreadyExistException.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogSlugAlreadyExistException.cs @@ -2,20 +2,19 @@ using System.Runtime.Serialization; using Volo.Abp; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +[Serializable] +public class BlogSlugAlreadyExistException : BusinessException { - [Serializable] - public class BlogSlugAlreadyExistException : BusinessException + public BlogSlugAlreadyExistException(string slug) + : base(code: CmsKitErrorCodes.Blogs.SlugAlreadyExists) + { + WithData(nameof(Blog.Slug), slug); + } + + public BlogSlugAlreadyExistException(SerializationInfo serializationInfo, StreamingContext context) + : base(serializationInfo, context) { - public BlogSlugAlreadyExistException(string slug) - : base(code: CmsKitErrorCodes.Blogs.SlugAlreadyExists) - { - WithData(nameof(Blog.Slug), slug); - } - - public BlogSlugAlreadyExistException(SerializationInfo serializationInfo, StreamingContext context) - : base(serializationInfo, context) - { - } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultBlogFeatureProvider.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultBlogFeatureProvider.cs index 0504bdaf93..7d08f0d3fd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultBlogFeatureProvider.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultBlogFeatureProvider.cs @@ -4,19 +4,18 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class DefaultBlogFeatureProvider : IDefaultBlogFeatureProvider, ITransientDependency { - public class DefaultBlogFeatureProvider : IDefaultBlogFeatureProvider, ITransientDependency + public virtual Task> GetDefaultFeaturesAsync(Guid blogId) { - public virtual Task> GetDefaultFeaturesAsync(Guid blogId) - { - return Task.FromResult(new List + return Task.FromResult(new List { new BlogFeature(blogId, CommentsFeature.Name), new BlogFeature(blogId, ReactionsFeature.Name), new BlogFeature(blogId, RatingsFeature.Name), new BlogFeature(blogId, TagsFeature.Name), }); - } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogFeatureRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogFeatureRepository.cs index 7f66f222db..1854353429 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogFeatureRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogFeatureRepository.cs @@ -5,14 +5,13 @@ using System.Text; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public interface IBlogFeatureRepository : IBasicRepository { - public interface IBlogFeatureRepository : IBasicRepository - { - Task> GetListAsync(Guid blogId); + Task> GetListAsync(Guid blogId); - Task> GetListAsync(Guid blogId, List featureNames); + Task> GetListAsync(Guid blogId, List featureNames); - Task FindAsync(Guid blogId, string featureName); - } + Task FindAsync(Guid blogId, string featureName); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostRepository.cs index e54045ced4..8b1e86f8b7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostRepository.cs @@ -4,25 +4,24 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public interface IBlogPostRepository : IBasicRepository { - public interface IBlogPostRepository : IBasicRepository - { - Task GetCountAsync( - string filter = null, - Guid? blogId = null, - CancellationToken cancellationToken = default); + Task GetCountAsync( + string filter = null, + Guid? blogId = null, + CancellationToken cancellationToken = default); + + Task> GetListAsync( + string filter = null, + Guid? blogId = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + string sorting = null, + CancellationToken cancellationToken = default); - Task> GetListAsync( - string filter = null, - Guid? blogId = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - string sorting = null, - CancellationToken cancellationToken = default); - - Task SlugExistsAsync(Guid blogId, string slug, CancellationToken cancellationToken = default); + Task SlugExistsAsync(Guid blogId, string slug, CancellationToken cancellationToken = default); - Task GetBySlugAsync(Guid blogId, string slug, CancellationToken cancellationToken = default); - } + Task GetBySlugAsync(Guid blogId, string slug, CancellationToken cancellationToken = default); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogRepository.cs index b340b9e256..60005db319 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogRepository.cs @@ -4,27 +4,26 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public interface IBlogRepository : IBasicRepository { - public interface IBlogRepository : IBasicRepository - { - Task> GetListAsync( - string filter = null, - string sorting = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - CancellationToken cancellationToken = default - ); + Task> GetListAsync( + string filter = null, + string sorting = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + CancellationToken cancellationToken = default + ); + + Task GetCountAsync( + string filter = null, + CancellationToken cancellationToken = default + ); + + Task GetBySlugAsync(string slug, CancellationToken cancellationToken = default); - Task GetCountAsync( - string filter = null, - CancellationToken cancellationToken = default - ); - - Task GetBySlugAsync(string slug, CancellationToken cancellationToken = default); - - Task ExistsAsync(Guid id, CancellationToken cancellationToken = default); + Task ExistsAsync(Guid id, CancellationToken cancellationToken = default); - Task SlugExistsAsync(string slug, CancellationToken cancellationToken = default); - } + Task SlugExistsAsync(string slug, CancellationToken cancellationToken = default); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IDefaultBlogFeatureProvider.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IDefaultBlogFeatureProvider.cs index 51234e3cbd..5f1af5e3d6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IDefaultBlogFeatureProvider.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IDefaultBlogFeatureProvider.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public interface IDefaultBlogFeatureProvider { - public interface IDefaultBlogFeatureProvider - { - Task> GetDefaultFeaturesAsync(Guid blogId); - } + Task> GetDefaultFeaturesAsync(Guid blogId); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDbProperties.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDbProperties.cs index 543636847d..6a29834233 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDbProperties.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDbProperties.cs @@ -1,11 +1,10 @@ -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public static class CmsKitDbProperties { - public static class CmsKitDbProperties - { - public static string DbTablePrefix { get; set; } = "Cms"; + public static string DbTablePrefix { get; set; } = "Cms"; - public static string DbSchema { get; set; } = null; + public static string DbSchema { get; set; } = null; - public const string ConnectionStringName = "CmsKit"; - } + public const string ConnectionStringName = "CmsKit"; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDomainModule.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDomainModule.cs index 53261fc8c2..b504266ce5 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDomainModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDomainModule.cs @@ -11,29 +11,29 @@ using Volo.CmsKit.Localization; using Volo.CmsKit.Ratings; using Volo.CmsKit.Reactions; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitDomainSharedModule), + typeof(AbpUsersDomainModule), + typeof(AbpDddDomainModule), + typeof(AbpBlobStoringModule) +)] +public class CmsKitDomainModule : AbpModule { - [DependsOn( - typeof(CmsKitDomainSharedModule), - typeof(AbpUsersDomainModule), - typeof(AbpDddDomainModule), - typeof(AbpBlobStoringModule) - )] - public class CmsKitDomainModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + if (GlobalFeatureManager.Instance.IsEnabled()) { - if (GlobalFeatureManager.Instance.IsEnabled()) + Configure(options => { - Configure(options => + if (GlobalFeatureManager.Instance.IsEnabled()) { - if (GlobalFeatureManager.Instance.IsEnabled()) - { - options.EntityTypes.Add( - new ReactionEntityTypeDefinition( - BlogPostConsts.EntityType, - reactions: new[] - { + options.EntityTypes.Add( + new ReactionEntityTypeDefinition( + BlogPostConsts.EntityType, + reactions: new[] + { new ReactionDefinition(StandardReactions.Smile), new ReactionDefinition(StandardReactions.ThumbsUp), new ReactionDefinition(StandardReactions.ThumbsDown), @@ -46,45 +46,44 @@ namespace Volo.CmsKit new ReactionDefinition(StandardReactions.Rocket), new ReactionDefinition(StandardReactions.Victory), new ReactionDefinition(StandardReactions.Rock), - })); - } + })); + } - if (GlobalFeatureManager.Instance.IsEnabled()) - { - options.EntityTypes.Add( - new ReactionEntityTypeDefinition( - CommentConsts.EntityType, - reactions: new[] - { + if (GlobalFeatureManager.Instance.IsEnabled()) + { + options.EntityTypes.Add( + new ReactionEntityTypeDefinition( + CommentConsts.EntityType, + reactions: new[] + { new ReactionDefinition(StandardReactions.ThumbsUp), new ReactionDefinition(StandardReactions.ThumbsDown), - })); - } - }); - } + })); + } + }); + } - if (GlobalFeatureManager.Instance.IsEnabled()) + if (GlobalFeatureManager.Instance.IsEnabled()) + { + Configure(options => { - Configure(options => + if (GlobalFeatureManager.Instance.IsEnabled()) { - if (GlobalFeatureManager.Instance.IsEnabled()) - { - options.EntityTypes.Add(new RatingEntityTypeDefinition(BlogPostConsts.EntityType)); - } + options.EntityTypes.Add(new RatingEntityTypeDefinition(BlogPostConsts.EntityType)); + } // TODO: Define entity types here which can be rated. }); - } - - if (GlobalFeatureManager.Instance.IsEnabled()) - { - // TODO: Configure TagEntityTypes here... - } } - private static LocalizableString L(string name) + if (GlobalFeatureManager.Instance.IsEnabled()) { - return LocalizableString.Create(name); + // TODO: Configure TagEntityTypes here... } } -} \ No newline at end of file + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDomainServiceBase.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDomainServiceBase.cs index ed26bb83a0..3c897c5422 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDomainServiceBase.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitDomainServiceBase.cs @@ -1,9 +1,8 @@ using Volo.Abp.Domain.Services; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public abstract class CmsKitDomainServiceBase : DomainService { - public abstract class CmsKitDomainServiceBase : DomainService - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CmsKitCommentOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CmsKitCommentOptions.cs index 7e1dcbc1dd..ca8476073c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CmsKitCommentOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CmsKitCommentOptions.cs @@ -1,11 +1,10 @@ using JetBrains.Annotations; using System.Collections.Generic; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public class CmsKitCommentOptions { - public class CmsKitCommentOptions - { - [NotNull] - public List EntityTypes { get; } = new List(); - } + [NotNull] + public List EntityTypes { get; } = new List(); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs index 813d25a39a..0029cabfd0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs @@ -5,56 +5,55 @@ using Volo.Abp.Auditing; using Volo.Abp.Domain.Entities; using Volo.Abp.MultiTenancy; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public class Comment : AggregateRoot, IHasCreationTime, IMustHaveCreator, IMultiTenant { - public class Comment: AggregateRoot, IHasCreationTime, IMustHaveCreator, IMultiTenant - { - public virtual Guid? TenantId { get; protected set; } + public virtual Guid? TenantId { get; protected set; } - public virtual string EntityType { get; protected set; } + public virtual string EntityType { get; protected set; } - public virtual string EntityId { get; protected set; } + public virtual string EntityId { get; protected set; } - public virtual string Text { get; protected set; } + public virtual string Text { get; protected set; } - public virtual Guid? RepliedCommentId { get; protected set; } + public virtual Guid? RepliedCommentId { get; protected set; } - public virtual Guid CreatorId { get; set; } + public virtual Guid CreatorId { get; set; } - public virtual DateTime CreationTime { get; set; } + public virtual DateTime CreationTime { get; set; } - protected Comment() - { + protected Comment() + { - } + } - internal Comment( - Guid id, - [NotNull] string entityType, - [NotNull] string entityId, - [NotNull] string text, - Guid? repliedCommentId, - Guid creatorId, - Guid? tenantId = null) - : base(id) - { - EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.MaxEntityTypeLength); - EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.MaxEntityIdLength); - RepliedCommentId = repliedCommentId; - CreatorId = creatorId; - TenantId = tenantId; + internal Comment( + Guid id, + [NotNull] string entityType, + [NotNull] string entityId, + [NotNull] string text, + Guid? repliedCommentId, + Guid creatorId, + Guid? tenantId = null) + : base(id) + { + EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.MaxEntityTypeLength); + EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.MaxEntityIdLength); + RepliedCommentId = repliedCommentId; + CreatorId = creatorId; + TenantId = tenantId; - SetTextInternal(text); - } + SetTextInternal(text); + } - public virtual void SetText(string text) - { - SetTextInternal(text); - } + public virtual void SetText(string text) + { + SetTextInternal(text); + } - protected virtual void SetTextInternal(string text) - { - Text = Check.NotNullOrWhiteSpace(text, nameof(text), CommentConsts.MaxTextLength); - } + protected virtual void SetTextInternal(string text) + { + Text = Check.NotNullOrWhiteSpace(text, nameof(text), CommentConsts.MaxTextLength); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentEntityTypeDefinition.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentEntityTypeDefinition.cs index cc235bda4d..3dfa822f6a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentEntityTypeDefinition.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentEntityTypeDefinition.cs @@ -2,13 +2,12 @@ using System; using Volo.Abp; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public class CommentEntityTypeDefinition : EntityTypeDefinition { - public class CommentEntityTypeDefinition : EntityTypeDefinition + public CommentEntityTypeDefinition([NotNull] string entityType) : base(entityType) { - public CommentEntityTypeDefinition([NotNull] string entityType) : base(entityType) - { - EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType)); - } + EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType)); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentManager.cs index bbc44c4d06..47ba463d99 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentManager.cs @@ -6,41 +6,40 @@ using Volo.Abp; using Volo.Abp.Domain.Services; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public class CommentManager : DomainService { - public class CommentManager : DomainService + protected ICommentEntityTypeDefinitionStore DefinitionStore { get; } + + public CommentManager(ICommentEntityTypeDefinitionStore definitionStore) { - protected ICommentEntityTypeDefinitionStore DefinitionStore { get; } + DefinitionStore = definitionStore; + } - public CommentManager(ICommentEntityTypeDefinitionStore definitionStore) - { - DefinitionStore = definitionStore; - } + public virtual async Task CreateAsync([NotNull] CmsUser creator, + [NotNull] string entityType, + [NotNull] string entityId, + [NotNull] string text, + [CanBeNull] Guid? repliedCommentId = null) + { + Check.NotNull(creator, nameof(creator)); + Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.MaxEntityTypeLength); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.MaxEntityIdLength); + Check.NotNullOrWhiteSpace(text, nameof(text), CommentConsts.MaxTextLength); - public virtual async Task CreateAsync([NotNull] CmsUser creator, - [NotNull] string entityType, - [NotNull] string entityId, - [NotNull] string text, - [CanBeNull] Guid? repliedCommentId = null) + if (!await DefinitionStore.IsDefinedAsync(entityType)) { - Check.NotNull(creator, nameof(creator)); - Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.MaxEntityTypeLength); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.MaxEntityIdLength); - Check.NotNullOrWhiteSpace(text, nameof(text), CommentConsts.MaxTextLength); - - if (!await DefinitionStore.IsDefinedAsync(entityType)) - { - throw new EntityNotCommentableException(entityType); - } - - return new Comment( - GuidGenerator.Create(), - entityType, - entityId, - text, - repliedCommentId, - creator.Id, - CurrentTenant.Id); + throw new EntityNotCommentableException(entityType); } + + return new Comment( + GuidGenerator.Create(), + entityType, + entityId, + text, + repliedCommentId, + creator.Id, + CurrentTenant.Id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthorQueryResultItem.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthorQueryResultItem.cs index a572ec1017..6765353d66 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthorQueryResultItem.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthorQueryResultItem.cs @@ -1,11 +1,10 @@ using Volo.CmsKit.Users; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public class CommentWithAuthorQueryResultItem { - public class CommentWithAuthorQueryResultItem - { - public Comment Comment { get; set; } + public Comment Comment { get; set; } - public CmsUser Author { get; set; } - } + public CmsUser Author { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/DefaultCommentEntityTypeDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/DefaultCommentEntityTypeDefinitionStore.cs index ac5ebddb59..7037a15a34 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/DefaultCommentEntityTypeDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/DefaultCommentEntityTypeDefinitionStore.cs @@ -8,34 +8,33 @@ using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.DependencyInjection; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public class DefaultCommentEntityTypeDefinitionStore : ICommentEntityTypeDefinitionStore { - public class DefaultCommentEntityTypeDefinitionStore : ICommentEntityTypeDefinitionStore - { - protected CmsKitCommentOptions Options { get; } + protected CmsKitCommentOptions Options { get; } - public DefaultCommentEntityTypeDefinitionStore(IOptions options) - { - Options = options.Value; - } + public DefaultCommentEntityTypeDefinitionStore(IOptions options) + { + Options = options.Value; + } - public virtual Task GetAsync([NotNull] string entityType) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + public virtual Task GetAsync([NotNull] string entityType) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - var result = Options.EntityTypes.SingleOrDefault(x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase)) ?? - throw new EntityNotCommentableException(entityType); + var result = Options.EntityTypes.SingleOrDefault(x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase)) ?? + throw new EntityNotCommentableException(entityType); - return Task.FromResult(result); - } + return Task.FromResult(result); + } - public virtual Task IsDefinedAsync([NotNull] string entityType) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + public virtual Task IsDefinedAsync([NotNull] string entityType) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - var isDefined = Options.EntityTypes.Any(x => x.EntityType == entityType); + var isDefined = Options.EntityTypes.Any(x => x.EntityType == entityType); - return Task.FromResult(isDefined); - } + return Task.FromResult(isDefined); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/EntityNotCommentableException.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/EntityNotCommentableException.cs index ee1a8621bb..5f6697704f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/EntityNotCommentableException.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/EntityNotCommentableException.cs @@ -6,22 +6,21 @@ using System.Text; using System.Threading.Tasks; using Volo.Abp; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +[Serializable] +public class EntityNotCommentableException : BusinessException { - [Serializable] - public class EntityNotCommentableException : BusinessException + public EntityNotCommentableException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context) { - public EntityNotCommentableException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context) - { - } - - public EntityNotCommentableException(string entityType) - { - Code = CmsKitErrorCodes.Comments.EntityNotCommentable; - EntityType = entityType; - WithData(nameof(EntityType), EntityType); - } + } - public string EntityType { get; } + public EntityNotCommentableException(string entityType) + { + Code = CmsKitErrorCodes.Comments.EntityNotCommentable; + EntityType = entityType; + WithData(nameof(EntityType), EntityType); } + + public string EntityType { get; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentEntityTypeDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentEntityTypeDefinitionStore.cs index da4c56ce25..ec2d56765c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentEntityTypeDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentEntityTypeDefinitionStore.cs @@ -1,7 +1,6 @@ -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public interface ICommentEntityTypeDefinitionStore : IEntityTypeDefinitionStore { - public interface ICommentEntityTypeDefinitionStore : IEntityTypeDefinitionStore - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs index 90d9623ce6..30541c2230 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs @@ -5,44 +5,43 @@ using System.Threading.Tasks; using JetBrains.Annotations; using Volo.Abp.Domain.Repositories; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public interface ICommentRepository : IBasicRepository { - public interface ICommentRepository : IBasicRepository - { - Task GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default); + Task GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default); + + Task> GetListAsync( + string filter = null, + string entityType = null, + Guid? repliedCommentId = null, + string authorUsername = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + string sorting = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + CancellationToken cancellationToken = default + ); - Task> GetListAsync( - string filter = null, - string entityType = null, - Guid? repliedCommentId = null, - string authorUsername = null, - DateTime? creationStartDate = null, - DateTime? creationEndDate = null, - string sorting = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - CancellationToken cancellationToken = default - ); + Task GetCountAsync( + string text = null, + string entityType = null, + Guid? repliedCommentId = null, + string authorUsername = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + CancellationToken cancellationToken = default + ); - Task GetCountAsync( - string text = null, - string entityType = null, - Guid? repliedCommentId = null, - string authorUsername = null, - DateTime? creationStartDate = null, - DateTime? creationEndDate = null, - CancellationToken cancellationToken = default - ); - - Task> GetListWithAuthorsAsync( - [NotNull] string entityType, - [NotNull] string entityId, - CancellationToken cancellationToken = default - ); + Task> GetListWithAuthorsAsync( + [NotNull] string entityType, + [NotNull] string entityId, + CancellationToken cancellationToken = default + ); - Task DeleteWithRepliesAsync( - Comment comment, - CancellationToken cancellationToken = default - ); - } + Task DeleteWithRepliesAsync( + Comment comment, + CancellationToken cancellationToken = default + ); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/EntityTypeDefinition.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/EntityTypeDefinition.cs index aed0f040bb..1e25dfd0c2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/EntityTypeDefinition.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/EntityTypeDefinition.cs @@ -2,21 +2,20 @@ using System; using Volo.Abp; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public abstract class EntityTypeDefinition : IEquatable { - public abstract class EntityTypeDefinition : IEquatable + public EntityTypeDefinition([NotNull] string entityType) { - public EntityTypeDefinition([NotNull] string entityType) - { - EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType)); - } + EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType)); + } - [NotNull] - public string EntityType { get; protected set; } + [NotNull] + public string EntityType { get; protected set; } - public bool Equals(EntityTypeDefinition other) - { - return EntityType == other?.EntityType; - } + public bool Equals(EntityTypeDefinition other) + { + return EntityType == other?.EntityType; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/IEntityTypeDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/IEntityTypeDefinitionStore.cs index efe1974a4e..2c35e91910 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/IEntityTypeDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/IEntityTypeDefinitionStore.cs @@ -2,13 +2,12 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public interface IEntityTypeDefinitionStore : ITransientDependency + where TPolicyDefinition : EntityTypeDefinition { - public interface IEntityTypeDefinitionStore : ITransientDependency - where TPolicyDefinition : EntityTypeDefinition - { - Task GetAsync([NotNull] string entityType); + Task GetAsync([NotNull] string entityType); - Task IsDefinedAsync([NotNull] string entityType); - } + Task IsDefinedAsync([NotNull] string entityType); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/CmsKitMediaOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/CmsKitMediaOptions.cs index 89f5d0dca3..8788ed6c8d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/CmsKitMediaOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/CmsKitMediaOptions.cs @@ -5,11 +5,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public class CmsKitMediaOptions { - public class CmsKitMediaOptions - { - [NotNull] - public List EntityTypes { get; } = new(); - } + [NotNull] + public List EntityTypes { get; } = new(); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/DefaultMediaDescriptorDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/DefaultMediaDescriptorDefinitionStore.cs index de191f6014..d8d09b1e7b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/DefaultMediaDescriptorDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/DefaultMediaDescriptorDefinitionStore.cs @@ -8,43 +8,42 @@ using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.DependencyInjection; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public class DefaultMediaDescriptorDefinitionStore : IMediaDescriptorDefinitionStore { - public class DefaultMediaDescriptorDefinitionStore : IMediaDescriptorDefinitionStore + protected CmsKitMediaOptions Options { get; } + + public DefaultMediaDescriptorDefinitionStore(IOptions options) + { + Options = options.Value; + } + + /// + /// Gets single by entityType. + /// + /// EntityType to get definition. + /// Thrown when EntityType is not configured as taggable. + /// More than one element satisfies the condition in predicate. + public virtual Task GetAsync([NotNull] string entityType) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + + var definition = Options.EntityTypes.SingleOrDefault( + x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase) + ) ?? throw new EntityCantHaveMediaException(entityType); + + return Task.FromResult(definition); + } + + public virtual Task IsDefinedAsync([NotNull] string entityType) { - protected CmsKitMediaOptions Options { get; } - - public DefaultMediaDescriptorDefinitionStore(IOptions options) - { - Options = options.Value; - } - - /// - /// Gets single by entityType. - /// - /// EntityType to get definition. - /// Thrown when EntityType is not configured as taggable. - /// More than one element satisfies the condition in predicate. - public virtual Task GetAsync([NotNull] string entityType) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - - var definition = Options.EntityTypes.SingleOrDefault( - x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase) - ) ?? throw new EntityCantHaveMediaException(entityType); - - return Task.FromResult(definition); - } - - public virtual Task IsDefinedAsync([NotNull] string entityType) - { - Check.NotNullOrEmpty(entityType, nameof(entityType)); - - var isDefined = Options.EntityTypes.Any( - a => a.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase) - ); - - return Task.FromResult(isDefined); - } + Check.NotNullOrEmpty(entityType, nameof(entityType)); + + var isDefined = Options.EntityTypes.Any( + a => a.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase) + ); + + return Task.FromResult(isDefined); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/EntityCantHaveMediaException.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/EntityCantHaveMediaException.cs index 911e8d2366..20175b19cd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/EntityCantHaveMediaException.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/EntityCantHaveMediaException.cs @@ -1,21 +1,20 @@ using System.Runtime.Serialization; using Volo.Abp; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public class EntityCantHaveMediaException : BusinessException { - public class EntityCantHaveMediaException : BusinessException + public EntityCantHaveMediaException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context) { - public EntityCantHaveMediaException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context) - { - } - - public EntityCantHaveMediaException(string entityType) - : base(code: CmsKitErrorCodes.MediaDescriptors.EntityTypeDoesntExist) - { - EntityType = entityType; - WithData(nameof(entityType), EntityType); - } + } - public string EntityType { get; } + public EntityCantHaveMediaException(string entityType) + : base(code: CmsKitErrorCodes.MediaDescriptors.EntityTypeDoesntExist) + { + EntityType = entityType; + WithData(nameof(entityType), EntityType); } + + public string EntityType { get; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/IMediaDescriptorDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/IMediaDescriptorDefinitionStore.cs index 1c3dd2bd62..2e47d40911 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/IMediaDescriptorDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/IMediaDescriptorDefinitionStore.cs @@ -1,7 +1,6 @@ -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public interface IMediaDescriptorDefinitionStore : IEntityTypeDefinitionStore { - public interface IMediaDescriptorDefinitionStore : IEntityTypeDefinitionStore - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/IMediaDescriptorRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/IMediaDescriptorRepository.cs index f9f003b6c3..43ab41cb62 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/IMediaDescriptorRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/IMediaDescriptorRepository.cs @@ -1,10 +1,9 @@ using System; using Volo.Abp.Domain.Repositories; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public interface IMediaDescriptorRepository : IBasicRepository { - public interface IMediaDescriptorRepository : IBasicRepository - { - - } -} \ No newline at end of file + +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/InvalidMediaDescriptorNameException.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/InvalidMediaDescriptorNameException.cs index 0634448fa2..4484354159 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/InvalidMediaDescriptorNameException.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/InvalidMediaDescriptorNameException.cs @@ -3,21 +3,20 @@ using System.Runtime.Serialization; using JetBrains.Annotations; using Volo.Abp; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +[Serializable] +public class InvalidMediaDescriptorNameException : BusinessException { - [Serializable] - public class InvalidMediaDescriptorNameException : BusinessException + public InvalidMediaDescriptorNameException([NotNull] string name) + { + Code = CmsKitErrorCodes.MediaDescriptors.InvalidName; + WithData(nameof(MediaDescriptor.Name), name); + } + + public InvalidMediaDescriptorNameException(SerializationInfo serializationInfo, StreamingContext context) + : base(serializationInfo, context) { - public InvalidMediaDescriptorNameException([NotNull] string name) - { - Code = CmsKitErrorCodes.MediaDescriptors.InvalidName; - WithData(nameof(MediaDescriptor.Name), name); - } - - public InvalidMediaDescriptorNameException(SerializationInfo serializationInfo, StreamingContext context) - : base(serializationInfo, context) - { - } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaContainer.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaContainer.cs index b1ea0fe1d4..01a6245963 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaContainer.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaContainer.cs @@ -1,10 +1,9 @@ using Volo.Abp.BlobStoring; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +[BlobContainerName("cms-kit-media")] +public class MediaContainer { - [BlobContainerName("cms-kit-media")] - public class MediaContainer - { - - } -} \ No newline at end of file + +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptor.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptor.cs index ee0df74b59..6bbbdff675 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptor.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptor.cs @@ -3,44 +3,43 @@ using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.MultiTenancy; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public class MediaDescriptor : FullAuditedAggregateRoot, IMultiTenant { - public class MediaDescriptor : FullAuditedAggregateRoot, IMultiTenant + public Guid? TenantId { get; protected set; } + + public string EntityType { get; protected set; } + + public string Name { get; protected set; } + + public string MimeType { get; protected set; } + + public long Size { get; protected set; } + + protected MediaDescriptor() { - public Guid? TenantId { get; protected set; } - public string EntityType { get; protected set; } - - public string Name { get; protected set; } + } - public string MimeType { get; protected set; } + internal MediaDescriptor(Guid id, string entityType, string name, string mimeType, long size, Guid? tenantId = null) : base(id) + { + TenantId = tenantId; - public long Size { get; protected set; } + EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), MediaDescriptorConsts.MaxEntityTypeLength); + MimeType = Check.NotNullOrWhiteSpace(mimeType, nameof(name), MediaDescriptorConsts.MaxMimeTypeLength); + Size = size; - protected MediaDescriptor() - { - - } + SetName(name); + } - internal MediaDescriptor(Guid id, string entityType, string name, string mimeType, long size, Guid? tenantId = null) : base(id) + public void SetName(string name) + { + if (!MediaDescriptorChecks.IsValidMediaFileName(name)) { - TenantId = tenantId; - - EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), MediaDescriptorConsts.MaxEntityTypeLength); - MimeType = Check.NotNullOrWhiteSpace(mimeType, nameof(name), MediaDescriptorConsts.MaxMimeTypeLength); - Size = size; - - SetName(name); + throw new InvalidMediaDescriptorNameException(name); } - public void SetName(string name) - { - if (!MediaDescriptorChecks.IsValidMediaFileName(name)) - { - throw new InvalidMediaDescriptorNameException(name); - } - - Name = name; - } + Name = name; } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorChecks.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorChecks.cs index 1881de83e3..d68ade0a73 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorChecks.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorChecks.cs @@ -1,18 +1,17 @@ using System.IO; using System.Linq; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public static class MediaDescriptorChecks { - public static class MediaDescriptorChecks + public static bool IsValidMediaFileName(string name) { - public static bool IsValidMediaFileName(string name) + if (string.IsNullOrWhiteSpace(name)) { - if (string.IsNullOrWhiteSpace(name)) - { - return false; - } - - return !Path.GetInvalidFileNameChars().Any(name.Contains); + return false; } + + return !Path.GetInvalidFileNameChars().Any(name.Contains); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorDefinition.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorDefinition.cs index 95bfaacb61..d94c54afc3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorDefinition.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorDefinition.cs @@ -2,19 +2,18 @@ using System; using System.Collections.Generic; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public class MediaDescriptorDefinition : PolicySpecifiedDefinition { - public class MediaDescriptorDefinition : PolicySpecifiedDefinition + public MediaDescriptorDefinition( + [NotNull] string entityType, + IEnumerable createPolicies = null, + IEnumerable updatePolicies = null, + IEnumerable deletePolicies = null) : base(entityType, + createPolicies, + updatePolicies, + deletePolicies) { - public MediaDescriptorDefinition( - [NotNull] string entityType, - IEnumerable createPolicies = null, - IEnumerable updatePolicies = null, - IEnumerable deletePolicies = null) : base(entityType, - createPolicies, - updatePolicies, - deletePolicies) - { - } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorManager.cs index 730e4e3ccf..a9c6e971a0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/MediaDescriptors/MediaDescriptorManager.cs @@ -1,31 +1,30 @@ using System.Threading.Tasks; using Volo.Abp.Domain.Services; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public class MediaDescriptorManager : DomainService { - public class MediaDescriptorManager : DomainService + protected IMediaDescriptorDefinitionStore MediaDescriptorDefinitionStore { get; } + + public MediaDescriptorManager(IMediaDescriptorDefinitionStore mediaDescriptorDefinitionStore) { - protected IMediaDescriptorDefinitionStore MediaDescriptorDefinitionStore { get; } + MediaDescriptorDefinitionStore = mediaDescriptorDefinitionStore; + } - public MediaDescriptorManager(IMediaDescriptorDefinitionStore mediaDescriptorDefinitionStore) + public virtual async Task CreateAsync(string entityType, string name, string mimeType, long size) + { + if (!await MediaDescriptorDefinitionStore.IsDefinedAsync(entityType)) { - MediaDescriptorDefinitionStore = mediaDescriptorDefinitionStore; + throw new EntityCantHaveMediaException(entityType); } - public virtual async Task CreateAsync(string entityType, string name, string mimeType, long size) - { - if(!await MediaDescriptorDefinitionStore.IsDefinedAsync(entityType)) - { - throw new EntityCantHaveMediaException(entityType); - } - - return new MediaDescriptor( - GuidGenerator.Create(), - entityType, - name, - mimeType, - size, - CurrentTenant.Id); - } + return new MediaDescriptor( + GuidGenerator.Create(), + entityType, + name, + mimeType, + size, + CurrentTenant.Id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/IMenuItemRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/IMenuItemRepository.cs index 9c46bab982..afee164e06 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/IMenuItemRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/IMenuItemRepository.cs @@ -1,9 +1,8 @@ using System; using Volo.Abp.Domain.Repositories; -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +public interface IMenuItemRepository : IBasicRepository { - public interface IMenuItemRepository : IBasicRepository - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/MenuItem.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/MenuItem.cs index 34b986b4d1..ab7e23df8b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/MenuItem.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/MenuItem.cs @@ -9,76 +9,75 @@ using Volo.Abp.Authorization.Permissions; using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.MultiTenancy; -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +public class MenuItem : AuditedAggregateRoot, IMultiTenant { - public class MenuItem : AuditedAggregateRoot, IMultiTenant + /// + /// Presents another Id. + /// If it's , then it's a root menu item. + /// + public Guid? ParentId { get; set; } + + [NotNull] + public string DisplayName { get; protected set; } + + public bool IsActive { get; set; } + + [NotNull] + public string Url { get; protected set; } + + public string Icon { get; set; } + + public int Order { get; set; } + + public string Target { get; set; } + + public string ElementId { get; set; } + + public string CssClass { get; set; } + + public Guid? PageId { get; protected set; } + + public Guid? TenantId { get; protected set; } + + public MenuItem(Guid id, + [NotNull] string displayName, + [NotNull] string url, + bool isActive = true, + [CanBeNull] Guid? parentId = null, + [CanBeNull] string icon = null, + int order = 0, + [CanBeNull] string target = null, + [CanBeNull] string elementId = null, + [CanBeNull] string cssClass = null, + [CanBeNull] Guid? tenantId = null) + : base(id) + { + SetDisplayName(displayName); + IsActive = isActive; + ParentId = parentId; + SetUrl(url); + Icon = icon; + Order = order; + Target = target; + ElementId = elementId; + CssClass = cssClass; + TenantId = tenantId; + } + + public void SetDisplayName([NotNull] string displayName) + { + DisplayName = Check.NotNullOrEmpty(displayName, nameof(displayName), MenuItemConsts.MaxDisplayNameLength); + } + + public void SetUrl([NotNull] string url) + { + Url = Check.NotNullOrEmpty(url, nameof(url), MenuItemConsts.MaxUrlLength); + } + + internal void SetPageId(Guid pageId) { - /// - /// Presents another Id. - /// If it's , then it's a root menu item. - /// - public Guid? ParentId { get; set; } - - [NotNull] - public string DisplayName { get; protected set; } - - public bool IsActive { get; set; } - - [NotNull] - public string Url { get; protected set; } - - public string Icon { get; set; } - - public int Order { get; set; } - - public string Target { get; set; } - - public string ElementId { get; set; } - - public string CssClass { get; set; } - - public Guid? PageId { get; protected set; } - - public Guid? TenantId { get; protected set; } - - public MenuItem(Guid id, - [NotNull] string displayName, - [NotNull] string url, - bool isActive = true, - [CanBeNull] Guid? parentId = null, - [CanBeNull] string icon = null, - int order = 0, - [CanBeNull] string target = null, - [CanBeNull] string elementId = null, - [CanBeNull] string cssClass = null, - [CanBeNull] Guid? tenantId = null) - : base(id) - { - SetDisplayName(displayName); - IsActive = isActive; - ParentId = parentId; - SetUrl(url); - Icon = icon; - Order = order; - Target = target; - ElementId = elementId; - CssClass = cssClass; - TenantId = tenantId; - } - - public void SetDisplayName([NotNull] string displayName) - { - DisplayName = Check.NotNullOrEmpty(displayName, nameof(displayName), MenuItemConsts.MaxDisplayNameLength); - } - - public void SetUrl([NotNull] string url) - { - Url = Check.NotNullOrEmpty(url, nameof(url), MenuItemConsts.MaxUrlLength); - } - - internal void SetPageId(Guid pageId) - { - PageId = pageId; - } + PageId = pageId; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/MenuItemManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/MenuItemManager.cs index 542f6f6259..16fbbbdb8e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/MenuItemManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/MenuItemManager.cs @@ -8,56 +8,55 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Uow; using Volo.CmsKit.Pages; -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +public class MenuItemManager : CmsKitDomainServiceBase { - public class MenuItemManager : CmsKitDomainServiceBase + protected IMenuItemRepository MenuItemRepository { get; } + + public MenuItemManager(IMenuItemRepository menuRepository) { - protected IMenuItemRepository MenuItemRepository { get; } + MenuItemRepository = menuRepository; + } - public MenuItemManager(IMenuItemRepository menuRepository) - { - MenuItemRepository = menuRepository; - } + public virtual void SetPageUrl(MenuItem menuItem, Page page) + { + menuItem.SetPageId(page.Id); + menuItem.SetUrl(PageConsts.UrlPrefix + page.Slug); + } + + [UnitOfWork] + public virtual async Task MoveAsync(Guid menuItemId, Guid? newParentMenuItemId, int position = 0) + { + var menuItems = await MenuItemRepository.GetListAsync(); - public virtual void SetPageUrl(MenuItem menuItem, Page page) + var movedMenuItem = menuItems.FirstOrDefault(x => x.Id == menuItemId) + ?? throw new EntityNotFoundException(typeof(MenuItem), menuItemId); + + if (newParentMenuItemId.HasValue && !menuItems.Any(a => a.Id == newParentMenuItemId.Value)) { - menuItem.SetPageId(page.Id); - menuItem.SetUrl(PageConsts.UrlPrefix + page.Slug); + throw new EntityNotFoundException(typeof(MenuItem), newParentMenuItemId); } - [UnitOfWork] - public virtual async Task MoveAsync(Guid menuItemId, Guid? newParentMenuItemId, int position = 0) - { - var menuItems = await MenuItemRepository.GetListAsync(); + movedMenuItem.ParentId = newParentMenuItemId; + movedMenuItem.Order = position; - var movedMenuItem = menuItems.FirstOrDefault(x => x.Id == menuItemId) - ?? throw new EntityNotFoundException(typeof(MenuItem), menuItemId); + OrganizeTreeOrderForMenuItem(menuItems, movedMenuItem); - if (newParentMenuItemId.HasValue && !menuItems.Any(a => a.Id == newParentMenuItemId.Value)) - { - throw new EntityNotFoundException(typeof(MenuItem), newParentMenuItemId); - } + await MenuItemRepository.UpdateManyAsync(menuItems); + } - movedMenuItem.ParentId = newParentMenuItemId; - movedMenuItem.Order = position; + public virtual void OrganizeTreeOrderForMenuItem(List items, MenuItem menuItem) + { + var sameTree = items.Where(x => x.ParentId == menuItem.ParentId).OrderBy(x => x.Order).ToList(); - OrganizeTreeOrderForMenuItem(menuItems, movedMenuItem); + sameTree.Remove(menuItem); // Remove if exists to prevent misordering with same order number - await MenuItemRepository.UpdateManyAsync(menuItems); - } + sameTree.Insert(menuItem.Order, menuItem); - public virtual void OrganizeTreeOrderForMenuItem(List items, MenuItem menuItem) + for (int i = 0; i < sameTree.Count; i++) { - var sameTree = items.Where(x => x.ParentId == menuItem.ParentId).OrderBy(x => x.Order).ToList(); - - sameTree.Remove(menuItem); // Remove if exists to prevent misordering with same order number - - sameTree.Insert(menuItem.Order, menuItem); - - for (int i = 0; i < sameTree.Count; i++) - { - sameTree[i].Order = i; - } + sameTree[i].Order = i; } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/PageChangedHandler.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/PageChangedHandler.cs index ca1b376afc..0c8d53d071 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/PageChangedHandler.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Menus/PageChangedHandler.cs @@ -5,38 +5,37 @@ using Volo.Abp.Domain.Entities.Events; using Volo.Abp.EventBus; using Volo.CmsKit.Pages; -namespace Volo.CmsKit.Menus -{ - public class PageChangedHandler : - ILocalEventHandler>, - ITransientDependency - { - protected IMenuItemRepository MenuRepository { get; } - protected MenuItemManager MenuManager { get; } +namespace Volo.CmsKit.Menus; - public PageChangedHandler( - IMenuItemRepository menuRepository, - MenuItemManager menuManager) - { - MenuRepository = menuRepository; - MenuManager = menuManager; - } +public class PageChangedHandler : + ILocalEventHandler>, + ITransientDependency +{ + protected IMenuItemRepository MenuRepository { get; } + protected MenuItemManager MenuManager { get; } - public async Task HandleEventAsync(EntityUpdatedEventData eventData) - { - // TODO: Write a repository query. - var allMenuItems = await MenuRepository.GetListAsync(); + public PageChangedHandler( + IMenuItemRepository menuRepository, + MenuItemManager menuManager) + { + MenuRepository = menuRepository; + MenuManager = menuManager; + } - var affectedMenuItems = allMenuItems - .Where(x => x.PageId == eventData.Entity.Id) - .ToArray(); + public async Task HandleEventAsync(EntityUpdatedEventData eventData) + { + // TODO: Write a repository query. + var allMenuItems = await MenuRepository.GetListAsync(); - foreach (var menuItem in affectedMenuItems) - { - MenuManager.SetPageUrl(menuItem, eventData.Entity); - } + var affectedMenuItems = allMenuItems + .Where(x => x.PageId == eventData.Entity.Id) + .ToArray(); - await MenuRepository.UpdateManyAsync(affectedMenuItems); + foreach (var menuItem in affectedMenuItems) + { + MenuManager.SetPageUrl(menuItem, eventData.Entity); } + + await MenuRepository.UpdateManyAsync(affectedMenuItems); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/IPageRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/IPageRepository.cs index b5ed3f0639..020622f080 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/IPageRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/IPageRepository.cs @@ -4,23 +4,22 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public interface IPageRepository : IBasicRepository { - public interface IPageRepository : IBasicRepository - { - Task GetCountAsync(string filter = null, CancellationToken cancellationToken = default); + Task GetCountAsync(string filter = null, CancellationToken cancellationToken = default); + + Task> GetListAsync( + string filter = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + string sorting = null, + CancellationToken cancellationToken = default); - Task> GetListAsync( - string filter = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - string sorting = null, - CancellationToken cancellationToken = default); - - Task GetBySlugAsync(string slug, CancellationToken cancellationToken = default); + Task GetBySlugAsync(string slug, CancellationToken cancellationToken = default); - Task FindBySlugAsync(string slug, CancellationToken cancellationToken = default); + Task FindBySlugAsync(string slug, CancellationToken cancellationToken = default); - Task ExistsAsync(string slug, CancellationToken cancellationToken = default); - } -} \ No newline at end of file + Task ExistsAsync(string slug, CancellationToken cancellationToken = default); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/Page.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/Page.cs index 7c3356a98b..504197e4fa 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/Page.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/Page.cs @@ -4,67 +4,66 @@ using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.MultiTenancy; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public class Page : FullAuditedAggregateRoot, IMultiTenant { - public class Page : FullAuditedAggregateRoot, IMultiTenant - { - public virtual Guid? TenantId { get; protected set; } + public virtual Guid? TenantId { get; protected set; } - public virtual string Title { get; protected set; } + public virtual string Title { get; protected set; } - public virtual string Slug { get; protected set; } + public virtual string Slug { get; protected set; } - public virtual string Content { get; protected set; } + public virtual string Content { get; protected set; } - public virtual string Script { get; protected set; } + public virtual string Script { get; protected set; } - public virtual string Style { get; protected set; } + public virtual string Style { get; protected set; } + + protected Page() + { + } - protected Page() - { - } + internal Page( + Guid id, + [NotNull] string title, + [NotNull] string slug, + string content = null, + string script = null, + string style = null, + Guid? tenantId = null) : base(id) + { + TenantId = tenantId; - internal Page( - Guid id, - [NotNull] string title, - [NotNull] string slug, - string content = null, - string script = null, - string style = null, - Guid? tenantId = null) : base(id) - { - TenantId = tenantId; - - SetTitle(title); - SetSlug(slug); - SetContent(content); - SetScript(script); - SetStyle(style); - } + SetTitle(title); + SetSlug(slug); + SetContent(content); + SetScript(script); + SetStyle(style); + } - public virtual void SetTitle(string title) - { - Title = Check.NotNullOrEmpty(title, nameof(title), PageConsts.MaxTitleLength); - } + public virtual void SetTitle(string title) + { + Title = Check.NotNullOrEmpty(title, nameof(title), PageConsts.MaxTitleLength); + } - internal virtual void SetSlug(string slug) - { - Slug = Check.NotNullOrEmpty(slug, nameof(slug), PageConsts.MaxSlugLength); - } + internal virtual void SetSlug(string slug) + { + Slug = Check.NotNullOrEmpty(slug, nameof(slug), PageConsts.MaxSlugLength); + } - public virtual void SetContent(string content) - { - Content = Check.Length(content, nameof(content), PageConsts.MaxContentLength); - } + public virtual void SetContent(string content) + { + Content = Check.Length(content, nameof(content), PageConsts.MaxContentLength); + } - public virtual void SetScript(string script) - { - Script = Check.Length(script, nameof(script), PageConsts.MaxScriptLength); - } + public virtual void SetScript(string script) + { + Script = Check.Length(script, nameof(script), PageConsts.MaxScriptLength); + } - public virtual void SetStyle(string style) - { - Style = Check.Length(style, nameof(style), PageConsts.MaxStyleLength); - } + public virtual void SetStyle(string style) + { + Style = Check.Length(style, nameof(style), PageConsts.MaxStyleLength); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageManager.cs index 6c0df936ba..f0d1bac1e7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageManager.cs @@ -7,54 +7,53 @@ using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Domain.Services; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public class PageManager : DomainService { - public class PageManager : DomainService + protected IPageRepository PageRepository { get; } + + public PageManager(IPageRepository pageRepository) { - protected IPageRepository PageRepository { get; } + PageRepository = pageRepository; + } - public PageManager(IPageRepository pageRepository) - { - PageRepository = pageRepository; - } + public virtual async Task CreateAsync( + [NotNull] string title, + [NotNull] string slug, + [CanBeNull] string content = null, + [CanBeNull] string script = null, + [CanBeNull] string style = null) + { + Check.NotNullOrEmpty(title, nameof(title)); + Check.NotNullOrEmpty(slug, nameof(slug)); - public virtual async Task CreateAsync( - [NotNull] string title, - [NotNull] string slug, - [CanBeNull] string content = null, - [CanBeNull] string script = null, - [CanBeNull] string style = null) - { - Check.NotNullOrEmpty(title, nameof(title)); - Check.NotNullOrEmpty(slug, nameof(slug)); - - await CheckPageSlugAsync(slug); - - return new Page( - GuidGenerator.Create(), - title, - slug, - content, - script, - style, - CurrentTenant.Id); - } + await CheckPageSlugAsync(slug); + + return new Page( + GuidGenerator.Create(), + title, + slug, + content, + script, + style, + CurrentTenant.Id); + } - public virtual async Task SetSlugAsync(Page page, string newSlug) + public virtual async Task SetSlugAsync(Page page, string newSlug) + { + if (page.Slug != newSlug) { - if (page.Slug != newSlug) - { - await CheckPageSlugAsync(newSlug); - page.SetSlug(newSlug); - } + await CheckPageSlugAsync(newSlug); + page.SetSlug(newSlug); } + } - protected virtual async Task CheckPageSlugAsync(string slug) + protected virtual async Task CheckPageSlugAsync(string slug) + { + if (await PageRepository.ExistsAsync(slug)) { - if (await PageRepository.ExistsAsync(slug)) - { - throw new PageSlugAlreadyExistsException(slug); - } + throw new PageSlugAlreadyExistsException(slug); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageSlugAlreadyExistsException.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageSlugAlreadyExistsException.cs index 9970c67b6f..8b8c8d924d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageSlugAlreadyExistsException.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/PageSlugAlreadyExistsException.cs @@ -3,21 +3,20 @@ using System.Runtime.Serialization; using JetBrains.Annotations; using Volo.Abp; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +[Serializable] +public class PageSlugAlreadyExistsException : BusinessException { - [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) { - public PageSlugAlreadyExistsException([NotNull] string slug) - { - Code = CmsKitErrorCodes.Pages.SlugAlreadyExist; - WithData(nameof(Page.Slug), slug); - } - - public PageSlugAlreadyExistsException(SerializationInfo serializationInfo, StreamingContext context) - : base(serializationInfo, context) - { - } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/PolicySpecifiedDefinition.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/PolicySpecifiedDefinition.cs index 743b5c280a..bf59781a88 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/PolicySpecifiedDefinition.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/PolicySpecifiedDefinition.cs @@ -4,44 +4,43 @@ using System.Collections.Generic; using System.Linq; using Volo.Abp; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public abstract class PolicySpecifiedDefinition : EntityTypeDefinition, IEquatable { - public abstract class PolicySpecifiedDefinition : EntityTypeDefinition, IEquatable + public PolicySpecifiedDefinition( + [NotNull] string entityType, + IEnumerable createPolicies = null, + IEnumerable updatePolicies = null, + IEnumerable deletePolicies = null) : base(entityType) { - public PolicySpecifiedDefinition( - [NotNull] string entityType, - IEnumerable createPolicies = null, - IEnumerable updatePolicies = null, - IEnumerable deletePolicies = null) : base(entityType) + if (createPolicies != null) { - if (createPolicies != null) - { - CreatePolicies = CreatePolicies.Concat(createPolicies).ToList(); - } - - if (updatePolicies != null) - { - UpdatePolicies = UpdatePolicies.Concat(updatePolicies).ToList(); - } - - if (deletePolicies != null) - { - DeletePolicies = DeletePolicies.Concat(deletePolicies).ToList(); - } + CreatePolicies = CreatePolicies.Concat(createPolicies).ToList(); } - [NotNull] - public virtual ICollection CreatePolicies { get; } = new List(); - - [NotNull] - public virtual ICollection UpdatePolicies { get; } = new List(); - - [NotNull] - public virtual ICollection DeletePolicies { get; } = new List(); + if (updatePolicies != null) + { + UpdatePolicies = UpdatePolicies.Concat(updatePolicies).ToList(); + } - public bool Equals(PolicySpecifiedDefinition other) + if (deletePolicies != null) { - return other?.EntityType == EntityType; + DeletePolicies = DeletePolicies.Concat(deletePolicies).ToList(); } } + + [NotNull] + public virtual ICollection CreatePolicies { get; } = new List(); + + [NotNull] + public virtual ICollection UpdatePolicies { get; } = new List(); + + [NotNull] + public virtual ICollection DeletePolicies { get; } = new List(); + + public bool Equals(PolicySpecifiedDefinition other) + { + return other?.EntityType == EntityType; + } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/CmsKitRatingOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/CmsKitRatingOptions.cs index 985e726b3c..fafcf0cdcb 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/CmsKitRatingOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/CmsKitRatingOptions.cs @@ -1,11 +1,10 @@ using JetBrains.Annotations; using System.Collections.Generic; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public class CmsKitRatingOptions { - public class CmsKitRatingOptions - { - [NotNull] - public List EntityTypes { get; } = new (); - } + [NotNull] + public List EntityTypes { get; } = new(); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/DefaultRatingEntityTypeDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/DefaultRatingEntityTypeDefinitionStore.cs index c0e8136986..ed4fc6ce0c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/DefaultRatingEntityTypeDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/DefaultRatingEntityTypeDefinitionStore.cs @@ -5,34 +5,33 @@ using System.Linq; using System.Threading.Tasks; using Volo.Abp; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public class DefaultRatingEntityTypeDefinitionStore : IRatingEntityTypeDefinitionStore { - public class DefaultRatingEntityTypeDefinitionStore : IRatingEntityTypeDefinitionStore - { - protected CmsKitRatingOptions Options { get; } + protected CmsKitRatingOptions Options { get; } - public DefaultRatingEntityTypeDefinitionStore(IOptions options) - { - Options = options.Value; - } + public DefaultRatingEntityTypeDefinitionStore(IOptions options) + { + Options = options.Value; + } - public virtual Task GetAsync([NotNull] string entityType) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + public virtual Task GetAsync([NotNull] string entityType) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - var definition = Options.EntityTypes.SingleOrDefault(x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase)) ?? - throw new EntityCantHaveRatingException(entityType); + var definition = Options.EntityTypes.SingleOrDefault(x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase)) ?? + throw new EntityCantHaveRatingException(entityType); - return Task.FromResult(definition); - } + return Task.FromResult(definition); + } - public virtual Task IsDefinedAsync([NotNull] string entityType) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + public virtual Task IsDefinedAsync([NotNull] string entityType) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - var isDefined = Options.EntityTypes.Any(x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase)); + var isDefined = Options.EntityTypes.Any(x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase)); - return Task.FromResult(isDefined); - } + return Task.FromResult(isDefined); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/EntityCantHaveRatingException.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/EntityCantHaveRatingException.cs index 82616482d7..fde7c0d438 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/EntityCantHaveRatingException.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/EntityCantHaveRatingException.cs @@ -2,21 +2,20 @@ using System.Runtime.Serialization; using Volo.Abp; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public class EntityCantHaveRatingException : BusinessException { - public class EntityCantHaveRatingException : BusinessException + public EntityCantHaveRatingException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context) { - public EntityCantHaveRatingException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context) - { - } - - public EntityCantHaveRatingException([NotNull] string entityType) - { - Code = CmsKitErrorCodes.Ratings.EntityCantHaveRating; - EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType)); - WithData(nameof(EntityType), EntityType); - } + } - public string EntityType { get; } + public EntityCantHaveRatingException([NotNull] string entityType) + { + Code = CmsKitErrorCodes.Ratings.EntityCantHaveRating; + EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType)); + WithData(nameof(EntityType), EntityType); } + + public string EntityType { get; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/IRatingEntityTypeDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/IRatingEntityTypeDefinitionStore.cs index ad964b272b..beb3ffcfda 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/IRatingEntityTypeDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/IRatingEntityTypeDefinitionStore.cs @@ -1,9 +1,8 @@ using Volo.CmsKit.Ratings; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public interface IRatingEntityTypeDefinitionStore : IEntityTypeDefinitionStore { - public interface IRatingEntityTypeDefinitionStore : IEntityTypeDefinitionStore - { - - } + } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/IRatingRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/IRatingRepository.cs index a9f71b0dfb..d1a6724ee3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/IRatingRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/IRatingRepository.cs @@ -5,21 +5,20 @@ using System.Threading.Tasks; using JetBrains.Annotations; using Volo.Abp.Domain.Repositories; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public interface IRatingRepository : IBasicRepository { - public interface IRatingRepository : IBasicRepository - { - Task GetCurrentUserRatingAsync( - [NotNull] string entityType, - [NotNull] string entityId, - Guid userId, - CancellationToken cancellationToken = default - ); + Task GetCurrentUserRatingAsync( + [NotNull] string entityType, + [NotNull] string entityId, + Guid userId, + CancellationToken cancellationToken = default + ); - Task> GetGroupedStarCountsAsync( - [NotNull] string entityType, - [NotNull] string entityId, - CancellationToken cancellationToken = default - ); - } -} \ No newline at end of file + Task> GetGroupedStarCountsAsync( + [NotNull] string entityType, + [NotNull] string entityId, + CancellationToken cancellationToken = default + ); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/Rating.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/Rating.cs index dd4b5510a1..5e80adfb54 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/Rating.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/Rating.cs @@ -4,54 +4,53 @@ using Volo.Abp; using Volo.Abp.Auditing; using Volo.Abp.Domain.Entities; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public class Rating : BasicAggregateRoot, IHasCreationTime, IMustHaveCreator { - public class Rating : BasicAggregateRoot, IHasCreationTime, IMustHaveCreator + public virtual Guid? TenantId { get; protected set; } + + public virtual string EntityType { get; protected set; } + + public virtual string EntityId { get; protected set; } + + public virtual short StarCount { get; protected set; } + + public virtual Guid CreatorId { get; set; } + + public virtual DateTime CreationTime { get; set; } + + protected Rating() { - public virtual Guid? TenantId { get; protected set; } - - public virtual string EntityType { get; protected set; } - public virtual string EntityId { get; protected set; } - - public virtual short StarCount { get; protected set; } - - public virtual Guid CreatorId { get; set; } + } - public virtual DateTime CreationTime { get; set; } + internal Rating( + Guid id, + [NotNull] string entityType, + [NotNull] string entityId, + short starCount, + Guid creatorId, + Guid? tenantId = null + ) + : base(id) + { + EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), RatingConsts.MaxEntityTypeLength); + EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), RatingConsts.MaxEntityIdLength); + SetStarCount(starCount); + CreatorId = creatorId; + TenantId = tenantId; + } - protected Rating() - { - - } - - internal Rating( - Guid id, - [NotNull] string entityType, - [NotNull] string entityId, - short starCount, - Guid creatorId, - Guid? tenantId = null - ) - : base(id) + public virtual void SetStarCount(short starCount) + { + if (starCount <= RatingConsts.MaxStarCount && starCount >= RatingConsts.MinStarCount) { - EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), RatingConsts.MaxEntityTypeLength); - EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), RatingConsts.MaxEntityIdLength); - SetStarCount(starCount); - CreatorId = creatorId; - TenantId = tenantId; + StarCount = starCount; } - - public virtual void SetStarCount(short starCount) + else { - if(starCount <= RatingConsts.MaxStarCount && starCount >= RatingConsts.MinStarCount) - { - StarCount = starCount; - } - else - { - throw new ArgumentOutOfRangeException($"Choosen star must between {RatingConsts.MinStarCount} and {RatingConsts.MaxStarCount}"); - } + throw new ArgumentOutOfRangeException($"Choosen star must between {RatingConsts.MinStarCount} and {RatingConsts.MaxStarCount}"); } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingEntityTypeDefinition.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingEntityTypeDefinition.cs index 47534f98ab..020cab3821 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingEntityTypeDefinition.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingEntityTypeDefinition.cs @@ -1,12 +1,11 @@ using JetBrains.Annotations; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public class RatingEntityTypeDefinition : EntityTypeDefinition { - public class RatingEntityTypeDefinition : EntityTypeDefinition + public RatingEntityTypeDefinition( + [NotNull] string entityType) : base(entityType) { - public RatingEntityTypeDefinition( - [NotNull] string entityType) : base(entityType) - { - } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingManager.cs index 7186089deb..d609979de8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingManager.cs @@ -6,47 +6,46 @@ using System.Threading.Tasks; using Volo.Abp.Domain.Services; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public class RatingManager : DomainService { - public class RatingManager : DomainService + protected IRatingRepository RatingRepository { get; } + protected IRatingEntityTypeDefinitionStore RatingDefinitionStore { get; } + + public RatingManager( + IRatingRepository ratingRepository, + IRatingEntityTypeDefinitionStore ratingDefinitionStore) { - protected IRatingRepository RatingRepository { get; } - protected IRatingEntityTypeDefinitionStore RatingDefinitionStore { get; } + RatingRepository = ratingRepository; + RatingDefinitionStore = ratingDefinitionStore; + } - public RatingManager( - IRatingRepository ratingRepository, - IRatingEntityTypeDefinitionStore ratingDefinitionStore) + public async Task SetStarAsync(CmsUser user, string entityType, string entityId, short starCount) + { + var currentUserRating = await RatingRepository.GetCurrentUserRatingAsync(entityType, entityId, user.Id); + + if (currentUserRating != null) { - RatingRepository = ratingRepository; - RatingDefinitionStore = ratingDefinitionStore; + currentUserRating.SetStarCount(starCount); + + return await RatingRepository.UpdateAsync(currentUserRating); } - public async Task SetStarAsync(CmsUser user, string entityType, string entityId, short starCount) + if (!await RatingDefinitionStore.IsDefinedAsync(entityType)) { - var currentUserRating = await RatingRepository.GetCurrentUserRatingAsync(entityType, entityId, user.Id); - - if (currentUserRating != null) - { - currentUserRating.SetStarCount(starCount); - - return await RatingRepository.UpdateAsync(currentUserRating); - } - - if (!await RatingDefinitionStore.IsDefinedAsync(entityType)) - { - throw new EntityCantHaveRatingException(entityType); - } - - return await RatingRepository.InsertAsync( - new Rating( - GuidGenerator.Create(), - entityType, - entityId, - starCount, - user.Id, - CurrentTenant.Id - ) - ); + throw new EntityCantHaveRatingException(entityType); } + + return await RatingRepository.InsertAsync( + new Rating( + GuidGenerator.Create(), + entityType, + entityId, + starCount, + user.Id, + CurrentTenant.Id + ) + ); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingWithStarCountQueryResultItem.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingWithStarCountQueryResultItem.cs index 5f53074b97..7195289f10 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingWithStarCountQueryResultItem.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Ratings/RatingWithStarCountQueryResultItem.cs @@ -1,9 +1,8 @@ -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public class RatingWithStarCountQueryResultItem { - public class RatingWithStarCountQueryResultItem - { - public short StarCount { get; set; } + public short StarCount { get; set; } - public int Count { get; set; } - } -} \ No newline at end of file + public int Count { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/CmsKitReactionOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/CmsKitReactionOptions.cs index 90c49cc4cf..788f9cdcc2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/CmsKitReactionOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/CmsKitReactionOptions.cs @@ -1,11 +1,10 @@ using JetBrains.Annotations; using System.Collections.Generic; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class CmsKitReactionOptions { - public class CmsKitReactionOptions - { - [NotNull] - public List EntityTypes { get; } = new (); - } + [NotNull] + public List EntityTypes { get; } = new(); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/DefaultReactionDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/DefaultReactionDefinitionStore.cs index 5705a4c091..8a6bc7dd76 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/DefaultReactionDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/DefaultReactionDefinitionStore.cs @@ -7,59 +7,58 @@ using Microsoft.Extensions.Options; using Volo.Abp; using Volo.Abp.DependencyInjection; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class DefaultReactionDefinitionStore : IReactionDefinitionStore { - public class DefaultReactionDefinitionStore : IReactionDefinitionStore - { - protected CmsKitReactionOptions Options { get; } + protected CmsKitReactionOptions Options { get; } - public DefaultReactionDefinitionStore(IOptions options) - { - Options = options.Value; - } + public DefaultReactionDefinitionStore(IOptions options) + { + Options = options.Value; + } - public virtual async Task> GetReactionsAsync([NotNull] string entityType) - { - Check.NotNullOrEmpty(entityType, nameof(entityType)); + public virtual async Task> GetReactionsAsync([NotNull] string entityType) + { + Check.NotNullOrEmpty(entityType, nameof(entityType)); - var definition = await GetAsync(entityType); + var definition = await GetAsync(entityType); - return definition.Reactions; - } + return definition.Reactions; + } - public virtual async Task GetReactionOrNullAsync([NotNull] string reactionName, [NotNull] string entityType) - { - Check.NotNullOrEmpty(entityType, nameof(entityType)); - Check.NotNullOrEmpty(reactionName, nameof(reactionName)); + public virtual async Task GetReactionOrNullAsync([NotNull] string reactionName, [NotNull] string entityType) + { + Check.NotNullOrEmpty(entityType, nameof(entityType)); + Check.NotNullOrEmpty(reactionName, nameof(reactionName)); - var definition = await GetAsync(entityType); + var definition = await GetAsync(entityType); - return definition.Reactions.SingleOrDefault(x => x.Name == reactionName); - } + return definition.Reactions.SingleOrDefault(x => x.Name == reactionName); + } - public virtual Task IsDefinedAsync([NotNull] string entityType) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + public virtual Task IsDefinedAsync([NotNull] string entityType) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - var isDefined = Options.EntityTypes.Any(x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase)); + var isDefined = Options.EntityTypes.Any(x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase)); - return Task.FromResult(isDefined); - } + return Task.FromResult(isDefined); + } - /// - /// Gets single by entityType. - /// - /// EntityType to get definition. - /// Thrown when EntityType is not configured as taggable. - /// More than one element satisfies the condition in predicate. - public virtual Task GetAsync([NotNull] string entityType) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + /// + /// Gets single by entityType. + /// + /// EntityType to get definition. + /// Thrown when EntityType is not configured as taggable. + /// More than one element satisfies the condition in predicate. + public virtual Task GetAsync([NotNull] string entityType) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - var definition = Options.EntityTypes.SingleOrDefault(x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase)) ?? - throw new EntityCantHaveReactionException(entityType); + var definition = Options.EntityTypes.SingleOrDefault(x => x.EntityType.Equals(entityType, StringComparison.InvariantCultureIgnoreCase)) ?? + throw new EntityCantHaveReactionException(entityType); - return Task.FromResult(definition); - } + return Task.FromResult(definition); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/EntityCantHaveReactionException.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/EntityCantHaveReactionException.cs index 0cf54bb6f9..217c3115f7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/EntityCantHaveReactionException.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/EntityCantHaveReactionException.cs @@ -3,21 +3,20 @@ using JetBrains.Annotations; using System.Runtime.Serialization; using Volo.Abp; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class EntityCantHaveReactionException : BusinessException { - public class EntityCantHaveReactionException : BusinessException + public EntityCantHaveReactionException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context) { - public EntityCantHaveReactionException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context) - { - } - - public EntityCantHaveReactionException([NotNull] string entityType) - { - EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType)); - Code = CmsKitErrorCodes.Reactions.EntityCantHaveReaction; - WithData(nameof(EntityType), EntityType); - } + } - public string EntityType { get; } + public EntityCantHaveReactionException([NotNull] string entityType) + { + EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType)); + Code = CmsKitErrorCodes.Reactions.EntityCantHaveReaction; + WithData(nameof(EntityType), EntityType); } + + public string EntityType { get; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IReactionDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IReactionDefinitionStore.cs index ce0be47f23..0afe25d3e1 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IReactionDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IReactionDefinitionStore.cs @@ -2,12 +2,11 @@ using System.Threading.Tasks; using JetBrains.Annotations; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public interface IReactionDefinitionStore : IEntityTypeDefinitionStore { - public interface IReactionDefinitionStore : IEntityTypeDefinitionStore - { - Task> GetReactionsAsync([NotNull] string entityType); + Task> GetReactionsAsync([NotNull] string entityType); - Task GetReactionOrNullAsync([NotNull] string reactionName, [NotNull] string entityType); - } + Task GetReactionOrNullAsync([NotNull] string reactionName, [NotNull] string entityType); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs index dbbcd0ac29..1ebf844cd3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs @@ -5,29 +5,28 @@ using System.Threading.Tasks; using JetBrains.Annotations; using Volo.Abp.Domain.Repositories; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public interface IUserReactionRepository : IBasicRepository { - public interface IUserReactionRepository : IBasicRepository - { - Task FindAsync( - Guid userId, - [NotNull] string entityType, - [NotNull] string entityId, - [NotNull] string reactionName, - CancellationToken cancellationToken = default - ); + Task FindAsync( + Guid userId, + [NotNull] string entityType, + [NotNull] string entityId, + [NotNull] string reactionName, + CancellationToken cancellationToken = default + ); - Task> GetListForUserAsync( - Guid userId, - [NotNull] string entityType, - [NotNull] string entityId, - CancellationToken cancellationToken = default - ); + Task> GetListForUserAsync( + Guid userId, + [NotNull] string entityType, + [NotNull] string entityId, + CancellationToken cancellationToken = default + ); - Task> GetSummariesAsync( - [NotNull] string entityType, - [NotNull] string entityId, - CancellationToken cancellationToken = default - ); - } + Task> GetSummariesAsync( + [NotNull] string entityType, + [NotNull] string entityId, + CancellationToken cancellationToken = default + ); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionDefinition.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionDefinition.cs index 463abc172d..adbf36233c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionDefinition.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionDefinition.cs @@ -3,22 +3,21 @@ using System; using Volo.Abp; using Volo.Abp.Localization; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class ReactionDefinition { - public class ReactionDefinition - { - [NotNull] - public string Name { get; } + [NotNull] + public string Name { get; } - [CanBeNull] - public ILocalizableString DisplayName { get; set; } + [CanBeNull] + public ILocalizableString DisplayName { get; set; } - public ReactionDefinition( - [NotNull] string name, - [CanBeNull] ILocalizableString displayName = null) - { - Name = Check.NotNullOrWhiteSpace(name, nameof(name)); - DisplayName = displayName; - } + public ReactionDefinition( + [NotNull] string name, + [CanBeNull] ILocalizableString displayName = null) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name)); + DisplayName = displayName; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionEntityTypeDefinition.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionEntityTypeDefinition.cs index d1036e1cd1..11497dbb6a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionEntityTypeDefinition.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionEntityTypeDefinition.cs @@ -6,21 +6,20 @@ using System.Text; using System.Threading.Tasks; using Volo.Abp; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class ReactionEntityTypeDefinition : PolicySpecifiedDefinition { - public class ReactionEntityTypeDefinition : PolicySpecifiedDefinition - { - [NotNull] - public List Reactions { get; } = new(); + [NotNull] + public List Reactions { get; } = new(); - public ReactionEntityTypeDefinition( - [NotNull] string entityType, - [NotNull] IEnumerable reactions, - IEnumerable createPolicies = null, - IEnumerable updatePolicies = null, - IEnumerable deletePolicies = null) : base(entityType, createPolicies, updatePolicies, deletePolicies) - { - Reactions = Check.NotNull(reactions, nameof(reactions)).ToList(); - } + public ReactionEntityTypeDefinition( + [NotNull] string entityType, + [NotNull] IEnumerable reactions, + IEnumerable createPolicies = null, + IEnumerable updatePolicies = null, + IEnumerable deletePolicies = null) : base(entityType, createPolicies, updatePolicies, deletePolicies) + { + Reactions = Check.NotNull(reactions, nameof(reactions)).ToList(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionManager.cs index d43fbe48d4..0cb098b1d0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionManager.cs @@ -6,104 +6,103 @@ using JetBrains.Annotations; using Volo.Abp; using Volo.Abp.MultiTenancy; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class ReactionManager : CmsKitDomainServiceBase { - public class ReactionManager : CmsKitDomainServiceBase + protected IReactionDefinitionStore ReactionDefinitionStore { get; } + protected IUserReactionRepository UserReactionRepository { get; } + + public ReactionManager( + IUserReactionRepository userReactionRepository, + IReactionDefinitionStore reactionDefinitionStore) { - protected IReactionDefinitionStore ReactionDefinitionStore { get; } - protected IUserReactionRepository UserReactionRepository { get; } + UserReactionRepository = userReactionRepository; + ReactionDefinitionStore = reactionDefinitionStore; + } - public ReactionManager( - IUserReactionRepository userReactionRepository, - IReactionDefinitionStore reactionDefinitionStore) - { - UserReactionRepository = userReactionRepository; - ReactionDefinitionStore = reactionDefinitionStore; - } + public virtual async Task> GetReactionsAsync( + [NotNull] string entityType) + { + Check.NotNullOrEmpty(entityType, nameof(entityType)); - public virtual async Task> GetReactionsAsync( - [NotNull] string entityType) - { - Check.NotNullOrEmpty(entityType, nameof(entityType)); + return await ReactionDefinitionStore.GetReactionsAsync(entityType); + } - return await ReactionDefinitionStore.GetReactionsAsync(entityType); - } + public virtual async Task> GetSummariesAsync( + [NotNull] string entityType, + [NotNull] string entityId) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - public virtual async Task> GetSummariesAsync( - [NotNull] string entityType, - [NotNull] string entityId) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - - var userReactionCounts = (await UserReactionRepository.GetSummariesAsync(entityType, entityId)) - .ToDictionary(x => x.ReactionName, x => x.Count); - - var reactions = await ReactionDefinitionStore - .GetReactionsAsync( - entityType - ); - - return reactions - .Select(reaction => new ReactionSummary - { - Reaction = reaction, - Count = userReactionCounts.GetOrDefault(reaction.Name) - }) - .ToList(); - } + var userReactionCounts = (await UserReactionRepository.GetSummariesAsync(entityType, entityId)) + .ToDictionary(x => x.ReactionName, x => x.Count); - public virtual async Task GetOrCreateAsync( - Guid creatorId, - [NotNull] string entityType, - [NotNull] string entityId, - [NotNull] string reactionName) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); + var reactions = await ReactionDefinitionStore + .GetReactionsAsync( + entityType + ); - var existingReaction = await UserReactionRepository.FindAsync(creatorId, entityType, entityId, reactionName); - if (existingReaction != null) + return reactions + .Select(reaction => new ReactionSummary { - return existingReaction; - } + Reaction = reaction, + Count = userReactionCounts.GetOrDefault(reaction.Name) + }) + .ToList(); + } - if (!await ReactionDefinitionStore.IsDefinedAsync(entityType)) - { - throw new EntityCantHaveReactionException(entityType); - } - - return await UserReactionRepository.InsertAsync( - new UserReaction( - GuidGenerator.Create(), - entityType, - entityId, - reactionName, - creatorId, - CurrentTenant.Id - ) - ); + public virtual async Task GetOrCreateAsync( + Guid creatorId, + [NotNull] string entityType, + [NotNull] string entityId, + [NotNull] string reactionName) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); + + var existingReaction = await UserReactionRepository.FindAsync(creatorId, entityType, entityId, reactionName); + if (existingReaction != null) + { + return existingReaction; } - public virtual async Task DeleteAsync( - Guid userId, - [NotNull] string entityType, - [NotNull] string entityId, - [NotNull] string reactionName) + if (!await ReactionDefinitionStore.IsDefinedAsync(entityType)) { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); + throw new EntityCantHaveReactionException(entityType); + } - var existingReaction = await UserReactionRepository.FindAsync(userId, entityType, entityId, reactionName); - if (existingReaction == null) - { - return false; - } + return await UserReactionRepository.InsertAsync( + new UserReaction( + GuidGenerator.Create(), + entityType, + entityId, + reactionName, + creatorId, + CurrentTenant.Id + ) + ); + } + + public virtual async Task DeleteAsync( + Guid userId, + [NotNull] string entityType, + [NotNull] string entityId, + [NotNull] string reactionName) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); - await UserReactionRepository.DeleteAsync(existingReaction); - return true; + var existingReaction = await UserReactionRepository.FindAsync(userId, entityType, entityId, reactionName); + if (existingReaction == null) + { + return false; } + + await UserReactionRepository.DeleteAsync(existingReaction); + return true; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionSummary.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionSummary.cs index 8e397a85f0..22daea4de0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionSummary.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionSummary.cs @@ -1,9 +1,8 @@ -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class ReactionSummary { - public class ReactionSummary - { - public ReactionDefinition Reaction { get; set; } + public ReactionDefinition Reaction { get; set; } - public int Count { get; set; } - } -} \ No newline at end of file + public int Count { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionSummaryQueryResultItem.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionSummaryQueryResultItem.cs index ddba49d73c..39084dc29f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionSummaryQueryResultItem.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionSummaryQueryResultItem.cs @@ -1,9 +1,8 @@ -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class ReactionSummaryQueryResultItem { - public class ReactionSummaryQueryResultItem - { - public string ReactionName { get; set; } + public string ReactionName { get; set; } - public int Count { get; set; } - } + public int Count { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/UserReaction.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/UserReaction.cs index eff74c7d66..f05ac8e5d5 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/UserReaction.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/UserReaction.cs @@ -5,41 +5,40 @@ using Volo.Abp.Auditing; using Volo.Abp.Domain.Entities; using Volo.Abp.MultiTenancy; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class UserReaction : BasicAggregateRoot, IHasCreationTime, IMustHaveCreator, IMultiTenant { - public class UserReaction : BasicAggregateRoot, IHasCreationTime, IMustHaveCreator, IMultiTenant - { - public virtual Guid? TenantId { get; protected set; } + public virtual Guid? TenantId { get; protected set; } - public virtual string EntityType { get; protected set; } + public virtual string EntityType { get; protected set; } - public virtual string EntityId { get; protected set; } + public virtual string EntityId { get; protected set; } - public virtual string ReactionName { get; protected set; } + public virtual string ReactionName { get; protected set; } - public virtual Guid CreatorId { get; set; } + public virtual Guid CreatorId { get; set; } - public virtual DateTime CreationTime { get; set; } + public virtual DateTime CreationTime { get; set; } - protected UserReaction() - { + protected UserReaction() + { - } + } - internal UserReaction( - Guid id, - [NotNull] string entityType, - [NotNull] string entityId, - [NotNull] string reactionName, - Guid creatorId, - Guid? tenantId = null) - : base(id) - { - EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - ReactionName = Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); - CreatorId = creatorId; - TenantId = tenantId; - } + internal UserReaction( + Guid id, + [NotNull] string entityType, + [NotNull] string entityId, + [NotNull] string reactionName, + Guid creatorId, + Guid? tenantId = null) + : base(id) + { + EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + ReactionName = Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); + CreatorId = creatorId; + TenantId = tenantId; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettingDefinitionProvider.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettingDefinitionProvider.cs index 4e4e88d999..a141a139ee 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettingDefinitionProvider.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettingDefinitionProvider.cs @@ -1,14 +1,13 @@ using Volo.Abp.Settings; -namespace Volo.CmsKit.Settings +namespace Volo.CmsKit.Settings; + +public class CmsKitSettingDefinitionProvider : SettingDefinitionProvider { - public class CmsKitSettingDefinitionProvider : SettingDefinitionProvider + public override void Define(ISettingDefinitionContext context) { - public override void Define(ISettingDefinitionContext context) - { - /* Define module settings here. - * Use names from CmsKitSettings class. - */ - } + /* Define module settings here. + * Use names from CmsKitSettings class. + */ } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettings.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettings.cs index 31752f3b4b..a01696c4c5 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettings.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Settings/CmsKitSettings.cs @@ -1,11 +1,10 @@ -namespace Volo.CmsKit.Settings +namespace Volo.CmsKit.Settings; + +public static class CmsKitSettings { - public static class CmsKitSettings - { - public const string GroupName = "CmsKit"; + public const string GroupName = "CmsKit"; - /* Add constants for setting names. Example: - * public const string MySettingName = GroupName + ".MySettingName"; - */ - } -} \ No newline at end of file + /* Add constants for setting names. Example: + * public const string MySettingName = GroupName + ".MySettingName"; + */ +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/SlugNormalizer.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/SlugNormalizer.cs index 30b23e4ba4..d7529441b1 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/SlugNormalizer.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/SlugNormalizer.cs @@ -1,14 +1,13 @@ using Slugify; using Unidecode.NET; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public static class SlugNormalizer { - public static class SlugNormalizer + static readonly SlugHelper SlugHelper = new(); + public static string Normalize(string value) { - static readonly SlugHelper SlugHelper = new (); - public static string Normalize(string value) - { - return SlugHelper.GenerateSlug(value?.Unidecode()); - } + return SlugHelper.GenerateSlug(value?.Unidecode()); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/CmsKitTagOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/CmsKitTagOptions.cs index 1b21af2417..8d25792b8f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/CmsKitTagOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/CmsKitTagOptions.cs @@ -1,10 +1,9 @@ using JetBrains.Annotations; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class CmsKitTagOptions { - public class CmsKitTagOptions - { - [NotNull] - public TagEntityTypeDefinitions EntityTypes { get; } = new TagEntityTypeDefinitions(); - } + [NotNull] + public TagEntityTypeDefinitions EntityTypes { get; } = new TagEntityTypeDefinitions(); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/DefaultTagDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/DefaultTagDefinitionStore.cs index 830052fb15..9b3c624389 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/DefaultTagDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/DefaultTagDefinitionStore.cs @@ -7,53 +7,52 @@ using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.DependencyInjection; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class DefaultTagDefinitionStore : ITagDefinitionStore { - public class DefaultTagDefinitionStore : ITagDefinitionStore + protected CmsKitTagOptions CmsKitTagOptions { get; } + + public DefaultTagDefinitionStore(IOptions options) + { + CmsKitTagOptions = options.Value; + } + + /// + /// Gets single by entityType. + /// + /// EntityType to get definition. + /// Thrown when EntityType is not configured as taggable. + /// More than one element satisfies the condition in predicate. + public virtual Task GetAsync([NotNull] string entityType) { - protected CmsKitTagOptions CmsKitTagOptions { get; } - - public DefaultTagDefinitionStore(IOptions options) - { - CmsKitTagOptions = options.Value; - } - - /// - /// Gets single by entityType. - /// - /// EntityType to get definition. - /// Thrown when EntityType is not configured as taggable. - /// More than one element satisfies the condition in predicate. - public virtual Task GetAsync([NotNull] string entityType) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - - var result = CmsKitTagOptions.EntityTypes.SingleOrDefault(x => x.EntityType == entityType) ?? - throw new EntityNotTaggableException(entityType); - - return Task.FromResult(result); - } - - /// - /// Gets all defined elements. - /// - public virtual Task> GetTagEntityTypeDefinitionListAsync() - { - return Task.FromResult(CmsKitTagOptions.EntityTypes.ToList()); - } - - /// - /// Checks if EntityType defined as taggable. - /// - /// EntityType to check. - /// More than one element satisfies the condition in predicate." - public virtual Task IsDefinedAsync([NotNull] string entityType) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - - var isDefined = CmsKitTagOptions.EntityTypes.Any(x => x.EntityType == entityType); - - return Task.FromResult(isDefined); - } + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + + var result = CmsKitTagOptions.EntityTypes.SingleOrDefault(x => x.EntityType == entityType) ?? + throw new EntityNotTaggableException(entityType); + + return Task.FromResult(result); + } + + /// + /// Gets all defined elements. + /// + public virtual Task> GetTagEntityTypeDefinitionListAsync() + { + return Task.FromResult(CmsKitTagOptions.EntityTypes.ToList()); + } + + /// + /// Checks if EntityType defined as taggable. + /// + /// EntityType to check. + /// More than one element satisfies the condition in predicate." + public virtual Task IsDefinedAsync([NotNull] string entityType) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + + var isDefined = CmsKitTagOptions.EntityTypes.Any(x => x.EntityType == entityType); + + return Task.FromResult(isDefined); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityNotTaggableException.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityNotTaggableException.cs index c73549f4a5..f506804d2f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityNotTaggableException.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityNotTaggableException.cs @@ -2,19 +2,18 @@ using System.Runtime.Serialization; using Volo.Abp; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +[Serializable] +public class EntityNotTaggableException : BusinessException { - [Serializable] - public class EntityNotTaggableException : BusinessException + public EntityNotTaggableException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context) { - public EntityNotTaggableException(SerializationInfo serializationInfo, StreamingContext context) : base(serializationInfo, context) - { - } + } - public EntityNotTaggableException(string entityType) - { - Code = CmsKitErrorCodes.Tags.EntityNotTaggable; - WithData(nameof(Tag.EntityType), entityType); - } + public EntityNotTaggableException(string entityType) + { + Code = CmsKitErrorCodes.Tags.EntityNotTaggable; + WithData(nameof(Tag.EntityType), entityType); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTag.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTag.cs index 793bf31d86..0ce0dc9518 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTag.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTag.cs @@ -4,30 +4,29 @@ using Volo.Abp; using Volo.Abp.Domain.Entities; using Volo.Abp.MultiTenancy; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class EntityTag : Entity, IMultiTenant { - public class EntityTag : Entity, IMultiTenant - { - public virtual Guid TagId { get; set; } + public virtual Guid TagId { get; set; } + + public virtual string EntityId { get; set; } - public virtual string EntityId { get; set; } - - public virtual Guid? TenantId { get; set; } - - protected EntityTag() - { - } + public virtual Guid? TenantId { get; set; } - internal EntityTag(Guid tagId, [NotNull] string entityId, Guid? tenantId = null) - { - TagId = tagId; - EntityId = Check.NotNullOrEmpty(entityId,nameof(entityId)); - TenantId = tenantId; - } + protected EntityTag() + { + } - public override object[] GetKeys() - { - return new object[] { TagId, EntityId }; - } + internal EntityTag(Guid tagId, [NotNull] string entityId, Guid? tenantId = null) + { + TagId = tagId; + EntityId = Check.NotNullOrEmpty(entityId, nameof(entityId)); + TenantId = tenantId; + } + + public override object[] GetKeys() + { + return new object[] { TagId, EntityId }; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTagManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTagManager.cs index 97a2e7cd74..4000cc8aec 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTagManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTagManager.cs @@ -6,70 +6,69 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Services; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class EntityTagManager : DomainService { - public class EntityTagManager : DomainService + protected IEntityTagRepository EntityTagRepository { get; } + protected ITagRepository TagRepository { get; } + protected ITagDefinitionStore TagDefinitionStore { get; } + protected TagManager TagManager { get; } + + public EntityTagManager( + IEntityTagRepository entityTagRepository, + ITagRepository tagRepository, + ITagDefinitionStore tagDefinitionStore, + TagManager tagManager) { - protected IEntityTagRepository EntityTagRepository { get; } - protected ITagRepository TagRepository { get; } - protected ITagDefinitionStore TagDefinitionStore { get; } - protected TagManager TagManager { get; } + EntityTagRepository = entityTagRepository; + TagRepository = tagRepository; + TagDefinitionStore = tagDefinitionStore; + TagManager = tagManager; + } - public EntityTagManager( - IEntityTagRepository entityTagRepository, - ITagRepository tagRepository, - ITagDefinitionStore tagDefinitionStore, - TagManager tagManager) + public virtual async Task AddTagToEntityAsync( + [NotNull] Guid tagId, + [NotNull] string entityType, + [NotNull] string entityId, + [CanBeNull] Guid? tenantId = null, + CancellationToken cancellationToken = default) + { + if (!await TagDefinitionStore.IsDefinedAsync(entityType)) { - EntityTagRepository = entityTagRepository; - TagRepository = tagRepository; - TagDefinitionStore = tagDefinitionStore; - TagManager = tagManager; + throw new EntityNotTaggableException(entityType); } - public virtual async Task AddTagToEntityAsync( - [NotNull] Guid tagId, - [NotNull] string entityType, - [NotNull] string entityId, - [CanBeNull] Guid? tenantId = null, - CancellationToken cancellationToken = default) - { - if (!await TagDefinitionStore.IsDefinedAsync(entityType)) - { - throw new EntityNotTaggableException(entityType); - } - - var entityTag = new EntityTag(tagId, entityId, tenantId); - return await EntityTagRepository.InsertAsync(entityTag, cancellationToken: cancellationToken); - } + var entityTag = new EntityTag(tagId, entityId, tenantId); + return await EntityTagRepository.InsertAsync(entityTag, cancellationToken: cancellationToken); + } - 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, cancellationToken: cancellationToken); - } + 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, cancellationToken: cancellationToken); + } - public async Task SetEntityTagsAsync(string entityType, string entityId, List tags) - { - var existingTags = - await TagRepository.GetAllRelatedTagsAsync(entityType, entityId); + public async Task SetEntityTagsAsync(string entityType, string entityId, List tags) + { + var existingTags = + await TagRepository.GetAllRelatedTagsAsync(entityType, entityId); - var deletedTags = existingTags.Where(x => !tags.Contains(x.Name)).ToList(); - var addedTags = tags.Where(x => !existingTags.Any(a => a.Name == x)); + var deletedTags = existingTags.Where(x => !tags.Contains(x.Name)).ToList(); + var addedTags = 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(entityType, addedTag); + foreach (var addedTag in addedTags) + { + var tag = await TagManager.GetOrAddAsync(entityType, addedTag); - await AddTagToEntityAsync(tag.Id, entityType, entityId, CurrentTenant?.Id); - } + await AddTagToEntityAsync(tag.Id, entityType, entityId, CurrentTenant?.Id); } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/IEntityTagRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/IEntityTagRepository.cs index 6ea4f009a2..15efdcd433 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/IEntityTagRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/IEntityTagRepository.cs @@ -4,16 +4,15 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public interface IEntityTagRepository : IBasicRepository { - public interface IEntityTagRepository : IBasicRepository - { - Task FindAsync( - [NotNull] Guid tagId, - [NotNull] string entityId, - [CanBeNull] Guid? tenantId, - CancellationToken cancellationToken = default); + Task FindAsync( + [NotNull] Guid tagId, + [NotNull] string entityId, + [CanBeNull] Guid? tenantId, + CancellationToken cancellationToken = default); - Task DeleteManyAsync(Guid[] tagIds, CancellationToken cancellationToken = default); - } -} \ No newline at end of file + Task DeleteManyAsync(Guid[] tagIds, CancellationToken cancellationToken = default); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagDefinitionStore.cs index 043b7a7e8a..d112689800 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagDefinitionStore.cs @@ -2,10 +2,9 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public interface ITagDefinitionStore : IEntityTypeDefinitionStore { - public interface ITagDefinitionStore : IEntityTypeDefinitionStore - { - Task> GetTagEntityTypeDefinitionListAsync(); - } + Task> GetTagEntityTypeDefinitionListAsync(); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagRepository.cs index a399a662db..7ac48eeb1a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagRepository.cs @@ -5,32 +5,31 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public interface ITagRepository : IBasicRepository { - public interface ITagRepository : IBasicRepository - { - Task GetAsync( - [NotNull] string entityType, - [NotNull] string name, - CancellationToken cancellationToken = default); + Task GetAsync( + [NotNull] string entityType, + [NotNull] string name, + CancellationToken cancellationToken = default); - Task AnyAsync( - [NotNull] string entityType, - [NotNull] string name, - CancellationToken cancellationToken = default); + Task AnyAsync( + [NotNull] string entityType, + [NotNull] string name, + CancellationToken cancellationToken = default); - Task FindAsync( - [NotNull] string entityType, - [NotNull] string name, - CancellationToken cancellationToken = default); + Task FindAsync( + [NotNull] string entityType, + [NotNull] string name, + CancellationToken cancellationToken = default); - Task> GetListAsync(string filter); + Task> GetListAsync(string filter); - Task GetCountAsync(string filter); + Task GetCountAsync(string filter); - Task> GetAllRelatedTagsAsync( - [NotNull] string entityType, - [NotNull] string entityId, - CancellationToken cancellationToken = default); - } + Task> GetAllRelatedTagsAsync( + [NotNull] string entityType, + [NotNull] string entityId, + CancellationToken cancellationToken = default); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs index 4b9aeebde1..d7591df967 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs @@ -4,41 +4,40 @@ using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.MultiTenancy; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class Tag : FullAuditedAggregateRoot, IMultiTenant { - public class Tag : FullAuditedAggregateRoot, IMultiTenant + public virtual Guid? TenantId { get; protected set; } + + [NotNull] + public virtual string EntityType { get; protected set; } + + [NotNull] + public virtual string Name { get; protected set; } + + protected Tag() + { + } + + public Tag( + Guid id, + [NotNull] string entityType, + [NotNull] string name, + Guid? tenantId = null) : base(id) + { + EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), TagConsts.MaxEntityTypeLength); + Name = Check.NotNullOrEmpty(name, nameof(name), TagConsts.MaxNameLength); + TenantId = tenantId; + } + + public virtual void SetName([NotNull] string name) + { + Name = Check.NotNullOrEmpty(name, nameof(name), TagConsts.MaxNameLength); + } + + public virtual void SetEntityType(string entityType) { - public virtual Guid? TenantId { get; protected set; } - - [NotNull] - public virtual string EntityType { get; protected set; } - - [NotNull] - public virtual string Name { get; protected set; } - - protected Tag() - { - } - - public Tag( - Guid id, - [NotNull] string entityType, - [NotNull] string name, - Guid? tenantId = null) : base(id) - { - EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), TagConsts.MaxEntityTypeLength); - Name = Check.NotNullOrEmpty(name, nameof(name), TagConsts.MaxNameLength); - TenantId = tenantId; - } - - public virtual void SetName([NotNull] string name) - { - Name = Check.NotNullOrEmpty(name, nameof(name), TagConsts.MaxNameLength); - } - - public virtual void SetEntityType(string entityType) - { - EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), TagConsts.MaxEntityTypeLength); - } + EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), TagConsts.MaxEntityTypeLength); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagAlreadyExistException.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagAlreadyExistException.cs index 2d87668043..810cc269fc 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagAlreadyExistException.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagAlreadyExistException.cs @@ -2,16 +2,15 @@ using System; using Volo.Abp; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +[Serializable] +public class TagAlreadyExistException : BusinessException { - [Serializable] - public class TagAlreadyExistException : BusinessException + public TagAlreadyExistException([NotNull] string entityType, [NotNull] string name) { - public TagAlreadyExistException([NotNull] string entityType, [NotNull] string name) - { - Code = CmsKitErrorCodes.Tags.TagAlreadyExist; - WithData(nameof(Tag.EntityType), entityType); - WithData(nameof(Tag.Name), name); - } + Code = CmsKitErrorCodes.Tags.TagAlreadyExist; + WithData(nameof(Tag.EntityType), entityType); + WithData(nameof(Tag.Name), name); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagEntityTypeDefinitions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagEntityTypeDefinitions.cs index e0d15f82fa..68d27f2a14 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagEntityTypeDefinitions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagEntityTypeDefinitions.cs @@ -1,8 +1,7 @@ using System.Collections.Generic; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class TagEntityTypeDefinitions : List { - public class TagEntityTypeDefinitions : List - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagEntityTypeDefiniton.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagEntityTypeDefiniton.cs index 37f9d16d39..e568849f19 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagEntityTypeDefiniton.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagEntityTypeDefiniton.cs @@ -4,26 +4,25 @@ using System.Collections.Generic; using Volo.Abp; using Volo.Abp.Localization; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class TagEntityTypeDefiniton : PolicySpecifiedDefinition, IEquatable { - public class TagEntityTypeDefiniton : PolicySpecifiedDefinition, IEquatable - { - [CanBeNull] - public virtual ILocalizableString DisplayName { get; } + [CanBeNull] + public virtual ILocalizableString DisplayName { get; } - public TagEntityTypeDefiniton( - [NotNull] string entityType, - [CanBeNull] ILocalizableString displayName = null, - IEnumerable createPolicies = null, - IEnumerable updatePolicies = null, - IEnumerable deletePolicies = null) : base(entityType, createPolicies, updatePolicies, deletePolicies) - { - DisplayName = displayName; - } + public TagEntityTypeDefiniton( + [NotNull] string entityType, + [CanBeNull] ILocalizableString displayName = null, + IEnumerable createPolicies = null, + IEnumerable updatePolicies = null, + IEnumerable deletePolicies = null) : base(entityType, createPolicies, updatePolicies, deletePolicies) + { + DisplayName = displayName; + } - public bool Equals(TagEntityTypeDefiniton other) - { - return EntityType == other?.EntityType; - } + public bool Equals(TagEntityTypeDefiniton other) + { + return EntityType == other?.EntityType; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagManager.cs index d1378bccb7..6afa771b41 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/TagManager.cs @@ -6,65 +6,64 @@ using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Domain.Services; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class TagManager : DomainService { - public class TagManager : DomainService + protected ITagRepository TagRepository { get; } + protected ITagDefinitionStore TagDefinitionStore { get; } + + public TagManager(ITagRepository tagRepository, ITagDefinitionStore tagDefinitionStore) { - protected ITagRepository TagRepository { get; } - protected ITagDefinitionStore TagDefinitionStore { get; } + TagRepository = tagRepository; + TagDefinitionStore = tagDefinitionStore; + } - public TagManager(ITagRepository tagRepository, ITagDefinitionStore tagDefinitionStore) - { - TagRepository = tagRepository; - TagDefinitionStore = tagDefinitionStore; - } + public virtual async Task GetOrAddAsync([NotNull] string entityType, [NotNull] string name) + { + var tag = await TagRepository.FindAsync(entityType, name); - public virtual async Task GetOrAddAsync([NotNull] string entityType, [NotNull] string name) + if (tag == null) { - var tag = await TagRepository.FindAsync(entityType, name); - - if (tag == null) - { - tag = await CreateAsync(GuidGenerator.Create(), entityType, name); - await TagRepository.InsertAsync(tag); - } - - return tag; + tag = await CreateAsync(GuidGenerator.Create(), entityType, name); + await TagRepository.InsertAsync(tag); } - public virtual async Task CreateAsync(Guid id, - [NotNull] string entityType, - [NotNull] string name) - { - if (!await TagDefinitionStore.IsDefinedAsync(entityType)) - { - throw new EntityNotTaggableException(entityType); - } - - if (await TagRepository.AnyAsync(entityType, name)) - { - throw new TagAlreadyExistException(entityType, name); - } + return tag; + } - return - new Tag(id, entityType, name, CurrentTenant.Id); + public virtual async Task CreateAsync(Guid id, + [NotNull] string entityType, + [NotNull] string name) + { + if (!await TagDefinitionStore.IsDefinedAsync(entityType)) + { + throw new EntityNotTaggableException(entityType); } - public virtual async Task UpdateAsync(Guid id, [NotNull] string name) + if (await TagRepository.AnyAsync(entityType, name)) { - Check.NotNullOrEmpty(name, nameof(name)); + throw new TagAlreadyExistException(entityType, name); + } - var tag = await TagRepository.GetAsync(id); + return + new Tag(id, entityType, name, CurrentTenant.Id); + } - if (name != tag.Name && - await TagRepository.AnyAsync(tag.EntityType, name)) - { - throw new TagAlreadyExistException(tag.EntityType, name); - } + public virtual async Task UpdateAsync(Guid id, [NotNull] string name) + { + Check.NotNullOrEmpty(name, nameof(name)); - tag.SetName(name); + var tag = await TagRepository.GetAsync(id); - return tag; + if (name != tag.Name && + await TagRepository.AnyAsync(tag.EntityType, name)) + { + throw new TagAlreadyExistException(tag.EntityType, name); } + + tag.SetName(name); + + return tag; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUser.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUser.cs index 7e66aae6a1..3fd8ff13d7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUser.cs @@ -2,81 +2,80 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Users; -namespace Volo.CmsKit.Users +namespace Volo.CmsKit.Users; + +public class CmsUser : AggregateRoot, IUser, IUpdateUserData { - public class CmsUser : AggregateRoot, IUser, IUpdateUserData - { - public virtual Guid? TenantId { get; protected set; } + public virtual Guid? TenantId { get; protected set; } - public virtual string UserName { get; protected set; } + public virtual string UserName { get; protected set; } - public virtual string Email { get; protected set; } + public virtual string Email { get; protected set; } - public virtual string Name { get; set; } + public virtual string Name { get; set; } - public virtual string Surname { get; set; } + public virtual string Surname { get; set; } - public virtual bool EmailConfirmed { get; protected set; } + public virtual bool EmailConfirmed { get; protected set; } - public virtual string PhoneNumber { get; protected set; } + public virtual string PhoneNumber { get; protected set; } - public virtual bool PhoneNumberConfirmed { get; protected set; } + public virtual bool PhoneNumberConfirmed { get; protected set; } - protected CmsUser() - { + protected CmsUser() + { - } + } - public CmsUser(IUserData user) - : base(user.Id) - { - TenantId = user.TenantId; - UpdateInternal(user); - } + public CmsUser(IUserData user) + : base(user.Id) + { + TenantId = user.TenantId; + UpdateInternal(user); + } - public virtual bool Update(IUserData user) + public virtual bool Update(IUserData user) + { + if (Id != user.Id) { - if (Id != user.Id) - { - throw new ArgumentException($"Given User's Id '{user.Id}' does not match to this User's Id '{Id}'"); - } - - if (TenantId != user.TenantId) - { - throw new ArgumentException($"Given User's TenantId '{user.TenantId}' does not match to this User's TenantId '{TenantId}'"); - } - - if (Equals(user)) - { - return false; - } - - UpdateInternal(user); - return true; + throw new ArgumentException($"Given User's Id '{user.Id}' does not match to this User's Id '{Id}'"); } - protected virtual bool Equals(IUserData user) + if (TenantId != user.TenantId) { - return Id == user.Id && - TenantId == user.TenantId && - UserName == user.UserName && - Name == user.Name && - Surname == user.Surname && - Email == user.Email && - EmailConfirmed == user.EmailConfirmed && - PhoneNumber == user.PhoneNumber && - PhoneNumberConfirmed == user.PhoneNumberConfirmed; + throw new ArgumentException($"Given User's TenantId '{user.TenantId}' does not match to this User's TenantId '{TenantId}'"); } - protected virtual void UpdateInternal(IUserData user) + if (Equals(user)) { - Email = user.Email; - Name = user.Name; - Surname = user.Surname; - EmailConfirmed = user.EmailConfirmed; - PhoneNumber = user.PhoneNumber; - PhoneNumberConfirmed = user.PhoneNumberConfirmed; - UserName = user.UserName; + return false; } + + UpdateInternal(user); + return true; + } + + protected virtual bool Equals(IUserData user) + { + return Id == user.Id && + TenantId == user.TenantId && + UserName == user.UserName && + Name == user.Name && + Surname == user.Surname && + Email == user.Email && + EmailConfirmed == user.EmailConfirmed && + PhoneNumber == user.PhoneNumber && + PhoneNumberConfirmed == user.PhoneNumberConfirmed; + } + + protected virtual void UpdateInternal(IUserData user) + { + Email = user.Email; + Name = user.Name; + Surname = user.Surname; + EmailConfirmed = user.EmailConfirmed; + PhoneNumber = user.PhoneNumber; + PhoneNumberConfirmed = user.PhoneNumberConfirmed; + UserName = user.UserName; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserLookupService.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserLookupService.cs index 126d2b9c60..110cf86a2d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserLookupService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserLookupService.cs @@ -1,23 +1,22 @@ using Volo.Abp.Uow; using Volo.Abp.Users; -namespace Volo.CmsKit.Users +namespace Volo.CmsKit.Users; + +public class CmsUserLookupService : UserLookupService, ICmsUserLookupService { - public class CmsUserLookupService: UserLookupService, ICmsUserLookupService + public CmsUserLookupService( + ICmsUserRepository userRepository, + IUnitOfWorkManager unitOfWorkManager) + : base( + userRepository, + unitOfWorkManager) { - public CmsUserLookupService( - ICmsUserRepository userRepository, - IUnitOfWorkManager unitOfWorkManager) - : base( - userRepository, - unitOfWorkManager) - { - } + } - protected override CmsUser CreateUser(IUserData externalUser) - { - return new CmsUser(externalUser); - } + protected override CmsUser CreateUser(IUserData externalUser) + { + return new CmsUser(externalUser); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserSynchronizer.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserSynchronizer.cs index 84425c4d16..a51762ec5c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserSynchronizer.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserSynchronizer.cs @@ -7,45 +7,44 @@ using Volo.Abp.GlobalFeatures; using Volo.Abp.Users; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.Users +namespace Volo.CmsKit.Users; + +public class CmsUserSynchronizer : + IDistributedEventHandler>, + ITransientDependency { - public class CmsUserSynchronizer : - IDistributedEventHandler>, - ITransientDependency - { - protected ICmsUserRepository UserRepository { get; } + protected ICmsUserRepository UserRepository { get; } - protected ICmsUserLookupService UserLookupService { get; } + protected ICmsUserLookupService UserLookupService { get; } + + public CmsUserSynchronizer( + ICmsUserRepository userRepository, + ICmsUserLookupService userLookupService) + { + UserRepository = userRepository; + UserLookupService = userLookupService; + } - public CmsUserSynchronizer( - ICmsUserRepository userRepository, - ICmsUserLookupService userLookupService) + public virtual async Task HandleEventAsync(EntityUpdatedEto eventData) + { + if (!GlobalFeatureManager.Instance.IsEnabled()) { - UserRepository = userRepository; - UserLookupService = userLookupService; + return; } - public virtual async Task HandleEventAsync(EntityUpdatedEto eventData) + var user = await UserRepository.FindAsync(eventData.Entity.Id); + if (user == null) { - if (!GlobalFeatureManager.Instance.IsEnabled()) - { - return; - } - - var user = await UserRepository.FindAsync(eventData.Entity.Id); + user = await UserLookupService.FindByIdAsync(eventData.Entity.Id); if (user == null) { - user = await UserLookupService.FindByIdAsync(eventData.Entity.Id); - if (user == null) - { - return; - } + return; } + } - if (user.Update(eventData.Entity)) - { - await UserRepository.UpdateAsync(user); - } + if (user.Update(eventData.Entity)) + { + await UserRepository.UpdateAsync(user); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/ICmsUserLookupService.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/ICmsUserLookupService.cs index 8731a187fc..8286288e61 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/ICmsUserLookupService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/ICmsUserLookupService.cs @@ -1,9 +1,8 @@ using Volo.Abp.Users; -namespace Volo.CmsKit.Users +namespace Volo.CmsKit.Users; + +public interface ICmsUserLookupService : IUserLookupService { - public interface ICmsUserLookupService : IUserLookupService - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/ICmsUserRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/ICmsUserRepository.cs index 95971911af..55ee9ea84e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/ICmsUserRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/ICmsUserRepository.cs @@ -1,9 +1,8 @@ using Volo.Abp.Users; -namespace Volo.CmsKit.Users +namespace Volo.CmsKit.Users; + +public interface ICmsUserRepository : IUserRepository { - public interface ICmsUserRepository: IUserRepository - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogFeatureRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogFeatureRepository.cs index c5fe9d658f..8c674e11f5 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogFeatureRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogFeatureRepository.cs @@ -7,31 +7,30 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class EfCoreBlogFeatureRepository : EfCoreRepository, IBlogFeatureRepository { - public class EfCoreBlogFeatureRepository : EfCoreRepository, IBlogFeatureRepository + public EfCoreBlogFeatureRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) { - public EfCoreBlogFeatureRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } - - public Task FindAsync(Guid blogId, string featureName) - { - return base.FindAsync(x => x.BlogId == blogId && x.FeatureName == featureName); - } + } - public async Task> GetListAsync(Guid blogId) - { - return await (await GetQueryableAsync()) - .Where(x => x.BlogId == blogId) - .ToListAsync(); - } + public Task FindAsync(Guid blogId, string featureName) + { + return base.FindAsync(x => x.BlogId == blogId && x.FeatureName == featureName); + } - public async Task> GetListAsync(Guid blogId, List featureNames) - { - return await (await GetQueryableAsync()) - .Where(x => x.BlogId == blogId && featureNames.Contains(x.FeatureName)) + public async Task> GetListAsync(Guid blogId) + { + return await (await GetQueryableAsync()) + .Where(x => x.BlogId == blogId) .ToListAsync(); - } + } + + public async Task> GetListAsync(Guid blogId, List featureNames) + { + return await (await GetQueryableAsync()) + .Where(x => x.BlogId == blogId && featureNames.Contains(x.FeatureName)) + .ToListAsync(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs index 2b2bdcffb7..f0a6aa61ee 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs @@ -12,88 +12,87 @@ using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class EfCoreBlogPostRepository : EfCoreRepository, IBlogPostRepository { - public class EfCoreBlogPostRepository : EfCoreRepository, IBlogPostRepository + public EfCoreBlogPostRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) { - public EfCoreBlogPostRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } + } - public async Task GetBySlugAsync( - Guid blogId, - [NotNull] string slug, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(slug, nameof(slug)); + public async Task GetBySlugAsync( + Guid blogId, + [NotNull] string slug, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); - var blogPost = await GetAsync( - x => x.BlogId == blogId && x.Slug.ToLower() == slug, - cancellationToken: GetCancellationToken(cancellationToken)); + var blogPost = await GetAsync( + x => x.BlogId == blogId && x.Slug.ToLower() == slug, + cancellationToken: GetCancellationToken(cancellationToken)); - blogPost.Author = await (await GetDbContextAsync()) - .Set() - .FirstOrDefaultAsync(x =>x.Id == blogPost.AuthorId, GetCancellationToken(cancellationToken)); + blogPost.Author = await (await GetDbContextAsync()) + .Set() + .FirstOrDefaultAsync(x => x.Id == blogPost.AuthorId, GetCancellationToken(cancellationToken)); - return blogPost; - } + return blogPost; + } - public virtual async Task GetCountAsync( - string filter = null, - Guid? blogId = null, - CancellationToken cancellationToken = default) - { - var queryable = (await GetDbSetAsync()) - .WhereIf(blogId.HasValue, x => x.BlogId == blogId) - .WhereIf(!string.IsNullOrEmpty(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)); - - var count = await queryable.CountAsync(GetCancellationToken(cancellationToken)); - return count; - } - - public virtual async Task> GetListAsync( - string filter = null, - Guid? blogId = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - string sorting = null, - CancellationToken cancellationToken = default) - - { - var dbContext = await GetDbContextAsync(); - var blogPostsDbSet = dbContext.Set(); - var usersDbSet = dbContext.Set(); - - var queryable = blogPostsDbSet - .WhereIf(blogId.HasValue, x => x.BlogId == blogId) - .WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)); - - queryable = queryable.OrderBy(sorting.IsNullOrEmpty() ? $"{nameof(BlogPost.CreationTime)} desc" : sorting); - - var combinedResult = await queryable - .Join( - usersDbSet, - o => o.AuthorId, - i => i.Id, - (blogPost,user) => new { blogPost, user }) - .Skip(skipCount) - .Take(maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); - - return combinedResult.Select(s => - { - s.blogPost.Author = s.user; - return s.blogPost; - }).ToList(); - } - - public async Task SlugExistsAsync(Guid blogId, [NotNull] string slug, - CancellationToken cancellationToken = default) + public virtual async Task GetCountAsync( + string filter = null, + Guid? blogId = null, + CancellationToken cancellationToken = default) + { + var queryable = (await GetDbSetAsync()) + .WhereIf(blogId.HasValue, x => x.BlogId == blogId) + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)); + + var count = await queryable.CountAsync(GetCancellationToken(cancellationToken)); + return count; + } + + public virtual async Task> GetListAsync( + string filter = null, + Guid? blogId = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + string sorting = null, + CancellationToken cancellationToken = default) + + { + var dbContext = await GetDbContextAsync(); + var blogPostsDbSet = dbContext.Set(); + var usersDbSet = dbContext.Set(); + + var queryable = blogPostsDbSet + .WhereIf(blogId.HasValue, x => x.BlogId == blogId) + .WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)); + + queryable = queryable.OrderBy(sorting.IsNullOrEmpty() ? $"{nameof(BlogPost.CreationTime)} desc" : sorting); + + var combinedResult = await queryable + .Join( + usersDbSet, + o => o.AuthorId, + i => i.Id, + (blogPost, user) => new { blogPost, user }) + .Skip(skipCount) + .Take(maxResultCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + + return combinedResult.Select(s => { - Check.NotNullOrEmpty(slug, nameof(slug)); + s.blogPost.Author = s.user; + return s.blogPost; + }).ToList(); + } + + public async Task SlugExistsAsync(Guid blogId, [NotNull] string slug, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); - return await (await GetDbSetAsync()).AnyAsync(x => x.BlogId == blogId && x.Slug.ToLower() == slug, - GetCancellationToken(cancellationToken)); - } + return await (await GetDbSetAsync()).AnyAsync(x => x.BlogId == blogId && x.Slug.ToLower() == slug, + GetCancellationToken(cancellationToken)); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogRepository.cs index ca63dc878b..daf915f675 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogRepository.cs @@ -11,55 +11,54 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class EfCoreBlogRepository : EfCoreRepository, IBlogRepository { - public class EfCoreBlogRepository : EfCoreRepository, IBlogRepository + public EfCoreBlogRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) { - public EfCoreBlogRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } + } - public virtual async Task ExistsAsync(Guid id, CancellationToken cancellationToken = default) - { - return await (await GetQueryableAsync()).AnyAsync(x => x.Id == id, GetCancellationToken(cancellationToken)); - } + public virtual async Task ExistsAsync(Guid id, CancellationToken cancellationToken = default) + { + return await (await GetQueryableAsync()).AnyAsync(x => x.Id == id, GetCancellationToken(cancellationToken)); + } - public virtual async Task SlugExistsAsync(string slug, CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()).AnyAsync(x => x.Slug == slug, GetCancellationToken(cancellationToken)); - } + public virtual async Task SlugExistsAsync(string slug, CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()).AnyAsync(x => x.Slug == slug, GetCancellationToken(cancellationToken)); + } - public virtual async Task> GetListAsync( - string filter = null, - string sorting = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - CancellationToken cancellationToken = default) - { - var query = await GetListQueryAsync(filter); + public virtual async Task> GetListAsync( + string filter = null, + string sorting = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + CancellationToken cancellationToken = default) + { + var query = await GetListQueryAsync(filter); - return await query.OrderBy(sorting.IsNullOrEmpty() ? "creationTime desc" : sorting) - .PageBy(skipCount, maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); - } + return await query.OrderBy(sorting.IsNullOrEmpty() ? "creationTime desc" : sorting) + .PageBy(skipCount, maxResultCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + } - public virtual async Task GetCountAsync(string filter = null, CancellationToken cancellationToken = default) - { - var query = await GetListQueryAsync(filter); + public virtual async Task GetCountAsync(string filter = null, CancellationToken cancellationToken = default) + { + var query = await GetListQueryAsync(filter); - return await query.LongCountAsync(GetCancellationToken(cancellationToken)); - } + return await query.LongCountAsync(GetCancellationToken(cancellationToken)); + } - public virtual Task GetBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(slug, nameof(slug)); - return GetAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken)); - } + public virtual Task GetBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); + return GetAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken)); + } - protected virtual async Task> GetListQueryAsync(string filter = null) - { - return (await GetDbSetAsync()) - .WhereIf(!filter.IsNullOrWhiteSpace(), b => b.Name.Contains(filter)); - } + protected virtual async Task> GetListQueryAsync(string filter = null) + { + return (await GetDbSetAsync()) + .WhereIf(!filter.IsNullOrWhiteSpace(), b => b.Name.Contains(filter)); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 8e0a1b1632..3116d191ba 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -12,163 +12,162 @@ using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public class EfCoreCommentRepository : EfCoreRepository, + ICommentRepository { - public class EfCoreCommentRepository : EfCoreRepository, - ICommentRepository + public EfCoreCommentRepository(IDbContextProvider dbContextProvider) + : base(dbContextProvider) { - public EfCoreCommentRepository(IDbContextProvider dbContextProvider) - : base(dbContextProvider) - { - } + } - public async Task GetWithAuthorAsync(Guid id, - CancellationToken cancellationToken = default) + public async Task GetWithAuthorAsync(Guid id, + CancellationToken cancellationToken = default) + { + var query = from comment in (await GetDbSetAsync()) + join user in (await GetDbContextAsync()).Set() on comment.CreatorId equals user.Id + where id == comment.Id + select new CommentWithAuthorQueryResultItem + { + Comment = comment, + Author = user + }; + + var commentWithAuthor = await query.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + + if (commentWithAuthor == null) { - var query = from comment in (await GetDbSetAsync()) - join user in (await GetDbContextAsync()).Set() on comment.CreatorId equals user.Id - where id == comment.Id - select new CommentWithAuthorQueryResultItem - { - Comment = comment, - Author = user - }; - - var commentWithAuthor = await query.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); - - if (commentWithAuthor == null) - { - throw new EntityNotFoundException(typeof(Comment), id); - } - - return commentWithAuthor; + throw new EntityNotFoundException(typeof(Comment), id); } - public async Task> GetListAsync( - string filter = null, - string entityType = null, - Guid? repliedCommentId = null, - string authorUsername = null, - DateTime? creationStartDate = null, - DateTime? creationEndDate = null, - string sorting = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - CancellationToken cancellationToken = default - ) - { - var token = GetCancellationToken(cancellationToken); - var query = await GetListQueryAsync( - filter, - entityType, - repliedCommentId, - authorUsername, - creationStartDate, - creationEndDate, - token); - - if (sorting != null) - { - sorting = "comment." + sorting; - } - - query = query.OrderBy(sorting.IsNullOrEmpty() ? "comment.creationTime desc" : sorting) - .PageBy(skipCount, maxResultCount); - - return await query.ToListAsync(token); - } + return commentWithAuthor; + } - public async Task GetCountAsync( - string text = null, - string entityType = null, - Guid? repliedCommentId = null, - string authorUsername = null, - DateTime? creationStartDate = null, - DateTime? creationEndDate = null, - CancellationToken cancellationToken = default - ) + public async Task> GetListAsync( + string filter = null, + string entityType = null, + Guid? repliedCommentId = null, + string authorUsername = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + string sorting = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + CancellationToken cancellationToken = default + ) + { + var token = GetCancellationToken(cancellationToken); + var query = await GetListQueryAsync( + filter, + entityType, + repliedCommentId, + authorUsername, + creationStartDate, + creationEndDate, + token); + + if (sorting != null) { - var token = GetCancellationToken(cancellationToken); - var query = await GetListQueryAsync( - text, - entityType, - repliedCommentId, - authorUsername, - creationStartDate, - creationEndDate, - token); - - return await query.LongCountAsync(token); + sorting = "comment." + sorting; } - public async Task> GetListWithAuthorsAsync( - string entityType, - string entityId, - CancellationToken cancellationToken = default) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - - var query = from comment in (await GetDbSetAsync()) - join user in (await GetDbContextAsync()).Set() on comment.CreatorId equals user.Id - where entityType == comment.EntityType && entityId == comment.EntityId - orderby comment.CreationTime - select new CommentWithAuthorQueryResultItem - { - Comment = comment, - Author = user - }; - - return await query.ToListAsync(GetCancellationToken(cancellationToken)); - } + query = query.OrderBy(sorting.IsNullOrEmpty() ? "comment.creationTime desc" : sorting) + .PageBy(skipCount, maxResultCount); - public async Task DeleteWithRepliesAsync( - Comment comment, - CancellationToken cancellationToken = default) - { - var replies = await (await GetDbSetAsync()) - .Where(x => x.RepliedCommentId == comment.Id) - .ToListAsync(GetCancellationToken(cancellationToken)); - - foreach (var reply in replies) - { - await DeleteAsync( - reply, - cancellationToken: GetCancellationToken(cancellationToken) - ); - } - - await DeleteAsync(comment, cancellationToken: GetCancellationToken(cancellationToken)); - } + return await query.ToListAsync(token); + } + + public async Task GetCountAsync( + string text = null, + string entityType = null, + Guid? repliedCommentId = null, + string authorUsername = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + CancellationToken cancellationToken = default + ) + { + var token = GetCancellationToken(cancellationToken); + var query = await GetListQueryAsync( + text, + entityType, + repliedCommentId, + authorUsername, + creationStartDate, + creationEndDate, + token); + + return await query.LongCountAsync(token); + } + + public async Task> GetListWithAuthorsAsync( + string entityType, + string entityId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + + var query = from comment in (await GetDbSetAsync()) + join user in (await GetDbContextAsync()).Set() on comment.CreatorId equals user.Id + where entityType == comment.EntityType && entityId == comment.EntityId + orderby comment.CreationTime + select new CommentWithAuthorQueryResultItem + { + Comment = comment, + Author = user + }; + + return await query.ToListAsync(GetCancellationToken(cancellationToken)); + } - protected virtual async Task> GetListQueryAsync( - string filter = null, - string entityType = null, - Guid? repliedCommentId = null, - string authorUsername = null, - DateTime? creationStartDate = null, - DateTime? creationEndDate = null, - CancellationToken cancellationToken = default - ) + public async Task DeleteWithRepliesAsync( + Comment comment, + CancellationToken cancellationToken = default) + { + var replies = await (await GetDbSetAsync()) + .Where(x => x.RepliedCommentId == comment.Id) + .ToListAsync(GetCancellationToken(cancellationToken)); + + foreach (var reply in replies) { - var commentDbSet = await GetDbSetAsync(); - var cmsUserSet = (await GetDbContextAsync()).Set(); - - var query = from comment in commentDbSet - join user in cmsUserSet - on comment.CreatorId equals user.Id - select new CommentWithAuthorQueryResultItem - { - Comment = comment, - Author = user - }; - - return query.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Comment.Text.Contains(filter)) - .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.Comment.EntityType.Contains(entityType)) - .WhereIf(repliedCommentId.HasValue, c => c.Comment.RepliedCommentId == repliedCommentId) - .WhereIf(!authorUsername.IsNullOrWhiteSpace(),c=>c.Author.UserName.Contains(authorUsername)) - .WhereIf(creationStartDate.HasValue, c => c.Comment.CreationTime >= creationStartDate) - .WhereIf(creationEndDate.HasValue, c => c.Comment.CreationTime <= creationEndDate); + await DeleteAsync( + reply, + cancellationToken: GetCancellationToken(cancellationToken) + ); } + + await DeleteAsync(comment, cancellationToken: GetCancellationToken(cancellationToken)); + } + + protected virtual async Task> GetListQueryAsync( + string filter = null, + string entityType = null, + Guid? repliedCommentId = null, + string authorUsername = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + CancellationToken cancellationToken = default + ) + { + var commentDbSet = await GetDbSetAsync(); + var cmsUserSet = (await GetDbContextAsync()).Set(); + + var query = from comment in commentDbSet + join user in cmsUserSet + on comment.CreatorId equals user.Id + select new CommentWithAuthorQueryResultItem + { + Comment = comment, + Author = user + }; + + return query.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Comment.Text.Contains(filter)) + .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.Comment.EntityType.Contains(entityType)) + .WhereIf(repliedCommentId.HasValue, c => c.Comment.RepliedCommentId == repliedCommentId) + .WhereIf(!authorUsername.IsNullOrWhiteSpace(), c => c.Author.UserName.Contains(authorUsername)) + .WhereIf(creationStartDate.HasValue, c => c.Comment.CreationTime >= creationStartDate) + .WhereIf(creationEndDate.HasValue, c => c.Comment.CreationTime <= creationEndDate); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs index 752b47cdaa..2ceb102267 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs @@ -11,34 +11,33 @@ using Volo.CmsKit.Reactions; using Volo.CmsKit.Tags; using Volo.CmsKit.Users; -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +[ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] +public class CmsKitDbContext : AbpDbContext, ICmsKitDbContext { - [ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] - public class CmsKitDbContext : AbpDbContext, ICmsKitDbContext - { - public DbSet Comments { get; set; } - public DbSet User { get; set; } - public DbSet Reactions { get; set; } - public DbSet Ratings { get; set; } - public DbSet Tags { get; set; } - public DbSet EntityTags { get; set; } - public DbSet Pages { get; set; } - public DbSet Blogs { get; set; } - public DbSet BlogPosts { get; set; } - public DbSet BlogFeatures { get; set; } - public DbSet MediaDescriptors { get; set; } - public DbSet MenuItems { get; set; } + public DbSet Comments { get; set; } + public DbSet User { get; set; } + public DbSet Reactions { get; set; } + public DbSet Ratings { get; set; } + public DbSet Tags { get; set; } + public DbSet EntityTags { get; set; } + public DbSet Pages { get; set; } + public DbSet Blogs { get; set; } + public DbSet BlogPosts { get; set; } + public DbSet BlogFeatures { get; set; } + public DbSet MediaDescriptors { get; set; } + public DbSet MenuItems { get; set; } - public CmsKitDbContext(DbContextOptions options) - : base(options) - { + public CmsKitDbContext(DbContextOptions options) + : base(options) + { - } + } - protected override void OnModelCreating(ModelBuilder builder) - { - base.OnModelCreating(builder); - builder.ConfigureCmsKit(); - } + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + builder.ConfigureCmsKit(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs index 14a242a9de..31424f6548 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs @@ -14,258 +14,256 @@ using Volo.CmsKit.Reactions; using Volo.CmsKit.Tags; using Volo.CmsKit.Users; -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +public static class CmsKitDbContextModelCreatingExtensions { - public static class CmsKitDbContextModelCreatingExtensions + public static void ConfigureCmsKit( + this ModelBuilder builder) { - public static void ConfigureCmsKit( - this ModelBuilder builder) - { - Check.NotNull(builder, nameof(builder)); + Check.NotNull(builder, nameof(builder)); - if (GlobalFeatureManager.Instance.IsEnabled()) + if (GlobalFeatureManager.Instance.IsEnabled()) + { + builder.Entity(b => { - builder.Entity(b => - { - b.ToTable(CmsKitDbProperties.DbTablePrefix + "Users", CmsKitDbProperties.DbSchema); + b.ToTable(CmsKitDbProperties.DbTablePrefix + "Users", CmsKitDbProperties.DbSchema); - b.ConfigureByConvention(); - b.ConfigureAbpUser(); + b.ConfigureByConvention(); + b.ConfigureAbpUser(); - b.HasIndex(x => new { x.TenantId, x.UserName }); - b.HasIndex(x => new { x.TenantId, x.Email }); + b.HasIndex(x => new { x.TenantId, x.UserName }); + b.HasIndex(x => new { x.TenantId, x.Email }); - b.ApplyObjectExtensionMappings(); - }); - } - else - { - builder.Ignore(); - } + b.ApplyObjectExtensionMappings(); + }); + } + else + { + builder.Ignore(); + } - if (GlobalFeatureManager.Instance.IsEnabled()) + if (GlobalFeatureManager.Instance.IsEnabled()) + { + builder.Entity(b => { - builder.Entity(b => - { - b.ToTable(CmsKitDbProperties.DbTablePrefix + "UserReactions", CmsKitDbProperties.DbSchema); + b.ToTable(CmsKitDbProperties.DbTablePrefix + "UserReactions", CmsKitDbProperties.DbSchema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityIdLength); - b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.MaxReactionNameLength); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityIdLength); + b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.MaxReactionNameLength); - b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId, x.ReactionName }); - b.HasIndex(x => new { x.TenantId, x.CreatorId, x.EntityType, x.EntityId, x.ReactionName }); + b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId, x.ReactionName }); + b.HasIndex(x => new { x.TenantId, x.CreatorId, x.EntityType, x.EntityId, x.ReactionName }); - b.ApplyObjectExtensionMappings(); - }); - } - else - { - builder.Ignore(); - } + b.ApplyObjectExtensionMappings(); + }); + } + else + { + builder.Ignore(); + } - if (GlobalFeatureManager.Instance.IsEnabled()) + if (GlobalFeatureManager.Instance.IsEnabled()) + { + builder.Entity(b => { - builder.Entity(b => - { - b.ToTable(CmsKitDbProperties.DbTablePrefix + "Comments", CmsKitDbProperties.DbSchema); + b.ToTable(CmsKitDbProperties.DbTablePrefix + "Comments", CmsKitDbProperties.DbSchema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.MaxEntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.MaxEntityIdLength); - b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength); - b.Property(x => x.RepliedCommentId); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.MaxEntityIdLength); + b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength); + b.Property(x => x.RepliedCommentId); - b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId }); - b.HasIndex(x => new { x.TenantId, x.RepliedCommentId }); + b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId }); + b.HasIndex(x => new { x.TenantId, x.RepliedCommentId }); - b.ApplyObjectExtensionMappings(); - }); - } - else - { - builder.Ignore(); - } + b.ApplyObjectExtensionMappings(); + }); + } + else + { + builder.Ignore(); + } - if (GlobalFeatureManager.Instance.IsEnabled()) + if (GlobalFeatureManager.Instance.IsEnabled()) + { + builder.Entity(r => { - builder.Entity(r => - { - r.ToTable(CmsKitDbProperties.DbTablePrefix + "Ratings", CmsKitDbProperties.DbSchema); + r.ToTable(CmsKitDbProperties.DbTablePrefix + "Ratings", CmsKitDbProperties.DbSchema); - r.ConfigureByConvention(); + r.ConfigureByConvention(); - r.Property(x => x.StarCount).IsRequired(); - r.Property(x => x.EntityType).IsRequired().HasMaxLength(RatingConsts.MaxEntityTypeLength); - r.Property(x => x.EntityId).IsRequired().HasMaxLength(RatingConsts.MaxEntityIdLength); + r.Property(x => x.StarCount).IsRequired(); + r.Property(x => x.EntityType).IsRequired().HasMaxLength(RatingConsts.MaxEntityTypeLength); + r.Property(x => x.EntityId).IsRequired().HasMaxLength(RatingConsts.MaxEntityIdLength); - r.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId, x.CreatorId }); + r.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId, x.CreatorId }); - r.ApplyObjectExtensionMappings(); - }); - } - else - { - builder.Ignore(); - } + r.ApplyObjectExtensionMappings(); + }); + } + else + { + builder.Ignore(); + } - if (GlobalFeatureManager.Instance.IsEnabled()) + if (GlobalFeatureManager.Instance.IsEnabled()) + { + builder.Entity(b => { - builder.Entity(b => - { - b.ToTable(CmsKitDbProperties.DbTablePrefix + "Tags", CmsKitDbProperties.DbSchema); - - b.ConfigureByConvention(); + b.ToTable(CmsKitDbProperties.DbTablePrefix + "Tags", CmsKitDbProperties.DbSchema); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength); - b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength); + b.ConfigureByConvention(); - b.HasIndex(x => new - { - x.TenantId, - x.Name - }); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength); + b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength); - b.ApplyObjectExtensionMappings(); + b.HasIndex(x => new { + x.TenantId, + x.Name }); - builder.Entity(b => - { - b.ToTable(CmsKitDbProperties.DbTablePrefix + "EntityTags", CmsKitDbProperties.DbSchema); + b.ApplyObjectExtensionMappings(); + }); - b.ConfigureByConvention(); + builder.Entity(b => + { + b.ToTable(CmsKitDbProperties.DbTablePrefix + "EntityTags", CmsKitDbProperties.DbSchema); - b.HasKey(x => new { x.EntityId, x.TagId }); + b.ConfigureByConvention(); - b.Property(x => x.EntityId).IsRequired(); - b.Property(x => x.TagId).IsRequired(); + b.HasKey(x => new { x.EntityId, x.TagId }); - b.HasIndex(x => new { x.TenantId, x.EntityId, x.TagId }); + b.Property(x => x.EntityId).IsRequired(); + b.Property(x => x.TagId).IsRequired(); - b.ApplyObjectExtensionMappings(); - }); - } - else - { - builder.Ignore(); - builder.Ignore(); - } + b.HasIndex(x => new { x.TenantId, x.EntityId, x.TagId }); + + b.ApplyObjectExtensionMappings(); + }); + } + else + { + builder.Ignore(); + builder.Ignore(); + } - if (GlobalFeatureManager.Instance.IsEnabled()) + if (GlobalFeatureManager.Instance.IsEnabled()) + { + builder.Entity(b => { - builder.Entity(b => - { - b.ToTable(CmsKitDbProperties.DbTablePrefix + "Pages", CmsKitDbProperties.DbSchema); + b.ToTable(CmsKitDbProperties.DbTablePrefix + "Pages", CmsKitDbProperties.DbSchema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - b.Property(x => x.Title).IsRequired().HasMaxLength(PageConsts.MaxTitleLength); - b.Property(x => x.Slug).IsRequired().HasMaxLength(PageConsts.MaxSlugLength); - b.Property(x => x.Content).HasMaxLength(PageConsts.MaxContentLength); + b.Property(x => x.Title).IsRequired().HasMaxLength(PageConsts.MaxTitleLength); + b.Property(x => x.Slug).IsRequired().HasMaxLength(PageConsts.MaxSlugLength); + b.Property(x => x.Content).HasMaxLength(PageConsts.MaxContentLength); - b.HasIndex(x => new { x.TenantId, Url = x.Slug }); + b.HasIndex(x => new { x.TenantId, Url = x.Slug }); - b.ApplyObjectExtensionMappings(); - }); - } - else - { - builder.Ignore(); - } + b.ApplyObjectExtensionMappings(); + }); + } + else + { + builder.Ignore(); + } - if (GlobalFeatureManager.Instance.IsEnabled()) + if (GlobalFeatureManager.Instance.IsEnabled()) + { + builder.Entity(b => { - builder.Entity(b => - { - b.ToTable(CmsKitDbProperties.DbTablePrefix + "Blogs", CmsKitDbProperties.DbSchema); + b.ToTable(CmsKitDbProperties.DbTablePrefix + "Blogs", CmsKitDbProperties.DbSchema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - b.Property(p => p.Name).IsRequired().HasMaxLength(BlogConsts.MaxNameLength); + b.Property(p => p.Name).IsRequired().HasMaxLength(BlogConsts.MaxNameLength); - b.Property(p => p.Slug).IsRequired().HasMaxLength(BlogConsts.MaxSlugLength); + b.Property(p => p.Slug).IsRequired().HasMaxLength(BlogConsts.MaxSlugLength); - b.ApplyObjectExtensionMappings(); - }); + b.ApplyObjectExtensionMappings(); + }); - builder.Entity(b => - { - b.ToTable(CmsKitDbProperties.DbTablePrefix + "BlogPosts", CmsKitDbProperties.DbSchema); + builder.Entity(b => + { + b.ToTable(CmsKitDbProperties.DbTablePrefix + "BlogPosts", CmsKitDbProperties.DbSchema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - b.Property(p => p.AuthorId).IsRequired(); - b.Property(p => p.Title).IsRequired().HasMaxLength(BlogPostConsts.MaxTitleLength); - b.Property(p => p.Slug).IsRequired().HasMaxLength(BlogPostConsts.MaxSlugLength); - b.Property(p => p.ShortDescription).HasMaxLength(BlogPostConsts.MaxShortDescriptionLength); - b.Property(p => p.Content).HasMaxLength(BlogPostConsts.MaxContentLength); + b.Property(p => p.AuthorId).IsRequired(); + b.Property(p => p.Title).IsRequired().HasMaxLength(BlogPostConsts.MaxTitleLength); + b.Property(p => p.Slug).IsRequired().HasMaxLength(BlogPostConsts.MaxSlugLength); + b.Property(p => p.ShortDescription).HasMaxLength(BlogPostConsts.MaxShortDescriptionLength); + b.Property(p => p.Content).HasMaxLength(BlogPostConsts.MaxContentLength); - b.HasIndex(x => new { x.Slug, x.BlogId }); + b.HasIndex(x => new { x.Slug, x.BlogId }); - b.ApplyObjectExtensionMappings(); - }); + b.ApplyObjectExtensionMappings(); + }); - builder.Entity(b => - { - b.ToTable(CmsKitDbProperties.DbTablePrefix + "BlogFeatures", CmsKitDbProperties.DbSchema); + builder.Entity(b => + { + b.ToTable(CmsKitDbProperties.DbTablePrefix + "BlogFeatures", CmsKitDbProperties.DbSchema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - b.Property(p => p.FeatureName).IsRequired().HasMaxLength(BlogFeatureConsts.MaxFeatureNameLenth); + b.Property(p => p.FeatureName).IsRequired().HasMaxLength(BlogFeatureConsts.MaxFeatureNameLenth); - b.ApplyObjectExtensionMappings(); - }); - } - else - { - builder.Ignore(); - builder.Ignore(); - builder.Ignore(); - } + b.ApplyObjectExtensionMappings(); + }); + } + else + { + builder.Ignore(); + builder.Ignore(); + builder.Ignore(); + } - if (GlobalFeatureManager.Instance.IsEnabled()) + if (GlobalFeatureManager.Instance.IsEnabled()) + { + builder.Entity(b => { - builder.Entity(b => - { - b.ToTable(CmsKitDbProperties.DbTablePrefix + "MediaDescriptors", CmsKitDbProperties.DbSchema); + b.ToTable(CmsKitDbProperties.DbTablePrefix + "MediaDescriptors", CmsKitDbProperties.DbSchema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(MediaDescriptorConsts.MaxEntityTypeLength); - b.Property(x => x.Name).IsRequired().HasMaxLength(MediaDescriptorConsts.MaxNameLength); - b.Property(x => x.MimeType).IsRequired().HasMaxLength(MediaDescriptorConsts.MaxMimeTypeLength); - b.Property(x => x.Size).HasMaxLength(MediaDescriptorConsts.MaxSizeLength); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(MediaDescriptorConsts.MaxEntityTypeLength); + b.Property(x => x.Name).IsRequired().HasMaxLength(MediaDescriptorConsts.MaxNameLength); + b.Property(x => x.MimeType).IsRequired().HasMaxLength(MediaDescriptorConsts.MaxMimeTypeLength); + b.Property(x => x.Size).HasMaxLength(MediaDescriptorConsts.MaxSizeLength); - b.ApplyObjectExtensionMappings(); - }); - } - else - { - builder.Ignore(); - } - - if (GlobalFeatureManager.Instance.IsEnabled()) + b.ApplyObjectExtensionMappings(); + }); + } + else + { + builder.Ignore(); + } + + if (GlobalFeatureManager.Instance.IsEnabled()) + { + builder.Entity(b => { - builder.Entity(b => - { - b.ToTable(CmsKitDbProperties.DbTablePrefix + "MenuItems", CmsKitDbProperties.DbSchema); + b.ToTable(CmsKitDbProperties.DbTablePrefix + "MenuItems", CmsKitDbProperties.DbSchema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - b.Property(x => x.DisplayName).IsRequired().HasMaxLength(MenuItemConsts.MaxDisplayNameLength); + b.Property(x => x.DisplayName).IsRequired().HasMaxLength(MenuItemConsts.MaxDisplayNameLength); - b.Property(x => x.Url).IsRequired().HasMaxLength(MenuItemConsts.MaxUrlLength); - }); - } - else - { - builder.Ignore(); - } - - builder.TryConfigureObjectExtensions(); + b.Property(x => x.Url).IsRequired().HasMaxLength(MenuItemConsts.MaxUrlLength); + }); + } + else + { + builder.Ignore(); } + + builder.TryConfigureObjectExtensions(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitEntityFrameworkCoreModule.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitEntityFrameworkCoreModule.cs index dd8e11f1f0..06afae9cd7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitEntityFrameworkCoreModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitEntityFrameworkCoreModule.cs @@ -11,31 +11,30 @@ using Volo.CmsKit.Reactions; using Volo.CmsKit.Tags; using Volo.CmsKit.Users; -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +[DependsOn( + typeof(CmsKitDomainModule), + typeof(AbpUsersEntityFrameworkCoreModule), + typeof(AbpEntityFrameworkCoreModule) +)] +public class CmsKitEntityFrameworkCoreModule : AbpModule { - [DependsOn( - typeof(CmsKitDomainModule), - typeof(AbpUsersEntityFrameworkCoreModule), - typeof(AbpEntityFrameworkCoreModule) - )] - public class CmsKitEntityFrameworkCoreModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + context.Services.AddAbpDbContext(options => { - context.Services.AddAbpDbContext(options => - { - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - }); - } + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs index 09118a1d69..b67b1a5d68 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs @@ -11,21 +11,20 @@ using Volo.CmsKit.Reactions; using Volo.CmsKit.Tags; using Volo.CmsKit.Users; -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +[ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] +public interface ICmsKitDbContext : IEfCoreDbContext { - [ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] - public interface ICmsKitDbContext : IEfCoreDbContext - { - DbSet Comments { get; } - DbSet User { get; } - DbSet Reactions { get; } - DbSet Ratings { get; } - DbSet Tags { get; } - DbSet EntityTags { get; } - DbSet Pages { get; } - DbSet Blogs { get; } - DbSet BlogPosts { get; } - DbSet MediaDescriptors { get; } - DbSet MenuItems { get; } - } -} \ No newline at end of file + DbSet Comments { get; } + DbSet User { get; } + DbSet Reactions { get; } + DbSet Ratings { get; } + DbSet Tags { get; } + DbSet EntityTags { get; } + DbSet Pages { get; } + DbSet Blogs { get; } + DbSet BlogPosts { get; } + DbSet MediaDescriptors { get; } + DbSet MenuItems { get; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/MediaDescriptors/EfCoreMediaDescriptorRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/MediaDescriptors/EfCoreMediaDescriptorRepository.cs index 083664e423..23850bf1ad 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/MediaDescriptors/EfCoreMediaDescriptorRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/MediaDescriptors/EfCoreMediaDescriptorRepository.cs @@ -3,12 +3,11 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public class EfCoreMediaDescriptorRepository : EfCoreRepository, IMediaDescriptorRepository { - public class EfCoreMediaDescriptorRepository : EfCoreRepository, IMediaDescriptorRepository + public EfCoreMediaDescriptorRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) { - public EfCoreMediaDescriptorRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Menus/EfCoreMenuItemRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Menus/EfCoreMenuItemRepository.cs index 6b5a314c1e..81595c9267 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Menus/EfCoreMenuItemRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Menus/EfCoreMenuItemRepository.cs @@ -3,12 +3,11 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +public class EfCoreMenuItemRepository : EfCoreRepository, IMenuItemRepository { - public class EfCoreMenuItemRepository : EfCoreRepository, IMenuItemRepository + public EfCoreMenuItemRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) { - public EfCoreMenuItemRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs index 5651fa99a7..248c42282a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs @@ -11,57 +11,56 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public class EfCorePageRepository : EfCoreRepository, IPageRepository { - public class EfCorePageRepository : EfCoreRepository, IPageRepository + public EfCorePageRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) { - public EfCorePageRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } + } - public virtual async Task GetCountAsync(string filter = null, - CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()).WhereIf( + public virtual async Task GetCountAsync(string filter = null, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()).WhereIf( + !filter.IsNullOrWhiteSpace(), + x => + x.Title.Contains(filter) + ).CountAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task> GetListAsync( + string filter = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + string sorting = null, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()).WhereIf( !filter.IsNullOrWhiteSpace(), x => - x.Title.Contains(filter) - ).CountAsync(GetCancellationToken(cancellationToken)); - } - - public virtual async Task> GetListAsync( - string filter = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - string sorting = null, - CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()).WhereIf( - !filter.IsNullOrWhiteSpace(), - x => - x.Title.Contains(filter)) - .OrderBy(sorting.IsNullOrEmpty() ? nameof(Page.Title) : sorting) - .PageBy(skipCount, maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); - } + x.Title.Contains(filter)) + .OrderBy(sorting.IsNullOrEmpty() ? nameof(Page.Title) : sorting) + .PageBy(skipCount, maxResultCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + } - public virtual Task GetBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(slug, nameof(slug)); - return GetAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken)); - } + public virtual Task GetBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); + return GetAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken)); + } - public virtual Task FindBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(slug, nameof(slug)); - return FindAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken)); - } + public virtual Task FindBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); + return FindAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken)); + } - public virtual async Task ExistsAsync([NotNull] string slug, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(slug, nameof(slug)); - return await (await GetDbSetAsync()).AnyAsync(x => x.Slug == slug, GetCancellationToken(cancellationToken)); - } + public virtual async Task ExistsAsync([NotNull] string slug, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); + return await (await GetDbSetAsync()).AnyAsync(x => x.Slug == slug, GetCancellationToken(cancellationToken)); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Ratings/EfCoreRatingRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Ratings/EfCoreRatingRepository.cs index a48c288932..909ea9037b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Ratings/EfCoreRatingRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Ratings/EfCoreRatingRepository.cs @@ -10,48 +10,47 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public class EfCoreRatingRepository : EfCoreRepository, IRatingRepository { - public class EfCoreRatingRepository : EfCoreRepository, IRatingRepository + public EfCoreRatingRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public async Task GetCurrentUserRatingAsync(string entityType, string entityId, Guid userId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + + var rating = await (await GetDbSetAsync()).FirstOrDefaultAsync( + r => r.EntityType == entityType && r.EntityId == entityId && r.CreatorId == userId, + GetCancellationToken(cancellationToken)); + + return rating; + } + + public async Task> GetGroupedStarCountsAsync(string entityType, + string entityId, CancellationToken cancellationToken = default) { - public EfCoreRatingRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } - - public async Task GetCurrentUserRatingAsync(string entityType, string entityId, Guid userId, - CancellationToken cancellationToken = default) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - - var rating = await (await GetDbSetAsync()).FirstOrDefaultAsync( - r => r.EntityType == entityType && r.EntityId == entityId && r.CreatorId == userId, - GetCancellationToken(cancellationToken)); - - return rating; - } - - public async Task> GetGroupedStarCountsAsync(string entityType, - string entityId, CancellationToken cancellationToken = default) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - - var query = ( - from rating in (await GetDbSetAsync()) - where rating.EntityType == entityType && rating.EntityId == entityId - group rating by rating.StarCount - into g - select new RatingWithStarCountQueryResultItem - { - StarCount = g.Key, - Count = g.Count() - } - ).OrderByDescending(r => r.StarCount); - - var ratings = await query.ToListAsync(GetCancellationToken(cancellationToken)); - - return ratings; - } + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + + var query = ( + from rating in (await GetDbSetAsync()) + where rating.EntityType == entityType && rating.EntityId == entityId + group rating by rating.StarCount + into g + select new RatingWithStarCountQueryResultItem + { + StarCount = g.Key, + Count = g.Count() + } + ).OrderByDescending(r => r.StarCount); + + var ratings = await query.ToListAsync(GetCancellationToken(cancellationToken)); + + return ratings; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs index 65824c79b6..522350dfd3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs @@ -9,72 +9,71 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class EfCoreUserReactionRepository : EfCoreRepository, + IUserReactionRepository { - public class EfCoreUserReactionRepository : EfCoreRepository, - IUserReactionRepository + public EfCoreUserReactionRepository(IDbContextProvider dbContextProvider) + : base(dbContextProvider) { - public EfCoreUserReactionRepository(IDbContextProvider dbContextProvider) - : base(dbContextProvider) - { - } + } - public async Task FindAsync( - Guid userId, - string entityType, - string entityId, - string reactionName, - CancellationToken cancellationToken = default) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); + public async Task FindAsync( + Guid userId, + string entityType, + string entityId, + string reactionName, + CancellationToken cancellationToken = default) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); - return await (await GetDbSetAsync()) - .Where(x => - x.CreatorId == userId && - x.EntityType == entityType && - x.EntityId == entityId && - x.ReactionName == reactionName) - .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); - } + return await (await GetDbSetAsync()) + .Where(x => + x.CreatorId == userId && + x.EntityType == entityType && + x.EntityId == entityId && + x.ReactionName == reactionName) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } - public async Task> GetListForUserAsync( - Guid userId, - string entityType, - string entityId, - CancellationToken cancellationToken = default) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + public async Task> GetListForUserAsync( + Guid userId, + string entityType, + string entityId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - return await (await GetDbSetAsync()) - .Where(x => - x.CreatorId == userId && - x.EntityType == entityType && - x.EntityId == entityId) - .ToListAsync(GetCancellationToken(cancellationToken)); - } + return await (await GetDbSetAsync()) + .Where(x => + x.CreatorId == userId && + x.EntityType == entityType && + x.EntityId == entityId) + .ToListAsync(GetCancellationToken(cancellationToken)); + } - public async Task> GetSummariesAsync( - string entityType, - string entityId, - CancellationToken cancellationToken = default) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + public async Task> GetSummariesAsync( + string entityType, + string entityId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - return await (await GetDbSetAsync()) - .Where(x => - x.EntityType == entityType && - x.EntityId == entityId) - .GroupBy(x => x.ReactionName) - .Select(g => new ReactionSummaryQueryResultItem - { - ReactionName = g.Key, - Count = g.Count() - }) - .ToListAsync(GetCancellationToken(cancellationToken)); - } + return await (await GetDbSetAsync()) + .Where(x => + x.EntityType == entityType && + x.EntityId == entityId) + .GroupBy(x => x.ReactionName) + .Select(g => new ReactionSummaryQueryResultItem + { + ReactionName = g.Key, + Count = g.Count() + }) + .ToListAsync(GetCancellationToken(cancellationToken)); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreEntityTagRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreEntityTagRepository.cs index ae5d081b6a..16d648ca61 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreEntityTagRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreEntityTagRepository.cs @@ -8,36 +8,35 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class EfCoreEntityTagRepository : EfCoreRepository, IEntityTagRepository { - public class EfCoreEntityTagRepository : EfCoreRepository, IEntityTagRepository + public EfCoreEntityTagRepository(IDbContextProvider dbContextProvider) : base( + dbContextProvider) + { + } + + public virtual async Task DeleteManyAsync(Guid[] tagIds, CancellationToken cancellationToken = default) { - public EfCoreEntityTagRepository(IDbContextProvider dbContextProvider) : base( - dbContextProvider) - { - } + var dbContext = await GetDbContextAsync(); + var dbSet = dbContext.Set(); + dbSet.RemoveRange(dbSet.Where(x => tagIds.Contains(x.TagId))); + await dbContext.SaveChangesAsync(GetCancellationToken(cancellationToken)); + } - public virtual async Task DeleteManyAsync(Guid[] tagIds, CancellationToken cancellationToken = default) - { - var dbContext = await GetDbContextAsync(); - var dbSet = dbContext.Set(); - dbSet.RemoveRange(dbSet.Where(x => tagIds.Contains(x.TagId))); - await dbContext.SaveChangesAsync(GetCancellationToken(cancellationToken)); - } + public virtual Task FindAsync( + [NotNull] Guid tagId, + [NotNull] string entityId, + [CanBeNull] Guid? tenantId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(entityId, nameof(entityId)); - public virtual Task FindAsync( - [NotNull] Guid tagId, - [NotNull] string entityId, - [CanBeNull] Guid? tenantId, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(entityId, nameof(entityId)); - - return base.FindAsync(x => - x.TagId == tagId && - x.EntityId == entityId && - x.TenantId == tenantId, - cancellationToken: GetCancellationToken(cancellationToken)); - } + return base.FindAsync(x => + x.TagId == tagId && + x.EntityId == entityId && + x.TenantId == tenantId, + cancellationToken: GetCancellationToken(cancellationToken)); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs index 3949ec61a4..dc026b32aa 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs @@ -10,94 +10,93 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class EfCoreTagRepository : EfCoreRepository, ITagRepository { - public class EfCoreTagRepository : EfCoreRepository, ITagRepository + public EfCoreTagRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) { - public EfCoreTagRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } + } - public virtual async Task AnyAsync( - [NotNull] string entityType, - [NotNull] string name, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(entityType, nameof(entityType)); - Check.NotNullOrEmpty(name, nameof(name)); + public virtual async Task AnyAsync( + [NotNull] string entityType, + [NotNull] string name, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(entityType, nameof(entityType)); + Check.NotNullOrEmpty(name, nameof(name)); - return await (await GetDbSetAsync()).AnyAsync(x => - x.EntityType == entityType && - x.Name == name, - GetCancellationToken(cancellationToken)); - } + return await (await GetDbSetAsync()).AnyAsync(x => + x.EntityType == entityType && + x.Name == name, + GetCancellationToken(cancellationToken)); + } - public virtual Task GetAsync( - [NotNull] string entityType, - [NotNull] string name, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(entityType, nameof(entityType)); - Check.NotNullOrEmpty(name, nameof(name)); + public virtual Task GetAsync( + [NotNull] string entityType, + [NotNull] string name, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(entityType, nameof(entityType)); + Check.NotNullOrEmpty(name, nameof(name)); - return GetAsync(x => - x.EntityType == entityType && - x.Name == name, - cancellationToken: GetCancellationToken(cancellationToken)); - } + return GetAsync(x => + x.EntityType == entityType && + x.Name == name, + cancellationToken: GetCancellationToken(cancellationToken)); + } - public virtual Task FindAsync( - [NotNull] string entityType, - [NotNull] string name, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(entityType, nameof(entityType)); - Check.NotNullOrEmpty(name, nameof(name)); + public virtual Task FindAsync( + [NotNull] string entityType, + [NotNull] string name, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(entityType, nameof(entityType)); + Check.NotNullOrEmpty(name, nameof(name)); - return FindAsync(x => - x.EntityType == entityType && - x.Name == name, - cancellationToken: GetCancellationToken(cancellationToken)); - } + return FindAsync(x => + x.EntityType == entityType && + x.Name == name, + cancellationToken: GetCancellationToken(cancellationToken)); + } - public virtual async Task> GetAllRelatedTagsAsync( - [NotNull] string entityType, - [NotNull] string entityId, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(entityType, nameof(entityType)); - Check.NotNullOrEmpty(entityId, nameof(entityId)); + public virtual async Task> GetAllRelatedTagsAsync( + [NotNull] string entityType, + [NotNull] string entityId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(entityType, nameof(entityType)); + Check.NotNullOrEmpty(entityId, nameof(entityId)); - var entityTagIds = await (await GetDbContextAsync()).Set() - .Where(q => q.EntityId == entityId) - .Select(q => q.TagId) - .ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); + var entityTagIds = await (await GetDbContextAsync()).Set() + .Where(q => q.EntityId == entityId) + .Select(q => q.TagId) + .ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); - var query = (await GetDbSetAsync()) - .Where(x => x.EntityType == entityType && - entityTagIds.Contains(x.Id)); + var query = (await GetDbSetAsync()) + .Where(x => x.EntityType == entityType && + entityTagIds.Contains(x.Id)); - return await query.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); - } + return await query.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); + } - public async Task> GetListAsync(string filter) - { - return await (await GetQueryableByFilterAsync(filter)).ToListAsync(); - } + public async Task> GetListAsync(string filter) + { + return await (await GetQueryableByFilterAsync(filter)).ToListAsync(); + } - public async Task GetCountAsync(string filter) - { - return await (await GetQueryableByFilterAsync(filter)).CountAsync(); - } + public async Task GetCountAsync(string filter) + { + return await (await GetQueryableByFilterAsync(filter)).CountAsync(); + } - private async Task> GetQueryableByFilterAsync(string filter) - { - return (await GetQueryableAsync()) - .WhereIf( - !filter.IsNullOrEmpty(), - x => - x.Name.ToLower().Contains(filter.ToLower()) || - x.EntityType.ToLower().Contains(filter.ToLower())); - } + private async Task> GetQueryableByFilterAsync(string filter) + { + return (await GetQueryableAsync()) + .WhereIf( + !filter.IsNullOrEmpty(), + x => + x.Name.ToLower().Contains(filter.ToLower()) || + x.EntityType.ToLower().Contains(filter.ToLower())); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Users/EfCoreCmsUserRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Users/EfCoreCmsUserRepository.cs index 0b6e804be0..e7c508d23f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Users/EfCoreCmsUserRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Users/EfCoreCmsUserRepository.cs @@ -2,13 +2,12 @@ using Volo.Abp.Users.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit.Users +namespace Volo.CmsKit.Users; + +public class EfCoreCmsUserRepository : EfCoreUserRepositoryBase, ICmsUserRepository { - public class EfCoreCmsUserRepository: EfCoreUserRepositoryBase, ICmsUserRepository + public EfCoreCmsUserRepository(IDbContextProvider dbContextProvider) + : base(dbContextProvider) { - public EfCoreCmsUserRepository(IDbContextProvider dbContextProvider) - : base(dbContextProvider) - { - } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.HttpApi.Client/Volo/CmsKit/CmsKitHttpApiClientModule.cs b/modules/cms-kit/src/Volo.CmsKit.HttpApi.Client/Volo/CmsKit/CmsKitHttpApiClientModule.cs index 25513a59bf..ac27b1411b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.HttpApi.Client/Volo/CmsKit/CmsKitHttpApiClientModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.HttpApi.Client/Volo/CmsKit/CmsKitHttpApiClientModule.cs @@ -2,15 +2,14 @@ using Volo.CmsKit.Admin; using Volo.CmsKit.Public; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitAdminHttpApiClientModule), + typeof(CmsKitPublicHttpApiClientModule), + typeof(CmsKitApplicationContractsModule) + )] +public class CmsKitHttpApiClientModule : AbpModule { - [DependsOn( - typeof(CmsKitAdminHttpApiClientModule), - typeof(CmsKitPublicHttpApiClientModule), - typeof(CmsKitApplicationContractsModule) - )] - public class CmsKitHttpApiClientModule : AbpModule - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.HttpApi/Volo/CmsKit/CmsKitHttpApiModule.cs b/modules/cms-kit/src/Volo.CmsKit.HttpApi/Volo/CmsKit/CmsKitHttpApiModule.cs index 219f2d9442..bcacd332dd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.HttpApi/Volo/CmsKit/CmsKitHttpApiModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.HttpApi/Volo/CmsKit/CmsKitHttpApiModule.cs @@ -2,15 +2,14 @@ using Volo.CmsKit.Admin; using Volo.CmsKit.Public; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitAdminHttpApiModule), + typeof(CmsKitPublicHttpApiModule), + typeof(CmsKitApplicationContractsModule) + )] +public class CmsKitHttpApiModule : AbpModule { - [DependsOn( - typeof(CmsKitAdminHttpApiModule), - typeof(CmsKitPublicHttpApiModule), - typeof(CmsKitApplicationContractsModule) - )] - public class CmsKitHttpApiModule : AbpModule - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Installer/Volo/Abp/CmsKit/AbpCmsKitInstallerModule.cs b/modules/cms-kit/src/Volo.CmsKit.Installer/Volo/Abp/CmsKit/AbpCmsKitInstallerModule.cs index 3b0d976f2a..4065d9c54a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Installer/Volo/Abp/CmsKit/AbpCmsKitInstallerModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Installer/Volo/Abp/CmsKit/AbpCmsKitInstallerModule.cs @@ -2,20 +2,19 @@ using Volo.Abp.Studio; using Volo.Abp.VirtualFileSystem; -namespace Volo.Abp.CmsKit +namespace Volo.Abp.CmsKit; + +[DependsOn( + typeof(AbpStudioModuleInstallerModule), + typeof(AbpVirtualFileSystemModule) + )] +public class VoloCmsKitDatabaseInstallerModule : AbpModule { - [DependsOn( - typeof(AbpStudioModuleInstallerModule), - typeof(AbpVirtualFileSystemModule) - )] - public class VoloCmsKitDatabaseInstallerModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.FileSets.AddEmbedded(); - }); - } + options.FileSets.AddEmbedded(); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Installer/Volo/Abp/CmsKit/CmsKitInstallerPipelineBuilder.cs b/modules/cms-kit/src/Volo.CmsKit.Installer/Volo/Abp/CmsKit/CmsKitInstallerPipelineBuilder.cs index a9333b3d5c..951ea57362 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Installer/Volo/Abp/CmsKit/CmsKitInstallerPipelineBuilder.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Installer/Volo/Abp/CmsKit/CmsKitInstallerPipelineBuilder.cs @@ -3,22 +3,21 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.DependencyInjection; using Volo.Abp.Studio.ModuleInstalling; -namespace Volo.Abp.CmsKit +namespace Volo.Abp.CmsKit; + +[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] +[ExposeServices(typeof(IModuleInstallingPipelineBuilder))] +public class BlobStoringDatabaseInstallerPipelineBuilder : ModuleInstallingPipelineBuilderBase, IModuleInstallingPipelineBuilder, ITransientDependency { - [Dependency(ServiceLifetime.Transient, ReplaceServices = true)] - [ExposeServices(typeof(IModuleInstallingPipelineBuilder))] - public class BlobStoringDatabaseInstallerPipelineBuilder : ModuleInstallingPipelineBuilderBase, IModuleInstallingPipelineBuilder, ITransientDependency + public async Task BuildAsync(ModuleInstallingContext context) { - public async Task BuildAsync(ModuleInstallingContext context) - { - context.AddEfCoreConfigurationMethodDeclaration( - new EfCoreConfigurationMethodDeclaration( - "Volo.CmsKit.EntityFrameworkCore", - "ConfigureCmsKit" - ) - ); - - return GetBasePipeline(context); - } + context.AddEfCoreConfigurationMethodDeclaration( + new EfCoreConfigurationMethodDeclaration( + "Volo.CmsKit.EntityFrameworkCore", + "ConfigureCmsKit" + ) + ); + + return GetBasePipeline(context); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogFeatureRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogFeatureRepository.cs index 3bfebe1626..45253b3991 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogFeatureRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogFeatureRepository.cs @@ -9,31 +9,30 @@ using Volo.Abp.MongoDB; using Volo.CmsKit.Blogs; using MongoDB.Driver; -namespace Volo.CmsKit.MongoDB.Blogs +namespace Volo.CmsKit.MongoDB.Blogs; + +public class MongoBlogFeatureRepository : MongoDbRepository, IBlogFeatureRepository { - public class MongoBlogFeatureRepository : MongoDbRepository , IBlogFeatureRepository + public MongoBlogFeatureRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) { - public MongoBlogFeatureRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } - - public Task FindAsync(Guid blogId, string featureName) - { - return base.FindAsync(x => x.BlogId == blogId && x.FeatureName == featureName); - } + } - public virtual async Task> GetListAsync(Guid blogId) - { - return await (await GetMongoQueryableAsync()) - .Where(x => x.BlogId == blogId) - .ToListAsync(); - } + public Task FindAsync(Guid blogId, string featureName) + { + return base.FindAsync(x => x.BlogId == blogId && x.FeatureName == featureName); + } - public virtual async Task> GetListAsync(Guid blogId, List featureNames) - { - return await (await GetMongoQueryableAsync()) - .Where(x => x.BlogId == blogId && featureNames.Contains(x.FeatureName)) + public virtual async Task> GetListAsync(Guid blogId) + { + return await (await GetMongoQueryableAsync()) + .Where(x => x.BlogId == blogId) .ToListAsync(); - } + } + + public virtual async Task> GetListAsync(Guid blogId, List featureNames) + { + return await (await GetMongoQueryableAsync()) + .Where(x => x.BlogId == blogId && featureNames.Contains(x.FeatureName)) + .ToListAsync(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs index 48f23e7ebd..f52dc3add4 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs @@ -13,91 +13,90 @@ using Volo.Abp.MongoDB; using Volo.CmsKit.Blogs; using Volo.CmsKit.Users; -namespace Volo.CmsKit.MongoDB.Blogs +namespace Volo.CmsKit.MongoDB.Blogs; + +public class MongoBlogPostRepository : MongoDbRepository, IBlogPostRepository { - public class MongoBlogPostRepository : MongoDbRepository, IBlogPostRepository + public MongoBlogPostRepository(IMongoDbContextProvider dbContextProvider) : base( + dbContextProvider) { - public MongoBlogPostRepository(IMongoDbContextProvider dbContextProvider) : base( - dbContextProvider) - { - } - - public virtual async Task GetBySlugAsync(Guid blogId, [NotNull] string slug, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(slug, nameof(slug)); - - var token = GetCancellationToken(cancellationToken); - - var blogPost = await GetAsync(x => - x.BlogId == blogId && - x.Slug.ToLower() == slug, - cancellationToken: token); - - blogPost.Author = await (await GetMongoQueryableAsync(token)).FirstOrDefaultAsync(x => x.Id == blogPost.AuthorId, token); - - return blogPost; - } - - public virtual async Task GetCountAsync( - string filter = null, - Guid? blogId = null, - CancellationToken cancellationToken = default) - { - var token = GetCancellationToken(cancellationToken); - - return await (await GetMongoQueryableAsync(token)) - .WhereIf>(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)) - .WhereIf>(blogId.HasValue, x => x.BlogId == blogId) - .CountAsync(GetCancellationToken(cancellationToken)); - } - - public virtual async Task> GetListAsync( - string filter = null, - Guid? blogId = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - string sorting = null, - CancellationToken cancellationToken = default) - { - var token = GetCancellationToken(cancellationToken); - var dbContext = await GetDbContextAsync(token); - var blogPostQueryable = await GetQueryableAsync(); - - var usersQueryable = dbContext.Collection().AsQueryable(); - - var queryable = blogPostQueryable - .WhereIf(blogId.HasValue, x => x.BlogId == blogId) - .WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)); - - queryable = queryable.OrderBy(sorting.IsNullOrEmpty() ? $"{nameof(BlogPost.CreationTime)} desc" : sorting); - - var combinedQueryable = queryable - .Join( - usersQueryable, - o => o.AuthorId, - i => i.Id, - (blogPost, user) => new { blogPost, user }) - .Skip(skipCount) - .Take(maxResultCount); - - var combinedResult = await AsyncExecuter.ToListAsync(combinedQueryable, GetCancellationToken(cancellationToken)); - - return combinedResult.Select(s => - { - s.blogPost.Author = s.user; - return s.blogPost; - }).ToList(); - } - - public virtual async Task SlugExistsAsync(Guid blogId, [NotNull] string slug, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(slug, nameof(slug)); - - var token = GetCancellationToken(cancellationToken); - var queryable = await GetMongoQueryableAsync(token); - return await queryable.AnyAsync(x => x.BlogId == blogId && x.Slug.ToLower() == slug, token); - } + } + + public virtual async Task GetBySlugAsync(Guid blogId, [NotNull] string slug, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); + + var token = GetCancellationToken(cancellationToken); + + var blogPost = await GetAsync(x => + x.BlogId == blogId && + x.Slug.ToLower() == slug, + cancellationToken: token); + + blogPost.Author = await (await GetMongoQueryableAsync(token)).FirstOrDefaultAsync(x => x.Id == blogPost.AuthorId, token); + + return blogPost; + } + + public virtual async Task GetCountAsync( + string filter = null, + Guid? blogId = null, + CancellationToken cancellationToken = default) + { + var token = GetCancellationToken(cancellationToken); + + return await (await GetMongoQueryableAsync(token)) + .WhereIf>(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)) + .WhereIf>(blogId.HasValue, x => x.BlogId == blogId) + .CountAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task> GetListAsync( + string filter = null, + Guid? blogId = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + string sorting = null, + CancellationToken cancellationToken = default) + { + var token = GetCancellationToken(cancellationToken); + var dbContext = await GetDbContextAsync(token); + var blogPostQueryable = await GetQueryableAsync(); + + var usersQueryable = dbContext.Collection().AsQueryable(); + + var queryable = blogPostQueryable + .WhereIf(blogId.HasValue, x => x.BlogId == blogId) + .WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)); + + queryable = queryable.OrderBy(sorting.IsNullOrEmpty() ? $"{nameof(BlogPost.CreationTime)} desc" : sorting); + + var combinedQueryable = queryable + .Join( + usersQueryable, + o => o.AuthorId, + i => i.Id, + (blogPost, user) => new { blogPost, user }) + .Skip(skipCount) + .Take(maxResultCount); + + var combinedResult = await AsyncExecuter.ToListAsync(combinedQueryable, GetCancellationToken(cancellationToken)); + + return combinedResult.Select(s => + { + s.blogPost.Author = s.user; + return s.blogPost; + }).ToList(); + } + + public virtual async Task SlugExistsAsync(Guid blogId, [NotNull] string slug, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); + + var token = GetCancellationToken(cancellationToken); + var queryable = await GetMongoQueryableAsync(token); + return await queryable.AnyAsync(x => x.BlogId == blogId && x.Slug.ToLower() == slug, token); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs index 1c498f9f9c..00d12a0246 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs @@ -12,62 +12,61 @@ using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.MongoDB.Blogs +namespace Volo.CmsKit.MongoDB.Blogs; + +public class MongoBlogRepository : MongoDbRepository, IBlogRepository { - public class MongoBlogRepository : MongoDbRepository, IBlogRepository + public MongoBlogRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public virtual async Task ExistsAsync(Guid id, CancellationToken cancellationToken = default) + { + var token = GetCancellationToken(cancellationToken); + return await (await GetMongoQueryableAsync(token)).AnyAsync(x => x.Id == id, token); + } + + public virtual async Task SlugExistsAsync(string slug, CancellationToken cancellationToken = default) + { + var token = GetCancellationToken(cancellationToken); + return await (await GetMongoQueryableAsync(token)).AnyAsync(x => x.Slug == slug, token); + } + + public virtual async Task> GetListAsync( + string filter = null, + string sorting = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + CancellationToken cancellationToken = default) { - public MongoBlogRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } + var token = GetCancellationToken(cancellationToken); - public virtual async Task ExistsAsync(Guid id, CancellationToken cancellationToken = default) - { - var token = GetCancellationToken(cancellationToken); - return await (await GetMongoQueryableAsync(token)).AnyAsync(x => x.Id == id, token); - } + var query = await GetListQueryAsync(filter, token); - public virtual async Task SlugExistsAsync(string slug, CancellationToken cancellationToken = default) - { - var token = GetCancellationToken(cancellationToken); - return await (await GetMongoQueryableAsync(token)).AnyAsync(x => x.Slug == slug, token); - } + return await query.OrderBy(sorting.IsNullOrEmpty() ? "creationTime desc" : sorting) + .As>() + .PageBy>(skipCount, maxResultCount) + .ToListAsync(token); + } - public virtual async Task> GetListAsync( - string filter = null, - string sorting = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - CancellationToken cancellationToken = default) - { - var token = GetCancellationToken(cancellationToken); - - var query = await GetListQueryAsync(filter, token); - - return await query.OrderBy(sorting.IsNullOrEmpty() ? "creationTime desc" : sorting) - .As>() - .PageBy>(skipCount, maxResultCount) - .ToListAsync(token); - } + public virtual async Task GetCountAsync(string filter = null, CancellationToken cancellationToken = default) + { + var token = GetCancellationToken(cancellationToken); - public virtual async Task GetCountAsync(string filter = null, CancellationToken cancellationToken = default) - { - var token = GetCancellationToken(cancellationToken); + var query = await GetListQueryAsync(filter, token); - var query = await GetListQueryAsync(filter, token); + return await query.As>().LongCountAsync(token); + } - return await query.As>().LongCountAsync(token); - } + public virtual Task GetBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); + return GetAsync(x => x.Slug == slug, cancellationToken: cancellationToken); + } - public virtual Task GetBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(slug, nameof(slug)); - return GetAsync(x => x.Slug == slug, cancellationToken: cancellationToken); - } - - protected virtual async Task> GetListQueryAsync(string filter = null, CancellationToken cancellationToken = default) - { - return (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))) - .WhereIf(!filter.IsNullOrWhiteSpace(), b => b.Name.Contains(filter)); - } + protected virtual async Task> GetListQueryAsync(string filter = null, CancellationToken cancellationToken = default) + { + return (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))) + .WhereIf(!filter.IsNullOrWhiteSpace(), b => b.Name.Contains(filter)); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContext.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContext.cs index d1fca18b18..8aaef9ab35 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContext.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContext.cs @@ -12,40 +12,39 @@ using Volo.CmsKit.Tags; using Volo.CmsKit.Users; using Tag = Volo.CmsKit.Tags.Tag; -namespace Volo.CmsKit.MongoDB +namespace Volo.CmsKit.MongoDB; + +[ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] +public class CmsKitMongoDbContext : AbpMongoDbContext, ICmsKitMongoDbContext { - [ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] - public class CmsKitMongoDbContext : AbpMongoDbContext, ICmsKitMongoDbContext - { - public IMongoCollection Comments => Collection(); + public IMongoCollection Comments => Collection(); + + public IMongoCollection UserReactions => Collection(); - public IMongoCollection UserReactions => Collection(); + public IMongoCollection CmsUsers => Collection(); - public IMongoCollection CmsUsers => Collection(); + public IMongoCollection Ratings => Collection(); - public IMongoCollection Ratings => Collection(); - - public IMongoCollection Tags => Collection(); - - public IMongoCollection EntityTags => Collection(); - - public IMongoCollection Pages => Collection(); + public IMongoCollection Tags => Collection(); - public IMongoCollection Blogs => Collection(); + public IMongoCollection EntityTags => Collection(); - public IMongoCollection BlogPosts => Collection(); + public IMongoCollection Pages => Collection(); - public IMongoCollection BlogFeatures => Collection(); + public IMongoCollection Blogs => Collection(); - public IMongoCollection MediaDescriptors => Collection(); + public IMongoCollection BlogPosts => Collection(); - public IMongoCollection MenuItems => Collection(); + public IMongoCollection BlogFeatures => Collection(); - protected override void CreateModel(IMongoModelBuilder modelBuilder) - { - base.CreateModel(modelBuilder); + public IMongoCollection MediaDescriptors => Collection(); + + public IMongoCollection MenuItems => Collection(); + + protected override void CreateModel(IMongoModelBuilder modelBuilder) + { + base.CreateModel(modelBuilder); - modelBuilder.ConfigureCmsKit(); - } + modelBuilder.ConfigureCmsKit(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContextExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContextExtensions.cs index a7dbbda5c4..daeb68af6c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContextExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContextExtensions.cs @@ -10,74 +10,73 @@ using Volo.CmsKit.Reactions; using Volo.CmsKit.Tags; using Volo.CmsKit.Users; -namespace Volo.CmsKit.MongoDB +namespace Volo.CmsKit.MongoDB; + +public static class CmsKitMongoDbContextExtensions { - public static class CmsKitMongoDbContextExtensions + public static void ConfigureCmsKit( + this IMongoModelBuilder builder) { - public static void ConfigureCmsKit( - this IMongoModelBuilder builder) + Check.NotNull(builder, nameof(builder)); + + builder.Entity(x => { - Check.NotNull(builder, nameof(builder)); + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Users"; + }); - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Users"; - }); + builder.Entity(x => + { + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "UserReactions"; + }); - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "UserReactions"; - }); + builder.Entity(x => + { + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Comments"; + }); - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Comments"; - }); - - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Ratings"; - }); - - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Tags"; - }); - - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "EntityTags"; - }); - - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Pages"; - }); + builder.Entity(x => + { + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Ratings"; + }); - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Blogs"; - }); + builder.Entity(x => + { + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Tags"; + }); - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "BlogPosts"; - }); + builder.Entity(x => + { + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "EntityTags"; + }); - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "BlogFeatures"; - }); - - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "MediaDescriptors"; - }); + builder.Entity(x => + { + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Pages"; + }); - builder.Entity(x => - { - x.CollectionName = CmsKitDbProperties.DbTablePrefix + "MenuItems"; - }); - } + builder.Entity(x => + { + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "Blogs"; + }); + + builder.Entity(x => + { + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "BlogPosts"; + }); + + builder.Entity(x => + { + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "BlogFeatures"; + }); + + builder.Entity(x => + { + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "MediaDescriptors"; + }); + + builder.Entity(x => + { + x.CollectionName = CmsKitDbProperties.DbTablePrefix + "MenuItems"; + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbModule.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbModule.cs index e3e9c32275..caf5580a92 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbModule.cs @@ -21,31 +21,30 @@ using Volo.CmsKit.Reactions; using Volo.CmsKit.Tags; using Volo.CmsKit.Users; -namespace Volo.CmsKit.MongoDB +namespace Volo.CmsKit.MongoDB; + +[DependsOn( + typeof(CmsKitDomainModule), + typeof(AbpUsersMongoDbModule), + typeof(AbpMongoDbModule) + )] +public class CmsKitMongoDbModule : AbpModule { - [DependsOn( - typeof(CmsKitDomainModule), - typeof(AbpUsersMongoDbModule), - typeof(AbpMongoDbModule) - )] - public class CmsKitMongoDbModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + context.Services.AddMongoDbContext(options => { - context.Services.AddMongoDbContext(options => - { - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - }); - } + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs index c15bb31a7f..b948f360d9 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs @@ -13,189 +13,187 @@ using Volo.Abp.MongoDB; using Volo.CmsKit.Comments; using Volo.CmsKit.Users; -namespace Volo.CmsKit.MongoDB.Comments +namespace Volo.CmsKit.MongoDB.Comments; + +public class MongoCommentRepository : MongoDbRepository, ICommentRepository { - public class MongoCommentRepository : MongoDbRepository, ICommentRepository + public MongoCommentRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) { - public MongoCommentRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } + } - public virtual async Task GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default) - { - var query = from comment in (await GetMongoQueryableAsync(cancellationToken)) - join user in (await GetDbContextAsync(cancellationToken)).CmsUsers on comment.CreatorId equals user.Id - where id == comment.Id - select new - { - Comment = comment, - Author = user - }; - - var commentWithAuthor = await query.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); - - if (commentWithAuthor == null) - { - throw new EntityNotFoundException(typeof(Comment), id); - } - - return new CommentWithAuthorQueryResultItem() - { - Comment = commentWithAuthor.Comment, - Author = commentWithAuthor.Author - }; - } + public virtual async Task GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default) + { + var query = from comment in (await GetMongoQueryableAsync(cancellationToken)) + join user in (await GetDbContextAsync(cancellationToken)).CmsUsers on comment.CreatorId equals user.Id + where id == comment.Id + select new { + Comment = comment, + Author = user + }; - public virtual async Task> GetListAsync( - string filter = null, - string entityType = null, - Guid? repliedCommentId = null, - string authorUsername = null, - DateTime? creationStartDate = null, - DateTime? creationEndDate = null, - string sorting = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - CancellationToken cancellationToken = default - ) - { - var token = GetCancellationToken(cancellationToken); - var query = await GetListQueryAsync( - filter, - entityType, - repliedCommentId, - authorUsername, - creationStartDate, - creationEndDate, - token); - - var comments = await query.OrderBy(sorting.IsNullOrEmpty() ? "creationTime desc" : sorting) - .As>() - .PageBy>(skipCount, maxResultCount) - .ToListAsync(token); - - var commentIds = comments.Select(x => x.Id).ToList(); - - var authorsQuery = from comment in (await GetMongoQueryableAsync(token)) - join user in (await GetDbContextAsync(token)).CmsUsers on comment.CreatorId equals user.Id - where commentIds.Contains(comment.Id) - orderby comment.CreationTime - select user; - - var authors = await ApplyDataFilters, CmsUser>(authorsQuery).ToListAsync(token); - - return comments - .Select( - comment => - new CommentWithAuthorQueryResultItem - { - Comment = comment, - Author = authors.FirstOrDefault(a => a.Id == comment.CreatorId) - }).ToList(); - } + var commentWithAuthor = await query.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); - public virtual async Task GetCountAsync( - string text = null, - string entityType = null, - Guid? repliedCommentId = null, - string authorUsername = null, - DateTime? creationStartDate = null, - DateTime? creationEndDate = null, - CancellationToken cancellationToken = default - ) + if (commentWithAuthor == null) { - var query = await GetListQueryAsync( - text, - entityType, - repliedCommentId, - authorUsername, - creationStartDate, - creationEndDate, - cancellationToken); - - return await query.As>() - .LongCountAsync(GetCancellationToken(cancellationToken)); + throw new EntityNotFoundException(typeof(Comment), id); } - public virtual async Task> GetListWithAuthorsAsync( - string entityType, - string entityId, - CancellationToken cancellationToken = default) + return new CommentWithAuthorQueryResultItem() { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - - var authorsQuery = from comment in (await GetMongoQueryableAsync(cancellationToken)) - join user in (await GetDbContextAsync(cancellationToken)).CmsUsers on comment.CreatorId equals user.Id - where entityType == comment.EntityType && entityId == comment.EntityId - orderby comment.CreationTime - select user; - - var authors = await ApplyDataFilters, CmsUser>(authorsQuery).ToListAsync(GetCancellationToken(cancellationToken)); - - var comments = await (await GetMongoQueryableAsync(cancellationToken)) - .Where(c => c.EntityId == entityId && c.EntityType == entityType) - .OrderBy(c => c.CreationTime) - .ToListAsync(GetCancellationToken(cancellationToken)); - - return comments - .Select( - comment => - new CommentWithAuthorQueryResultItem - { - Comment = comment, - Author = authors.FirstOrDefault(a => a.Id == comment.CreatorId) - }).ToList(); - } + Comment = commentWithAuthor.Comment, + Author = commentWithAuthor.Author + }; + } - public virtual async Task DeleteWithRepliesAsync( - Comment comment, - CancellationToken cancellationToken = default) - { - var replies = await (await GetMongoQueryableAsync(cancellationToken)) - .Where(x => x.RepliedCommentId == comment.Id) - .ToListAsync(GetCancellationToken(cancellationToken)); + public virtual async Task> GetListAsync( + string filter = null, + string entityType = null, + Guid? repliedCommentId = null, + string authorUsername = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + string sorting = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + CancellationToken cancellationToken = default + ) + { + var token = GetCancellationToken(cancellationToken); + var query = await GetListQueryAsync( + filter, + entityType, + repliedCommentId, + authorUsername, + creationStartDate, + creationEndDate, + token); + + var comments = await query.OrderBy(sorting.IsNullOrEmpty() ? "creationTime desc" : sorting) + .As>() + .PageBy>(skipCount, maxResultCount) + .ToListAsync(token); + + var commentIds = comments.Select(x => x.Id).ToList(); + + var authorsQuery = from comment in (await GetMongoQueryableAsync(token)) + join user in (await GetDbContextAsync(token)).CmsUsers on comment.CreatorId equals user.Id + where commentIds.Contains(comment.Id) + orderby comment.CreationTime + select user; + + var authors = await ApplyDataFilters, CmsUser>(authorsQuery).ToListAsync(token); + + return comments + .Select( + comment => + new CommentWithAuthorQueryResultItem + { + Comment = comment, + Author = authors.FirstOrDefault(a => a.Id == comment.CreatorId) + }).ToList(); + } + public virtual async Task GetCountAsync( + string text = null, + string entityType = null, + Guid? repliedCommentId = null, + string authorUsername = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + CancellationToken cancellationToken = default + ) + { + var query = await GetListQueryAsync( + text, + entityType, + repliedCommentId, + authorUsername, + creationStartDate, + creationEndDate, + cancellationToken); + + return await query.As>() + .LongCountAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task> GetListWithAuthorsAsync( + string entityType, + string entityId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + + var authorsQuery = from comment in (await GetMongoQueryableAsync(cancellationToken)) + join user in (await GetDbContextAsync(cancellationToken)).CmsUsers on comment.CreatorId equals user.Id + where entityType == comment.EntityType && entityId == comment.EntityId + orderby comment.CreationTime + select user; + + var authors = await ApplyDataFilters, CmsUser>(authorsQuery).ToListAsync(GetCancellationToken(cancellationToken)); + + var comments = await (await GetMongoQueryableAsync(cancellationToken)) + .Where(c => c.EntityId == entityId && c.EntityType == entityType) + .OrderBy(c => c.CreationTime) + .ToListAsync(GetCancellationToken(cancellationToken)); + + return comments + .Select( + comment => + new CommentWithAuthorQueryResultItem + { + Comment = comment, + Author = authors.FirstOrDefault(a => a.Id == comment.CreatorId) + }).ToList(); + } + + public virtual async Task DeleteWithRepliesAsync( + Comment comment, + CancellationToken cancellationToken = default) + { + var replies = await (await GetMongoQueryableAsync(cancellationToken)) + .Where(x => x.RepliedCommentId == comment.Id) + .ToListAsync(GetCancellationToken(cancellationToken)); + + await base.DeleteAsync( + comment, + cancellationToken: GetCancellationToken(cancellationToken) + ); + + foreach (var reply in replies) + { await base.DeleteAsync( - comment, + reply, cancellationToken: GetCancellationToken(cancellationToken) ); - - foreach (var reply in replies) - { - await base.DeleteAsync( - reply, - cancellationToken: GetCancellationToken(cancellationToken) - ); - } } + } - protected virtual async Task> GetListQueryAsync( - string filter = null, - string entityType = null, - Guid? repliedCommentId = null, - string authorUsername = null, - DateTime? creationStartDate = null, - DateTime? creationEndDate = null, - CancellationToken cancellationToken = default - ) - { - var queryable = await GetMongoQueryableAsync(cancellationToken); - - if (!string.IsNullOrEmpty(authorUsername)) - { - var author = await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(x => x.UserName == authorUsername, cancellationToken: cancellationToken); + protected virtual async Task> GetListQueryAsync( + string filter = null, + string entityType = null, + Guid? repliedCommentId = null, + string authorUsername = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + CancellationToken cancellationToken = default + ) + { + var queryable = await GetMongoQueryableAsync(cancellationToken); - var authorId = author?.Id ?? Guid.Empty; + if (!string.IsNullOrEmpty(authorUsername)) + { + var author = await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(x => x.UserName == authorUsername, cancellationToken: cancellationToken); - queryable = queryable.Where(x => x.CreatorId == authorId); - } + var authorId = author?.Id ?? Guid.Empty; - return queryable.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter)) - .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType == entityType) - .WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId) - .WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate) - .WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate); + queryable = queryable.Where(x => x.CreatorId == authorId); } + + return queryable.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter)) + .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType == entityType) + .WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId) + .WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate) + .WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/ICmsKitMongoDbContext.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/ICmsKitMongoDbContext.cs index 9e71b4a72e..40977c6a90 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/ICmsKitMongoDbContext.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/ICmsKitMongoDbContext.cs @@ -12,33 +12,32 @@ using Volo.CmsKit.Tags; using Volo.CmsKit.Users; using Tag = Volo.CmsKit.Tags.Tag; -namespace Volo.CmsKit.MongoDB +namespace Volo.CmsKit.MongoDB; + +[ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] +public interface ICmsKitMongoDbContext : IAbpMongoDbContext { - [ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] - public interface ICmsKitMongoDbContext : IAbpMongoDbContext - { - IMongoCollection UserReactions { get; } + IMongoCollection UserReactions { get; } + + IMongoCollection Comments { get; } - IMongoCollection Comments { get; } + IMongoCollection CmsUsers { get; } - IMongoCollection CmsUsers { get; } + IMongoCollection Ratings { get; } - IMongoCollection Ratings { get; } + IMongoCollection Tags { get; } - IMongoCollection Tags { get; } + IMongoCollection EntityTags { get; } - IMongoCollection EntityTags { get; } + IMongoCollection Pages { get; } - IMongoCollection Pages { get; } + IMongoCollection Blogs { get; } - IMongoCollection Blogs { get; } + IMongoCollection BlogPosts { get; } - IMongoCollection BlogPosts { get; } + IMongoCollection BlogFeatures { get; } - IMongoCollection BlogFeatures { get; } - - IMongoCollection MediaDescriptors { get; } + IMongoCollection MediaDescriptors { get; } - IMongoCollection MenuItems { get; } - } + IMongoCollection MenuItems { get; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/MediaDescriptors/MongoMediaDescriptorRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/MediaDescriptors/MongoMediaDescriptorRepository.cs index 0d656eb0dd..f058ab5c5d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/MediaDescriptors/MongoMediaDescriptorRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/MediaDescriptors/MongoMediaDescriptorRepository.cs @@ -3,12 +3,11 @@ using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using Volo.CmsKit.MediaDescriptors; -namespace Volo.CmsKit.MongoDB.MediaDescriptors +namespace Volo.CmsKit.MongoDB.MediaDescriptors; + +public class MongoMediaDescriptorRepository : MongoDbRepository, IMediaDescriptorRepository { - public class MongoMediaDescriptorRepository : MongoDbRepository, IMediaDescriptorRepository + public MongoMediaDescriptorRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) { - public MongoMediaDescriptorRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Menus/MongoMenuItemRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Menus/MongoMenuItemRepository.cs index d68923572f..259ac9c92a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Menus/MongoMenuItemRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Menus/MongoMenuItemRepository.cs @@ -10,12 +10,11 @@ using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using Volo.CmsKit.Menus; -namespace Volo.CmsKit.MongoDB.Menus +namespace Volo.CmsKit.MongoDB.Menus; + +public class MongoMenuItemRepository : MongoDbRepository, IMenuItemRepository { - public class MongoMenuItemRepository : MongoDbRepository, IMenuItemRepository + public MongoMenuItemRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) { - public MongoMenuItemRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs index bbe9ea8ae7..85b596ff1b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs @@ -12,66 +12,65 @@ using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using Volo.CmsKit.Pages; -namespace Volo.CmsKit.MongoDB.Pages +namespace Volo.CmsKit.MongoDB.Pages; + +public class MongoPageRepository : MongoDbRepository, IPageRepository { - public class MongoPageRepository : MongoDbRepository, IPageRepository + public MongoPageRepository(IMongoDbContextProvider dbContextProvider) : base( + dbContextProvider) { - public MongoPageRepository(IMongoDbContextProvider dbContextProvider) : base( - dbContextProvider) - { - } + } - public virtual async Task GetCountAsync(string filter = null, - CancellationToken cancellationToken = default) - { - var cancellation = GetCancellationToken(cancellationToken); + public virtual async Task GetCountAsync(string filter = null, + CancellationToken cancellationToken = default) + { + var cancellation = GetCancellationToken(cancellationToken); - return await (await GetMongoQueryableAsync(cancellation)) - .WhereIf>( - !filter.IsNullOrWhiteSpace(), - u => - u.Title.Contains(filter) - ).CountAsync(cancellation); - } + return await (await GetMongoQueryableAsync(cancellation)) + .WhereIf>( + !filter.IsNullOrWhiteSpace(), + u => + u.Title.Contains(filter) + ).CountAsync(cancellation); + } - public virtual async Task> GetListAsync( - string filter = null, - int maxResultCount = int.MaxValue, - int skipCount = 0, - string sorting = null, - CancellationToken cancellationToken = default) - { - var cancellation = GetCancellationToken(cancellationToken); + public virtual async Task> GetListAsync( + string filter = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + string sorting = null, + CancellationToken cancellationToken = default) + { + var cancellation = GetCancellationToken(cancellationToken); - return await (await GetMongoQueryableAsync(cancellation)) - .WhereIf>( - !filter.IsNullOrWhiteSpace(), - u => - u.Title.Contains(filter) - ) - .OrderBy(sorting.IsNullOrEmpty() ? nameof(Page.Title) : sorting) - .As>() - .PageBy>(skipCount, maxResultCount) - .ToListAsync(cancellation); - } + return await (await GetMongoQueryableAsync(cancellation)) + .WhereIf>( + !filter.IsNullOrWhiteSpace(), + u => + u.Title.Contains(filter) + ) + .OrderBy(sorting.IsNullOrEmpty() ? nameof(Page.Title) : sorting) + .As>() + .PageBy>(skipCount, maxResultCount) + .ToListAsync(cancellation); + } - public virtual Task GetBySlugAsync([NotNull]string slug, CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(slug, nameof(slug)); - return GetAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken)); - } + public virtual Task GetBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); + return GetAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken)); + } - public virtual Task FindBySlugAsync([NotNull]string slug, CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(slug, nameof(slug)); - return FindAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken)); - } + public virtual Task FindBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); + return FindAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken)); + } - public virtual async Task ExistsAsync([NotNull]string slug, CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(slug, nameof(slug)); - return await (await GetMongoQueryableAsync(cancellationToken)).AnyAsync(x => x.Slug == slug, - GetCancellationToken(cancellationToken)); - } + public virtual async Task ExistsAsync([NotNull] string slug, CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(slug, nameof(slug)); + return await (await GetMongoQueryableAsync(cancellationToken)).AnyAsync(x => x.Slug == slug, + GetCancellationToken(cancellationToken)); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Ratings/MongoRatingRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Ratings/MongoRatingRepository.cs index 32e68245e0..3a18f31719 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Ratings/MongoRatingRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Ratings/MongoRatingRepository.cs @@ -10,49 +10,48 @@ using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using Volo.CmsKit.Ratings; -namespace Volo.CmsKit.MongoDB.Ratings +namespace Volo.CmsKit.MongoDB.Ratings; + +public class MongoRatingRepository : MongoDbRepository, IRatingRepository { - public class MongoRatingRepository : MongoDbRepository, IRatingRepository + public MongoRatingRepository(IMongoDbContextProvider dbContextProvider) : base( + dbContextProvider) + { + } + + public virtual async Task GetCurrentUserRatingAsync(string entityType, string entityId, Guid userId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + + var rating = await (await GetMongoQueryableAsync(cancellationToken)) + .FirstOrDefaultAsync(r => r.EntityType == entityType && r.EntityId == entityId && r.CreatorId == userId, + GetCancellationToken(cancellationToken)); + + return rating; + } + + public virtual async Task> GetGroupedStarCountsAsync(string entityType, + string entityId, CancellationToken cancellationToken = default) { - public MongoRatingRepository(IMongoDbContextProvider dbContextProvider) : base( - dbContextProvider) - { - } - - public virtual async Task GetCurrentUserRatingAsync(string entityType, string entityId, Guid userId, - CancellationToken cancellationToken = default) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - - var rating = await (await GetMongoQueryableAsync(cancellationToken)) - .FirstOrDefaultAsync(r => r.EntityType == entityType && r.EntityId == entityId && r.CreatorId == userId, - GetCancellationToken(cancellationToken)); - - return rating; - } - - public virtual async Task> GetGroupedStarCountsAsync(string entityType, - string entityId, CancellationToken cancellationToken = default) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - - var query = ( - from rating in (await GetMongoQueryableAsync(cancellationToken)) - where rating.EntityType == entityType && rating.EntityId == entityId - group rating by rating.StarCount - into g - select new RatingWithStarCountQueryResultItem - { - StarCount = g.Key, - Count = g.Count() - } - ).OrderByDescending(r => r.StarCount); - - var ratings = await query.ToListAsync(GetCancellationToken(cancellationToken)); - - return ratings; - } + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + + var query = ( + from rating in (await GetMongoQueryableAsync(cancellationToken)) + where rating.EntityType == entityType && rating.EntityId == entityId + group rating by rating.StarCount + into g + select new RatingWithStarCountQueryResultItem + { + StarCount = g.Key, + Count = g.Count() + } + ).OrderByDescending(r => r.StarCount); + + var ratings = await query.ToListAsync(GetCancellationToken(cancellationToken)); + + return ratings; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs index b0a2eca982..7a6cdebea2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs @@ -10,70 +10,69 @@ using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using Volo.CmsKit.Reactions; -namespace Volo.CmsKit.MongoDB.Reactions +namespace Volo.CmsKit.MongoDB.Reactions; + +public class MongoUserReactionRepository : MongoDbRepository, IUserReactionRepository { - public class MongoUserReactionRepository : MongoDbRepository, IUserReactionRepository + public MongoUserReactionRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) { - public MongoUserReactionRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } + } - public virtual async Task FindAsync( - Guid userId, - string entityType, - string entityId, - string reactionName, - CancellationToken cancellationToken = default) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); + public virtual async Task FindAsync( + Guid userId, + string entityType, + string entityId, + string reactionName, + CancellationToken cancellationToken = default) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); - return await (await GetMongoQueryableAsync(cancellationToken)) - .Where(x => - x.CreatorId == userId && - x.EntityType == entityType && - x.EntityId == entityId && - x.ReactionName == reactionName) - .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); - } + return await (await GetMongoQueryableAsync(cancellationToken)) + .Where(x => + x.CreatorId == userId && + x.EntityType == entityType && + x.EntityId == entityId && + x.ReactionName == reactionName) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } - public virtual async Task> GetListForUserAsync( - Guid userId, - string entityType, - string entityId, - CancellationToken cancellationToken = default) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + public virtual async Task> GetListForUserAsync( + Guid userId, + string entityType, + string entityId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - return await (await GetMongoQueryableAsync(cancellationToken)) - .Where(x => - x.CreatorId == userId && - x.EntityType == entityType && - x.EntityId == entityId) - .ToListAsync(GetCancellationToken(cancellationToken)); - } + return await (await GetMongoQueryableAsync(cancellationToken)) + .Where(x => + x.CreatorId == userId && + x.EntityType == entityType && + x.EntityId == entityId) + .ToListAsync(GetCancellationToken(cancellationToken)); + } - public virtual async Task> GetSummariesAsync( - string entityType, - string entityId, - CancellationToken cancellationToken = default) - { - Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); - Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); + public virtual async Task> GetSummariesAsync( + string entityType, + string entityId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); + Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - return await (await GetMongoQueryableAsync(cancellationToken)) - .Where(x => - x.EntityType == entityType && - x.EntityId == entityId) - .GroupBy(x => x.ReactionName) - .Select(g => new ReactionSummaryQueryResultItem - { - ReactionName = g.Key, - Count = g.Count() - }) - .ToListAsync(GetCancellationToken(cancellationToken)); - } + return await (await GetMongoQueryableAsync(cancellationToken)) + .Where(x => + x.EntityType == entityType && + x.EntityId == entityId) + .GroupBy(x => x.ReactionName) + .Select(g => new ReactionSummaryQueryResultItem + { + ReactionName = g.Key, + Count = g.Count() + }) + .ToListAsync(GetCancellationToken(cancellationToken)); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoEntityTagRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoEntityTagRepository.cs index 7ab2fe3a23..e4d6143996 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoEntityTagRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoEntityTagRepository.cs @@ -9,35 +9,34 @@ using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.MongoDB.Tags +namespace Volo.CmsKit.MongoDB.Tags; + +public class MongoEntityTagRepository : MongoDbRepository, IEntityTagRepository { - public class MongoEntityTagRepository : MongoDbRepository, IEntityTagRepository + public MongoEntityTagRepository(IMongoDbContextProvider dbContextProvider) : base( + dbContextProvider) + { + } + + public virtual async Task DeleteManyAsync(Guid[] tagIds, CancellationToken cancellationToken = default) { - public MongoEntityTagRepository(IMongoDbContextProvider dbContextProvider) : base( - dbContextProvider) - { - } + var token = GetCancellationToken(cancellationToken); - public virtual async Task DeleteManyAsync(Guid[] tagIds, CancellationToken cancellationToken = default) - { - var token = GetCancellationToken(cancellationToken); - - var collection = await GetCollectionAsync(token); - await collection.DeleteManyAsync(Builders.Filter.In(x => x.TagId, tagIds), token); - } + var collection = await GetCollectionAsync(token); + await collection.DeleteManyAsync(Builders.Filter.In(x => x.TagId, tagIds), token); + } - public virtual Task FindAsync( - [NotNull] Guid tagId, - [NotNull] string entityId, - [CanBeNull] Guid? tenantId, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(entityId, nameof(entityId)); - return base.FindAsync(x => - x.TagId == tagId && - x.EntityId == entityId && - x.TenantId == tenantId, - cancellationToken: GetCancellationToken(cancellationToken)); - } + public virtual Task FindAsync( + [NotNull] Guid tagId, + [NotNull] string entityId, + [CanBeNull] Guid? tenantId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(entityId, nameof(entityId)); + return base.FindAsync(x => + x.TagId == tagId && + x.EntityId == entityId && + x.TenantId == tenantId, + cancellationToken: GetCancellationToken(cancellationToken)); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs index 167c91c4e9..2230c36f19 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs @@ -11,99 +11,98 @@ using Volo.Abp.MongoDB; using Volo.CmsKit.Tags; using Tag = Volo.CmsKit.Tags.Tag; -namespace Volo.CmsKit.MongoDB.Tags +namespace Volo.CmsKit.MongoDB.Tags; + +public class MongoTagRepository : MongoDbRepository, ITagRepository { - public class MongoTagRepository : MongoDbRepository, ITagRepository + public MongoTagRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) { - public MongoTagRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } + } - public async Task AnyAsync( - [NotNull] string entityType, - [NotNull] string name, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(entityType, nameof(entityType)); - Check.NotNullOrEmpty(name, nameof(name)); + public async Task AnyAsync( + [NotNull] string entityType, + [NotNull] string name, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(entityType, nameof(entityType)); + Check.NotNullOrEmpty(name, nameof(name)); + + return await (await GetMongoQueryableAsync(cancellationToken)) + .AnyAsync(x => + x.EntityType == entityType && + x.Name == name, + GetCancellationToken(cancellationToken)); + } - return await (await GetMongoQueryableAsync(cancellationToken)) - .AnyAsync(x => - x.EntityType == entityType && - x.Name == name, - GetCancellationToken(cancellationToken)); - } + public Task GetAsync( + [NotNull] string entityType, + [NotNull] string name, + CancellationToken cancellationToken = default) + { + return GetAsync(x => + x.EntityType == entityType && + x.Name == name, + cancellationToken: GetCancellationToken(cancellationToken)); + } - public Task GetAsync( - [NotNull] string entityType, - [NotNull] string name, - CancellationToken cancellationToken = default) - { - return GetAsync(x => - x.EntityType == entityType && - x.Name == name, - cancellationToken: GetCancellationToken(cancellationToken)); - } + public Task FindAsync( + [NotNull] string entityType, + [NotNull] string name, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(entityType, nameof(entityType)); + Check.NotNullOrEmpty(name, nameof(name)); - public Task FindAsync( - [NotNull] string entityType, - [NotNull] string name, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(entityType, nameof(entityType)); - Check.NotNullOrEmpty(name, nameof(name)); + return FindAsync(x => + x.EntityType == entityType && + x.Name == name, + cancellationToken: GetCancellationToken(cancellationToken)); + } - return FindAsync(x => - x.EntityType == entityType && - x.Name == name, - cancellationToken: GetCancellationToken(cancellationToken)); - } + public virtual async Task> GetAllRelatedTagsAsync( + [NotNull] string entityType, + [NotNull] string entityId, + CancellationToken cancellationToken = default) + { + Check.NotNullOrEmpty(entityType, nameof(entityType)); + Check.NotNullOrEmpty(entityId, nameof(entityId)); - public virtual async Task> GetAllRelatedTagsAsync( - [NotNull] string entityType, - [NotNull] string entityId, - CancellationToken cancellationToken = default) - { - Check.NotNullOrEmpty(entityType, nameof(entityType)); - Check.NotNullOrEmpty(entityId, nameof(entityId)); + var entityTagIds = await (await GetMongoQueryableAsync(cancellationToken)) + .Where(q => q.EntityId == entityId) + .Select(q => q.TagId) + .ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); - var entityTagIds = await (await GetMongoQueryableAsync(cancellationToken)) - .Where(q => q.EntityId == entityId) - .Select(q => q.TagId) - .ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); + var query = (await GetMongoQueryableAsync(cancellationToken)) + .Where(x => + x.EntityType == entityType && + entityTagIds.Contains(x.Id)); - var query = (await GetMongoQueryableAsync(cancellationToken)) - .Where(x => - x.EntityType == entityType && - entityTagIds.Contains(x.Id)); + var result = await query.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); + return result; + } - var result = await query.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); - return result; - } + public async Task> GetListAsync(string filter) + { + return await (await GetQueryableByFilterAsync(filter)).ToListAsync(); + } - public async Task> GetListAsync(string filter) - { - return await (await GetQueryableByFilterAsync(filter)).ToListAsync(); - } + public async Task GetCountAsync(string filter) + { + return await (await GetQueryableByFilterAsync(filter)).CountAsync(); + } - public async Task GetCountAsync(string filter) - { - return await (await GetQueryableByFilterAsync(filter)).CountAsync(); - } + private async Task> GetQueryableByFilterAsync(string filter) + { + var mongoQueryable = await GetMongoQueryableAsync(); - private async Task> GetQueryableByFilterAsync(string filter) + if (!filter.IsNullOrWhiteSpace()) { - var mongoQueryable = await GetMongoQueryableAsync(); - - if (!filter.IsNullOrWhiteSpace()) - { - mongoQueryable = mongoQueryable.Where(x => - x.Name.ToLower().Contains(filter) || - x.EntityType.ToLower().Contains(filter)); - } - - return mongoQueryable; + mongoQueryable = mongoQueryable.Where(x => + x.Name.ToLower().Contains(filter) || + x.EntityType.ToLower().Contains(filter)); } + + return mongoQueryable; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Users/MongoCmsUserRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Users/MongoCmsUserRepository.cs index 22012e48c0..cfc405d8b6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Users/MongoCmsUserRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Users/MongoCmsUserRepository.cs @@ -2,13 +2,12 @@ using Volo.Abp.Users.MongoDB; using Volo.CmsKit.Users; -namespace Volo.CmsKit.MongoDB.Users +namespace Volo.CmsKit.MongoDB.Users; + +public class MongoCmsUserRepository : MongoUserRepositoryBase, ICmsUserRepository { - public class MongoCmsUserRepository : MongoUserRepositoryBase, ICmsUserRepository + public MongoCmsUserRepository(IMongoDbContextProvider dbContextProvider) + : base(dbContextProvider) { - public MongoCmsUserRepository(IMongoDbContextProvider dbContextProvider) - : base(dbContextProvider) - { - } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs index b2b3cc88e0..8c6a6a01e9 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs @@ -2,23 +2,22 @@ using Volo.Abp.Application.Dtos; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Public.Blogs -{ - [Serializable] - public class BlogPostPublicDto : AuditedEntityDto - { - public Guid BlogId { get; set; } +namespace Volo.CmsKit.Public.Blogs; - public string Title { get; set; } +[Serializable] +public class BlogPostPublicDto : AuditedEntityDto +{ + public Guid BlogId { get; set; } - public string Slug { get; set; } + public string Title { get; set; } - public string ShortDescription { get; set; } + public string Slug { get; set; } - public string Content { get; set; } + public string ShortDescription { get; set; } - public Guid? CoverImageMediaId { get; set; } + public string Content { get; set; } - public CmsUserDto Author { get; set; } - } + public Guid? CoverImageMediaId { get; set; } + + public CmsUserDto Author { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/GetBlogFeatureInput.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/GetBlogFeatureInput.cs index 5a95402564..90557ab1d8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/GetBlogFeatureInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/GetBlogFeatureInput.cs @@ -1,11 +1,10 @@ using System; using System.Collections.Generic; -namespace Volo.CmsKit.Public.Blogs +namespace Volo.CmsKit.Public.Blogs; + +[Serializable] +public class GetBlogFeatureInput { - [Serializable] - public class GetBlogFeatureInput - { - public List FeatureNames { get; set; } - } + public List FeatureNames { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/IBlogPostPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/IBlogPostPublicAppService.cs index b74cc70dbf..f561a289cf 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/IBlogPostPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/IBlogPostPublicAppService.cs @@ -3,12 +3,11 @@ using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; -namespace Volo.CmsKit.Public.Blogs +namespace Volo.CmsKit.Public.Blogs; + +public interface IBlogPostPublicAppService : IApplicationService { - public interface IBlogPostPublicAppService : IApplicationService - { - Task> GetListAsync([NotNull] string blogSlug, PagedAndSortedResultRequestDto input); + Task> GetListAsync([NotNull] string blogSlug, PagedAndSortedResultRequestDto input); - Task GetAsync([NotNull] string blogSlug, [NotNull] string blogPostSlug); - } + Task GetAsync([NotNull] string blogSlug, [NotNull] string blogPostSlug); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/CmsKitPublicApplicationContractsModule.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/CmsKitPublicApplicationContractsModule.cs index 52996a1bdd..62d94f6930 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/CmsKitPublicApplicationContractsModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/CmsKitPublicApplicationContractsModule.cs @@ -1,14 +1,13 @@ using Volo.Abp.Modularity; using Volo.Abp.EventBus; -namespace Volo.CmsKit.Public +namespace Volo.CmsKit.Public; + +[DependsOn( + typeof(CmsKitCommonApplicationContractsModule), + typeof(AbpEventBusModule) + )] +public class CmsKitPublicApplicationContractsModule : AbpModule { - [DependsOn( - typeof(CmsKitCommonApplicationContractsModule), - typeof(AbpEventBusModule) - )] - public class CmsKitPublicApplicationContractsModule : AbpModule - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/CmsKitPublicRemoteServiceConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/CmsKitPublicRemoteServiceConsts.cs index 4fe886823e..8f2a42cd53 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/CmsKitPublicRemoteServiceConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/CmsKitPublicRemoteServiceConsts.cs @@ -1,9 +1,8 @@ -namespace Volo.CmsKit.Public +namespace Volo.CmsKit.Public; + +public class CmsKitPublicRemoteServiceConsts { - public class CmsKitPublicRemoteServiceConsts - { - public const string RemoteServiceName = "CmsKitPublic"; + public const string RemoteServiceName = "CmsKitPublic"; - public const string ModuleName = "cms-kit"; - } + public const string ModuleName = "cms-kit"; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CmsUserDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CmsUserDto.cs index 4b79bb7e5e..aaa5d9ab67 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CmsUserDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CmsUserDto.cs @@ -1,16 +1,15 @@ using System; -namespace Volo.CmsKit.Public.Comments +namespace Volo.CmsKit.Public.Comments; + +[Serializable] +public class CmsUserDto { - [Serializable] - public class CmsUserDto - { - public Guid Id { get; set; } + public Guid Id { get; set; } - public string UserName { get; set; } + public string UserName { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public string Surname { get; set; } - } + public string Surname { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentDto.cs index b5b3cbf1d2..654a16ebdb 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentDto.cs @@ -1,27 +1,26 @@ using System; using Volo.Abp.Domain.Entities; -namespace Volo.CmsKit.Public.Comments +namespace Volo.CmsKit.Public.Comments; + +[Serializable] +public class CommentDto : IHasConcurrencyStamp { - [Serializable] - public class CommentDto : IHasConcurrencyStamp - { - public Guid Id { get; set; } + public Guid Id { get; set; } - public string EntityType { get; set; } + public string EntityType { get; set; } - public string EntityId { get; set; } + public string EntityId { get; set; } - public string Text { get; set; } + public string Text { get; set; } - public Guid? RepliedCommentId { get; set; } + public Guid? RepliedCommentId { get; set; } - public Guid CreatorId { get; set; } + public Guid CreatorId { get; set; } - public DateTime CreationTime { get; set; } + public DateTime CreationTime { get; set; } - public CmsUserDto Author { get; set; } //TODO: Should only have AuthorId for the basic dto. see https://docs.abp.io/en/abp/latest/Best-Practices/Application-Services + public CmsUserDto Author { get; set; } //TODO: Should only have AuthorId for the basic dto. see https://docs.abp.io/en/abp/latest/Best-Practices/Application-Services - public string ConcurrencyStamp { get; set; } - } + public string ConcurrencyStamp { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentWithDetailsDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentWithDetailsDto.cs index 453de6752f..621781e198 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentWithDetailsDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CommentWithDetailsDto.cs @@ -2,27 +2,26 @@ using System.Collections.Generic; using Volo.Abp.Domain.Entities; -namespace Volo.CmsKit.Public.Comments +namespace Volo.CmsKit.Public.Comments; + +[Serializable] +public class CommentWithDetailsDto : IHasConcurrencyStamp { - [Serializable] - public class CommentWithDetailsDto : IHasConcurrencyStamp - { - public Guid Id { get; set; } + public Guid Id { get; set; } - public string EntityType { get; set; } + public string EntityType { get; set; } - public string EntityId { get; set; } + public string EntityId { get; set; } - public string Text { get; set; } + public string Text { get; set; } - public Guid CreatorId { get; set; } + public Guid CreatorId { get; set; } - public DateTime CreationTime { get; set; } + public DateTime CreationTime { get; set; } - public List Replies { get; set; } + public List Replies { get; set; } - public CmsUserDto Author { get; set; } + public CmsUserDto Author { get; set; } - public string ConcurrencyStamp { get; set; } - } + public string ConcurrencyStamp { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs index 7f63896652..6ae524f0f2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs @@ -3,15 +3,14 @@ using System.ComponentModel.DataAnnotations; using Volo.Abp.Validation; using Volo.CmsKit.Comments; -namespace Volo.CmsKit.Public.Comments +namespace Volo.CmsKit.Public.Comments; + +[Serializable] +public class CreateCommentInput { - [Serializable] - public class CreateCommentInput - { - [Required] - [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxTextLength))] - public string Text { get; set; } + [Required] + [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxTextLength))] + public string Text { get; set; } - public Guid? RepliedCommentId { get; set; } - } + public Guid? RepliedCommentId { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreatedCommentEvent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreatedCommentEvent.cs index 7db2c10d8b..5b30a5c27d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreatedCommentEvent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreatedCommentEvent.cs @@ -1,11 +1,10 @@ using System; using Volo.Abp.EventBus; -namespace Volo.CmsKit.Public.Comments +namespace Volo.CmsKit.Public.Comments; + +[EventName("Volo.CmsKit.Comments.Created")] +public class CreatedCommentEvent { - [EventName("Volo.CmsKit.Comments.Created")] - public class CreatedCommentEvent - { - public Guid Id { get; set; } - } + public Guid Id { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/ICommentPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/ICommentPublicAppService.cs index 8ac8c92988..279561cc52 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/ICommentPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/ICommentPublicAppService.cs @@ -3,16 +3,15 @@ using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; -namespace Volo.CmsKit.Public.Comments +namespace Volo.CmsKit.Public.Comments; + +public interface ICommentPublicAppService : IApplicationService { - public interface ICommentPublicAppService : IApplicationService - { - Task> GetListAsync(string entityType, string entityId); + Task> GetListAsync(string entityType, string entityId); - Task CreateAsync(string entityType, string entityId, CreateCommentInput input); + Task CreateAsync(string entityType, string entityId, CreateCommentInput input); - Task UpdateAsync(Guid id, UpdateCommentInput input); + Task UpdateAsync(Guid id, UpdateCommentInput input); - Task DeleteAsync(Guid id); - } + Task DeleteAsync(Guid id); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/UpdateCommentInput.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/UpdateCommentInput.cs index 0b60ba8681..7ec1279704 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/UpdateCommentInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/UpdateCommentInput.cs @@ -4,15 +4,14 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Validation; using Volo.CmsKit.Comments; -namespace Volo.CmsKit.Public.Comments +namespace Volo.CmsKit.Public.Comments; + +[Serializable] +public class UpdateCommentInput : IHasConcurrencyStamp { - [Serializable] - public class UpdateCommentInput : IHasConcurrencyStamp - { - [Required] - [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxTextLength))] - public string Text { get; set; } + [Required] + [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxTextLength))] + public string Text { get; set; } - public string ConcurrencyStamp { get; set; } - } + public string ConcurrencyStamp { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Menus/IMenuItemPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Menus/IMenuItemPublicAppService.cs index 0acd43de27..a3ffc5efbf 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Menus/IMenuItemPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Menus/IMenuItemPublicAppService.cs @@ -3,10 +3,9 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.CmsKit.Menus; -namespace Volo.CmsKit.Public.Menus +namespace Volo.CmsKit.Public.Menus; + +public interface IMenuItemPublicAppService : IApplicationService { - public interface IMenuItemPublicAppService : IApplicationService - { - Task> GetListAsync(); - } -} \ No newline at end of file + Task> GetListAsync(); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/IPagePublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/IPagePublicAppService.cs index f81887d360..0b33a91236 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/IPagePublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/IPagePublicAppService.cs @@ -2,10 +2,9 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; -namespace Volo.CmsKit.Public.Pages +namespace Volo.CmsKit.Public.Pages; + +public interface IPagePublicAppService : IApplicationService { - public interface IPagePublicAppService : IApplicationService - { - Task FindBySlugAsync([NotNull] string slug); - } -} \ No newline at end of file + Task FindBySlugAsync([NotNull] string slug); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs index 5f6d984b88..64175d0f18 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs @@ -1,19 +1,18 @@ using System; using Volo.Abp.Application.Dtos; -namespace Volo.CmsKit.Public.Pages +namespace Volo.CmsKit.Public.Pages; + +[Serializable] +public class PageDto : EntityDto { - [Serializable] - public class PageDto : EntityDto - { - public string Title { get; set; } + public string Title { get; set; } - public string Slug { get; set; } + public string Slug { get; set; } - public string Content { get; set; } + public string Content { get; set; } - public string Script { get; set; } + public string Script { get; set; } - public string Style { get; set; } - } -} \ No newline at end of file + public string Style { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/CreateUpdateRatingInput.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/CreateUpdateRatingInput.cs index c3a7fab1f9..995b290a4d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/CreateUpdateRatingInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/CreateUpdateRatingInput.cs @@ -3,13 +3,12 @@ using System.ComponentModel.DataAnnotations; using Volo.Abp.Validation; using Volo.CmsKit.Ratings; -namespace Volo.CmsKit.Public.Ratings +namespace Volo.CmsKit.Public.Ratings; + +[Serializable] +public class CreateUpdateRatingInput { - [Serializable] - public class CreateUpdateRatingInput - { - [Required] - [DynamicRange(typeof(RatingConsts), typeof(int), nameof(RatingConsts.MinStarCount), nameof(RatingConsts.MaxStarCount))] - public short StarCount { get; set; } - } -} \ No newline at end of file + [Required] + [DynamicRange(typeof(RatingConsts), typeof(int), nameof(RatingConsts.MinStarCount), nameof(RatingConsts.MaxStarCount))] + public short StarCount { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/IRatingPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/IRatingPublicAppService.cs index 39d6b01ccb..5486eec262 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/IRatingPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/IRatingPublicAppService.cs @@ -2,14 +2,13 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; -namespace Volo.CmsKit.Public.Ratings +namespace Volo.CmsKit.Public.Ratings; + +public interface IRatingPublicAppService : IApplicationService { - public interface IRatingPublicAppService : IApplicationService - { - Task CreateAsync(string entityType, string entityId, CreateUpdateRatingInput input); + Task CreateAsync(string entityType, string entityId, CreateUpdateRatingInput input); - Task DeleteAsync(string entityType, string entityId); + Task DeleteAsync(string entityType, string entityId); - Task> GetGroupedStarCountsAsync(string entityType, string entityId); - } -} \ No newline at end of file + Task> GetGroupedStarCountsAsync(string entityType, string entityId); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/RatingDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/RatingDto.cs index b7ed97c315..917e703e61 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/RatingDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/RatingDto.cs @@ -1,20 +1,19 @@ using System; -namespace Volo.CmsKit.Public.Ratings +namespace Volo.CmsKit.Public.Ratings; + +[Serializable] +public class RatingDto { - [Serializable] - public class RatingDto - { - public Guid Id { get; set; } + public Guid Id { get; set; } + + public string EntityType { get; set; } + + public string EntityId { get; set; } - public string EntityType { get; set; } + public short StarCount { get; set; } - public string EntityId { get; set; } - - public short StarCount { get; set; } - - public Guid CreatorId { get; set; } + public Guid CreatorId { get; set; } - public DateTime CreationTime { get; set; } - } -} \ No newline at end of file + public DateTime CreationTime { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/RatingWithStarCountDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/RatingWithStarCountDto.cs index 66fa0d1738..6008fd7211 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/RatingWithStarCountDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Ratings/RatingWithStarCountDto.cs @@ -1,14 +1,13 @@ using System; -namespace Volo.CmsKit.Public.Ratings +namespace Volo.CmsKit.Public.Ratings; + +[Serializable] +public class RatingWithStarCountDto { - [Serializable] - public class RatingWithStarCountDto - { - public short StarCount { get; set; } + public short StarCount { get; set; } - public int Count { get; set; } + public int Count { get; set; } - public bool IsSelectedByCurrentUser { get; set; } - } -} \ No newline at end of file + public bool IsSelectedByCurrentUser { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/IReactionPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/IReactionPublicAppService.cs index 8a32d7cc11..d69c53c4ab 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/IReactionPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/IReactionPublicAppService.cs @@ -2,14 +2,13 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; -namespace Volo.CmsKit.Public.Reactions +namespace Volo.CmsKit.Public.Reactions; + +public interface IReactionPublicAppService : IApplicationService { - public interface IReactionPublicAppService : IApplicationService - { - Task> GetForSelectionAsync(string entityType, string entityId); + Task> GetForSelectionAsync(string entityType, string entityId); - Task CreateAsync(string entityType, string entityId, string reaction); + Task CreateAsync(string entityType, string entityId, string reaction); - Task DeleteAsync(string entityType, string entityId, string reaction); - } + Task DeleteAsync(string entityType, string entityId, string reaction); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/ReactionDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/ReactionDto.cs index 23908fa4f6..9dcc22c76b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/ReactionDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/ReactionDto.cs @@ -1,15 +1,14 @@ using System; using JetBrains.Annotations; -namespace Volo.CmsKit.Public.Reactions +namespace Volo.CmsKit.Public.Reactions; + +[Serializable] +public class ReactionDto { - [Serializable] - public class ReactionDto - { - [NotNull] - public string Name { get; set; } + [NotNull] + public string Name { get; set; } - [CanBeNull] - public string DisplayName { get; set; } - } + [CanBeNull] + public string DisplayName { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/ReactionWithSelectionDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/ReactionWithSelectionDto.cs index 71adc4756c..82183a6a79 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/ReactionWithSelectionDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Reactions/ReactionWithSelectionDto.cs @@ -1,11 +1,10 @@ -namespace Volo.CmsKit.Public.Reactions +namespace Volo.CmsKit.Public.Reactions; + +public class ReactionWithSelectionDto { - public class ReactionWithSelectionDto - { - public ReactionDto Reaction { get; set; } + public ReactionDto Reaction { get; set; } - public int Count { get; set; } + public int Count { get; set; } - public bool IsSelectedByCurrentUser { get; set; } - } -} \ No newline at end of file + public bool IsSelectedByCurrentUser { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs index 6ae4a785d6..4160639815 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs @@ -6,41 +6,40 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.Blogs; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.Public.Blogs +namespace Volo.CmsKit.Public.Blogs; + +[RequiresGlobalFeature(typeof(BlogsFeature))] +public class BlogPostPublicAppService : CmsKitPublicAppServiceBase, IBlogPostPublicAppService { - [RequiresGlobalFeature(typeof(BlogsFeature))] - public class BlogPostPublicAppService : CmsKitPublicAppServiceBase, IBlogPostPublicAppService - { - protected IBlogRepository BlogRepository { get; } + protected IBlogRepository BlogRepository { get; } - protected IBlogPostRepository BlogPostRepository { get; } + protected IBlogPostRepository BlogPostRepository { get; } - public BlogPostPublicAppService( - IBlogRepository blogRepository, - IBlogPostRepository blogPostRepository) - { - BlogRepository = blogRepository; - BlogPostRepository = blogPostRepository; - } + public BlogPostPublicAppService( + IBlogRepository blogRepository, + IBlogPostRepository blogPostRepository) + { + BlogRepository = blogRepository; + BlogPostRepository = blogPostRepository; + } - public virtual async Task GetAsync([NotNull] string blogSlug, [NotNull] string blogPostSlug) - { - var blog = await BlogRepository.GetBySlugAsync(blogSlug); + public virtual async Task GetAsync([NotNull] string blogSlug, [NotNull] string blogPostSlug) + { + var blog = await BlogRepository.GetBySlugAsync(blogSlug); - var blogPost = await BlogPostRepository.GetBySlugAsync(blog.Id, blogPostSlug); + var blogPost = await BlogPostRepository.GetBySlugAsync(blog.Id, blogPostSlug); - return ObjectMapper.Map(blogPost); - } + return ObjectMapper.Map(blogPost); + } - public virtual async Task> GetListAsync([NotNull] string blogSlug, PagedAndSortedResultRequestDto input) - { - var blog = await BlogRepository.GetBySlugAsync(blogSlug); + public virtual async Task> GetListAsync([NotNull] string blogSlug, PagedAndSortedResultRequestDto input) + { + var blog = await BlogRepository.GetBySlugAsync(blogSlug); - var blogPosts = await BlogPostRepository.GetListAsync(null, blog.Id, input.MaxResultCount, input.SkipCount, input.Sorting); + var blogPosts = await BlogPostRepository.GetListAsync(null, blog.Id, input.MaxResultCount, input.SkipCount, input.Sorting); - return new PagedResultDto( - await BlogPostRepository.GetCountAsync(blogId: blog.Id), - ObjectMapper.Map, List>(blogPosts)); - } + return new PagedResultDto( + await BlogPostRepository.GetCountAsync(blogId: blog.Id), + ObjectMapper.Map, List>(blogPosts)); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicAppServiceBase.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicAppServiceBase.cs index eb2c185a6d..263bca4b30 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicAppServiceBase.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicAppServiceBase.cs @@ -1,10 +1,9 @@ -namespace Volo.CmsKit.Public +namespace Volo.CmsKit.Public; + +public abstract class CmsKitPublicAppServiceBase : CmsKitAppServiceBase { - public abstract class CmsKitPublicAppServiceBase : CmsKitAppServiceBase + protected CmsKitPublicAppServiceBase() { - protected CmsKitPublicAppServiceBase() - { - ObjectMapperContext = typeof(CmsKitPublicApplicationModule); - } + ObjectMapperContext = typeof(CmsKitPublicApplicationModule); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicApplicationModule.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicApplicationModule.cs index ede4a7ef29..4d7f816081 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicApplicationModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicApplicationModule.cs @@ -3,23 +3,22 @@ using Volo.Abp.AutoMapper; using Volo.Abp.Caching; using Volo.Abp.Modularity; -namespace Volo.CmsKit.Public +namespace Volo.CmsKit.Public; + +[DependsOn( + typeof(CmsKitCommonApplicationModule), + typeof(CmsKitPublicApplicationContractsModule), + typeof(AbpCachingModule) + )] +public class CmsKitPublicApplicationModule : AbpModule { - [DependsOn( - typeof(CmsKitCommonApplicationModule), - typeof(CmsKitPublicApplicationContractsModule), - typeof(AbpCachingModule) - )] - public class CmsKitPublicApplicationModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddAutoMapperObjectMapper(); + context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); - } + Configure(options => + { + options.AddMaps(validate: true); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs index 9d21d603d9..b1fae564d2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs @@ -13,130 +13,129 @@ using Volo.CmsKit.Comments; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Public.Comments +namespace Volo.CmsKit.Public.Comments; + +[RequiresGlobalFeature(typeof(CommentsFeature))] +public class CommentPublicAppService : CmsKitPublicAppServiceBase, ICommentPublicAppService { - [RequiresGlobalFeature(typeof(CommentsFeature))] - public class CommentPublicAppService : CmsKitPublicAppServiceBase, ICommentPublicAppService + protected ICommentRepository CommentRepository { get; } + protected ICmsUserLookupService CmsUserLookupService { get; } + public IDistributedEventBus DistributedEventBus { get; } + protected CommentManager CommentManager { get; } + + public CommentPublicAppService( + ICommentRepository commentRepository, + ICmsUserLookupService cmsUserLookupService, + IDistributedEventBus distributedEventBus, + CommentManager commentManager) { - protected ICommentRepository CommentRepository { get; } - protected ICmsUserLookupService CmsUserLookupService { get; } - public IDistributedEventBus DistributedEventBus { get; } - protected CommentManager CommentManager { get; } - - public CommentPublicAppService( - ICommentRepository commentRepository, - ICmsUserLookupService cmsUserLookupService, - IDistributedEventBus distributedEventBus, - CommentManager commentManager) - { - CommentRepository = commentRepository; - CmsUserLookupService = cmsUserLookupService; - DistributedEventBus = distributedEventBus; - CommentManager = commentManager; - } + CommentRepository = commentRepository; + CmsUserLookupService = cmsUserLookupService; + DistributedEventBus = distributedEventBus; + CommentManager = commentManager; + } - public virtual async Task> GetListAsync(string entityType, string entityId) - { - var commentsWithAuthor = await CommentRepository - .GetListWithAuthorsAsync(entityType, entityId); + public virtual async Task> GetListAsync(string entityType, string entityId) + { + var commentsWithAuthor = await CommentRepository + .GetListWithAuthorsAsync(entityType, entityId); - return new ListResultDto( - ConvertCommentsToNestedStructure(commentsWithAuthor) - ); - } + return new ListResultDto( + ConvertCommentsToNestedStructure(commentsWithAuthor) + ); + } + + [Authorize] + public virtual async Task CreateAsync(string entityType, string entityId, CreateCommentInput input) + { + var user = await CmsUserLookupService.GetByIdAsync(CurrentUser.GetId()); - [Authorize] - public virtual async Task CreateAsync(string entityType, string entityId, CreateCommentInput input) + if (input.RepliedCommentId.HasValue) { - var user = await CmsUserLookupService.GetByIdAsync(CurrentUser.GetId()); + await CommentRepository.GetAsync(input.RepliedCommentId.Value); + } - if (input.RepliedCommentId.HasValue) - { - await CommentRepository.GetAsync(input.RepliedCommentId.Value); - } + var comment = await CommentRepository.InsertAsync( + await CommentManager.CreateAsync( + user, + entityType, + entityId, + input.Text, + input.RepliedCommentId + ) + ); - var comment = await CommentRepository.InsertAsync( - await CommentManager.CreateAsync( - user, - entityType, - entityId, - input.Text, - input.RepliedCommentId - ) - ); + await UnitOfWorkManager.Current.SaveChangesAsync(); - await UnitOfWorkManager.Current.SaveChangesAsync(); + await DistributedEventBus.PublishAsync(new CreatedCommentEvent + { + Id = comment.Id + }); - await DistributedEventBus.PublishAsync(new CreatedCommentEvent - { - Id = comment.Id - }); + return ObjectMapper.Map(comment); + } - return ObjectMapper.Map(comment); - } + [Authorize] + public virtual async Task UpdateAsync(Guid id, UpdateCommentInput input) + { + var comment = await CommentRepository.GetAsync(id); - [Authorize] - public virtual async Task UpdateAsync(Guid id, UpdateCommentInput input) + if (comment.CreatorId != CurrentUser.GetId()) { - var comment = await CommentRepository.GetAsync(id); + throw new AbpAuthorizationException(); + } - if (comment.CreatorId != CurrentUser.GetId()) - { - throw new AbpAuthorizationException(); - } + comment.SetText(input.Text); + comment.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); - comment.SetText(input.Text); - comment.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); + var updatedComment = await CommentRepository.UpdateAsync(comment); - var updatedComment = await CommentRepository.UpdateAsync(comment); + return ObjectMapper.Map(updatedComment); + } - return ObjectMapper.Map(updatedComment); - } + [Authorize] + public virtual async Task DeleteAsync(Guid id) + { + var comment = await CommentRepository.GetAsync(id); - [Authorize] - public virtual async Task DeleteAsync(Guid id) + if (comment.CreatorId != CurrentUser.GetId()) { - var comment = await CommentRepository.GetAsync(id); + throw new AbpAuthorizationException(); + } - if (comment.CreatorId != CurrentUser.GetId()) - { - throw new AbpAuthorizationException(); - } + await CommentRepository.DeleteWithRepliesAsync(comment); + } - await CommentRepository.DeleteWithRepliesAsync(comment); - } + private List ConvertCommentsToNestedStructure(List comments) + { + //TODO: I think this method can be optimized if you use dictionaries instead of straight search - private List ConvertCommentsToNestedStructure(List comments) + var parentComments = comments + .Where(c => c.Comment.RepliedCommentId == null) + .Select(c => ObjectMapper.Map(c.Comment)) + .ToList(); + + foreach (var parentComment in parentComments) { - //TODO: I think this method can be optimized if you use dictionaries instead of straight search + parentComment.Author = GetAuthorAsDtoFromCommentList(comments, parentComment.Id); - var parentComments = comments - .Where(c => c.Comment.RepliedCommentId == null) - .Select(c => ObjectMapper.Map(c.Comment)) + parentComment.Replies = comments + .Where(c => c.Comment.RepliedCommentId == parentComment.Id) + .Select(c => ObjectMapper.Map(c.Comment)) .ToList(); - foreach (var parentComment in parentComments) + foreach (var reply in parentComment.Replies) { - parentComment.Author = GetAuthorAsDtoFromCommentList(comments, parentComment.Id); - - parentComment.Replies = comments - .Where(c => c.Comment.RepliedCommentId == parentComment.Id) - .Select(c => ObjectMapper.Map(c.Comment)) - .ToList(); - - foreach (var reply in parentComment.Replies) - { - reply.Author = GetAuthorAsDtoFromCommentList(comments, reply.Id); - } + reply.Author = GetAuthorAsDtoFromCommentList(comments, reply.Id); } - - return parentComments; } - private CmsUserDto GetAuthorAsDtoFromCommentList(List comments, Guid commentId) - { - return ObjectMapper.Map(comments.Single(c => c.Comment.Id == commentId).Author); - } + return parentComments; + } + + private CmsUserDto GetAuthorAsDtoFromCommentList(List comments, Guid commentId) + { + return ObjectMapper.Map(comments.Single(c => c.Comment.Id == commentId).Author); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Menus/MenuItemPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Menus/MenuItemPublicAppService.cs index 1d2e4a0fc3..11a58d5935 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Menus/MenuItemPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Menus/MenuItemPublicAppService.cs @@ -5,39 +5,38 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Menus; -namespace Volo.CmsKit.Public.Menus +namespace Volo.CmsKit.Public.Menus; + +[RequiresGlobalFeature(typeof(MenuFeature))] +public class MenuItemPublicAppService : CmsKitPublicAppServiceBase, IMenuItemPublicAppService { - [RequiresGlobalFeature(typeof(MenuFeature))] - public class MenuItemPublicAppService : CmsKitPublicAppServiceBase, IMenuItemPublicAppService + protected IMenuItemRepository MenuItemRepository { get; } + protected IDistributedCache> DistributedCache { get; } + + public MenuItemPublicAppService( + IMenuItemRepository menuRepository, + IDistributedCache> distributedCache) { - protected IMenuItemRepository MenuItemRepository { get; } - protected IDistributedCache> DistributedCache { get; } + MenuItemRepository = menuRepository; + DistributedCache = distributedCache; + } - public MenuItemPublicAppService( - IMenuItemRepository menuRepository, - IDistributedCache> distributedCache) - { - MenuItemRepository = menuRepository; - DistributedCache = distributedCache; - } + public async Task> GetListAsync() + { + var cachedMenu = await DistributedCache.GetOrAddAsync( + MenuApplicationConsts.MainMenuCacheKey, + async () => + { + var menuItems = await MenuItemRepository.GetListAsync(); - public async Task> GetListAsync() - { - var cachedMenu = await DistributedCache.GetOrAddAsync( - MenuApplicationConsts.MainMenuCacheKey, - async () => + if (menuItems == null) { - var menuItems = await MenuItemRepository.GetListAsync(); - - if (menuItems == null) - { - return new(); - } + return new(); + } - return ObjectMapper.Map, List>(menuItems); - }); + return ObjectMapper.Map, List>(menuItems); + }); - return cachedMenu; - } + return cachedMenu; } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PagePublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PagePublicAppService.cs index 31fe76599f..258ef935ed 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PagePublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PagePublicAppService.cs @@ -3,28 +3,27 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Pages; -namespace Volo.CmsKit.Public.Pages +namespace Volo.CmsKit.Public.Pages; + +[RequiresGlobalFeature(typeof(PagesFeature))] +public class PagePublicAppService : CmsKitPublicAppServiceBase, IPagePublicAppService { - [RequiresGlobalFeature(typeof(PagesFeature))] - public class PagePublicAppService : CmsKitPublicAppServiceBase, IPagePublicAppService + protected IPageRepository PageRepository { get; } + + public PagePublicAppService(IPageRepository pageRepository) { - protected IPageRepository PageRepository { get; } + PageRepository = pageRepository; + } - public PagePublicAppService(IPageRepository pageRepository) - { - PageRepository = pageRepository; - } + public virtual async Task FindBySlugAsync(string slug) + { + var page = await PageRepository.FindBySlugAsync(slug); - public virtual async Task FindBySlugAsync(string slug) + if (page == null) { - var page = await PageRepository.FindBySlugAsync(slug); - - if (page == null) - { - return null; - } - - return ObjectMapper.Map(page); + return null; } + + return ObjectMapper.Map(page); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs index 72ab7bebdc..74a4bf1050 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs @@ -11,28 +11,27 @@ using Volo.CmsKit.Public.Ratings; using Volo.CmsKit.Ratings; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Public +namespace Volo.CmsKit.Public; + +public class PublicApplicationAutoMapperProfile : Profile { - public class PublicApplicationAutoMapperProfile : Profile + public PublicApplicationAutoMapperProfile() { - public PublicApplicationAutoMapperProfile() - { - CreateMap(); + CreateMap(); + + CreateMap() + .Ignore(x => x.Author); - CreateMap() - .Ignore(x=> x.Author); + CreateMap() + .Ignore(x => x.Replies) + .Ignore(x => x.Author); - CreateMap() - .Ignore(x=> x.Replies) - .Ignore(x=> x.Author); + CreateMap(); - CreateMap(); - - CreateMap(); + CreateMap(); - CreateMap(MemberList.None); + CreateMap(MemberList.None); - CreateMap(); - } + CreateMap(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Ratings/RatingPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Ratings/RatingPublicAppService.cs index 6fa4677710..87ea0531db 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Ratings/RatingPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Ratings/RatingPublicAppService.cs @@ -8,73 +8,72 @@ using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Ratings; using Volo.CmsKit.Users; -namespace Volo.CmsKit.Public.Ratings +namespace Volo.CmsKit.Public.Ratings; + +[RequiresGlobalFeature(typeof(RatingsFeature))] +public class RatingPublicAppService : CmsKitPublicAppServiceBase, IRatingPublicAppService { - [RequiresGlobalFeature(typeof(RatingsFeature))] - public class RatingPublicAppService : CmsKitPublicAppServiceBase, IRatingPublicAppService + protected IRatingRepository RatingRepository { get; } + public ICmsUserLookupService CmsUserLookupService { get; } + protected RatingManager RatingManager { get; } + + public RatingPublicAppService( + IRatingRepository ratingRepository, + ICmsUserLookupService cmsUserLookupService, + RatingManager ratingManager) { - protected IRatingRepository RatingRepository { get; } - public ICmsUserLookupService CmsUserLookupService { get; } - protected RatingManager RatingManager { get; } + RatingRepository = ratingRepository; + CmsUserLookupService = cmsUserLookupService; + RatingManager = ratingManager; + } - public RatingPublicAppService( - IRatingRepository ratingRepository, - ICmsUserLookupService cmsUserLookupService, - RatingManager ratingManager) - { - RatingRepository = ratingRepository; - CmsUserLookupService = cmsUserLookupService; - RatingManager = ratingManager; - } + [Authorize] + public virtual async Task CreateAsync(string entityType, string entityId, + CreateUpdateRatingInput input) + { + var userId = CurrentUser.GetId(); + var user = await CmsUserLookupService.GetByIdAsync(userId); - [Authorize] - public virtual async Task CreateAsync(string entityType, string entityId, - CreateUpdateRatingInput input) - { - var userId = CurrentUser.GetId(); - var user = await CmsUserLookupService.GetByIdAsync(userId); + var rating = await RatingManager.SetStarAsync(user, entityType, entityId, input.StarCount); - var rating = await RatingManager.SetStarAsync(user, entityType, entityId, input.StarCount); + return ObjectMapper.Map(rating); + } - return ObjectMapper.Map(rating); - } + [Authorize] + public virtual async Task DeleteAsync(string entityType, string entityId) + { + var rating = await RatingRepository.GetCurrentUserRatingAsync(entityType, entityId, CurrentUser.GetId()); - [Authorize] - public virtual async Task DeleteAsync(string entityType, string entityId) + if (rating.CreatorId != CurrentUser.GetId()) { - var rating = await RatingRepository.GetCurrentUserRatingAsync(entityType, entityId, CurrentUser.GetId()); - - if (rating.CreatorId != CurrentUser.GetId()) - { - throw new AbpAuthorizationException(); - } - - await RatingRepository.DeleteAsync(rating.Id); + throw new AbpAuthorizationException(); } - public virtual async Task> GetGroupedStarCountsAsync(string entityType, - string entityId) - { - var ratings = await RatingRepository.GetGroupedStarCountsAsync(entityType, entityId); + await RatingRepository.DeleteAsync(rating.Id); + } - var userRatingOrNull = CurrentUser.IsAuthenticated - ? await RatingRepository.GetCurrentUserRatingAsync(entityType, entityId, CurrentUser.GetId()) - : null; + public virtual async Task> GetGroupedStarCountsAsync(string entityType, + string entityId) + { + var ratings = await RatingRepository.GetGroupedStarCountsAsync(entityType, entityId); - var ratingWithStarCountDto = new List(); + var userRatingOrNull = CurrentUser.IsAuthenticated + ? await RatingRepository.GetCurrentUserRatingAsync(entityType, entityId, CurrentUser.GetId()) + : null; - foreach (var rating in ratings) - { - ratingWithStarCountDto.Add( - new RatingWithStarCountDto - { - StarCount = rating.StarCount, - Count = rating.Count, - IsSelectedByCurrentUser = userRatingOrNull != null && userRatingOrNull.StarCount == rating.StarCount - }); - } + var ratingWithStarCountDto = new List(); - return ratingWithStarCountDto; + foreach (var rating in ratings) + { + ratingWithStarCountDto.Add( + new RatingWithStarCountDto + { + StarCount = rating.StarCount, + Count = rating.Count, + IsSelectedByCurrentUser = userRatingOrNull != null && userRatingOrNull.StarCount == rating.StarCount + }); } + + return ratingWithStarCountDto; } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs index 4f9746ef9f..d20a0ed058 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs @@ -8,86 +8,85 @@ using Volo.Abp.Users; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Reactions; -namespace Volo.CmsKit.Public.Reactions -{ - [RequiresGlobalFeature(typeof(ReactionsFeature))] - public class ReactionPublicAppService : CmsKitPublicAppServiceBase, IReactionPublicAppService - { - protected IReactionDefinitionStore ReactionDefinitionStore { get; } - - protected IUserReactionRepository UserReactionRepository { get; } +namespace Volo.CmsKit.Public.Reactions; - protected ReactionManager ReactionManager { get; } +[RequiresGlobalFeature(typeof(ReactionsFeature))] +public class ReactionPublicAppService : CmsKitPublicAppServiceBase, IReactionPublicAppService +{ + protected IReactionDefinitionStore ReactionDefinitionStore { get; } - public ReactionPublicAppService( - IReactionDefinitionStore reactionDefinitionStore, - IUserReactionRepository userReactionRepository, - ReactionManager reactionManager) - { - ReactionDefinitionStore = reactionDefinitionStore; - UserReactionRepository = userReactionRepository; - ReactionManager = reactionManager; - } + protected IUserReactionRepository UserReactionRepository { get; } - public virtual async Task> GetForSelectionAsync(string entityType, string entityId) - { - var summaries = await ReactionManager.GetSummariesAsync(entityType, entityId); + protected ReactionManager ReactionManager { get; } - var userReactionsOrNull = CurrentUser.IsAuthenticated - ? (await UserReactionRepository - .GetListForUserAsync( - CurrentUser.GetId(), - entityType, - entityId - )).ToDictionary(x => x.ReactionName, x => x) - : null; + public ReactionPublicAppService( + IReactionDefinitionStore reactionDefinitionStore, + IUserReactionRepository userReactionRepository, + ReactionManager reactionManager) + { + ReactionDefinitionStore = reactionDefinitionStore; + UserReactionRepository = userReactionRepository; + ReactionManager = reactionManager; + } - var reactionWithSelectionDtos = new List(); + public virtual async Task> GetForSelectionAsync(string entityType, string entityId) + { + var summaries = await ReactionManager.GetSummariesAsync(entityType, entityId); - foreach (var summary in summaries) - { - reactionWithSelectionDtos.Add( - new ReactionWithSelectionDto - { - Reaction = ConvertToReactionDto(summary.Reaction), - Count = summary.Count, - IsSelectedByCurrentUser = userReactionsOrNull?.ContainsKey(summary.Reaction.Name) ?? false - } - ); - } + var userReactionsOrNull = CurrentUser.IsAuthenticated + ? (await UserReactionRepository + .GetListForUserAsync( + CurrentUser.GetId(), + entityType, + entityId + )).ToDictionary(x => x.ReactionName, x => x) + : null; - return new ListResultDto(reactionWithSelectionDtos); - } + var reactionWithSelectionDtos = new List(); - [Authorize] - public virtual async Task CreateAsync(string entityType, string entityId, string reaction) + foreach (var summary in summaries) { - await ReactionManager.GetOrCreateAsync( - CurrentUser.GetId(), - entityType, - entityId, - reaction + reactionWithSelectionDtos.Add( + new ReactionWithSelectionDto + { + Reaction = ConvertToReactionDto(summary.Reaction), + Count = summary.Count, + IsSelectedByCurrentUser = userReactionsOrNull?.ContainsKey(summary.Reaction.Name) ?? false + } ); } - [Authorize] - public virtual async Task DeleteAsync(string entityType, string entityId, string reaction) - { - await ReactionManager.DeleteAsync( - CurrentUser.GetId(), - entityType, - entityId, - reaction - ); - } + return new ListResultDto(reactionWithSelectionDtos); + } + + [Authorize] + public virtual async Task CreateAsync(string entityType, string entityId, string reaction) + { + await ReactionManager.GetOrCreateAsync( + CurrentUser.GetId(), + entityType, + entityId, + reaction + ); + } - private ReactionDto ConvertToReactionDto(ReactionDefinition reactionDefinition) + [Authorize] + public virtual async Task DeleteAsync(string entityType, string entityId, string reaction) + { + await ReactionManager.DeleteAsync( + CurrentUser.GetId(), + entityType, + entityId, + reaction + ); + } + + private ReactionDto ConvertToReactionDto(ReactionDefinition reactionDefinition) + { + return new ReactionDto { - return new ReactionDto - { - Name = reactionDefinition.Name, - DisplayName = reactionDefinition.DisplayName?.Localize(StringLocalizerFactory) - }; - } + Name = reactionDefinition.Name, + DisplayName = reactionDefinition.DisplayName?.Localize(StringLocalizerFactory) + }; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/BlogPostPublicClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/BlogPostPublicClientProxy.cs index fa759c80ef..ea09b5fdd0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/BlogPostPublicClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/BlogPostPublicClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of BlogPostPublicClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Public.Blogs.ClientProxies +namespace Volo.CmsKit.Public.Blogs.ClientProxies; + +public partial class BlogPostPublicClientProxy { - public partial class BlogPostPublicClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/CommentPublicClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/CommentPublicClientProxy.cs index 1963df8405..826d4c0fb2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/CommentPublicClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/CommentPublicClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of CommentPublicClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Public.Comments.ClientProxies +namespace Volo.CmsKit.Public.Comments.ClientProxies; + +public partial class CommentPublicClientProxy { - public partial class CommentPublicClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/MenuItemPublicClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/MenuItemPublicClientProxy.cs index 1bf574d2b9..f08a3be274 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/MenuItemPublicClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/MenuItemPublicClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of MenuItemPublicClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Public.Menus.ClientProxies +namespace Volo.CmsKit.Public.Menus.ClientProxies; + +public partial class MenuItemPublicClientProxy { - public partial class MenuItemPublicClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PagesPublicClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PagesPublicClientProxy.cs index 661a49cbaf..3a735babc6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PagesPublicClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PagesPublicClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of PagesPublicClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Public.Pages.ClientProxies +namespace Volo.CmsKit.Public.Pages.ClientProxies; + +public partial class PagesPublicClientProxy { - public partial class PagesPublicClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/RatingPublicClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/RatingPublicClientProxy.cs index 223433693c..6a4609f568 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/RatingPublicClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/RatingPublicClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of RatingPublicClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Public.Ratings.ClientProxies +namespace Volo.CmsKit.Public.Ratings.ClientProxies; + +public partial class RatingPublicClientProxy { - public partial class RatingPublicClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/ReactionPublicClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/ReactionPublicClientProxy.cs index 975413f87f..b351daadb3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/ReactionPublicClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/ReactionPublicClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of ReactionPublicClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Public.Reactions.ClientProxies +namespace Volo.CmsKit.Public.Reactions.ClientProxies; + +public partial class ReactionPublicClientProxy { - public partial class ReactionPublicClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/TagPublicClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/TagPublicClientProxy.cs index 339fc2c05f..c1fa0d9ae4 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/TagPublicClientProxy.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/TagPublicClientProxy.cs @@ -1,8 +1,7 @@ // This file is part of TagPublicClientProxy, you can customize it here // ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Public.Tags.ClientProxies +namespace Volo.CmsKit.Public.Tags.ClientProxies; + +public partial class TagPublicClientProxy { - public partial class TagPublicClientProxy - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/Volo/CmsKit/Public/CmsKitPublicHttpApiClientModule.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/Volo/CmsKit/Public/CmsKitPublicHttpApiClientModule.cs index cc5d5e2794..4b998944f4 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/Volo/CmsKit/Public/CmsKitPublicHttpApiClientModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/Volo/CmsKit/Public/CmsKitPublicHttpApiClientModule.cs @@ -3,24 +3,23 @@ using Volo.Abp.Http.Client; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; -namespace Volo.CmsKit.Public +namespace Volo.CmsKit.Public; + +[DependsOn( + typeof(CmsKitPublicApplicationContractsModule), + typeof(CmsKitCommonHttpApiClientModule))] +public class CmsKitPublicHttpApiClientModule : AbpModule { - [DependsOn( - typeof(CmsKitPublicApplicationContractsModule), - typeof(CmsKitCommonHttpApiClientModule))] - public class CmsKitPublicHttpApiClientModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddStaticHttpClientProxies( - typeof(CmsKitPublicApplicationContractsModule).Assembly, - CmsKitPublicRemoteServiceConsts.RemoteServiceName - ); + context.Services.AddStaticHttpClientProxies( + typeof(CmsKitPublicApplicationContractsModule).Assembly, + CmsKitPublicRemoteServiceConsts.RemoteServiceName + ); - Configure(options => - { - options.FileSets.AddEmbedded(); - }); - } + Configure(options => + { + options.FileSets.AddEmbedded(); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs index adc97217cd..bdd0b2cf32 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs @@ -7,33 +7,32 @@ using Volo.Abp.Content; using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.Public.Blogs +namespace Volo.CmsKit.Public.Blogs; + +[RequiresGlobalFeature(typeof(BlogsFeature))] +[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitPublicRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit-public/blog-posts")] +public class BlogPostPublicController : CmsKitPublicControllerBase, IBlogPostPublicAppService { - [RequiresGlobalFeature(typeof(BlogsFeature))] - [RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitPublicRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit-public/blog-posts")] - public class BlogPostPublicController : CmsKitPublicControllerBase, IBlogPostPublicAppService - { - protected IBlogPostPublicAppService BlogPostPublicAppService { get; } + protected IBlogPostPublicAppService BlogPostPublicAppService { get; } - public BlogPostPublicController(IBlogPostPublicAppService blogPostPublicAppService) - { - BlogPostPublicAppService = blogPostPublicAppService; - } + public BlogPostPublicController(IBlogPostPublicAppService blogPostPublicAppService) + { + BlogPostPublicAppService = blogPostPublicAppService; + } - [HttpGet] - [Route("{blogSlug}/{blogPostSlug}")] - public virtual Task GetAsync(string blogSlug, string blogPostSlug) - { - return BlogPostPublicAppService.GetAsync(blogSlug, blogPostSlug); - } + [HttpGet] + [Route("{blogSlug}/{blogPostSlug}")] + public virtual Task GetAsync(string blogSlug, string blogPostSlug) + { + return BlogPostPublicAppService.GetAsync(blogSlug, blogPostSlug); + } - [HttpGet] - [Route("{blogSlug}")] - public virtual Task> GetListAsync(string blogSlug, PagedAndSortedResultRequestDto input) - { - return BlogPostPublicAppService.GetListAsync(blogSlug, input); - } + [HttpGet] + [Route("{blogSlug}")] + public virtual Task> GetListAsync(string blogSlug, PagedAndSortedResultRequestDto input) + { + return BlogPostPublicAppService.GetListAsync(blogSlug, input); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/CmsKitPublicControllerBase.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/CmsKitPublicControllerBase.cs index af20a697bc..8096538c63 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/CmsKitPublicControllerBase.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/CmsKitPublicControllerBase.cs @@ -1,7 +1,6 @@ -namespace Volo.CmsKit.Public +namespace Volo.CmsKit.Public; + +public abstract class CmsKitPublicControllerBase : CmsKitControllerBase { - public abstract class CmsKitPublicControllerBase : CmsKitControllerBase - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/CmsKitPublicHttpApiModule.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/CmsKitPublicHttpApiModule.cs index 7e667ace38..44b1444b52 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/CmsKitPublicHttpApiModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/CmsKitPublicHttpApiModule.cs @@ -1,19 +1,18 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; -namespace Volo.CmsKit.Public +namespace Volo.CmsKit.Public; + +[DependsOn( + typeof(CmsKitPublicApplicationContractsModule), + typeof(CmsKitCommonHttpApiModule))] +public class CmsKitPublicHttpApiModule : AbpModule { - [DependsOn( - typeof(CmsKitPublicApplicationContractsModule), - typeof(CmsKitCommonHttpApiModule))] - public class CmsKitPublicHttpApiModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + PreConfigure(mvcBuilder => { - PreConfigure(mvcBuilder => - { - mvcBuilder.AddApplicationPartIfNotExists(typeof(CmsKitPublicHttpApiModule).Assembly); - }); - } + mvcBuilder.AddApplicationPartIfNotExists(typeof(CmsKitPublicHttpApiModule).Assembly); + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Comments/CommentPublicController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Comments/CommentPublicController.cs index d827381ba0..afbf11e843 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Comments/CommentPublicController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Comments/CommentPublicController.cs @@ -6,47 +6,46 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.Public.Comments +namespace Volo.CmsKit.Public.Comments; + +[RequiresGlobalFeature(typeof(CommentsFeature))] +[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitPublicRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit-public/comments")] +public class CommentPublicController : CmsKitPublicControllerBase, ICommentPublicAppService { - [RequiresGlobalFeature(typeof(CommentsFeature))] - [RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitPublicRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit-public/comments")] - public class CommentPublicController : CmsKitPublicControllerBase, ICommentPublicAppService - { - public ICommentPublicAppService CommentPublicAppService { get; } + public ICommentPublicAppService CommentPublicAppService { get; } - public CommentPublicController(ICommentPublicAppService commentPublicAppService) - { - CommentPublicAppService = commentPublicAppService; - } + public CommentPublicController(ICommentPublicAppService commentPublicAppService) + { + CommentPublicAppService = commentPublicAppService; + } - [HttpGet] - [Route("{entityType}/{entityId}")] - public Task> GetListAsync(string entityType, string entityId) - { - return CommentPublicAppService.GetListAsync(entityType, entityId); - } + [HttpGet] + [Route("{entityType}/{entityId}")] + public Task> GetListAsync(string entityType, string entityId) + { + return CommentPublicAppService.GetListAsync(entityType, entityId); + } - [HttpPost] - [Route("{entityType}/{entityId}")] - public Task CreateAsync(string entityType, string entityId, CreateCommentInput input) - { - return CommentPublicAppService.CreateAsync(entityType, entityId, input); - } + [HttpPost] + [Route("{entityType}/{entityId}")] + public Task CreateAsync(string entityType, string entityId, CreateCommentInput input) + { + return CommentPublicAppService.CreateAsync(entityType, entityId, input); + } - [HttpPut] - [Route("{id}")] - public Task UpdateAsync(Guid id, UpdateCommentInput input) - { - return CommentPublicAppService.UpdateAsync(id, input); - } + [HttpPut] + [Route("{id}")] + public Task UpdateAsync(Guid id, UpdateCommentInput input) + { + return CommentPublicAppService.UpdateAsync(id, input); + } - [HttpDelete] - [Route("{id}")] - public Task DeleteAsync(Guid id) - { - return CommentPublicAppService.DeleteAsync(id); - } + [HttpDelete] + [Route("{id}")] + public Task DeleteAsync(Guid id) + { + return CommentPublicAppService.DeleteAsync(id); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Menus/MenuItemPublicController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Menus/MenuItemPublicController.cs index cf2450c9a6..fc8820c1b2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Menus/MenuItemPublicController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Menus/MenuItemPublicController.cs @@ -6,25 +6,24 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Menus; -namespace Volo.CmsKit.Public.Menus +namespace Volo.CmsKit.Public.Menus; + +[RequiresGlobalFeature(typeof(BlogsFeature))] +[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitPublicRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit-public/menu-items")] +public class MenuItemPublicController : CmsKitPublicControllerBase, IMenuItemPublicAppService { - [RequiresGlobalFeature(typeof(BlogsFeature))] - [RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitPublicRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit-public/menu-items")] - public class MenuItemPublicController : CmsKitPublicControllerBase, IMenuItemPublicAppService - { - protected IMenuItemPublicAppService MenuPublicAppService { get; } + protected IMenuItemPublicAppService MenuPublicAppService { get; } - public MenuItemPublicController(IMenuItemPublicAppService menuPublicAppService) - { - MenuPublicAppService = menuPublicAppService; - } + public MenuItemPublicController(IMenuItemPublicAppService menuPublicAppService) + { + MenuPublicAppService = menuPublicAppService; + } - [HttpGet] - public Task> GetListAsync() - { - return MenuPublicAppService.GetListAsync(); - } + [HttpGet] + public Task> GetListAsync() + { + return MenuPublicAppService.GetListAsync(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Pages/PagesPublicController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Pages/PagesPublicController.cs index 76fc579d50..763fe7522d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Pages/PagesPublicController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Pages/PagesPublicController.cs @@ -4,26 +4,25 @@ using Volo.Abp; using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.Public.Pages +namespace Volo.CmsKit.Public.Pages; + +[RequiresGlobalFeature(typeof(PagesFeature))] +[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitPublicRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit-public/pages")] +public class PagesPublicController : CmsKitPublicControllerBase, IPagePublicAppService { - [RequiresGlobalFeature(typeof(PagesFeature))] - [RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitPublicRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit-public/pages")] - public class PagesPublicController : CmsKitPublicControllerBase, IPagePublicAppService - { - protected IPagePublicAppService PageAppService { get; } + protected IPagePublicAppService PageAppService { get; } - public PagesPublicController(IPagePublicAppService pageAppService) - { - PageAppService = pageAppService; - } + public PagesPublicController(IPagePublicAppService pageAppService) + { + PageAppService = pageAppService; + } - [HttpGet] - [Route("{slug}")] - public virtual Task FindBySlugAsync(string slug) - { - return PageAppService.FindBySlugAsync(slug); - } + [HttpGet] + [Route("{slug}")] + public virtual Task FindBySlugAsync(string slug) + { + return PageAppService.FindBySlugAsync(slug); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Ratings/RatingPublicController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Ratings/RatingPublicController.cs index 1879c65376..11e8d22a69 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Ratings/RatingPublicController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Ratings/RatingPublicController.cs @@ -5,40 +5,39 @@ using Volo.Abp; using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.Public.Ratings +namespace Volo.CmsKit.Public.Ratings; + +[RequiresGlobalFeature(typeof(RatingsFeature))] +[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitPublicRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit-public/ratings")] +public class RatingPublicController : CmsKitPublicControllerBase, IRatingPublicAppService { - [RequiresGlobalFeature(typeof(RatingsFeature))] - [RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitPublicRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit-public/ratings")] - public class RatingPublicController : CmsKitPublicControllerBase, IRatingPublicAppService + protected IRatingPublicAppService RatingPublicAppService { get; } + + public RatingPublicController(IRatingPublicAppService ratingPublicAppService) { - protected IRatingPublicAppService RatingPublicAppService { get; } + RatingPublicAppService = ratingPublicAppService; + } - public RatingPublicController(IRatingPublicAppService ratingPublicAppService) - { - RatingPublicAppService = ratingPublicAppService; - } - - [HttpPut] - [Route("{entityType}/{entityId}")] - public virtual Task CreateAsync(string entityType, string entityId, CreateUpdateRatingInput input) - { - return RatingPublicAppService.CreateAsync(entityType, entityId, input); - } + [HttpPut] + [Route("{entityType}/{entityId}")] + public virtual Task CreateAsync(string entityType, string entityId, CreateUpdateRatingInput input) + { + return RatingPublicAppService.CreateAsync(entityType, entityId, input); + } - [HttpDelete] - [Route("{entityType}/{entityId}")] - public virtual Task DeleteAsync(string entityType, string entityId) - { - return RatingPublicAppService.DeleteAsync(entityType, entityId); - } + [HttpDelete] + [Route("{entityType}/{entityId}")] + public virtual Task DeleteAsync(string entityType, string entityId) + { + return RatingPublicAppService.DeleteAsync(entityType, entityId); + } - [HttpGet] - [Route("{entityType}/{entityId}")] - public virtual Task> GetGroupedStarCountsAsync(string entityType, string entityId) - { - return RatingPublicAppService.GetGroupedStarCountsAsync(entityType, entityId); - } + [HttpGet] + [Route("{entityType}/{entityId}")] + public virtual Task> GetGroupedStarCountsAsync(string entityType, string entityId) + { + return RatingPublicAppService.GetGroupedStarCountsAsync(entityType, entityId); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Reactions/ReactionPublicController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Reactions/ReactionPublicController.cs index c40673d741..4a9df74df7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Reactions/ReactionPublicController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Reactions/ReactionPublicController.cs @@ -5,40 +5,39 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; -namespace Volo.CmsKit.Public.Reactions +namespace Volo.CmsKit.Public.Reactions; + +[RequiresGlobalFeature(typeof(ReactionsFeature))] +[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitPublicRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit-public/reactions")] +public class ReactionPublicController : CmsKitPublicControllerBase, IReactionPublicAppService { - [RequiresGlobalFeature(typeof(ReactionsFeature))] - [RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitPublicRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit-public/reactions")] - public class ReactionPublicController : CmsKitPublicControllerBase, IReactionPublicAppService - { - protected IReactionPublicAppService ReactionPublicAppService { get; } + protected IReactionPublicAppService ReactionPublicAppService { get; } - public ReactionPublicController(IReactionPublicAppService reactionPublicAppService) - { - ReactionPublicAppService = reactionPublicAppService; - } + public ReactionPublicController(IReactionPublicAppService reactionPublicAppService) + { + ReactionPublicAppService = reactionPublicAppService; + } - [HttpGet] - [Route("{entityType}/{entityId}")] - public virtual Task> GetForSelectionAsync(string entityType, string entityId) - { - return ReactionPublicAppService.GetForSelectionAsync(entityType, entityId); - } + [HttpGet] + [Route("{entityType}/{entityId}")] + public virtual Task> GetForSelectionAsync(string entityType, string entityId) + { + return ReactionPublicAppService.GetForSelectionAsync(entityType, entityId); + } - [HttpPut] - [Route("{entityType}/{entityId}/{reaction}")] - public virtual Task CreateAsync(string entityType, string entityId, string reaction) - { - return ReactionPublicAppService.CreateAsync(entityType, entityId, reaction); - } + [HttpPut] + [Route("{entityType}/{entityId}/{reaction}")] + public virtual Task CreateAsync(string entityType, string entityId, string reaction) + { + return ReactionPublicAppService.CreateAsync(entityType, entityId, reaction); + } - [HttpDelete] - [Route("{entityType}/{entityId}/{reaction}")] - public virtual Task DeleteAsync(string entityType, string entityId, string reaction) - { - return ReactionPublicAppService.DeleteAsync(entityType, entityId, reaction); - } + [HttpDelete] + [Route("{entityType}/{entityId}/{reaction}")] + public virtual Task DeleteAsync(string entityType, string entityId, string reaction) + { + return ReactionPublicAppService.DeleteAsync(entityType, entityId, reaction); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagPublicController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagPublicController.cs index d5266a49ee..ec45901118 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagPublicController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagPublicController.cs @@ -6,26 +6,25 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Public.Tags +namespace Volo.CmsKit.Public.Tags; + +[RequiresGlobalFeature(typeof(TagsFeature))] +[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitPublicRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit-public/tags")] +public class TagPublicController : CmsKitPublicControllerBase, ITagAppService { - [RequiresGlobalFeature(typeof(TagsFeature))] - [RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] - [Area(CmsKitPublicRemoteServiceConsts.ModuleName)] - [Route("api/cms-kit-public/tags")] - public class TagPublicController : CmsKitPublicControllerBase, ITagAppService - { - protected ITagAppService TagAppService { get; } + protected ITagAppService TagAppService { get; } - public TagPublicController(ITagAppService tagAppService) - { - TagAppService = tagAppService; - } + public TagPublicController(ITagAppService tagAppService) + { + TagAppService = tagAppService; + } - [HttpGet] - [Route("{entityType}/{entityId}")] - public Task> GetAllRelatedTagsAsync(string entityType, string entityId) - { - return TagAppService.GetAllRelatedTagsAsync(entityType, entityId); - } + [HttpGet] + [Route("{entityType}/{entityId}")] + public Task> GetAllRelatedTagsAsync(string entityType, string entityId) + { + return TagAppService.GetAllRelatedTagsAsync(entityType, entityId); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebAutoMapperProfile.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebAutoMapperProfile.cs index d168c4fc75..f5884149d4 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebAutoMapperProfile.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebAutoMapperProfile.cs @@ -1,12 +1,11 @@ using AutoMapper; -namespace Volo.CmsKit.Public.Web +namespace Volo.CmsKit.Public.Web; + +public class CmsKitPublicWebAutoMapperProfile : Profile { - public class CmsKitPublicWebAutoMapperProfile : Profile + public CmsKitPublicWebAutoMapperProfile() { - public CmsKitPublicWebAutoMapperProfile() - { - } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs index ca441edbcc..da7e9e249a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPublicWebModule.cs @@ -14,77 +14,76 @@ using Volo.CmsKit.Pages; using Volo.CmsKit.Public.Web.Menus; using Volo.CmsKit.Web; -namespace Volo.CmsKit.Public.Web +namespace Volo.CmsKit.Public.Web; + +[DependsOn( + typeof(CmsKitPublicApplicationContractsModule), + typeof(CmsKitCommonWebModule) +)] +public class CmsKitPublicWebModule : AbpModule { - [DependsOn( - typeof(CmsKitPublicApplicationContractsModule), - typeof(CmsKitCommonWebModule) - )] - public class CmsKitPublicWebModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + context.Services.PreConfigure(options => { - context.Services.PreConfigure(options => - { - options.AddAssemblyResource( - typeof(CmsKitResource), - typeof(CmsKitPublicWebModule).Assembly, - typeof(CmsKitPublicApplicationContractsModule).Assembly, - typeof(CmsKitCommonApplicationContractsModule).Assembly - ); - }); + options.AddAssemblyResource( + typeof(CmsKitResource), + typeof(CmsKitPublicWebModule).Assembly, + typeof(CmsKitPublicApplicationContractsModule).Assembly, + typeof(CmsKitCommonApplicationContractsModule).Assembly + ); + }); - PreConfigure(mvcBuilder => - { - mvcBuilder.AddApplicationPartIfNotExists(typeof(CmsKitPublicWebModule).Assembly); - }); - } + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(CmsKitPublicWebModule).Assembly); + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.MenuContributors.Add(new CmsKitPublicMenuContributor()); - options.MainMenuNames.Add(CmsKitMenus.Public); - }); + options.MenuContributors.Add(new CmsKitPublicMenuContributor()); + options.MainMenuNames.Add(CmsKitMenus.Public); + }); - Configure(options => - { - options.FileSets.AddEmbedded("Volo.CmsKit.Public.Web"); - }); + Configure(options => + { + options.FileSets.AddEmbedded("Volo.CmsKit.Public.Web"); + }); - context.Services.AddAutoMapperObjectMapper(); + context.Services.AddAutoMapperObjectMapper(); - Configure(options => - { - options.AddMaps(validate: true); - }); + Configure(options => + { + options.AddMaps(validate: true); + }); - context.Services - .AddSingleton(_ => new MarkdownPipelineBuilder() - .UseAutoLinks() - .UseBootstrap() - .UseGridTables() - .UsePipeTables() - .Build()); + context.Services + .AddSingleton(_ => new MarkdownPipelineBuilder() + .UseAutoLinks() + .UseBootstrap() + .UseGridTables() + .UsePipeTables() + .Build()); - Configure(options => - { - options.DisableModule(CmsKitPublicRemoteServiceConsts.ModuleName); - }); - } + Configure(options => + { + options.DisableModule(CmsKitPublicRemoteServiceConsts.ModuleName); + }); + } - public override void PostConfigureServices(ServiceConfigurationContext context) + public override void PostConfigureServices(ServiceConfigurationContext context) + { + if (GlobalFeatureManager.Instance.IsEnabled()) { - if (GlobalFeatureManager.Instance.IsEnabled()) + Configure(options => { - Configure(options => - { - options.Conventions.AddPageRoute("/Public/CmsKit/Pages/Index", PageConsts.UrlPrefix + "{slug:minlength(1)}"); - options.Conventions.AddPageRoute("/Public/CmsKit/Blogs/Index", @"/blogs/{blogSlug:minlength(1)}"); - options.Conventions.AddPageRoute("/Public/CmsKit/Blogs/BlogPost", @"/blogs/{blogSlug}/{blogPostSlug:minlength(1)}"); - }); - } + options.Conventions.AddPageRoute("/Public/CmsKit/Pages/Index", PageConsts.UrlPrefix + "{slug:minlength(1)}"); + options.Conventions.AddPageRoute("/Public/CmsKit/Blogs/Index", @"/blogs/{blogSlug:minlength(1)}"); + options.Conventions.AddPageRoute("/Public/CmsKit/Blogs/BlogPost", @"/blogs/{blogSlug}/{blogPostSlug:minlength(1)}"); + }); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/CmsKitPublicWidgetsController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/CmsKitPublicWidgetsController.cs index 7aaefc8f9b..c73fba95e7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/CmsKitPublicWidgetsController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/CmsKitPublicWidgetsController.cs @@ -5,23 +5,22 @@ using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting; using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Rating; using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection; -namespace Volo.CmsKit.Public.Web.Controllers +namespace Volo.CmsKit.Public.Web.Controllers; + +public class CmsKitPublicWidgetsController : AbpController { - public class CmsKitPublicWidgetsController : AbpController + public Task ReactionSelection(string entityType, string entityId) { - public Task ReactionSelection(string entityType, string entityId) - { - return Task.FromResult((IActionResult)ViewComponent(typeof(ReactionSelectionViewComponent), new {entityType, entityId})); - } + return Task.FromResult((IActionResult)ViewComponent(typeof(ReactionSelectionViewComponent), new { entityType, entityId })); + } - public Task Commenting(string entityType, string entityId) - { - return Task.FromResult((IActionResult)ViewComponent(typeof(CommentingViewComponent), new {entityType, entityId})); - } + public Task Commenting(string entityType, string entityId) + { + return Task.FromResult((IActionResult)ViewComponent(typeof(CommentingViewComponent), new { entityType, entityId })); + } - public Task Rating(string entityType, string entityId) - { - return Task.FromResult((IActionResult) ViewComponent(typeof(RatingViewComponent), new {entityType, entityId})); - } + public Task Rating(string entityType, string entityId) + { + return Task.FromResult((IActionResult)ViewComponent(typeof(RatingViewComponent), new { entityType, entityId })); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Menus/CmsKitPublicMenuContributor.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Menus/CmsKitPublicMenuContributor.cs index c31d52740d..845db61425 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Menus/CmsKitPublicMenuContributor.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Menus/CmsKitPublicMenuContributor.cs @@ -8,61 +8,60 @@ using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Menus; using Volo.CmsKit.Public.Menus; -namespace Volo.CmsKit.Public.Web.Menus +namespace Volo.CmsKit.Public.Web.Menus; + +public class CmsKitPublicMenuContributor : IMenuContributor { - public class CmsKitPublicMenuContributor : IMenuContributor + public async Task ConfigureMenuAsync(MenuConfigurationContext context) { - public async Task ConfigureMenuAsync(MenuConfigurationContext context) + if (context.Menu.Name == CmsKitMenus.Public) { - if (context.Menu.Name == CmsKitMenus.Public) - { - await ConfigureMainMenuAsync(context); - } + await ConfigureMainMenuAsync(context); } + } - private async Task ConfigureMainMenuAsync(MenuConfigurationContext context) + private async Task ConfigureMainMenuAsync(MenuConfigurationContext context) + { + if (GlobalFeatureManager.Instance.IsEnabled()) { - if (GlobalFeatureManager.Instance.IsEnabled()) - { - var menuAppService = context.ServiceProvider.GetRequiredService(); + var menuAppService = context.ServiceProvider.GetRequiredService(); - var menuItems = await menuAppService.GetListAsync(); + var menuItems = await menuAppService.GetListAsync(); - if (!menuItems.IsNullOrEmpty()) + if (!menuItems.IsNullOrEmpty()) + { + foreach (var menuItemDto in menuItems.Where(x => x.ParentId == null && x.IsActive)) { - foreach (var menuItemDto in menuItems.Where(x => x.ParentId == null && x.IsActive)) - { - AddChildItems(menuItemDto, menuItems, context.Menu); - } + AddChildItems(menuItemDto, menuItems, context.Menu); } } } + } - private void AddChildItems(MenuItemDto menuItem, List source, IHasMenuItems parent = null) - { - var applicationMenuItem = CreateApplicationMenuItem(menuItem); - - foreach (var item in source.Where(x => x.ParentId == menuItem.Id && x.IsActive)) - { - AddChildItems(item, source, applicationMenuItem); - } - - parent?.Items.Add(applicationMenuItem); - } + private void AddChildItems(MenuItemDto menuItem, List source, IHasMenuItems parent = null) + { + var applicationMenuItem = CreateApplicationMenuItem(menuItem); - private ApplicationMenuItem CreateApplicationMenuItem(MenuItemDto menuItem) + foreach (var item in source.Where(x => x.ParentId == menuItem.Id && x.IsActive)) { - return new ApplicationMenuItem( - menuItem.DisplayName, - menuItem.DisplayName, - menuItem.Url, - menuItem.Icon, - menuItem.Order, - customData: null, - menuItem.Target, - menuItem.ElementId, - menuItem.CssClass - ); + AddChildItems(item, source, applicationMenuItem); } + + parent?.Items.Add(applicationMenuItem); + } + + private ApplicationMenuItem CreateApplicationMenuItem(MenuItemDto menuItem) + { + return new ApplicationMenuItem( + menuItem.DisplayName, + menuItem.DisplayName, + menuItem.Url, + menuItem.Icon, + menuItem.Order, + customData: null, + menuItem.Target, + menuItem.ElementId, + menuItem.CssClass + ); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Menus/CmsKitPublicMenus.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Menus/CmsKitPublicMenus.cs index 41cf4b0e96..55597af562 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Menus/CmsKitPublicMenus.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Menus/CmsKitPublicMenus.cs @@ -1,15 +1,14 @@ -namespace Volo.CmsKit.Public.Web.Menus +namespace Volo.CmsKit.Public.Web.Menus; + +public class CmsKitPublicMenus { - public class CmsKitPublicMenus - { - private const string Prefix = "CmsKit.Public"; + private const string Prefix = "CmsKit.Public"; - //Add your menu items here... - //public const string Home = Prefix + ".MyNewMenuItem"; - } + //Add your menu items here... + //public const string Home = Prefix + ".MyNewMenuItem"; +} - public class CmsKitMenus - { - public const string Public = "CmsKit.Public"; - } +public class CmsKitMenus +{ + public const string Public = "CmsKit.Public"; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Blogs/BlogPostComment/DefaultBlogPostCommentViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Blogs/BlogPostComment/DefaultBlogPostCommentViewComponent.cs index c551146f5f..389a8c81b9 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Blogs/BlogPostComment/DefaultBlogPostCommentViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Blogs/BlogPostComment/DefaultBlogPostCommentViewComponent.cs @@ -7,33 +7,32 @@ using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc; using Volo.CmsKit.Public.Blogs; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPostComment +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPostComment; + +[ViewComponent(Name = "CmsDefaultBlogPostComment")] +public class DefaultBlogPostCommentViewComponent : AbpViewComponent { - [ViewComponent(Name = "CmsDefaultBlogPostComment")] - public class DefaultBlogPostCommentViewComponent : AbpViewComponent - { - protected IBlogPostPublicAppService BlogPostPublicAppService; + protected IBlogPostPublicAppService BlogPostPublicAppService; - public DefaultBlogPostCommentViewComponent(IBlogPostPublicAppService blogPostPublicAppService) - { - BlogPostPublicAppService = blogPostPublicAppService; - } + public DefaultBlogPostCommentViewComponent(IBlogPostPublicAppService blogPostPublicAppService) + { + BlogPostPublicAppService = blogPostPublicAppService; + } - public virtual async Task InvokeAsync(string entityType, string entityId) - { - return View( - "~/Pages/CmsKit/Shared/Components/Blogs/BlogPostComment/Default.cshtml", - new DefaultBlogPostCommentViewModel - { - EntityType = entityType, - EntityId = entityId - }); - } + public virtual async Task InvokeAsync(string entityType, string entityId) + { + return View( + "~/Pages/CmsKit/Shared/Components/Blogs/BlogPostComment/Default.cshtml", + new DefaultBlogPostCommentViewModel + { + EntityType = entityType, + EntityId = entityId + }); + } - public class DefaultBlogPostCommentViewModel - { - public string EntityType { get; set; } - public string EntityId { get; set; } - } + public class DefaultBlogPostCommentViewModel + { + public string EntityType { get; set; } + public string EntityId { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingScriptBundleContributor.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingScriptBundleContributor.cs index 2b92891e6e..f616446507 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingScriptBundleContributor.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingScriptBundleContributor.cs @@ -1,15 +1,14 @@ using System.Collections.Generic; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting; + +public class CommentingScriptBundleContributor : BundleContributor { - public class CommentingScriptBundleContributor : BundleContributor + public override void ConfigureBundle(BundleConfigurationContext context) { - public override void ConfigureBundle(BundleConfigurationContext context) - { - context.Files.AddIfNotContains("/client-proxies/cms-kit-common-proxy.js"); - context.Files.AddIfNotContains("/client-proxies/cms-kit-proxy.js"); - context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Commenting/default.js"); - } + context.Files.AddIfNotContains("/client-proxies/cms-kit-common-proxy.js"); + context.Files.AddIfNotContains("/client-proxies/cms-kit-proxy.js"); + context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Commenting/default.js"); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingStyleBundleContributor.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingStyleBundleContributor.cs index 7e4445bbb2..00e1587f1b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingStyleBundleContributor.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingStyleBundleContributor.cs @@ -1,13 +1,12 @@ using System.Collections.Generic; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting; + +public class CommentingStyleBundleContributor : BundleContributor { - public class CommentingStyleBundleContributor : BundleContributor + public override void ConfigureBundle(BundleConfigurationContext context) { - public override void ConfigureBundle(BundleConfigurationContext context) - { - context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Commenting/default.css"); - } + context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Commenting/default.css"); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingViewComponent.cs index bbe3bbeebf..411b088682 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Commenting/CommentingViewComponent.cs @@ -9,57 +9,56 @@ using Volo.Abp.AspNetCore.Mvc.UI; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.CmsKit.Public.Comments; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting; + +[ViewComponent(Name = "CmsCommenting")] +[Widget( + ScriptTypes = new[] { typeof(CommentingScriptBundleContributor) }, + StyleTypes = new[] { typeof(CommentingStyleBundleContributor) }, + RefreshUrl = "/CmsKitPublicWidgets/Commenting", + AutoInitialize = true +)] +public class CommentingViewComponent : AbpViewComponent { - [ViewComponent(Name = "CmsCommenting")] - [Widget( - ScriptTypes = new[] {typeof(CommentingScriptBundleContributor)}, - StyleTypes = new[] {typeof(CommentingStyleBundleContributor)}, - RefreshUrl = "/CmsKitPublicWidgets/Commenting", - AutoInitialize = true - )] - public class CommentingViewComponent : AbpViewComponent - { - public ICommentPublicAppService CommentPublicAppService { get; } - public AbpMvcUiOptions AbpMvcUiOptions { get; } + public ICommentPublicAppService CommentPublicAppService { get; } + public AbpMvcUiOptions AbpMvcUiOptions { get; } - public CommentingViewComponent( - ICommentPublicAppService commentPublicAppService, - IOptions options) - { - CommentPublicAppService = commentPublicAppService; - AbpMvcUiOptions = options.Value; - } + public CommentingViewComponent( + ICommentPublicAppService commentPublicAppService, + IOptions options) + { + CommentPublicAppService = commentPublicAppService; + AbpMvcUiOptions = options.Value; + } - public virtual async Task InvokeAsync( - string entityType, - string entityId) - { - var result = await CommentPublicAppService - .GetListAsync(entityType, entityId); + public virtual async Task InvokeAsync( + string entityType, + string entityId) + { + var result = await CommentPublicAppService + .GetListAsync(entityType, entityId); - var loginUrl = $"{AbpMvcUiOptions.LoginUrl}?returnUrl={HttpContext.Request.Path.ToString()}&returnUrlHash=#cms-comment_{entityType}_{entityId}"; + var loginUrl = $"{AbpMvcUiOptions.LoginUrl}?returnUrl={HttpContext.Request.Path.ToString()}&returnUrlHash=#cms-comment_{entityType}_{entityId}"; - var viewModel = new CommentingViewModel - { - EntityId = entityId, - EntityType = entityType, - LoginUrl = loginUrl, - Comments = result.Items.OrderByDescending(i=> i.CreationTime).ToList() - }; + var viewModel = new CommentingViewModel + { + EntityId = entityId, + EntityType = entityType, + LoginUrl = loginUrl, + Comments = result.Items.OrderByDescending(i => i.CreationTime).ToList() + }; - return View("~/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml", viewModel); - } + return View("~/Pages/CmsKit/Shared/Components/Commenting/Default.cshtml", viewModel); + } - public class CommentingViewModel - { - public string EntityType { get; set; } + public class CommentingViewModel + { + public string EntityType { get; set; } - public string EntityId { get; set; } + public string EntityId { get; set; } - public string LoginUrl { get; set; } + public string LoginUrl { get; set; } - public IReadOnlyList Comments { get; set; } - } + public IReadOnlyList Comments { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs index 4545a366c1..c5427af114 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs @@ -7,49 +7,48 @@ using Volo.CmsKit.Public.Web.Renderers; using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages -{ - [Widget( - StyleTypes = new[] - { +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; + +[Widget( + StyleTypes = new[] + { typeof(HighlightJsStyleContributor) - }, - ScriptTypes = new[] - { + }, + ScriptTypes = new[] + { typeof(HighlightJsScriptContributor) - }, - ScriptFiles = new[] - { + }, + ScriptFiles = new[] + { "/Pages/Public/CmsKit/highlightOnLoad.js" - })] - public class DefaultPageViewComponent : AbpViewComponent + })] +public class DefaultPageViewComponent : AbpViewComponent +{ + protected IPagePublicAppService PagePublicAppService { get; } + + public DefaultPageViewComponent(IPagePublicAppService pagePublicAppService) { - protected IPagePublicAppService PagePublicAppService { get; } + PagePublicAppService = pagePublicAppService; + } - public DefaultPageViewComponent(IPagePublicAppService pagePublicAppService) + public virtual async Task InvokeAsync(Guid pageId, string title, string content) + { + var model = new PageViewModel { - PagePublicAppService = pagePublicAppService; - } + Id = pageId, + Title = title, + Content = content + }; - public virtual async Task InvokeAsync(Guid pageId, string title, string content) - { - var model = new PageViewModel - { - Id = pageId, - Title = title, - Content = content - }; - - return View("~/Pages/CmsKit/Shared/Components/Pages/Default.cshtml", model); - } + return View("~/Pages/CmsKit/Shared/Components/Pages/Default.cshtml", model); } +} - public class PageViewModel - { - public Guid Id { get; set; } +public class PageViewModel +{ + public Guid Id { get; set; } - public string Title { get; set; } + public string Title { get; set; } - public string Content { get; set; } - } -} \ No newline at end of file + public string Content { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingScriptBundleContributor.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingScriptBundleContributor.cs index d89322e213..d30a9f1ffe 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingScriptBundleContributor.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingScriptBundleContributor.cs @@ -3,16 +3,15 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Packages.StarRatingSvg; using Volo.Abp.Modularity; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Rating +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Rating; + +[DependsOn(typeof(StarRatingSvgScriptContributor))] +public class RatingScriptBundleContributor : BundleContributor { - [DependsOn(typeof(StarRatingSvgScriptContributor))] - public class RatingScriptBundleContributor : BundleContributor + public override void ConfigureBundle(BundleConfigurationContext context) { - public override void ConfigureBundle(BundleConfigurationContext context) - { - context.Files.AddIfNotContains("/client-proxies/cms-kit-common-proxy.js"); - context.Files.AddIfNotContains("/client-proxies/cms-kit-proxy.js"); - context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Rating/default.js"); - } + context.Files.AddIfNotContains("/client-proxies/cms-kit-common-proxy.js"); + context.Files.AddIfNotContains("/client-proxies/cms-kit-proxy.js"); + context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Rating/default.js"); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingStyleBundleContributor.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingStyleBundleContributor.cs index bd017f9d1e..9ceca7f80c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingStyleBundleContributor.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingStyleBundleContributor.cs @@ -3,14 +3,13 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Packages.StarRatingSvg; using Volo.Abp.Modularity; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Rating +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Rating; + +[DependsOn(typeof(StarRatingSvgStyleContributor))] +public class RatingStyleBundleContributor : BundleContributor { - [DependsOn(typeof(StarRatingSvgStyleContributor))] - public class RatingStyleBundleContributor : BundleContributor + public override void ConfigureBundle(BundleConfigurationContext context) { - public override void ConfigureBundle(BundleConfigurationContext context) - { - context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Rating/default.css"); - } + context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Rating/default.css"); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingViewComponent.cs index 9a4613d003..b928f7e2af 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Rating/RatingViewComponent.cs @@ -9,68 +9,67 @@ using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.Abp.Users; using Volo.CmsKit.Public.Ratings; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Rating +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Rating; + +[ViewComponent(Name = "CmsRating")] +[Widget( + StyleTypes = new[] { typeof(RatingStyleBundleContributor) }, + ScriptTypes = new[] { typeof(RatingScriptBundleContributor) }, + RefreshUrl = "/CmsKitPublicWidgets/Rating", + AutoInitialize = true +)] +public class RatingViewComponent : AbpViewComponent { - [ViewComponent(Name = "CmsRating")] - [Widget( - StyleTypes = new[] {typeof(RatingStyleBundleContributor)}, - ScriptTypes = new[] {typeof(RatingScriptBundleContributor)}, - RefreshUrl = "/CmsKitPublicWidgets/Rating", - AutoInitialize = true - )] - public class RatingViewComponent : AbpViewComponent + public IRatingPublicAppService RatingPublicAppService { get; } + public AbpMvcUiOptions AbpMvcUiOptions { get; } + public ICurrentUser CurrentUser { get; } + + public RatingViewComponent(IRatingPublicAppService ratingPublicAppService, IOptions options, ICurrentUser currentUser) { - public IRatingPublicAppService RatingPublicAppService { get; } - public AbpMvcUiOptions AbpMvcUiOptions { get; } - public ICurrentUser CurrentUser { get; } + RatingPublicAppService = ratingPublicAppService; + AbpMvcUiOptions = options.Value; + CurrentUser = currentUser; + } - public RatingViewComponent(IRatingPublicAppService ratingPublicAppService, IOptions options, ICurrentUser currentUser) - { - RatingPublicAppService = ratingPublicAppService; - AbpMvcUiOptions = options.Value; - CurrentUser = currentUser; - } + public virtual async Task InvokeAsync(string entityType, string entityId) + { + var ratings = await RatingPublicAppService.GetGroupedStarCountsAsync(entityType, entityId); + var totalRating = ratings.Sum(x => x.Count); - public virtual async Task InvokeAsync(string entityType, string entityId) + short? currentUserRating = null; + if (CurrentUser.IsAuthenticated) { - var ratings = await RatingPublicAppService.GetGroupedStarCountsAsync(entityType, entityId); - var totalRating = ratings.Sum(x => x.Count); - - short? currentUserRating = null; - if (CurrentUser.IsAuthenticated) - { - currentUserRating = ratings.Find(x => x.IsSelectedByCurrentUser)?.StarCount; - } + currentUserRating = ratings.Find(x => x.IsSelectedByCurrentUser)?.StarCount; + } - var loginUrl = - $"{AbpMvcUiOptions.LoginUrl}?returnUrl={HttpContext.Request.Path.ToString()}&returnUrlHash=#cms-rating_{entityType}_{entityId}"; + var loginUrl = + $"{AbpMvcUiOptions.LoginUrl}?returnUrl={HttpContext.Request.Path.ToString()}&returnUrlHash=#cms-rating_{entityType}_{entityId}"; - var viewModel = new RatingViewModel - { - EntityId = entityId, - EntityType = entityType, - LoginUrl = loginUrl, - Ratings = ratings, - CurrentRating = currentUserRating, - TotalRating = totalRating - }; + var viewModel = new RatingViewModel + { + EntityId = entityId, + EntityType = entityType, + LoginUrl = loginUrl, + Ratings = ratings, + CurrentRating = currentUserRating, + TotalRating = totalRating + }; - return View("~/Pages/CmsKit/Shared/Components/Rating/Default.cshtml", viewModel); - } + return View("~/Pages/CmsKit/Shared/Components/Rating/Default.cshtml", viewModel); } +} - public class RatingViewModel - { - public string EntityType { get; set; } +public class RatingViewModel +{ + public string EntityType { get; set; } - public string EntityId { get; set; } + public string EntityId { get; set; } - public string LoginUrl { get; set; } + public string LoginUrl { get; set; } - public List Ratings { get; set; } + public List Ratings { get; set; } - public short? CurrentRating { get; set; } + public short? CurrentRating { get; set; } - public int TotalRating { get; set; } - } + public int TotalRating { get; set; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionScriptBundleContributor.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionScriptBundleContributor.cs index ee9bc5d032..325a36712a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionScriptBundleContributor.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionScriptBundleContributor.cs @@ -1,15 +1,14 @@ using System.Collections.Generic; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection; + +public class ReactionSelectionScriptBundleContributor : BundleContributor { - public class ReactionSelectionScriptBundleContributor : BundleContributor + public override void ConfigureBundle(BundleConfigurationContext context) { - public override void ConfigureBundle(BundleConfigurationContext context) - { - context.Files.AddIfNotContains("/client-proxies/cms-kit-common-proxy.js"); - context.Files.AddIfNotContains("/client-proxies/cms-kit-proxy.js"); - context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/ReactionSelection/default.js"); - } + context.Files.AddIfNotContains("/client-proxies/cms-kit-common-proxy.js"); + context.Files.AddIfNotContains("/client-proxies/cms-kit-proxy.js"); + context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/ReactionSelection/default.js"); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionStyleBundleContributor.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionStyleBundleContributor.cs index 11d6453236..6c108ed826 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionStyleBundleContributor.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionStyleBundleContributor.cs @@ -1,13 +1,12 @@ using System.Collections.Generic; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection; + +public class ReactionSelectionStyleBundleContributor : BundleContributor { - public class ReactionSelectionStyleBundleContributor : BundleContributor + public override void ConfigureBundle(BundleConfigurationContext context) { - public override void ConfigureBundle(BundleConfigurationContext context) - { - context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/ReactionSelection/default.css"); - } + context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/ReactionSelection/default.css"); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionViewComponent.cs index 46869a3399..9785b683fb 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/ReactionSelection/ReactionSelectionViewComponent.cs @@ -9,91 +9,90 @@ using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.CmsKit.Public.Reactions; using Volo.CmsKit.Web; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection; + +[ViewComponent(Name = "CmsReactionSelection")] +[Widget( + ScriptTypes = new[] { typeof(ReactionSelectionScriptBundleContributor) }, + StyleTypes = new[] { typeof(ReactionSelectionStyleBundleContributor) }, + RefreshUrl = "/CmsKitPublicWidgets/ReactionSelection", + AutoInitialize = true +)] +public class ReactionSelectionViewComponent : AbpViewComponent { - [ViewComponent(Name = "CmsReactionSelection")] - [Widget( - ScriptTypes = new[] {typeof(ReactionSelectionScriptBundleContributor)}, - StyleTypes = new[] {typeof(ReactionSelectionStyleBundleContributor)}, - RefreshUrl = "/CmsKitPublicWidgets/ReactionSelection", - AutoInitialize = true - )] - public class ReactionSelectionViewComponent : AbpViewComponent + protected IReactionPublicAppService ReactionPublicAppService { get; } + + protected CmsKitUiOptions Options { get; } + + public AbpMvcUiOptions AbpMvcUiOptions { get; } + + public ReactionSelectionViewComponent( + IReactionPublicAppService reactionPublicAppService, + IOptions options, + IOptions abpMvcUiOptions) { - protected IReactionPublicAppService ReactionPublicAppService { get; } + ReactionPublicAppService = reactionPublicAppService; + Options = options.Value; + AbpMvcUiOptions = abpMvcUiOptions.Value; + } - protected CmsKitUiOptions Options { get; } + public virtual async Task InvokeAsync( + string entityType, + string entityId) + { + var result = await ReactionPublicAppService.GetForSelectionAsync(entityType, entityId); - public AbpMvcUiOptions AbpMvcUiOptions { get; } + var loginUrl = + $"{AbpMvcUiOptions.LoginUrl}?returnUrl={HttpContext.Request.Path.ToString()}&returnUrlHash=#cms-rating_{entityType}_{entityId}"; - public ReactionSelectionViewComponent( - IReactionPublicAppService reactionPublicAppService, - IOptions options, - IOptions abpMvcUiOptions) + var viewModel = new ReactionSelectionViewModel { - ReactionPublicAppService = reactionPublicAppService; - Options = options.Value; - AbpMvcUiOptions = abpMvcUiOptions.Value; - } + EntityType = entityType, + EntityId = entityId, + Reactions = new List(), + LoginUrl = loginUrl + }; - public virtual async Task InvokeAsync( - string entityType, - string entityId) + foreach (var reactionDto in result.Items) { - var result = await ReactionPublicAppService.GetForSelectionAsync(entityType, entityId); - - var loginUrl = - $"{AbpMvcUiOptions.LoginUrl}?returnUrl={HttpContext.Request.Path.ToString()}&returnUrlHash=#cms-rating_{entityType}_{entityId}"; - - var viewModel = new ReactionSelectionViewModel - { - EntityType = entityType, - EntityId = entityId, - Reactions = new List(), - LoginUrl = loginUrl - }; - - foreach (var reactionDto in result.Items) - { - viewModel.Reactions.Add( - new ReactionViewModel //TODO: AutoMap + viewModel.Reactions.Add( + new ReactionViewModel //TODO: AutoMap { - Name = reactionDto.Reaction.Name, - DisplayName = reactionDto.Reaction.DisplayName, - Icon = Options.ReactionIcons.GetLocalizedIcon(reactionDto.Reaction.Name), - Count = reactionDto.Count, - IsSelectedByCurrentUser = reactionDto.IsSelectedByCurrentUser - }); - } - - return View("~/Pages/CmsKit/Shared/Components/ReactionSelection/Default.cshtml", viewModel); + Name = reactionDto.Reaction.Name, + DisplayName = reactionDto.Reaction.DisplayName, + Icon = Options.ReactionIcons.GetLocalizedIcon(reactionDto.Reaction.Name), + Count = reactionDto.Count, + IsSelectedByCurrentUser = reactionDto.IsSelectedByCurrentUser + }); } - public class ReactionSelectionViewModel - { - public string EntityType { get; set; } + return View("~/Pages/CmsKit/Shared/Components/ReactionSelection/Default.cshtml", viewModel); + } - public string EntityId { get; set; } + public class ReactionSelectionViewModel + { + public string EntityType { get; set; } - public List Reactions { get; set; } + public string EntityId { get; set; } - public string LoginUrl { get; set; } - } + public List Reactions { get; set; } - public class ReactionViewModel - { - [NotNull] - public string Name { get; set; } + public string LoginUrl { get; set; } + } - [CanBeNull] - public string DisplayName { get; set; } + public class ReactionViewModel + { + [NotNull] + public string Name { get; set; } - [NotNull] - public string Icon { get; set; } + [CanBeNull] + public string DisplayName { get; set; } - public int Count { get; set; } + [NotNull] + public string Icon { get; set; } - public bool IsSelectedByCurrentUser { get; set; } - } + public int Count { get; set; } + + public bool IsSelectedByCurrentUser { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs index e8c271d463..43fb6ea8cc 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs @@ -8,43 +8,42 @@ using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Tags -{ - [Widget( - StyleFiles = new[] - { +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Tags; + +[Widget( + StyleFiles = new[] + { "/Pages/CmsKit/Shared/Components/Tags/default.css" - })] - public class TagViewComponent : AbpViewComponent + })] +public class TagViewComponent : AbpViewComponent +{ + protected readonly ITagAppService TagAppService; + + public TagViewComponent(ITagAppService tagAppService) { - protected readonly ITagAppService TagAppService; + TagAppService = tagAppService; + } - public TagViewComponent(ITagAppService tagAppService) - { - TagAppService = tagAppService; - } + public virtual async Task InvokeAsync( + string entityType, + string entityId) + { + var tagDtos = await TagAppService.GetAllRelatedTagsAsync(entityType, entityId); - public virtual async Task InvokeAsync( - string entityType, - string entityId) + var viewModel = new TagViewModel { - var tagDtos = await TagAppService.GetAllRelatedTagsAsync(entityType, entityId); - - var viewModel = new TagViewModel - { - EntityId = entityId, - EntityType = entityType, - Tags = tagDtos - }; + EntityId = entityId, + EntityType = entityType, + Tags = tagDtos + }; - return View("~/Pages/CmsKit/Shared/Components/Tags/Default.cshtml", viewModel); - } + return View("~/Pages/CmsKit/Shared/Components/Tags/Default.cshtml", viewModel); + } - public class TagViewModel - { - public List Tags { get; set; } - public string EntityId { get; set; } - public string EntityType { get; set; } - } + public class TagViewModel + { + public List Tags { get; set; } + public string EntityId { get; set; } + public string EntityType { get; set; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitPublicPageBase.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitPublicPageBase.cs index 879745bf24..30176155c5 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitPublicPageBase.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitPublicPageBase.cs @@ -8,19 +8,18 @@ using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.Layout; using Volo.CmsKit.Localization; -namespace Volo.CmsKit.Public.Web.Pages +namespace Volo.CmsKit.Public.Web.Pages; + +public class CmsKitPublicPageBase : Microsoft.AspNetCore.Mvc.RazorPages.Page { - public class CmsKitPublicPageBase : Microsoft.AspNetCore.Mvc.RazorPages.Page - { - [RazorInject] - public IStringLocalizer L { get; set; } + [RazorInject] + public IStringLocalizer L { get; set; } - [RazorInject] - public IPageLayout PageLayout { get; set; } + [RazorInject] + public IPageLayout PageLayout { get; set; } - public override Task ExecuteAsync() - { - return Task.CompletedTask; // Will be overriden by razor pages. (.cshtml) - } + public override Task ExecuteAsync() + { + return Task.CompletedTask; // Will be overriden by razor pages. (.cshtml) } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitPublicPageModelBase.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitPublicPageModelBase.cs index bbc6de3dfe..8837fb662d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitPublicPageModelBase.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitPublicPageModelBase.cs @@ -1,14 +1,13 @@ using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.CmsKit.Localization; -namespace Volo.CmsKit.Public.Web.Pages +namespace Volo.CmsKit.Public.Web.Pages; + +public abstract class CmsKitPublicPageModelBase : AbpPageModel { - public abstract class CmsKitPublicPageModelBase : AbpPageModel + protected CmsKitPublicPageModelBase() { - protected CmsKitPublicPageModelBase() - { - LocalizationResourceType = typeof(CmsKitResource); - ObjectMapperContext = typeof(CmsKitPublicWebModule); - } + LocalizationResourceType = typeof(CmsKitResource); + ObjectMapperContext = typeof(CmsKitPublicWebModule); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs index 3bf3874868..a00359da0f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs @@ -11,61 +11,60 @@ using Volo.CmsKit.Blogs; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Public.Blogs; -namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs +namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; + +public class BlogPostModel : CmsKitPublicPageModelBase { - public class BlogPostModel : CmsKitPublicPageModelBase - { - [BindProperty(SupportsGet = true)] - public string BlogSlug { get; set; } + [BindProperty(SupportsGet = true)] + public string BlogSlug { get; set; } - [BindProperty(SupportsGet = true)] - public string BlogPostSlug { get; set; } + [BindProperty(SupportsGet = true)] + public string BlogPostSlug { get; set; } - public BlogPostPublicDto BlogPost { get; private set; } + public BlogPostPublicDto BlogPost { get; private set; } - public BlogFeatureDto CommentsFeature { get; private set; } + public BlogFeatureDto CommentsFeature { get; private set; } - public BlogFeatureDto ReactionsFeature { get; private set; } + public BlogFeatureDto ReactionsFeature { get; private set; } - public BlogFeatureDto RatingsFeature { get; private set; } + public BlogFeatureDto RatingsFeature { get; private set; } - public BlogFeatureDto TagsFeature { get; private set; } + public BlogFeatureDto TagsFeature { get; private set; } - protected IBlogPostPublicAppService BlogPostPublicAppService { get; } + protected IBlogPostPublicAppService BlogPostPublicAppService { get; } - protected IBlogFeatureAppService BlogFeatureAppService { get; } + protected IBlogFeatureAppService BlogFeatureAppService { get; } + + public BlogPostModel( + IBlogPostPublicAppService blogPostPublicAppService, + IBlogFeatureAppService blogFeaturePublicAppService) + { + BlogPostPublicAppService = blogPostPublicAppService; + BlogFeatureAppService = blogFeaturePublicAppService; + } + + public virtual async Task OnGetAsync() + { + BlogPost = await BlogPostPublicAppService.GetAsync(BlogSlug, BlogPostSlug); + + if (GlobalFeatureManager.Instance.IsEnabled()) + { + CommentsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, GlobalFeatures.CommentsFeature.Name); + } + + if (GlobalFeatureManager.Instance.IsEnabled()) + { + ReactionsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, GlobalFeatures.ReactionsFeature.Name); + } - public BlogPostModel( - IBlogPostPublicAppService blogPostPublicAppService, - IBlogFeatureAppService blogFeaturePublicAppService) + if (GlobalFeatureManager.Instance.IsEnabled()) { - BlogPostPublicAppService = blogPostPublicAppService; - BlogFeatureAppService = blogFeaturePublicAppService; + RatingsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, GlobalFeatures.RatingsFeature.Name); } - public virtual async Task OnGetAsync() + if (GlobalFeatureManager.Instance.IsEnabled()) { - BlogPost = await BlogPostPublicAppService.GetAsync(BlogSlug, BlogPostSlug); - - if (GlobalFeatureManager.Instance.IsEnabled()) - { - CommentsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, GlobalFeatures.CommentsFeature.Name); - } - - if (GlobalFeatureManager.Instance.IsEnabled()) - { - ReactionsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, GlobalFeatures.ReactionsFeature.Name); - } - - if (GlobalFeatureManager.Instance.IsEnabled()) - { - RatingsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, GlobalFeatures.RatingsFeature.Name); - } - - if (GlobalFeatureManager.Instance.IsEnabled()) - { - TagsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, GlobalFeatures.TagsFeature.Name); - } + TagsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, GlobalFeatures.TagsFeature.Name); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs index eca0917d85..30d4c6bcf2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs @@ -8,38 +8,37 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination; using Volo.CmsKit.Public.Blogs; -namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs +namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; + +public class IndexModel : CmsKitPublicPageModelBase { - public class IndexModel : CmsKitPublicPageModelBase - { - public const int PageSize = 12; + public const int PageSize = 12; - [BindProperty(SupportsGet = true)] - public string BlogSlug { get; set; } + [BindProperty(SupportsGet = true)] + public string BlogSlug { get; set; } - [BindProperty(SupportsGet = true)] - public int CurrentPage { get; set; } = 1; + [BindProperty(SupportsGet = true)] + public int CurrentPage { get; set; } = 1; - public PagedResultDto Blogs { get; private set; } + public PagedResultDto Blogs { get; private set; } - public PagerModel PagerModel => new PagerModel(Blogs.TotalCount, Blogs.Items.Count, CurrentPage, PageSize, Request.Path.ToString()); + public PagerModel PagerModel => new PagerModel(Blogs.TotalCount, Blogs.Items.Count, CurrentPage, PageSize, Request.Path.ToString()); - protected IBlogPostPublicAppService BlogPostPublicAppService { get; } + protected IBlogPostPublicAppService BlogPostPublicAppService { get; } - public IndexModel(IBlogPostPublicAppService blogPostPublicAppService) - { - BlogPostPublicAppService = blogPostPublicAppService; - } + public IndexModel(IBlogPostPublicAppService blogPostPublicAppService) + { + BlogPostPublicAppService = blogPostPublicAppService; + } - public async Task OnGetAsync() - { - Blogs = await BlogPostPublicAppService.GetListAsync( - BlogSlug, - new PagedAndSortedResultRequestDto - { - SkipCount = PageSize * (CurrentPage - 1), - MaxResultCount = PageSize - }); - } + public async Task OnGetAsync() + { + Blogs = await BlogPostPublicAppService.GetListAsync( + BlogSlug, + new PagedAndSortedResultRequestDto + { + SkipCount = PageSize * (CurrentPage - 1), + MaxResultCount = PageSize + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml.cs index 2a30af8ae7..6eeac638cf 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml.cs @@ -3,32 +3,31 @@ using Microsoft.AspNetCore.Mvc; using Volo.CmsKit.Public.Pages; using Volo.CmsKit.Web.Pages; -namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Pages +namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Pages; + +public class IndexModel : CommonPageModel { - 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; - } + [BindProperty(SupportsGet = true)] + public string Slug { get; set; } - public async Task OnGetAsync() - { - Page = await PagePublicAppService.FindBySlugAsync(Slug); + protected IPagePublicAppService PagePublicAppService { get; } + + public PageDto Page; - if (Page == null) - { - return NotFound(); - } + public IndexModel(IPagePublicAppService pagePublicAppService) + { + PagePublicAppService = pagePublicAppService; + } + + public async Task OnGetAsync() + { + Page = await PagePublicAppService.FindBySlugAsync(Slug); - return Page(); + if (Page == null) + { + return NotFound(); } + + return Page(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Properties/launchSettings.json b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Properties/launchSettings.json new file mode 100644 index 0000000000..20cf448737 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:50567/", + "sslPort": 44318 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Volo.CmsKit.Public.Web": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:5000" + } + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Renderers/IMarkdownToHtmlRenderer.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Renderers/IMarkdownToHtmlRenderer.cs index 61d2139ccf..9f19d9f3da 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Renderers/IMarkdownToHtmlRenderer.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Renderers/IMarkdownToHtmlRenderer.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; -namespace Volo.CmsKit.Public.Web.Renderers +namespace Volo.CmsKit.Public.Web.Renderers; + +public interface IMarkdownToHtmlRenderer { - public interface IMarkdownToHtmlRenderer - { - Task RenderAsync(string rawMarkdown); - } + Task RenderAsync(string rawMarkdown); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Renderers/MarkdownToHtmlRenderer.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Renderers/MarkdownToHtmlRenderer.cs index 8224cfb7dc..6998a3d828 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Renderers/MarkdownToHtmlRenderer.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Renderers/MarkdownToHtmlRenderer.cs @@ -2,21 +2,20 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace Volo.CmsKit.Public.Web.Renderers +namespace Volo.CmsKit.Public.Web.Renderers; + +public class MarkdownToHtmlRenderer : IMarkdownToHtmlRenderer, ITransientDependency { - public class MarkdownToHtmlRenderer : IMarkdownToHtmlRenderer, ITransientDependency - { - protected MarkdownPipeline MarkdownPipeline { get; } + protected MarkdownPipeline MarkdownPipeline { get; } - public MarkdownToHtmlRenderer(MarkdownPipeline markdownPipeline) - { - MarkdownPipeline = markdownPipeline; - } + public MarkdownToHtmlRenderer(MarkdownPipeline markdownPipeline) + { + MarkdownPipeline = markdownPipeline; + } - public Task RenderAsync(string rawMarkdown) - { - return Task.FromResult( - Markdown.ToHtml(rawMarkdown, MarkdownPipeline)); - } + public Task RenderAsync(string rawMarkdown) + { + return Task.FromResult( + Markdown.ToHtml(rawMarkdown, MarkdownPipeline)); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Web/CmsKitWebModule.cs b/modules/cms-kit/src/Volo.CmsKit.Web/CmsKitWebModule.cs index a73939032c..02b002a892 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Web/CmsKitWebModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Web/CmsKitWebModule.cs @@ -2,14 +2,13 @@ using Volo.CmsKit.Admin.Web; using Volo.CmsKit.Public.Web; -namespace Volo.CmsKit.Web +namespace Volo.CmsKit.Web; + +[DependsOn( + typeof(CmsKitPublicWebModule), + typeof(CmsKitAdminWebModule), + typeof(CmsKitApplicationContractsModule) + )] +public class CmsKitWebModule : AbpModule { - [DependsOn( - typeof(CmsKitPublicWebModule), - typeof(CmsKitAdminWebModule), - typeof(CmsKitApplicationContractsModule) - )] - public class CmsKitWebModule : AbpModule - { - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Web/Properties/launchSettings.json b/modules/cms-kit/src/Volo.CmsKit.Web/Properties/launchSettings.json new file mode 100644 index 0000000000..15172f1087 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Web/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:50563/", + "sslPort": 44319 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Volo.CmsKit.Web": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:5000" + } + } +} \ No newline at end of file diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogAdminAppService_Tests.cs index 0f0e4ee2f8..5be7d312b5 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogAdminAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogAdminAppService_Tests.cs @@ -5,88 +5,87 @@ using Volo.Abp.Domain.Entities; using Volo.CmsKit.Admin.Blogs; using Xunit; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogAdminAppService_Tests : CmsKitApplicationTestBase { - public class BlogAdminAppService_Tests : CmsKitApplicationTestBase + protected IBlogAdminAppService BlogAdminAppService { get; } + protected CmsKitTestData CmsKitTestData { get; } + protected IBlogRepository BlogRepository { get; } + + public BlogAdminAppService_Tests() { - protected IBlogAdminAppService BlogAdminAppService { get; } - protected CmsKitTestData CmsKitTestData { get; } - protected IBlogRepository BlogRepository { get; } + BlogAdminAppService = GetRequiredService(); + CmsKitTestData = GetRequiredService(); + BlogRepository = GetRequiredService(); + } - public BlogAdminAppService_Tests() - { - BlogAdminAppService = GetRequiredService(); - CmsKitTestData = GetRequiredService(); - BlogRepository = GetRequiredService(); - } + [Fact] + public async Task GetAsync() + { + var blog = await BlogAdminAppService.GetAsync(CmsKitTestData.Blog_Id); - [Fact] - public async Task GetAsync() - { - var blog = await BlogAdminAppService.GetAsync(CmsKitTestData.Blog_Id); - - blog.Slug.ShouldBe(CmsKitTestData.BlogSlug); - } - - [Fact] - public async Task GetListAsync() - { - var blogs = await BlogAdminAppService.GetListAsync(new BlogGetListInput()); - - blogs.TotalCount.ShouldBeGreaterThan(0); - blogs.Items.Any(x => x.Slug == CmsKitTestData.BlogSlug).ShouldBeTrue(); - } - - [Fact] - public async Task CreateAsync_ShouldWork() - { - var blog = await BlogAdminAppService.CreateAsync(new CreateBlogDto - { - Name = "News", - Slug = "latest-news" - }); + blog.Slug.ShouldBe(CmsKitTestData.BlogSlug); + } + + [Fact] + public async Task GetListAsync() + { + var blogs = await BlogAdminAppService.GetListAsync(new BlogGetListInput()); + + blogs.TotalCount.ShouldBeGreaterThan(0); + blogs.Items.Any(x => x.Slug == CmsKitTestData.BlogSlug).ShouldBeTrue(); + } - blog.ShouldNotBeNull(); - blog.Name.ShouldBe("News"); - blog.Slug.ShouldBe("latest-news"); - } - - [Fact] - public async Task CreateAsync_ShouldThrow_WithExistSlug() + [Fact] + public async Task CreateAsync_ShouldWork() + { + var blog = await BlogAdminAppService.CreateAsync(new CreateBlogDto { - await Should.ThrowAsync( - async () => - await BlogAdminAppService.CreateAsync(new CreateBlogDto - { - Name = "News", - Slug = CmsKitTestData.BlogSlug - })); - } - - [Fact] - public async Task UpdateAsync_ShouldWork() + Name = "News", + Slug = "latest-news" + }); + + blog.ShouldNotBeNull(); + blog.Name.ShouldBe("News"); + blog.Slug.ShouldBe("latest-news"); + } + + [Fact] + public async Task CreateAsync_ShouldThrow_WithExistSlug() + { + await Should.ThrowAsync( + async () => + await BlogAdminAppService.CreateAsync(new CreateBlogDto { - var blog = await BlogAdminAppService.UpdateAsync(CmsKitTestData.Blog_Id, new UpdateBlogDto - { - Name = "New Name", - Slug = "new-slug" - }); + Name = "News", + Slug = CmsKitTestData.BlogSlug + })); + } - var updatedBlog = await BlogAdminAppService.GetAsync(CmsKitTestData.Blog_Id); - - updatedBlog.Name.ShouldBe("New Name"); - updatedBlog.Slug.ShouldBe("new-slug"); - } - - [Fact] - public async Task DeleteAsync_ShouldWork() + [Fact] + public async Task UpdateAsync_ShouldWork() + { + var blog = await BlogAdminAppService.UpdateAsync(CmsKitTestData.Blog_Id, new UpdateBlogDto { - await BlogAdminAppService.DeleteAsync(CmsKitTestData.Blog_Id); + Name = "New Name", + Slug = "new-slug" + }); + + var updatedBlog = await BlogAdminAppService.GetAsync(CmsKitTestData.Blog_Id); + + updatedBlog.Name.ShouldBe("New Name"); + updatedBlog.Slug.ShouldBe("new-slug"); + } + + [Fact] + public async Task DeleteAsync_ShouldWork() + { + await BlogAdminAppService.DeleteAsync(CmsKitTestData.Blog_Id); - await Should.ThrowAsync( - async () => - await BlogAdminAppService.GetAsync(CmsKitTestData.Blog_Id) - ); - } + await Should.ThrowAsync( + async () => + await BlogAdminAppService.GetAsync(CmsKitTestData.Blog_Id) + ); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeatureAdminAppService_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeatureAdminAppService_Test.cs index 56bf3d2cd3..929640875f 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeatureAdminAppService_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeatureAdminAppService_Test.cs @@ -3,65 +3,64 @@ using System.Threading.Tasks; using Volo.CmsKit.Admin.Blogs; using Xunit; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogFeatureAdminAppService_Test : CmsKitApplicationTestBase { - public class BlogFeatureAdminAppService_Test : CmsKitApplicationTestBase - { - private readonly CmsKitTestData testData; - private readonly IBlogFeatureAdminAppService blogFeatureAdminAppService; - private readonly IBlogFeatureRepository blogFeatureRepository; + private readonly CmsKitTestData testData; + private readonly IBlogFeatureAdminAppService blogFeatureAdminAppService; + private readonly IBlogFeatureRepository blogFeatureRepository; - public BlogFeatureAdminAppService_Test() - { - testData = GetRequiredService(); - blogFeatureAdminAppService = GetRequiredService(); - blogFeatureRepository = GetRequiredService(); - } + public BlogFeatureAdminAppService_Test() + { + testData = GetRequiredService(); + blogFeatureAdminAppService = GetRequiredService(); + blogFeatureRepository = GetRequiredService(); + } - [Fact] - public async Task SetAsync_ShouldWorkProperly_WithNonExistingFeature() + [Fact] + public async Task SetAsync_ShouldWorkProperly_WithNonExistingFeature() + { + var dto = new BlogFeatureInputDto { - var dto = new BlogFeatureInputDto - { - FeatureName = "My.Awesome.Feature", - IsEnabled = true - }; + FeatureName = "My.Awesome.Feature", + IsEnabled = true + }; - await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto); + await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto); - var feature = await blogFeatureRepository.FindAsync(testData.Blog_Id, dto.FeatureName); + var feature = await blogFeatureRepository.FindAsync(testData.Blog_Id, dto.FeatureName); - feature.ShouldNotBeNull(); - feature.BlogId.ShouldBe(testData.Blog_Id); - feature.IsEnabled.ShouldBe(dto.IsEnabled); - } + feature.ShouldNotBeNull(); + feature.BlogId.ShouldBe(testData.Blog_Id); + feature.IsEnabled.ShouldBe(dto.IsEnabled); + } - [Fact] - public async Task SetAsync_ShouldWorkProperly_WithExistingFeature() + [Fact] + public async Task SetAsync_ShouldWorkProperly_WithExistingFeature() + { + var dto = new BlogFeatureInputDto { - var dto = new BlogFeatureInputDto - { - FeatureName = testData.BlogFeature_2_FeatureName, - IsEnabled = !testData.BlogFeature_2_Enabled - }; + FeatureName = testData.BlogFeature_2_FeatureName, + IsEnabled = !testData.BlogFeature_2_Enabled + }; - await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto); + await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto); - var feature = await blogFeatureRepository.FindAsync(testData.Blog_Id, dto.FeatureName); + var feature = await blogFeatureRepository.FindAsync(testData.Blog_Id, dto.FeatureName); - feature.ShouldNotBeNull(); - feature.BlogId.ShouldBe(testData.Blog_Id); - feature.IsEnabled.ShouldBe(dto.IsEnabled); - } + feature.ShouldNotBeNull(); + feature.BlogId.ShouldBe(testData.Blog_Id); + feature.IsEnabled.ShouldBe(dto.IsEnabled); + } - [Fact] - public async Task GetListAsync_ShouldWorkProperly_WithBlogId() - { - var result = await blogFeatureAdminAppService.GetListAsync(testData.Blog_Id); + [Fact] + public async Task GetListAsync_ShouldWorkProperly_WithBlogId() + { + var result = await blogFeatureAdminAppService.GetListAsync(testData.Blog_Id); - result.ShouldNotBeNull(); - result.ShouldNotBeEmpty(); - result.Count.ShouldBeGreaterThanOrEqualTo(2); // 2 are seeded and there are built-in Features. - } + result.ShouldNotBeNull(); + result.ShouldNotBeEmpty(); + result.Count.ShouldBeGreaterThanOrEqualTo(2); // 2 are seeded and there are built-in Features. } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeaturePublicAppService_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeaturePublicAppService_Test.cs index e4c3d99f92..0115cf6170 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeaturePublicAppService_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeaturePublicAppService_Test.cs @@ -7,37 +7,36 @@ using System.Threading.Tasks; using Volo.CmsKit.Public.Blogs; using Xunit; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogFeaturePublicAppService_Test : CmsKitApplicationTestBase { - public class BlogFeaturePublicAppService_Test : CmsKitApplicationTestBase - { - private readonly CmsKitTestData testData; - private readonly IBlogFeatureAppService blogFeatureAppService; + private readonly CmsKitTestData testData; + private readonly IBlogFeatureAppService blogFeatureAppService; - public BlogFeaturePublicAppService_Test() - { - testData = GetRequiredService(); - blogFeatureAppService = GetRequiredService(); - } + public BlogFeaturePublicAppService_Test() + { + testData = GetRequiredService(); + blogFeatureAppService = GetRequiredService(); + } - [Fact] - public async Task GetAsync_ShouldWorkProperly_WithExistingFeatureName() - { - var result = await blogFeatureAppService.GetOrDefaultAsync(testData.Blog_Id, testData.BlogFeature_1_FeatureName); + [Fact] + public async Task GetAsync_ShouldWorkProperly_WithExistingFeatureName() + { + var result = await blogFeatureAppService.GetOrDefaultAsync(testData.Blog_Id, testData.BlogFeature_1_FeatureName); - result.ShouldNotBeNull(); - result.FeatureName.ShouldBe(testData.BlogFeature_1_FeatureName); - } + result.ShouldNotBeNull(); + result.FeatureName.ShouldBe(testData.BlogFeature_1_FeatureName); + } - [Fact] - public async Task GetAsync_ShouldReturnDefault_WithNonExistingFeatureName() - { - var nonExistingFeatureName = "AnyOtherFeature"; - var result = await blogFeatureAppService.GetOrDefaultAsync(testData.Blog_Id, nonExistingFeatureName); + [Fact] + public async Task GetAsync_ShouldReturnDefault_WithNonExistingFeatureName() + { + var nonExistingFeatureName = "AnyOtherFeature"; + var result = await blogFeatureAppService.GetOrDefaultAsync(testData.Blog_Id, nonExistingFeatureName); - var defaultFeature = new BlogFeature(Guid.Empty, nonExistingFeatureName); - result.ShouldNotBeNull(); - result.IsEnabled.ShouldBe(defaultFeature.IsEnabled); - } + var defaultFeature = new BlogFeature(Guid.Empty, nonExistingFeatureName); + result.ShouldNotBeNull(); + result.IsEnabled.ShouldBe(defaultFeature.IsEnabled); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostAdminAppService_Tests.cs index 0c39c8ef46..1910e3b925 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostAdminAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostAdminAppService_Tests.cs @@ -9,152 +9,151 @@ using Volo.Abp.Domain.Entities; using Volo.CmsKit.Admin.Blogs; using Xunit; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogPostAdminAppService_Tests : CmsKitApplicationTestBase { - public class BlogPostAdminAppService_Tests : CmsKitApplicationTestBase + private readonly IBlogPostAdminAppService blogPostAdminAppService; + private readonly CmsKitTestData cmsKitTestData; + private readonly IBlogPostRepository blogPostRepository; + + public BlogPostAdminAppService_Tests() { - private readonly IBlogPostAdminAppService blogPostAdminAppService; - private readonly CmsKitTestData cmsKitTestData; - private readonly IBlogPostRepository blogPostRepository; + blogPostAdminAppService = GetRequiredService(); + cmsKitTestData = GetRequiredService(); + blogPostRepository = GetRequiredService(); + } - public BlogPostAdminAppService_Tests() - { - blogPostAdminAppService = GetRequiredService(); - cmsKitTestData = GetRequiredService(); - blogPostRepository = GetRequiredService(); - } + [Fact] + public async Task CreateAsync_ShouldWorkProperly_WithCorrectData() + { + var title = "My awesome new Post"; + var slug = "my-awesome-new-post"; + var shortDescription = "This blog is all about awesomeness 🤗!"; + var content = "Another blog post shared on internet"; - [Fact] - public async Task CreateAsync_ShouldWorkProperly_WithCorrectData() - { - var title = "My awesome new Post"; - var slug = "my-awesome-new-post"; - var shortDescription = "This blog is all about awesomeness 🤗!"; - var content = "Another blog post shared on internet"; - - var created = await blogPostAdminAppService.CreateAsync(new CreateBlogPostDto - { - BlogId = cmsKitTestData.Blog_Id, - Title = title, - Slug = slug, - ShortDescription = shortDescription, - Content = content - }); - - created.Id.ShouldNotBe(Guid.Empty); - - var blogPost = await blogPostRepository.GetAsync(created.Id); - - blogPost.Title.ShouldBe(title); - blogPost.Slug.ShouldBe(slug); - blogPost.ShortDescription.ShouldBe(shortDescription); - blogPost.Content.ShouldBe(content); - } - - [Fact] - public async Task CreateAsync_ShouldThrowException_WithNonExistingBlogId() + var created = await blogPostAdminAppService.CreateAsync(new CreateBlogPostDto { - var title = "Another My Awesome New Post"; - var slug = "another-my-awesome-new-post"; - var shortDescription = "This blog is all about awesomeness 🤗!"; - var content = "Another blog post shared on internet"; - - var dto = new CreateBlogPostDto - { - // Non-existing Id - BlogId = Guid.NewGuid(), - Title = title, - Slug = slug, - ShortDescription = shortDescription, - Content = content - }; - - var exception = await Should.ThrowAsync(async () => - await blogPostAdminAppService.CreateAsync(dto)); - - exception.EntityType.ShouldBe(typeof(Blog)); - } - - [Fact] - public async Task GetAsync_ShouldWorkProperly_WithExistingId() - { - var blogPost = await blogPostAdminAppService.GetAsync(cmsKitTestData.BlogPost_1_Id); + BlogId = cmsKitTestData.Blog_Id, + Title = title, + Slug = slug, + ShortDescription = shortDescription, + Content = content + }); - blogPost.Title.ShouldBe(cmsKitTestData.BlogPost_1_Title); - blogPost.Slug.ShouldBe(cmsKitTestData.BlogPost_1_Slug); - } + created.Id.ShouldNotBe(Guid.Empty); - [Fact] - public async Task GetAsync_ShouldThrowException_WithNonExistingId() - { - var nonExistingId = Guid.NewGuid(); - var exception = await Should.ThrowAsync(async () => - await blogPostAdminAppService.GetAsync(nonExistingId)); + var blogPost = await blogPostRepository.GetAsync(created.Id); - exception.EntityType.ShouldBe(typeof(BlogPost)); - exception.Id.ShouldBe(nonExistingId); - } + blogPost.Title.ShouldBe(title); + blogPost.Slug.ShouldBe(slug); + blogPost.ShortDescription.ShouldBe(shortDescription); + blogPost.Content.ShouldBe(content); + } + + [Fact] + public async Task CreateAsync_ShouldThrowException_WithNonExistingBlogId() + { + var title = "Another My Awesome New Post"; + var slug = "another-my-awesome-new-post"; + var shortDescription = "This blog is all about awesomeness 🤗!"; + var content = "Another blog post shared on internet"; - [Fact] - public async Task GetListAsync_ShouldWorkProperly_WithDefaultParameters() + var dto = new CreateBlogPostDto { - var list = await blogPostAdminAppService.GetListAsync(new BlogPostGetListInput()); + // Non-existing Id + BlogId = Guid.NewGuid(), + Title = title, + Slug = slug, + ShortDescription = shortDescription, + Content = content + }; + + var exception = await Should.ThrowAsync(async () => + await blogPostAdminAppService.CreateAsync(dto)); + + exception.EntityType.ShouldBe(typeof(Blog)); + } - list.ShouldNotBeNull(); - list.TotalCount.ShouldBe(2); - list.Items.ShouldNotBeEmpty(); - list.Items.Count.ShouldBe(2); - } + [Fact] + public async Task GetAsync_ShouldWorkProperly_WithExistingId() + { + var blogPost = await blogPostAdminAppService.GetAsync(cmsKitTestData.BlogPost_1_Id); + + blogPost.Title.ShouldBe(cmsKitTestData.BlogPost_1_Title); + blogPost.Slug.ShouldBe(cmsKitTestData.BlogPost_1_Slug); + } - [Fact] - public async Task UpdateAsync_ShouldWorkProperly_WithRegularDatas() + [Fact] + public async Task GetAsync_ShouldThrowException_WithNonExistingId() + { + var nonExistingId = Guid.NewGuid(); + var exception = await Should.ThrowAsync(async () => + await blogPostAdminAppService.GetAsync(nonExistingId)); + + exception.EntityType.ShouldBe(typeof(BlogPost)); + exception.Id.ShouldBe(nonExistingId); + } + + [Fact] + public async Task GetListAsync_ShouldWorkProperly_WithDefaultParameters() + { + var list = await blogPostAdminAppService.GetListAsync(new BlogPostGetListInput()); + + list.ShouldNotBeNull(); + list.TotalCount.ShouldBe(2); + list.Items.ShouldNotBeEmpty(); + list.Items.Count.ShouldBe(2); + } + + [Fact] + public async Task UpdateAsync_ShouldWorkProperly_WithRegularDatas() + { + var shortDescription = "Another short description"; + var title = "[Solved] Another Blog Post"; + var slug = "another-short-blog-post"; + var content = "Another blog post shared on internet"; + + await blogPostAdminAppService.UpdateAsync(cmsKitTestData.BlogPost_2_Id, new UpdateBlogPostDto { - var shortDescription = "Another short description"; - var title = "[Solved] Another Blog Post"; - var slug = "another-short-blog-post"; - var content = "Another blog post shared on internet"; - - await blogPostAdminAppService.UpdateAsync(cmsKitTestData.BlogPost_2_Id, new UpdateBlogPostDto - { - ShortDescription = shortDescription, - Title = title, - Slug = slug, - Content = content - }); - - var blogPost = await blogPostRepository.GetAsync(cmsKitTestData.BlogPost_2_Id); - - blogPost.Title.ShouldBe(title); - blogPost.ShortDescription.ShouldBe(shortDescription); - blogPost.Slug.ShouldBe(slug); - blogPost.Content.ShouldBe(content); - } - - [Fact] - public async Task UpdateAsync_ShouldThrowException_WhileUpdatingWithAlreadyExistingSlug() + ShortDescription = shortDescription, + Title = title, + Slug = slug, + Content = content + }); + + var blogPost = await blogPostRepository.GetAsync(cmsKitTestData.BlogPost_2_Id); + + blogPost.Title.ShouldBe(title); + blogPost.ShortDescription.ShouldBe(shortDescription); + blogPost.Slug.ShouldBe(slug); + blogPost.Content.ShouldBe(content); + } + + [Fact] + public async Task UpdateAsync_ShouldThrowException_WhileUpdatingWithAlreadyExistingSlug() + { + var dto = new UpdateBlogPostDto { - var dto = new UpdateBlogPostDto - { - Title = "Some new title", - Slug = cmsKitTestData.BlogPost_1_Slug - }; + Title = "Some new title", + Slug = cmsKitTestData.BlogPost_1_Slug + }; - var exception = await Should.ThrowAsync(async () => - await blogPostAdminAppService.UpdateAsync(cmsKitTestData.BlogPost_2_Id, dto)); + var exception = await Should.ThrowAsync(async () => + await blogPostAdminAppService.UpdateAsync(cmsKitTestData.BlogPost_2_Id, dto)); - exception.Slug.ShouldBe(cmsKitTestData.BlogPost_1_Slug); - } + exception.Slug.ShouldBe(cmsKitTestData.BlogPost_1_Slug); + } - [Fact] - public async Task DeleteAsync_ShouldWorkProperly_WithExistingId() - { - await blogPostAdminAppService.DeleteAsync(cmsKitTestData.Page_2_Id); + [Fact] + public async Task DeleteAsync_ShouldWorkProperly_WithExistingId() + { + await blogPostAdminAppService.DeleteAsync(cmsKitTestData.Page_2_Id); - var exception = await Should.ThrowAsync(async () => - await blogPostRepository.GetAsync(cmsKitTestData.Page_2_Id)); + var exception = await Should.ThrowAsync(async () => + await blogPostRepository.GetAsync(cmsKitTestData.Page_2_Id)); - exception.EntityType.ShouldBe(typeof(BlogPost)); - exception.Id.ShouldBe(cmsKitTestData.Page_2_Id); - } + exception.EntityType.ShouldBe(typeof(BlogPost)); + exception.Id.ShouldBe(cmsKitTestData.Page_2_Id); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostPublicAppService_Tests.cs index 55310a4e84..2301941920 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostPublicAppService_Tests.cs @@ -9,58 +9,57 @@ using Volo.Abp.Domain.Entities; using Volo.CmsKit.Public.Blogs; using Xunit; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogPostPublicAppService_Tests : CmsKitApplicationTestBase { - public class BlogPostPublicAppService_Tests : CmsKitApplicationTestBase - { - private readonly IBlogPostPublicAppService blogPostAppService; + private readonly IBlogPostPublicAppService blogPostAppService; - private readonly CmsKitTestData cmsKitTestData; + private readonly CmsKitTestData cmsKitTestData; - public BlogPostPublicAppService_Tests() - { - blogPostAppService = GetRequiredService(); - cmsKitTestData = GetRequiredService(); - } + public BlogPostPublicAppService_Tests() + { + blogPostAppService = GetRequiredService(); + cmsKitTestData = GetRequiredService(); + } - [Fact] - public async Task GetListAsync_ShouldWorkProperly_WithExistingBlog() - { - var blogPosts = await blogPostAppService.GetListAsync(cmsKitTestData.BlogSlug, new PagedAndSortedResultRequestDto { MaxResultCount = 2 }); + [Fact] + public async Task GetListAsync_ShouldWorkProperly_WithExistingBlog() + { + var blogPosts = await blogPostAppService.GetListAsync(cmsKitTestData.BlogSlug, new PagedAndSortedResultRequestDto { MaxResultCount = 2 }); - blogPosts.ShouldNotBeNull(); - blogPosts.TotalCount.ShouldBe(2); - blogPosts.Items.ShouldNotBeEmpty(); - blogPosts.Items.Count.ShouldBe(2); - } + blogPosts.ShouldNotBeNull(); + blogPosts.TotalCount.ShouldBe(2); + blogPosts.Items.ShouldNotBeEmpty(); + blogPosts.Items.Count.ShouldBe(2); + } - [Fact] - public async Task GetAsync_ShouldWorkProperly_WithExistingSlug() - { - var blogPost = await blogPostAppService.GetAsync(cmsKitTestData.BlogSlug, cmsKitTestData.BlogPost_1_Slug); + [Fact] + public async Task GetAsync_ShouldWorkProperly_WithExistingSlug() + { + var blogPost = await blogPostAppService.GetAsync(cmsKitTestData.BlogSlug, cmsKitTestData.BlogPost_1_Slug); - blogPost.Id.ShouldBe(cmsKitTestData.BlogPost_1_Id); - blogPost.Title.ShouldBe(cmsKitTestData.BlogPost_1_Title); - } + blogPost.Id.ShouldBe(cmsKitTestData.BlogPost_1_Id); + blogPost.Title.ShouldBe(cmsKitTestData.BlogPost_1_Title); + } - [Fact] - public async Task GetAsync_ShouldThrowException_WithNonExistingBlogPostSlug() - { - var nonExistingSlug = "any-other-url"; - var exception = await Should.ThrowAsync(async () => - await blogPostAppService.GetAsync(cmsKitTestData.BlogSlug, nonExistingSlug)); + [Fact] + public async Task GetAsync_ShouldThrowException_WithNonExistingBlogPostSlug() + { + var nonExistingSlug = "any-other-url"; + var exception = await Should.ThrowAsync(async () => + await blogPostAppService.GetAsync(cmsKitTestData.BlogSlug, nonExistingSlug)); - exception.EntityType.ShouldBe(typeof(BlogPost)); - } + exception.EntityType.ShouldBe(typeof(BlogPost)); + } - [Fact] - public async Task GetAsync_ShouldThrowException_WithNonExistingBlogSlug() - { - var nonExistingSlug = "any-other-url"; - var exception = await Should.ThrowAsync(async () => - await blogPostAppService.GetAsync(nonExistingSlug, cmsKitTestData.Page_1_Slug)); + [Fact] + public async Task GetAsync_ShouldThrowException_WithNonExistingBlogSlug() + { + var nonExistingSlug = "any-other-url"; + var exception = await Should.ThrowAsync(async () => + await blogPostAppService.GetAsync(nonExistingSlug, cmsKitTestData.Page_1_Slug)); - exception.EntityType.ShouldBe(typeof(Blog)); - } + exception.EntityType.ShouldBe(typeof(Blog)); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/CmsKitApplicationTestBase.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/CmsKitApplicationTestBase.cs index d07fe0d1d1..73743510e8 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/CmsKitApplicationTestBase.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/CmsKitApplicationTestBase.cs @@ -1,27 +1,26 @@ using System; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +/* Inherit from this class for your application layer tests. + * See SampleAppService_Tests for example. + */ +public abstract class CmsKitApplicationTestBase : CmsKitTestBase { - /* Inherit from this class for your application layer tests. - * See SampleAppService_Tests for example. - */ - public abstract class CmsKitApplicationTestBase : CmsKitTestBase + protected virtual void UsingDbContext(Action action) { - protected virtual void UsingDbContext(Action action) + using (var dbContext = GetRequiredService()) { - using (var dbContext = GetRequiredService()) - { - action.Invoke(dbContext); - } + action.Invoke(dbContext); } + } - protected virtual T UsingDbContext(Func action) + protected virtual T UsingDbContext(Func action) + { + using (var dbContext = GetRequiredService()) { - using (var dbContext = GetRequiredService()) - { - return action.Invoke(dbContext); - } + return action.Invoke(dbContext); } } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/CmsKitApplicationTestModule.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/CmsKitApplicationTestModule.cs index 724c1042e2..e20c222a58 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/CmsKitApplicationTestModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/CmsKitApplicationTestModule.cs @@ -1,13 +1,12 @@ using Volo.Abp.Modularity; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitApplicationModule), + typeof(CmsKitDomainTestModule) + )] +public class CmsKitApplicationTestModule : AbpModule { - [DependsOn( - typeof(CmsKitApplicationModule), - typeof(CmsKitDomainTestModule) - )] - public class CmsKitApplicationTestModule : AbpModule - { - } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs index 7c62889201..ac1c83135b 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs @@ -5,47 +5,46 @@ using Volo.Abp.Domain.Entities; using Volo.CmsKit.Admin.Comments; using Xunit; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public class CommentAdminAppService_Tests : CmsKitApplicationTestBase { - public class CommentAdminAppService_Tests : CmsKitApplicationTestBase + private readonly ICommentAdminAppService _commentAdminAppService; + private readonly CmsKitTestData _cmsKitTestData; + + public CommentAdminAppService_Tests() { - private readonly ICommentAdminAppService _commentAdminAppService; - private readonly CmsKitTestData _cmsKitTestData; + _commentAdminAppService = GetRequiredService(); + _cmsKitTestData = GetRequiredService(); + } - public CommentAdminAppService_Tests() + [Fact] + public async Task ShouldGet_PagedListAsync() + { + var comments = await _commentAdminAppService.GetListAsync(new CommentGetListInput { - _commentAdminAppService = GetRequiredService(); - _cmsKitTestData = GetRequiredService(); - } + MaxResultCount = 3 + }); - [Fact] - public async Task ShouldGet_PagedListAsync() - { - var comments = await _commentAdminAppService.GetListAsync(new CommentGetListInput - { - MaxResultCount = 3 - }); - - comments.TotalCount.ShouldBe(6); - comments.Items.Count.ShouldBe(3); - comments.Items.Any(x => x.Author != null).ShouldBeTrue(); - } - - [Fact] - public async Task ShouldGet_CommentWithAuthorAsync() - { - var comment = await _commentAdminAppService.GetAsync(_cmsKitTestData.CommentWithChildId); - - comment.ShouldNotBeNull(); - comment.Author.ShouldNotBeNull(); - } - - [Fact] - public async Task ShouldDelete_WithRepliesAsync() - { - await _commentAdminAppService.DeleteAsync(_cmsKitTestData.CommentWithChildId); + comments.TotalCount.ShouldBe(6); + comments.Items.Count.ShouldBe(3); + comments.Items.Any(x => x.Author != null).ShouldBeTrue(); + } + + [Fact] + public async Task ShouldGet_CommentWithAuthorAsync() + { + var comment = await _commentAdminAppService.GetAsync(_cmsKitTestData.CommentWithChildId); + + comment.ShouldNotBeNull(); + comment.Author.ShouldNotBeNull(); + } + + [Fact] + public async Task ShouldDelete_WithRepliesAsync() + { + await _commentAdminAppService.DeleteAsync(_cmsKitTestData.CommentWithChildId); - await Should.ThrowAsync(async () => await _commentAdminAppService.GetAsync(_cmsKitTestData.CommentWithChildId)); - } + await Should.ThrowAsync(async () => await _commentAdminAppService.GetAsync(_cmsKitTestData.CommentWithChildId)); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs index ada9805a51..d0e698937d 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs @@ -7,94 +7,93 @@ using Volo.Abp.Users; using Volo.CmsKit.Public.Comments; using Xunit; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public class CommentPublicAppService_Tests : CmsKitApplicationTestBase { - public class CommentPublicAppService_Tests : CmsKitApplicationTestBase + private readonly ICommentPublicAppService _commentAppService; + private ICurrentUser _currentUser; + private readonly CmsKitTestData _cmsKitTestData; + + public CommentPublicAppService_Tests() { - private readonly ICommentPublicAppService _commentAppService; - private ICurrentUser _currentUser; - private readonly CmsKitTestData _cmsKitTestData; + _commentAppService = GetRequiredService(); + _cmsKitTestData = GetRequiredService(); + } - public CommentPublicAppService_Tests() - { - _commentAppService = GetRequiredService(); - _cmsKitTestData = GetRequiredService(); - } + protected override void AfterAddApplication(IServiceCollection services) + { + _currentUser = Substitute.For(); + services.AddSingleton(_currentUser); + } - protected override void AfterAddApplication(IServiceCollection services) - { - _currentUser = Substitute.For(); - services.AddSingleton(_currentUser); - } + [Fact] + public async Task GetAllForEntityAsync() + { + var list = await _commentAppService.GetListAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); - [Fact] - public async Task GetAllForEntityAsync() - { - var list = await _commentAppService.GetListAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); + list.Items.Count.ShouldBe(2); + list.Items.First().Replies.Count.ShouldBe(2); + } - list.Items.Count.ShouldBe(2); - list.Items.First().Replies.Count.ShouldBe(2); - } + [Fact] + public async Task CreateAsync() + { + _currentUser.Id.Returns(_cmsKitTestData.User2Id); - [Fact] - public async Task CreateAsync() - { - _currentUser.Id.Returns(_cmsKitTestData.User2Id); - - var newComment = await _commentAppService.CreateAsync( - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - new CreateCommentInput - { - RepliedCommentId = null, - Text = "newComment" - } - ); - - UsingDbContext(context => + var newComment = await _commentAppService.CreateAsync( + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + new CreateCommentInput { - var comments = context.Set().Where(x => - x.EntityId == _cmsKitTestData.EntityId1 && x.EntityType == _cmsKitTestData.EntityType1).ToList(); + RepliedCommentId = null, + Text = "newComment" + } + ); - comments - .Any(c=>c.Id == newComment.Id && c.CreatorId == newComment.CreatorId && c.Text == "newComment") - .ShouldBeTrue(); - }); - } - - [Fact] - public async Task UpdateAsync() + UsingDbContext(context => { - _currentUser.Id.Returns(_cmsKitTestData.User1Id); + var comments = context.Set().Where(x => + x.EntityId == _cmsKitTestData.EntityId1 && x.EntityType == _cmsKitTestData.EntityType1).ToList(); - await _commentAppService.UpdateAsync(_cmsKitTestData.CommentWithChildId, new UpdateCommentInput - { - Text = "I'm Updated" - }); + comments + .Any(c => c.Id == newComment.Id && c.CreatorId == newComment.CreatorId && c.Text == "newComment") + .ShouldBeTrue(); + }); + } - UsingDbContext(context => - { - var comment = context.Set().Single(x => - x.Id == _cmsKitTestData.CommentWithChildId); + [Fact] + public async Task UpdateAsync() + { + _currentUser.Id.Returns(_cmsKitTestData.User1Id); - comment.Text.ShouldBe("I'm Updated"); - }); - } + await _commentAppService.UpdateAsync(_cmsKitTestData.CommentWithChildId, new UpdateCommentInput + { + Text = "I'm Updated" + }); - [Fact] - public async Task DeleteAsync() + UsingDbContext(context => { - _currentUser.Id.Returns(_cmsKitTestData.User1Id); + var comment = context.Set().Single(x => + x.Id == _cmsKitTestData.CommentWithChildId); - await _commentAppService.DeleteAsync(_cmsKitTestData.CommentWithChildId); + comment.Text.ShouldBe("I'm Updated"); + }); + } - UsingDbContext(context => - { - var comment = context.Set().FirstOrDefault(x => - x.Id == _cmsKitTestData.CommentWithChildId); + [Fact] + public async Task DeleteAsync() + { + _currentUser.Id.Returns(_cmsKitTestData.User1Id); + + await _commentAppService.DeleteAsync(_cmsKitTestData.CommentWithChildId); + + UsingDbContext(context => + { + var comment = context.Set().FirstOrDefault(x => + x.Id == _cmsKitTestData.CommentWithChildId); - comment.ShouldBeNull(); - }); - } + comment.ShouldBeNull(); + }); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/MediaDescriptors/MediaDescriptorAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/MediaDescriptors/MediaDescriptorAdminAppService_Tests.cs index 2559d6ab90..37ed26ff4d 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/MediaDescriptors/MediaDescriptorAdminAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/MediaDescriptors/MediaDescriptorAdminAppService_Tests.cs @@ -7,46 +7,45 @@ using Volo.Abp.Content; using Volo.CmsKit.Admin.MediaDescriptors; using Xunit; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public class MediaDescriptorAdminAppService_Tests : CmsKitApplicationTestBase { - public class MediaDescriptorAdminAppService_Tests : CmsKitApplicationTestBase - { - private readonly CmsKitTestData _cmsKitTestData; - private readonly IMediaDescriptorAdminAppService _mediaDescriptorAdminAppService; - private readonly IMediaDescriptorRepository _mediaDescriptorRepository; + private readonly CmsKitTestData _cmsKitTestData; + private readonly IMediaDescriptorAdminAppService _mediaDescriptorAdminAppService; + private readonly IMediaDescriptorRepository _mediaDescriptorRepository; - public MediaDescriptorAdminAppService_Tests() - { - _cmsKitTestData = GetRequiredService(); - _mediaDescriptorAdminAppService = GetRequiredService(); - _mediaDescriptorRepository = GetRequiredService(); - } + public MediaDescriptorAdminAppService_Tests() + { + _cmsKitTestData = GetRequiredService(); + _mediaDescriptorAdminAppService = GetRequiredService(); + _mediaDescriptorRepository = GetRequiredService(); + } - [Fact] - public async Task Should_Create_Media() - { - var mediaName = "README.md"; - var mediaType = "text/markdown"; - var mediaContent = - "# ABP Framework\nABP Framework is a complete **infrastructure** based on the **ASP.NET Core** to create **modern web applications** and **APIs** by following the software development **best practices** and the **latest technologies**."; + [Fact] + public async Task Should_Create_Media() + { + var mediaName = "README.md"; + var mediaType = "text/markdown"; + var mediaContent = + "# ABP Framework\nABP Framework is a complete **infrastructure** based on the **ASP.NET Core** to create **modern web applications** and **APIs** by following the software development **best practices** and the **latest technologies**."; - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(mediaContent)); + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(mediaContent)); - var media = await _mediaDescriptorAdminAppService.CreateAsync(_cmsKitTestData.Media_1_EntityType, new CreateMediaInputWithStream - { - Name = mediaName, - File = new RemoteStreamContent(stream, mediaName, mediaType) - }); + var media = await _mediaDescriptorAdminAppService.CreateAsync(_cmsKitTestData.Media_1_EntityType, new CreateMediaInputWithStream + { + Name = mediaName, + File = new RemoteStreamContent(stream, mediaName, mediaType) + }); - media.ShouldNotBeNull(); - } + media.ShouldNotBeNull(); + } - [Fact] - public async Task Should_Delete_Media() - { - await _mediaDescriptorAdminAppService.DeleteAsync(_cmsKitTestData.Media_1_Id); + [Fact] + public async Task Should_Delete_Media() + { + await _mediaDescriptorAdminAppService.DeleteAsync(_cmsKitTestData.Media_1_Id); - (await _mediaDescriptorRepository.FindAsync(_cmsKitTestData.Media_1_Id)).ShouldBeNull(); - } + (await _mediaDescriptorRepository.FindAsync(_cmsKitTestData.Media_1_Id)).ShouldBeNull(); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Menus/MenuItemAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Menus/MenuItemAdminAppService_Tests.cs index 5826d6114a..cd210a3ba5 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Menus/MenuItemAdminAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Menus/MenuItemAdminAppService_Tests.cs @@ -9,83 +9,82 @@ using Volo.Abp.Domain.Entities; using Volo.CmsKit.Admin.Menus; using Xunit; -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +public class MenuItemAdminAppService_Tests : CmsKitApplicationTestBase { - public class MenuItemAdminAppService_Tests : CmsKitApplicationTestBase - { - protected IMenuItemAdminAppService MenuAdminAppService { get; } - protected CmsKitTestData TestData { get; } - protected IMenuItemRepository MenuRepository { get; } + protected IMenuItemAdminAppService MenuAdminAppService { get; } + protected CmsKitTestData TestData { get; } + protected IMenuItemRepository MenuRepository { get; } - public MenuItemAdminAppService_Tests() - { - MenuAdminAppService = GetRequiredService(); - TestData = GetRequiredService(); - MenuRepository = GetRequiredService(); - } + public MenuItemAdminAppService_Tests() + { + MenuAdminAppService = GetRequiredService(); + TestData = GetRequiredService(); + MenuRepository = GetRequiredService(); + } - [Fact] - public async Task GetAsync_ShouldWorkProperly_WithCorrectId() - { - var menu = await MenuAdminAppService.GetAsync(TestData.MenuItem_1_Id); + [Fact] + public async Task GetAsync_ShouldWorkProperly_WithCorrectId() + { + var menu = await MenuAdminAppService.GetAsync(TestData.MenuItem_1_Id); - menu.ShouldNotBeNull(); - } + menu.ShouldNotBeNull(); + } - public async Task GetListAsync_ShouldWorkProperly() - { - var result = await MenuAdminAppService.GetListAsync(); + public async Task GetListAsync_ShouldWorkProperly() + { + var result = await MenuAdminAppService.GetListAsync(); - result.ShouldNotBeNull(); - result.Items.ShouldNotBeEmpty(); - result.Items.Count.ShouldBe(3); - } + result.ShouldNotBeNull(); + result.Items.ShouldNotBeEmpty(); + result.Items.Count.ShouldBe(3); + } - [Fact] - public async Task CreateAsync_ShouldWorkProperly_WithOnlyName() + [Fact] + public async Task CreateAsync_ShouldWorkProperly_WithOnlyName() + { + var name = "My Awesome Menu"; + var menu = await MenuAdminAppService.CreateAsync(new MenuItemCreateInput { - var name = "My Awesome Menu"; - var menu = await MenuAdminAppService.CreateAsync(new MenuItemCreateInput - { - DisplayName = name - }); + DisplayName = name + }); - menu.ShouldNotBeNull(); - menu.Id.ShouldNotBe(Guid.Empty); - menu.DisplayName.ShouldBe(name); - } + menu.ShouldNotBeNull(); + menu.Id.ShouldNotBe(Guid.Empty); + menu.DisplayName.ShouldBe(name); + } - [Fact] - public async Task UpdateAsync_ShouldWorkProperly_WithName() + [Fact] + public async Task UpdateAsync_ShouldWorkProperly_WithName() + { + var newName = "My New Name"; + var newUrl = "my-new-url"; + await WithUnitOfWorkAsync(async () => { - var newName = "My New Name"; - var newUrl = "my-new-url"; - await WithUnitOfWorkAsync(async () => + await MenuAdminAppService.UpdateAsync(TestData.MenuItem_1_Id, new MenuItemUpdateInput { - await MenuAdminAppService.UpdateAsync(TestData.MenuItem_1_Id, new MenuItemUpdateInput - { - DisplayName = newName, - Url = newUrl - }); + DisplayName = newName, + Url = newUrl }); - + }); - var menu = await MenuRepository.FindAsync(TestData.MenuItem_1_Id); - menu.ShouldNotBeNull(); - menu.DisplayName.ShouldBe(newName); - menu.Url.ShouldBe(newUrl); - } + var menu = await MenuRepository.FindAsync(TestData.MenuItem_1_Id); - [Fact] - public async Task DeleteAsync_ShouldWorkProperly_WithExistingId() - { - await MenuAdminAppService.DeleteAsync(TestData.MenuItem_1_Id); + menu.ShouldNotBeNull(); + menu.DisplayName.ShouldBe(newName); + menu.Url.ShouldBe(newUrl); + } + + [Fact] + public async Task DeleteAsync_ShouldWorkProperly_WithExistingId() + { + await MenuAdminAppService.DeleteAsync(TestData.MenuItem_1_Id); - var menu = await MenuRepository.FindAsync(TestData.MenuItem_1_Id); + var menu = await MenuRepository.FindAsync(TestData.MenuItem_1_Id); - menu.ShouldBeNull(); - } + menu.ShouldBeNull(); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PageAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PageAdminAppService_Tests.cs index 60ee25f28d..97a931fb70 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PageAdminAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PageAdminAppService_Tests.cs @@ -5,130 +5,129 @@ using System.Threading.Tasks; using Volo.CmsKit.Admin.Pages; using Xunit; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public class PageAdminAppService_Tests : CmsKitApplicationTestBase { - public class PageAdminAppService_Tests : CmsKitApplicationTestBase + private readonly CmsKitTestData _data; + private readonly IPageAdminAppService _pageAdminAppService; + + private readonly IPageRepository _pageRepository; + + public PageAdminAppService_Tests() { - private readonly CmsKitTestData _data; - private readonly IPageAdminAppService _pageAdminAppService; + _data = GetRequiredService(); + _pageAdminAppService = GetRequiredService(); + _pageRepository = GetRequiredService(); + } - private readonly IPageRepository _pageRepository; + [Fact] + public async Task ShouldGetListAsync() + { + var input = new GetPagesInputDto(); - public PageAdminAppService_Tests() - { - _data = GetRequiredService(); - _pageAdminAppService = GetRequiredService(); - _pageRepository = GetRequiredService(); - } + var pages = await _pageAdminAppService.GetListAsync(input); - [Fact] - public async Task ShouldGetListAsync() - { - var input = new GetPagesInputDto(); - - var pages = await _pageAdminAppService.GetListAsync(input); - - pages.TotalCount.ShouldBe(2); - pages.Items.Count.ShouldBe(2); - - input.MaxResultCount = 1; - - var pages2 = await _pageAdminAppService.GetListAsync(input); - - pages2.TotalCount.ShouldBe(2); - pages2.Items.Count.ShouldBe(1); - pages2.Items.First().Title.ShouldBe(_data.Page_1_Title); - - input.SkipCount = 1; - - var pages3 = await _pageAdminAppService.GetListAsync(input); - - pages3.TotalCount.ShouldBe(2); - pages3.Items.Count.ShouldBe(1); - pages3.Items.First().Title.ShouldBe(_data.Page_2_Title); - } - - [Fact] - public async Task ShouldGetAsync() - { - var page = await _pageAdminAppService.GetAsync(_data.Page_1_Id); - - page.Title.ShouldBe(_data.Page_1_Title); - } - - [Fact] - public async Task ShouldCreateAsync() - { - var dto = new CreatePageInputDto - { - Title = "test", - Slug = "test-url", - Content = "test*content" - }; - - await Should.NotThrowAsync(async () => await _pageAdminAppService.CreateAsync(dto)); - - var page = await _pageRepository.GetBySlugAsync(dto.Slug); - - page.Title.ShouldBe(dto.Title); - } - - [Fact] - public async Task ShouldNotCreateExistUrlAsync() + pages.TotalCount.ShouldBe(2); + pages.Items.Count.ShouldBe(2); + + input.MaxResultCount = 1; + + var pages2 = await _pageAdminAppService.GetListAsync(input); + + pages2.TotalCount.ShouldBe(2); + pages2.Items.Count.ShouldBe(1); + pages2.Items.First().Title.ShouldBe(_data.Page_1_Title); + + input.SkipCount = 1; + + var pages3 = await _pageAdminAppService.GetListAsync(input); + + pages3.TotalCount.ShouldBe(2); + pages3.Items.Count.ShouldBe(1); + pages3.Items.First().Title.ShouldBe(_data.Page_2_Title); + } + + [Fact] + public async Task ShouldGetAsync() + { + var page = await _pageAdminAppService.GetAsync(_data.Page_1_Id); + + page.Title.ShouldBe(_data.Page_1_Title); + } + + [Fact] + public async Task ShouldCreateAsync() + { + var dto = new CreatePageInputDto { - var dto = new CreatePageInputDto - { - Title = "test", - Slug = _data.Page_1_Slug - }; - - var exception = await Should.ThrowAsync(async () => await _pageAdminAppService.CreateAsync(dto)); - - exception.Code.ShouldBe(CmsKitErrorCodes.Pages.SlugAlreadyExist); - } - - [Fact] - public async Task ShouldUpdatePageAsync() + Title = "test", + Slug = "test-url", + Content = "test*content" + }; + + await Should.NotThrowAsync(async () => await _pageAdminAppService.CreateAsync(dto)); + + var page = await _pageRepository.GetBySlugAsync(dto.Slug); + + page.Title.ShouldBe(dto.Title); + } + + [Fact] + public async Task ShouldNotCreateExistUrlAsync() + { + var dto = new CreatePageInputDto { - var dto = new UpdatePageInputDto - { - Title = _data.Page_1_Title + "++", - Slug = _data.Page_1_Slug+ "test", - Content = "changed" - }; - - await Should.NotThrowAsync(async () => await _pageAdminAppService.UpdateAsync(_data.Page_1_Id, dto)); - - var updatedPage = await _pageRepository.GetAsync(_data.Page_1_Id); - - updatedPage.Title.ShouldNotBe(_data.Page_1_Title); - updatedPage.Title.ShouldBe(dto.Title); - - updatedPage.Slug.ShouldNotBe(_data.Page_1_Slug); - updatedPage.Slug.ShouldBe(dto.Slug); - - updatedPage.Content.ShouldNotBe(_data.Content_1); - updatedPage.Content.ShouldBe(dto.Content); - } - - [Fact] - public async Task ShouldNotUpdateWithExistUrlAsync() + Title = "test", + Slug = _data.Page_1_Slug + }; + + var exception = await Should.ThrowAsync(async () => await _pageAdminAppService.CreateAsync(dto)); + + exception.Code.ShouldBe(CmsKitErrorCodes.Pages.SlugAlreadyExist); + } + + [Fact] + public async Task ShouldUpdatePageAsync() + { + var dto = new UpdatePageInputDto { - var dto = new UpdatePageInputDto - { - Title = _data.Page_1_Title + "++", - Slug = _data.Page_2_Slug - }; + Title = _data.Page_1_Title + "++", + Slug = _data.Page_1_Slug + "test", + Content = "changed" + }; - await Should.ThrowAsync(async () => await _pageAdminAppService.UpdateAsync(_data.Page_1_Id, dto)); - } + await Should.NotThrowAsync(async () => await _pageAdminAppService.UpdateAsync(_data.Page_1_Id, dto)); - [Fact] - public async Task ShouldDeleteAsync() + var updatedPage = await _pageRepository.GetAsync(_data.Page_1_Id); + + updatedPage.Title.ShouldNotBe(_data.Page_1_Title); + updatedPage.Title.ShouldBe(dto.Title); + + updatedPage.Slug.ShouldNotBe(_data.Page_1_Slug); + updatedPage.Slug.ShouldBe(dto.Slug); + + updatedPage.Content.ShouldNotBe(_data.Content_1); + updatedPage.Content.ShouldBe(dto.Content); + } + + [Fact] + public async Task ShouldNotUpdateWithExistUrlAsync() + { + var dto = new UpdatePageInputDto { - await _pageAdminAppService.DeleteAsync(_data.Page_1_Id); + Title = _data.Page_1_Title + "++", + Slug = _data.Page_2_Slug + }; + + await Should.ThrowAsync(async () => await _pageAdminAppService.UpdateAsync(_data.Page_1_Id, dto)); + } + + [Fact] + public async Task ShouldDeleteAsync() + { + await _pageAdminAppService.DeleteAsync(_data.Page_1_Id); - await Should.ThrowAsync(async () => await _pageRepository.GetAsync(_data.Page_1_Id)); - } + await Should.ThrowAsync(async () => await _pageRepository.GetAsync(_data.Page_1_Id)); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PagePublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PagePublicAppService_Tests.cs index 6b16e35f41..0eeb3210a9 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PagePublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PagePublicAppService_Tests.cs @@ -4,34 +4,33 @@ using Shouldly; using Volo.CmsKit.Public.Pages; using Xunit; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public class PagePublicAppService_Tests : CmsKitApplicationTestBase { - public class PagePublicAppService_Tests : CmsKitApplicationTestBase + private readonly CmsKitTestData _data; + private readonly IPagePublicAppService _pageAppService; + + public PagePublicAppService_Tests() + { + _data = GetRequiredService(); + _pageAppService = GetRequiredService(); + } + + [Fact] + public async Task ShouldFindByUrlAsync() { - private readonly CmsKitTestData _data; - private readonly IPagePublicAppService _pageAppService; - - public PagePublicAppService_Tests() - { - _data = GetRequiredService(); - _pageAppService = GetRequiredService(); - } + var page = await _pageAppService.FindBySlugAsync(_data.Page_1_Slug); + + page.ShouldNotBeNull(); + page.Title.ShouldBe(_data.Page_1_Title); + } - [Fact] - public async Task ShouldFindByUrlAsync() - { - var page = await _pageAppService.FindBySlugAsync(_data.Page_1_Slug); + [Fact] + public async Task ShouldNotGetByUrlAsync() + { + var page = await _pageAppService.FindBySlugAsync("not-exist-url"); - page.ShouldNotBeNull(); - page.Title.ShouldBe(_data.Page_1_Title); - } - - [Fact] - public async Task ShouldNotGetByUrlAsync() - { - var page = await _pageAppService.FindBySlugAsync("not-exist-url"); - - page.ShouldBeNull(); - } + page.ShouldBeNull(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Ratings/RatingPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Ratings/RatingPublicAppService_Tests.cs index dabcbb6c91..6cc660dedd 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Ratings/RatingPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Ratings/RatingPublicAppService_Tests.cs @@ -7,106 +7,105 @@ using Volo.Abp.Users; using Volo.CmsKit.Public.Ratings; using Xunit; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public class RatingPublicAppService_Tests : CmsKitApplicationTestBase { - public class RatingPublicAppService_Tests : CmsKitApplicationTestBase + private readonly IRatingPublicAppService _ratingAppService; + private ICurrentUser _currentUser; + private readonly CmsKitTestData _cmsKitTestData; + + public RatingPublicAppService_Tests() { - private readonly IRatingPublicAppService _ratingAppService; - private ICurrentUser _currentUser; - private readonly CmsKitTestData _cmsKitTestData; + _ratingAppService = GetRequiredService(); + _cmsKitTestData = GetRequiredService(); + } - public RatingPublicAppService_Tests() - { - _ratingAppService = GetRequiredService(); - _cmsKitTestData = GetRequiredService(); - } + protected override void AfterAddApplication(IServiceCollection services) + { + _currentUser = Substitute.For(); + services.AddSingleton(_currentUser); + } - protected override void AfterAddApplication(IServiceCollection services) - { - _currentUser = Substitute.For(); - services.AddSingleton(_currentUser); - } + [Fact] + public async Task CreateAsync() + { + _currentUser.Id.Returns(_cmsKitTestData.User1Id); + + var newRating = await _ratingAppService.CreateAsync( + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId2, + new CreateUpdateRatingInput + { + StarCount = 4 + }); - [Fact] - public async Task CreateAsync() + UsingDbContext(context => { - _currentUser.Id.Returns(_cmsKitTestData.User1Id); + var ratings = context.Set().Where(x => + x.EntityId == _cmsKitTestData.EntityId2 && x.EntityType == _cmsKitTestData.EntityType1).ToList(); + + ratings + .Any(c => c.Id == newRating.Id && c.CreatorId == newRating.CreatorId && + c.StarCount == newRating.StarCount) + .ShouldBeTrue(); + }); + } - var newRating = await _ratingAppService.CreateAsync( - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId2, - new CreateUpdateRatingInput - { - StarCount = 4 - }); + [Fact] + public async Task CreateAsync_Should_Update_If_Rating_Is_Exist() + { + _currentUser.Id.Returns(_cmsKitTestData.User1Id); - UsingDbContext(context => - { - var ratings = context.Set().Where(x => - x.EntityId == _cmsKitTestData.EntityId2 && x.EntityType == _cmsKitTestData.EntityType1).ToList(); + var entity = + (await _ratingAppService.GetGroupedStarCountsAsync(_cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1)).FirstOrDefault(); - ratings - .Any(c => c.Id == newRating.Id && c.CreatorId == newRating.CreatorId && - c.StarCount == newRating.StarCount) - .ShouldBeTrue(); + var updatedEntity = await _ratingAppService.CreateAsync( + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + new CreateUpdateRatingInput + { + StarCount = 5 }); - } - - [Fact] - public async Task CreateAsync_Should_Update_If_Rating_Is_Exist() - { - _currentUser.Id.Returns(_cmsKitTestData.User1Id); - - var entity = - (await _ratingAppService.GetGroupedStarCountsAsync(_cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1)).FirstOrDefault(); - - var updatedEntity = await _ratingAppService.CreateAsync( - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - new CreateUpdateRatingInput - { - StarCount = 5 - }); - - entity.StarCount.ShouldBe(updatedEntity.StarCount); - } - - [Fact] - public async Task GetGroupedStarCountsAsync() - { - _currentUser.Id.Returns(_cmsKitTestData.User1Id); - var ratings = await _ratingAppService.GetGroupedStarCountsAsync( - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1 - ); + entity.StarCount.ShouldBe(updatedEntity.StarCount); + } - ratings.ShouldNotBeNull(); - ratings.Count.ShouldBeGreaterThan(0); - } + [Fact] + public async Task GetGroupedStarCountsAsync() + { + _currentUser.Id.Returns(_cmsKitTestData.User1Id); - [Fact] - public async Task DeleteAsync() - { - _currentUser.Id.Returns(_cmsKitTestData.User1Id); + var ratings = await _ratingAppService.GetGroupedStarCountsAsync( + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1 + ); - var rating = await _ratingAppService.CreateAsync( - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - new CreateUpdateRatingInput - { - StarCount = 4 - }); + ratings.ShouldNotBeNull(); + ratings.Count.ShouldBeGreaterThan(0); + } - await _ratingAppService.DeleteAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); + [Fact] + public async Task DeleteAsync() + { + _currentUser.Id.Returns(_cmsKitTestData.User1Id); - UsingDbContext(context => + var rating = await _ratingAppService.CreateAsync( + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + new CreateUpdateRatingInput { - var deletedComment = context.Set().FirstOrDefault(x => x.Id == rating.Id); - - deletedComment.ShouldBeNull(); + StarCount = 4 }); - } + + await _ratingAppService.DeleteAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); + + UsingDbContext(context => + { + var deletedComment = context.Set().FirstOrDefault(x => x.Id == rating.Id); + + deletedComment.ShouldBeNull(); + }); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs index ad8dac23ba..b7fe55289c 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs @@ -7,96 +7,95 @@ using Volo.Abp.Users; using Volo.CmsKit.Public.Reactions; using Xunit; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class ReactionPublicAppService_Tests : CmsKitApplicationTestBase { - public class ReactionPublicAppService_Tests : CmsKitApplicationTestBase + + private readonly CmsKitTestData _cmsKitTestData; + private readonly ReactionPublicAppService _reactionPublicAppService; + private ICurrentUser _currentUser; + + public ReactionPublicAppService_Tests() { + _cmsKitTestData = GetRequiredService(); + _reactionPublicAppService = GetRequiredService(); + } - private readonly CmsKitTestData _cmsKitTestData; - private readonly ReactionPublicAppService _reactionPublicAppService; - private ICurrentUser _currentUser; + protected override void AfterAddApplication(IServiceCollection services) + { + _currentUser = Substitute.For(); + services.AddSingleton(_currentUser); + } - public ReactionPublicAppService_Tests() - { - _cmsKitTestData = GetRequiredService(); - _reactionPublicAppService = GetRequiredService(); - } + [Fact] + public async Task GetForSelectionAsync() + { + _currentUser.Id.Returns(_cmsKitTestData.User1Id); + _currentUser.IsAuthenticated.Returns(true); + + var reactions = await _reactionPublicAppService.GetForSelectionAsync( + _cmsKitTestData.EntityType2, + _cmsKitTestData.EntityId1 + ); + + reactions.Items. + First(r => r.Reaction.Name == StandardReactions.Rocket).IsSelectedByCurrentUser.ShouldBeTrue(); + + reactions.Items. + First(r => r.Reaction.Name == StandardReactions.Rocket).Count.ShouldBe(1); + + reactions.Items. + Where(r => r.Reaction.Name != StandardReactions.Rocket).All(r => !r.IsSelectedByCurrentUser) + .ShouldBeTrue(); + reactions.Items. + Where(r => r.Reaction.Name != StandardReactions.Rocket).All(r => r.Count == 0) + .ShouldBeTrue(); + } - protected override void AfterAddApplication(IServiceCollection services) - { - _currentUser = Substitute.For(); - services.AddSingleton(_currentUser); - } + [Fact] + public async Task CreateAsync() + { + _currentUser.Id.Returns(_cmsKitTestData.User1Id); - [Fact] - public async Task GetForSelectionAsync() - { - _currentUser.Id.Returns(_cmsKitTestData.User1Id); - _currentUser.IsAuthenticated.Returns(true); - - var reactions = await _reactionPublicAppService.GetForSelectionAsync( - _cmsKitTestData.EntityType2, - _cmsKitTestData.EntityId1 - ); - - reactions.Items. - First(r=>r.Reaction.Name == StandardReactions.Rocket).IsSelectedByCurrentUser.ShouldBeTrue(); - - reactions.Items. - First(r=>r.Reaction.Name == StandardReactions.Rocket).Count.ShouldBe(1); - - reactions.Items. - Where(r=>r.Reaction.Name != StandardReactions.Rocket).All(r=>!r.IsSelectedByCurrentUser) - .ShouldBeTrue(); - reactions.Items. - Where(r=>r.Reaction.Name != StandardReactions.Rocket).All(r=> r.Count == 0) - .ShouldBeTrue(); - } - - [Fact] - public async Task CreateAsync() + await _reactionPublicAppService.CreateAsync( + _cmsKitTestData.EntityType2, + _cmsKitTestData.EntityId2, + StandardReactions.Eyes + ); + + UsingDbContext(context => { - _currentUser.Id.Returns(_cmsKitTestData.User1Id); - - await _reactionPublicAppService.CreateAsync( - _cmsKitTestData.EntityType2, - _cmsKitTestData.EntityId2, - StandardReactions.Eyes - ); - - UsingDbContext(context => - { - var reaction = context.Set().Where(x => - x.CreatorId == _cmsKitTestData.User1Id && - x.ReactionName == StandardReactions.Eyes && - x.EntityId == _cmsKitTestData.EntityId2 && - x.EntityType == _cmsKitTestData.EntityType2).ToList(); - - reaction.Count.ShouldBe(1); - }); - } - - [Fact] - public async Task DeleteAsync() + var reaction = context.Set().Where(x => + x.CreatorId == _cmsKitTestData.User1Id && + x.ReactionName == StandardReactions.Eyes && + x.EntityId == _cmsKitTestData.EntityId2 && + x.EntityType == _cmsKitTestData.EntityType2).ToList(); + + reaction.Count.ShouldBe(1); + }); + } + + [Fact] + public async Task DeleteAsync() + { + _currentUser.Id.Returns(_cmsKitTestData.User1Id); + + await _reactionPublicAppService.DeleteAsync( + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + StandardReactions.Confused + ); + + UsingDbContext(context => { - _currentUser.Id.Returns(_cmsKitTestData.User1Id); - - await _reactionPublicAppService.DeleteAsync( - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - StandardReactions.Confused - ); - - UsingDbContext(context => - { - var reaction = context.Set().FirstOrDefault(x => - x.CreatorId == _cmsKitTestData.User1Id && - x.ReactionName == StandardReactions.Confused && - x.EntityId == _cmsKitTestData.EntityId1 && - x.EntityType == _cmsKitTestData.EntityType1); - - reaction.ShouldBeNull(); - }); - } + var reaction = context.Set().FirstOrDefault(x => + x.CreatorId == _cmsKitTestData.User1Id && + x.ReactionName == StandardReactions.Confused && + x.EntityId == _cmsKitTestData.EntityId1 && + x.EntityType == _cmsKitTestData.EntityType1); + + reaction.ShouldBeNull(); + }); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagAdminAppService_Tests.cs index e621e87caa..bd3e72c98b 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagAdminAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagAdminAppService_Tests.cs @@ -7,56 +7,55 @@ using Volo.Abp.Users; using Volo.CmsKit.Admin.Tags; using Xunit; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class TagAdminAppService_Tests : CmsKitApplicationTestBase { - public class TagAdminAppService_Tests : CmsKitApplicationTestBase - { - private readonly ITagAdminAppService _tagAdminAppService; - private ICurrentUser _currentUser; - private readonly CmsKitTestData _cmsKitTestData; + private readonly ITagAdminAppService _tagAdminAppService; + private ICurrentUser _currentUser; + private readonly CmsKitTestData _cmsKitTestData; - public TagAdminAppService_Tests() - { - _tagAdminAppService = GetRequiredService(); - _cmsKitTestData = GetRequiredService(); - } + public TagAdminAppService_Tests() + { + _tagAdminAppService = GetRequiredService(); + _cmsKitTestData = GetRequiredService(); + } - protected override void AfterAddApplication(IServiceCollection services) - { - _currentUser = Substitute.For(); - services.AddSingleton(_currentUser); - } + protected override void AfterAddApplication(IServiceCollection services) + { + _currentUser = Substitute.For(); + services.AddSingleton(_currentUser); + } - [Fact] - public async Task ShouldCreateProperly() + [Fact] + public async Task ShouldCreateProperly() + { + var list = await _tagAdminAppService.CreateAsync(new TagCreateDto { - var list = await _tagAdminAppService.CreateAsync(new TagCreateDto - { - EntityType = _cmsKitTestData.EntityType1, - Name = "My First Tag", - }); + EntityType = _cmsKitTestData.EntityType1, + Name = "My First Tag", + }); - list.Id.ShouldNotBe(Guid.Empty); - } + list.Id.ShouldNotBe(Guid.Empty); + } - [Fact] - public async Task ShouldThrowException_WhenTagAlreadyExist() - { - await Should.ThrowAsync(async () => await _tagAdminAppService.CreateAsync(new TagCreateDto - { - EntityType = _cmsKitTestData.Content_1_EntityType, - Name = _cmsKitTestData.Content_1_Tags[0], - })); - } - - public async Task GetTagDefinitionsAsync_ShouldWorkProperly_WithoutParameters() + [Fact] + public async Task ShouldThrowException_WhenTagAlreadyExist() + { + await Should.ThrowAsync(async () => await _tagAdminAppService.CreateAsync(new TagCreateDto { - var definitions = await _tagAdminAppService.GetTagDefinitionsAsync(); + EntityType = _cmsKitTestData.Content_1_EntityType, + Name = _cmsKitTestData.Content_1_Tags[0], + })); + } + + public async Task GetTagDefinitionsAsync_ShouldWorkProperly_WithoutParameters() + { + var definitions = await _tagAdminAppService.GetTagDefinitionsAsync(); - definitions.ShouldNotBeNull(); - definitions.ShouldNotBeEmpty(); - definitions.Count.ShouldBeGreaterThan(1); - definitions.ShouldContain(x => x.EntityType == _cmsKitTestData.TagDefinition_1_EntityType); - } + definitions.ShouldNotBeNull(); + definitions.ShouldNotBeEmpty(); + definitions.Count.ShouldBeGreaterThan(1); + definitions.ShouldContain(x => x.EntityType == _cmsKitTestData.TagDefinition_1_EntityType); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagPublicAppService_Tests.cs index 26a7454a2b..7e177aebe3 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagPublicAppService_Tests.cs @@ -6,42 +6,41 @@ using Volo.Abp.Users; using Volo.CmsKit.Tags; using Xunit; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class TagPublicAppService_Tests : CmsKitApplicationTestBase { - public class TagPublicAppService_Tests : CmsKitApplicationTestBase + private readonly ITagAppService _tagAppService; + private ICurrentUser _currentUser; + private readonly CmsKitTestData _cmsKitTestData; + + public TagPublicAppService_Tests() { - private readonly ITagAppService _tagAppService; - private ICurrentUser _currentUser; - private readonly CmsKitTestData _cmsKitTestData; - - public TagPublicAppService_Tests() - { - _tagAppService = GetRequiredService(); - _cmsKitTestData = GetRequiredService(); - } - - protected override void AfterAddApplication(IServiceCollection services) - { - _currentUser = Substitute.For(); - services.AddSingleton(_currentUser); - } - - [Fact] - public async Task GetAllRelatedTagsAsync() - { - var list = await _tagAppService.GetAllRelatedTagsAsync(_cmsKitTestData.Content_1_EntityType, - _cmsKitTestData.EntityId1); - - list.ShouldNotBeEmpty(); - list.Count.ShouldBe(2); - } - - [Fact] - public async Task ShouldntGet_GetAllRelatedTagsAsync() - { - var list = await _tagAppService.GetAllRelatedTagsAsync("any_other_type", "1"); - - list.ShouldBeEmpty(); - } + _tagAppService = GetRequiredService(); + _cmsKitTestData = GetRequiredService(); + } + + protected override void AfterAddApplication(IServiceCollection services) + { + _currentUser = Substitute.For(); + services.AddSingleton(_currentUser); + } + + [Fact] + public async Task GetAllRelatedTagsAsync() + { + var list = await _tagAppService.GetAllRelatedTagsAsync(_cmsKitTestData.Content_1_EntityType, + _cmsKitTestData.EntityId1); + + list.ShouldNotBeEmpty(); + list.Count.ShouldBe(2); + } + + [Fact] + public async Task ShouldntGet_GetAllRelatedTagsAsync() + { + var list = await _tagAppService.GetAllRelatedTagsAsync("any_other_type", "1"); + + list.ShouldBeEmpty(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/BlogManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/BlogManager_Test.cs index a5b878d454..7b96f2c11f 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/BlogManager_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/BlogManager_Test.cs @@ -3,48 +3,47 @@ using System.Threading.Tasks; using Shouldly; using Xunit; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogManager_Test : CmsKitDomainTestBase { - public class BlogManager_Test : CmsKitDomainTestBase + protected IBlogRepository BlogRepository { get; } + protected BlogManager BlogManager { get; } + protected CmsKitTestData TestData { get; } + + public BlogManager_Test() + { + BlogRepository = GetRequiredService(); + BlogManager = GetRequiredService(); + TestData = GetRequiredService(); + } + + [Fact] + public async Task BlogCreate_ShouldThrowException_WithExistSlug() + { + await Should.ThrowAsync( + async () => + await BlogManager.CreateAsync("test-name", TestData.BlogSlug) + ); + } + + [Fact] + public async Task BlogCreate_ShouldWorkProperly() { - protected IBlogRepository BlogRepository { get; } - protected BlogManager BlogManager { get; } - protected CmsKitTestData TestData { get; } - - public BlogManager_Test() - { - BlogRepository = GetRequiredService(); - BlogManager = GetRequiredService(); - TestData = GetRequiredService(); - } - - [Fact] - public async Task BlogCreate_ShouldThrowException_WithExistSlug() - { - await Should.ThrowAsync( - async () => - await BlogManager.CreateAsync("test-name", TestData.BlogSlug) - ); - } - - [Fact] - public async Task BlogCreate_ShouldWorkProperly() - { - var blog = await BlogManager.CreateAsync("test-name", "test-slug"); - - blog.ShouldNotBeNull(); - blog.Id.ShouldNotBe(Guid.Empty); - } - - [Fact] - public async Task BlogUpdate_ShouldWork() - { - var blog = await BlogRepository.GetAsync(TestData.Blog_Id); - - await BlogManager.UpdateAsync(blog, "New name", "new-slug"); - - blog.Name.ShouldBe("New name"); - blog.Slug.ShouldBe("new-slug"); - } + var blog = await BlogManager.CreateAsync("test-name", "test-slug"); + + blog.ShouldNotBeNull(); + blog.Id.ShouldNotBe(Guid.Empty); + } + + [Fact] + public async Task BlogUpdate_ShouldWork() + { + var blog = await BlogRepository.GetAsync(TestData.Blog_Id); + + await BlogManager.UpdateAsync(blog, "New name", "new-slug"); + + blog.Name.ShouldBe("New name"); + blog.Slug.ShouldBe("new-slug"); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/BlogPostManager_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/BlogPostManager_Tests.cs index 76fa64b2cd..40f552dfdb 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/BlogPostManager_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/BlogPostManager_Tests.cs @@ -10,78 +10,77 @@ using Volo.CmsKit.Tags; using Volo.CmsKit.Users; using Xunit; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class BlogPostManager_Tests : CmsKitDomainTestBase { - public class BlogPostManager_Tests : CmsKitDomainTestBase + private readonly BlogPostManager blogPostManager; + private readonly IGuidGenerator guidGenerator; + private readonly IBlogPostRepository blogPostRepository; + private readonly IBlogRepository blogRepository; + private readonly ICmsUserRepository userRepository; + private readonly CmsKitTestData cmsKitTestData; + + public BlogPostManager_Tests() { - private readonly BlogPostManager blogPostManager; - private readonly IGuidGenerator guidGenerator; - private readonly IBlogPostRepository blogPostRepository; - private readonly IBlogRepository blogRepository; - private readonly ICmsUserRepository userRepository; - private readonly CmsKitTestData cmsKitTestData; - - public BlogPostManager_Tests() - { - blogPostManager = GetRequiredService(); - guidGenerator = GetRequiredService(); - blogPostRepository = GetRequiredService(); - blogRepository = GetRequiredService(); - cmsKitTestData = GetRequiredService(); - userRepository = GetRequiredService(); - } + blogPostManager = GetRequiredService(); + guidGenerator = GetRequiredService(); + blogPostRepository = GetRequiredService(); + blogRepository = GetRequiredService(); + cmsKitTestData = GetRequiredService(); + userRepository = GetRequiredService(); + } - [Fact] - public async Task CreateAsync_ShouldWorkProperly_WithExistingUserAndBlog() - { - var title = "New blog post"; - var slug = "new-blog-post"; + [Fact] + public async Task CreateAsync_ShouldWorkProperly_WithExistingUserAndBlog() + { + var title = "New blog post"; + var slug = "new-blog-post"; - var author = await userRepository.GetAsync(cmsKitTestData.User1Id); + var author = await userRepository.GetAsync(cmsKitTestData.User1Id); - var blog = await blogRepository.GetAsync(cmsKitTestData.Blog_Id); + var blog = await blogRepository.GetAsync(cmsKitTestData.Blog_Id); - var blogPost = await blogPostManager.CreateAsync(author, blog, title, slug); + var blogPost = await blogPostManager.CreateAsync(author, blog, title, slug); - blogPost.Id.ShouldNotBe(Guid.Empty); - blogPost.Title.ShouldBe(title); - blogPost.Slug.ShouldBe(slug); - } + blogPost.Id.ShouldNotBe(Guid.Empty); + blogPost.Title.ShouldBe(title); + blogPost.Slug.ShouldBe(slug); + } - [Fact] - public async Task CreateAsync_ShouldThrowException_WhenSlugAlreadyExists() - { + [Fact] + public async Task CreateAsync_ShouldThrowException_WhenSlugAlreadyExists() + { - var author = await userRepository.GetAsync(cmsKitTestData.User1Id); + var author = await userRepository.GetAsync(cmsKitTestData.User1Id); - var blog = await blogRepository.GetAsync(cmsKitTestData.Blog_Id); + var blog = await blogRepository.GetAsync(cmsKitTestData.Blog_Id); - await Should.ThrowAsync(async () => - await blogPostManager.CreateAsync(author, blog, "Any New Title", cmsKitTestData.BlogPost_1_Slug)); - } + await Should.ThrowAsync(async () => + await blogPostManager.CreateAsync(author, blog, "Any New Title", cmsKitTestData.BlogPost_1_Slug)); + } - [Fact] - public async Task SetSlugAsync_ShouldWorkProperly_WithNonExistingSlug() - { - var newSlug = "yet-another-post"; + [Fact] + public async Task SetSlugAsync_ShouldWorkProperly_WithNonExistingSlug() + { + var newSlug = "yet-another-post"; - var blogPost = await blogPostRepository.GetAsync(cmsKitTestData.BlogPost_1_Id); + var blogPost = await blogPostRepository.GetAsync(cmsKitTestData.BlogPost_1_Id); - await blogPostManager.SetSlugUrlAsync(blogPost, newSlug); + await blogPostManager.SetSlugUrlAsync(blogPost, newSlug); - blogPost.Slug.ShouldBe(newSlug); - } + blogPost.Slug.ShouldBe(newSlug); + } - [Fact] - public async Task SetSlugAsync_ShouldThrowException_WithExistingSlug() - { - var blogPost = await blogPostRepository.GetAsync(cmsKitTestData.BlogPost_1_Id); + [Fact] + public async Task SetSlugAsync_ShouldThrowException_WithExistingSlug() + { + var blogPost = await blogPostRepository.GetAsync(cmsKitTestData.BlogPost_1_Id); - var exception = await Should.ThrowAsync(async () => - await blogPostManager.SetSlugUrlAsync(blogPost, cmsKitTestData.BlogPost_2_Slug)); + var exception = await Should.ThrowAsync(async () => + await blogPostManager.SetSlugUrlAsync(blogPost, cmsKitTestData.BlogPost_2_Slug)); - exception.BlogId.ShouldBe(blogPost.BlogId); - exception.Slug.ShouldBe(cmsKitTestData.BlogPost_2_Slug); - } + exception.BlogId.ShouldBe(blogPost.BlogId); + exception.Slug.ShouldBe(cmsKitTestData.BlogPost_2_Slug); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/SlugExtensions_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/SlugExtensions_Tests.cs index 268cfbab71..941f82c7bf 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/SlugExtensions_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/SlugExtensions_Tests.cs @@ -1,133 +1,132 @@ using Shouldly; using Xunit; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public class SlugExtensions_Tests { - public class SlugExtensions_Tests + [Fact] + public void NormalizeSlug_ShouldWorkProperly() + { + // Arrange + var name = "My awesome name"; + var expected = "my-awesome-name"; + + // Act + var actual = SlugNormalizer.Normalize(name); + + // Assert + actual.ShouldBe(expected); + } + [Fact] + public void NormalizeSlug_ShouldWorkProperly_WithDot() + { + // Arrange + var name = "My Perfect Title v.2"; + var expected = "my-perfect-title-v.2"; + + // Act + var actual = SlugNormalizer.Normalize(name); + + // Assert + actual.ShouldBe(expected); + } + + [Fact] + public void NormalizeSlug_ShouldWorkProperly_WithQuestionMark() + { + // Arrange + var name = "Are you gonna die?"; + var expected = "are-you-gonna-die"; + + // Act + var actual = SlugNormalizer.Normalize(name); + + // Assert + actual.ShouldBe(expected); + } + + [Fact] + public void NormalizeSlug_ShouldWorkProperly_WithAmpersand() + { + // Arrange + var name = "We & Machines Challenge"; + var expected = "we-machines-challenge"; + + // Act + var actual = SlugNormalizer.Normalize(name); + + // Assert + actual.ShouldBe(expected); + } + + [Fact] + public void NormalizeSlug_ShouldWorkProperly_WithDoubleDash() + { + // Arrange + var name = "Go and Code --part 2"; + var expected = "go-and-code-part-2"; + + // Act + var actual = SlugNormalizer.Normalize(name); + + // Assert + actual.ShouldBe(expected); + } + + [Fact] + public void NormalizeSlug_ShouldWorkProperly_WithCyrillicChars() { - [Fact] - public void NormalizeSlug_ShouldWorkProperly() - { - // Arrange - var name = "My awesome name"; - var expected = "my-awesome-name"; - - // Act - var actual = SlugNormalizer.Normalize(name); - - // Assert - actual.ShouldBe(expected); - } - [Fact] - public void NormalizeSlug_ShouldWorkProperly_WithDot() - { - // Arrange - var name = "My Perfect Title v.2"; - var expected = "my-perfect-title-v.2"; - - // Act - var actual = SlugNormalizer.Normalize(name); - - // Assert - actual.ShouldBe(expected); - } - - [Fact] - public void NormalizeSlug_ShouldWorkProperly_WithQuestionMark() - { - // Arrange - var name = "Are you gonna die?"; - var expected = "are-you-gonna-die"; - - // Act - var actual = SlugNormalizer.Normalize(name); - - // Assert - actual.ShouldBe(expected); - } - - [Fact] - public void NormalizeSlug_ShouldWorkProperly_WithAmpersand() - { - // Arrange - var name = "We & Machines Challenge"; - var expected = "we-machines-challenge"; - - // Act - var actual = SlugNormalizer.Normalize(name); - - // Assert - actual.ShouldBe(expected); - } - - [Fact] - public void NormalizeSlug_ShouldWorkProperly_WithDoubleDash() - { - // Arrange - var name = "Go and Code --part 2"; - var expected = "go-and-code-part-2"; - - // Act - var actual = SlugNormalizer.Normalize(name); - - // Assert - actual.ShouldBe(expected); - } - - [Fact] - public void NormalizeSlug_ShouldWorkProperly_WithCyrillicChars() - { - // Arrange - var name = "Мое классное название"; - var expected = "moe-klassnoe-nazvanie"; - - // Act - var actual = SlugNormalizer.Normalize(name); - - // Assert - actual.ShouldBe(expected); - } - - [Fact] - public void NormalizeSlug_ShouldWorkProperly_WithTurkishChars() - { - // Arrange - var name = "Özel Türkçe karakterler: ğüşiöç"; - var expected = "ozel-turkce-karakterler-gusioc"; - - // Act - var actual = SlugNormalizer.Normalize(name); - - // Assert - actual.ShouldBe(expected); - } - - [Fact] - public void NormalizeSlug_ShouldWorkProperly_WithChineseChars() - { - // Arrange - var name = "我的真棒头衔"; - var expected = "wo-de-zhen-bang-tou-xian"; - - // Act - var actual = SlugNormalizer.Normalize(name); - - // Assert - actual.ShouldBe(expected); - } - - [Fact] - public void NormalizeSlug_ShouldWorkProperly_WithEmoji() - { - // Arrange - var name = "Let's Rock 👊"; - var expected = "lets-rock"; - - // Act - var actual = SlugNormalizer.Normalize(name); - - // Assert - actual.ShouldBe(expected); - } + // Arrange + var name = "Мое классное название"; + var expected = "moe-klassnoe-nazvanie"; + + // Act + var actual = SlugNormalizer.Normalize(name); + + // Assert + actual.ShouldBe(expected); + } + + [Fact] + public void NormalizeSlug_ShouldWorkProperly_WithTurkishChars() + { + // Arrange + var name = "Özel Türkçe karakterler: ğüşiöç"; + var expected = "ozel-turkce-karakterler-gusioc"; + + // Act + var actual = SlugNormalizer.Normalize(name); + + // Assert + actual.ShouldBe(expected); + } + + [Fact] + public void NormalizeSlug_ShouldWorkProperly_WithChineseChars() + { + // Arrange + var name = "我的真棒头衔"; + var expected = "wo-de-zhen-bang-tou-xian"; + + // Act + var actual = SlugNormalizer.Normalize(name); + + // Assert + actual.ShouldBe(expected); + } + + [Fact] + public void NormalizeSlug_ShouldWorkProperly_WithEmoji() + { + // Arrange + var name = "Let's Rock 👊"; + var expected = "lets-rock"; + + // Act + var actual = SlugNormalizer.Normalize(name); + + // Assert + actual.ShouldBe(expected); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/CmsKitDomainTestBase.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/CmsKitDomainTestBase.cs index 763942e5ac..42aad0050c 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/CmsKitDomainTestBase.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/CmsKitDomainTestBase.cs @@ -1,27 +1,26 @@ using System; using Volo.CmsKit.EntityFrameworkCore; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +/* Inherit from this class for your domain layer tests. + * See SampleManager_Tests for example. + */ +public abstract class CmsKitDomainTestBase : CmsKitTestBase { - /* Inherit from this class for your domain layer tests. - * See SampleManager_Tests for example. - */ - public abstract class CmsKitDomainTestBase : CmsKitTestBase + protected virtual void UsingDbContext(Action action) { - protected virtual void UsingDbContext(Action action) + using (var dbContext = GetRequiredService()) { - using (var dbContext = GetRequiredService()) - { - action.Invoke(dbContext); - } + action.Invoke(dbContext); } + } - protected virtual T UsingDbContext(Func action) + protected virtual T UsingDbContext(Func action) + { + using (var dbContext = GetRequiredService()) { - using (var dbContext = GetRequiredService()) - { - return action.Invoke(dbContext); - } + return action.Invoke(dbContext); } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/CmsKitDomainTestModule.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/CmsKitDomainTestModule.cs index b5af93fc74..25ceb791a8 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/CmsKitDomainTestModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/CmsKitDomainTestModule.cs @@ -1,16 +1,15 @@ using Volo.CmsKit.EntityFrameworkCore; using Volo.Abp.Modularity; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +/* Domain tests are configured to use the EF Core provider. + * You can switch to MongoDB, however your domain tests should be + * database independent anyway. + */ +[DependsOn( + typeof(CmsKitEntityFrameworkCoreTestModule) + )] +public class CmsKitDomainTestModule : AbpModule { - /* Domain tests are configured to use the EF Core provider. - * You can switch to MongoDB, however your domain tests should be - * database independent anyway. - */ - [DependsOn( - typeof(CmsKitEntityFrameworkCoreTestModule) - )] - public class CmsKitDomainTestModule : AbpModule - { - } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Comments/CommentManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Comments/CommentManager_Test.cs index 5065ec9c06..13846388f1 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Comments/CommentManager_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Comments/CommentManager_Test.cs @@ -7,53 +7,52 @@ using System.Threading.Tasks; using Volo.CmsKit.Users; using Xunit; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public class CommentManager_Test : CmsKitDomainTestBase { - public class CommentManager_Test : CmsKitDomainTestBase + private readonly CommentManager commentManager; + private readonly CmsKitTestData testData; + private readonly ICmsUserRepository userRepository; + + public CommentManager_Test() + { + commentManager = GetRequiredService(); + testData = GetRequiredService(); + userRepository = GetRequiredService(); + } + + [Fact] + public async Task CreateAsync_ShouldWorkProperly_WithCorrectData() + { + var creator = await userRepository.GetAsync(testData.User1Id); + + var text = "Thank you for the article. It's awesome"; + + var comment = await commentManager.CreateAsync(creator, testData.EntityType1, testData.EntityId1, text); + + comment.Id.ShouldNotBe(Guid.Empty); + comment.CreatorId.ShouldBe(creator.Id); + comment.EntityType.ShouldBe(testData.EntityType1); + comment.EntityId.ShouldBe(testData.EntityId1); + comment.Text.ShouldBe(text); + } + + [Fact] + public async Task CreateAsync_ShouldThrowException_WithNotConfiguredEntityType() { - private readonly CommentManager commentManager; - private readonly CmsKitTestData testData; - private readonly ICmsUserRepository userRepository; - - public CommentManager_Test() - { - commentManager = GetRequiredService(); - testData = GetRequiredService(); - userRepository = GetRequiredService(); - } - - [Fact] - public async Task CreateAsync_ShouldWorkProperly_WithCorrectData() - { - var creator = await userRepository.GetAsync(testData.User1Id); - - var text = "Thank you for the article. It's awesome"; - - var comment = await commentManager.CreateAsync(creator, testData.EntityType1, testData.EntityId1, text); - - comment.Id.ShouldNotBe(Guid.Empty); - comment.CreatorId.ShouldBe(creator.Id); - comment.EntityType.ShouldBe(testData.EntityType1); - comment.EntityId.ShouldBe(testData.EntityId1); - comment.Text.ShouldBe(text); - } - - [Fact] - public async Task CreateAsync_ShouldThrowException_WithNotConfiguredEntityType() - { - var creator = await userRepository.GetAsync(testData.User1Id); - var notConfiguredEntityType = "Some.New.Entity"; - var text = "Thank you for the article. It's awesome"; - - var exception = await Should.ThrowAsync(async () => - await commentManager.CreateAsync( - creator, - notConfiguredEntityType, - testData.EntityId1, - text)); - - exception.ShouldNotBeNull(); - exception.EntityType.ShouldBe(notConfiguredEntityType); - } + var creator = await userRepository.GetAsync(testData.User1Id); + var notConfiguredEntityType = "Some.New.Entity"; + var text = "Thank you for the article. It's awesome"; + + var exception = await Should.ThrowAsync(async () => + await commentManager.CreateAsync( + creator, + notConfiguredEntityType, + testData.EntityId1, + text)); + + exception.ShouldNotBeNull(); + exception.EntityType.ShouldBe(notConfiguredEntityType); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Features/GlobalCmsKitFeatures_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Features/GlobalCmsKitFeatures_Tests.cs index 6fcdd52a0f..a56c5961e8 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Features/GlobalCmsKitFeatures_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Features/GlobalCmsKitFeatures_Tests.cs @@ -3,27 +3,26 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.GlobalFeatures; using Xunit; -namespace Volo.CmsKit.Features +namespace Volo.CmsKit.Features; + +public class GlobalCmsKitFeatures_Tests : CmsKitDomainTestBase { - public class GlobalCmsKitFeatures_Tests : CmsKitDomainTestBase + private readonly GlobalCmsKitFeatures _cmsKitFeatures; + + public GlobalCmsKitFeatures_Tests() { - private readonly GlobalCmsKitFeatures _cmsKitFeatures; + _cmsKitFeatures = new GlobalCmsKitFeatures(GlobalFeatureManager.Instance); + } - public GlobalCmsKitFeatures_Tests() - { - _cmsKitFeatures = new GlobalCmsKitFeatures(GlobalFeatureManager.Instance); - } + [Fact] + public void Page_Feature_Should_Enable_Dependent_Features() + { + _cmsKitFeatures.DisableAll(); + _cmsKitFeatures.User.IsEnabled.ShouldBeFalse(); + _cmsKitFeatures.Pages.IsEnabled.ShouldBeFalse(); - [Fact] - public void Page_Feature_Should_Enable_Dependent_Features() - { - _cmsKitFeatures.DisableAll(); - _cmsKitFeatures.User.IsEnabled.ShouldBeFalse(); - _cmsKitFeatures.Pages.IsEnabled.ShouldBeFalse(); - - _cmsKitFeatures.Pages.Enable(); - _cmsKitFeatures.User.IsEnabled.ShouldBeTrue(); - _cmsKitFeatures.Pages.IsEnabled.ShouldBeTrue(); - } + _cmsKitFeatures.Pages.Enable(); + _cmsKitFeatures.User.IsEnabled.ShouldBeTrue(); + _cmsKitFeatures.Pages.IsEnabled.ShouldBeTrue(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/MediaDescriptors/MediaDescriptorManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/MediaDescriptors/MediaDescriptorManager_Test.cs index 6bf183564e..0fc6b111c9 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/MediaDescriptors/MediaDescriptorManager_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/MediaDescriptors/MediaDescriptorManager_Test.cs @@ -7,38 +7,37 @@ using System.Threading.Tasks; using Volo.CmsKit.Blogs; using Xunit; -namespace Volo.CmsKit.MediaDescriptors +namespace Volo.CmsKit.MediaDescriptors; + +public class MediaDescriptorManager_Test : CmsKitDomainTestBase { - public class MediaDescriptorManager_Test : CmsKitDomainTestBase + private readonly MediaDescriptorManager manager; + private readonly CmsKitTestData testData; + + public MediaDescriptorManager_Test() + { + manager = GetRequiredService(); + testData = GetRequiredService(); + } + + [Fact] + public async Task CreateAsync_ShouldWorkProperly_WithDefinedEntityType() { - private readonly MediaDescriptorManager manager; - private readonly CmsKitTestData testData; - - public MediaDescriptorManager_Test() - { - manager = GetRequiredService(); - testData = GetRequiredService(); - } - - [Fact] - public async Task CreateAsync_ShouldWorkProperly_WithDefinedEntityType() - { - var created = await manager.CreateAsync(testData.Media_1_EntityType, "MyAwesomeImage.png", "image/png", 128000); - - created.ShouldNotBeNull(); - created.Id.ShouldNotBe(Guid.Empty); - } - - [Fact] - public async Task CreateAsync_ShouldThrowException_WithUndefinedEntityType() - { - var undefinedEntityType = "My.Any.EntityType"; - - var exception = await Should.ThrowAsync(async () => - await manager.CreateAsync(undefinedEntityType, "import.json", "application/json", 256000)); - - exception.ShouldNotBeNull(); - exception.EntityType.ShouldBe(undefinedEntityType); - } + var created = await manager.CreateAsync(testData.Media_1_EntityType, "MyAwesomeImage.png", "image/png", 128000); + + created.ShouldNotBeNull(); + created.Id.ShouldNotBe(Guid.Empty); + } + + [Fact] + public async Task CreateAsync_ShouldThrowException_WithUndefinedEntityType() + { + var undefinedEntityType = "My.Any.EntityType"; + + var exception = await Should.ThrowAsync(async () => + await manager.CreateAsync(undefinedEntityType, "import.json", "application/json", 256000)); + + exception.ShouldNotBeNull(); + exception.EntityType.ShouldBe(undefinedEntityType); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Menus/MenuManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Menus/MenuManager_Test.cs index c40dab0118..514aa47797 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Menus/MenuManager_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Menus/MenuManager_Test.cs @@ -5,78 +5,77 @@ using System.Threading.Tasks; using Volo.CmsKit.Pages; using Xunit; -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +public class MenuManager_Test : CmsKitDomainTestBase { - public class MenuManager_Test : CmsKitDomainTestBase - { - private readonly MenuItemManager menuManager; - private readonly CmsKitTestData testData; - private readonly IMenuItemRepository menuItemRepository; - private readonly IPageRepository pageRepository; + private readonly MenuItemManager menuManager; + private readonly CmsKitTestData testData; + private readonly IMenuItemRepository menuItemRepository; + private readonly IPageRepository pageRepository; - public MenuManager_Test() - { - menuManager = GetRequiredService(); - testData = GetRequiredService(); - menuItemRepository = GetRequiredService(); - pageRepository = GetRequiredService(); - } + public MenuManager_Test() + { + menuManager = GetRequiredService(); + testData = GetRequiredService(); + menuItemRepository = GetRequiredService(); + pageRepository = GetRequiredService(); + } - [Fact] - public async Task SetPageUrl_ShouldSetUrlSameWithPage_WithExistingPage() - { - var page = await pageRepository.GetAsync(testData.Page_1_Id); + [Fact] + public async Task SetPageUrl_ShouldSetUrlSameWithPage_WithExistingPage() + { + var page = await pageRepository.GetAsync(testData.Page_1_Id); - var menuItem = await menuItemRepository.GetAsync(testData.MenuItem_1_Id); + var menuItem = await menuItemRepository.GetAsync(testData.MenuItem_1_Id); - menuManager.SetPageUrl(menuItem, page); + menuManager.SetPageUrl(menuItem, page); - menuItem.Url.ShouldNotBeNullOrEmpty(); - menuItem.Url.ShouldBe(PageConsts.UrlPrefix + page.Slug); - } + menuItem.Url.ShouldNotBeNullOrEmpty(); + menuItem.Url.ShouldBe(PageConsts.UrlPrefix + page.Slug); + } - [Fact] - public async Task MoveAsync_ShouldMoveCorrectly_UnderAnotherMenu() - { - await menuManager.MoveAsync(testData.MenuItem_3_Id, testData.MenuItem_1_Id); + [Fact] + public async Task MoveAsync_ShouldMoveCorrectly_UnderAnotherMenu() + { + await menuManager.MoveAsync(testData.MenuItem_3_Id, testData.MenuItem_1_Id); - var menu = await menuItemRepository.GetAsync(testData.MenuItem_3_Id); + var menu = await menuItemRepository.GetAsync(testData.MenuItem_3_Id); - menu.ParentId.ShouldBe(testData.MenuItem_1_Id); - } + menu.ParentId.ShouldBe(testData.MenuItem_1_Id); + } - [Fact] - public async Task MoveAsync_ShouldChangePositionCorrectly_UnderRoot() - { - await menuManager.MoveAsync(testData.MenuItem_2_Id, null, 0); + [Fact] + public async Task MoveAsync_ShouldChangePositionCorrectly_UnderRoot() + { + await menuManager.MoveAsync(testData.MenuItem_2_Id, null, 0); - var menuItems = await menuItemRepository.GetListAsync(); + var menuItems = await menuItemRepository.GetListAsync(); - var menuItem1 = menuItems.First(x => x.Id == testData.MenuItem_1_Id); - var menuItem2 = menuItems.First(x => x.Id == testData.MenuItem_2_Id); + var menuItem1 = menuItems.First(x => x.Id == testData.MenuItem_1_Id); + var menuItem2 = menuItems.First(x => x.Id == testData.MenuItem_2_Id); - menuItem1.Order.ShouldBeGreaterThan(menuItem2.Order); - } + menuItem1.Order.ShouldBeGreaterThan(menuItem2.Order); + } - [Fact] - public async Task OrganizeTreeOrderForMenuItem_ShouldWorkProperly_WithNewMenuItem() - { - var menu3Id = Guid.NewGuid(); + [Fact] + public async Task OrganizeTreeOrderForMenuItem_ShouldWorkProperly_WithNewMenuItem() + { + var menu3Id = Guid.NewGuid(); - var menuItems = await menuItemRepository.GetListAsync(); + var menuItems = await menuItemRepository.GetListAsync(); - var menuItem1 = menuItems.First(x => x.Id == testData.MenuItem_1_Id); - var menuItem2 = menuItems.First(x => x.Id == testData.MenuItem_2_Id); - var menuItem3 = new MenuItem(menu3Id, "Menu 3", "#"); + var menuItem1 = menuItems.First(x => x.Id == testData.MenuItem_1_Id); + var menuItem2 = menuItems.First(x => x.Id == testData.MenuItem_2_Id); + var menuItem3 = new MenuItem(menu3Id, "Menu 3", "#"); - menuItems.Add(menuItem3); + menuItems.Add(menuItem3); - menuItem3.Order = 0; + menuItem3.Order = 0; - menuManager.OrganizeTreeOrderForMenuItem(menuItems, menuItem3); + menuManager.OrganizeTreeOrderForMenuItem(menuItems, menuItem3); - menuItem3.Order.ShouldBeLessThan(menuItem1.Order); - menuItem3.Order.ShouldBeLessThan(menuItem2.Order); - } + menuItem3.Order.ShouldBeLessThan(menuItem1.Order); + menuItem3.Order.ShouldBeLessThan(menuItem2.Order); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Pages/PageManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Pages/PageManager_Test.cs index 10dc874399..92dac10caf 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Pages/PageManager_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Pages/PageManager_Test.cs @@ -5,66 +5,65 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public class PageManager_Test : CmsKitDomainTestBase { - public class PageManager_Test : CmsKitDomainTestBase - { - private readonly PageManager pageManager; - private readonly CmsKitTestData testData; - private readonly IPageRepository pageRepository; + private readonly PageManager pageManager; + private readonly CmsKitTestData testData; + private readonly IPageRepository pageRepository; - public PageManager_Test() - { - pageManager = GetRequiredService(); - testData = GetRequiredService(); - pageRepository = GetRequiredService(); - } + public PageManager_Test() + { + pageManager = GetRequiredService(); + testData = GetRequiredService(); + pageRepository = GetRequiredService(); + } - public async Task CreateAsync_ShouldWorkProperly_WithNonExistingSlug() - { - var title = "My awesome page"; - var slug = "my-awesome-page"; - var content = "

My Awesome Page

This is my awesome page content!

"; + public async Task CreateAsync_ShouldWorkProperly_WithNonExistingSlug() + { + var title = "My awesome page"; + var slug = "my-awesome-page"; + var content = "

My Awesome Page

This is my awesome page content!

"; - var page = await pageManager.CreateAsync(title, slug, content); + var page = await pageManager.CreateAsync(title, slug, content); - page.ShouldNotBeNull(); - page.Title.ShouldBe(title); - page.Slug.ShouldBe(slug); - page.Content.ShouldBe(content); - } + page.ShouldNotBeNull(); + page.Title.ShouldBe(title); + page.Slug.ShouldBe(slug); + page.Content.ShouldBe(content); + } - public async Task CreateAsync_ShouldThrowException_WithExistingSlug() - { - var title = "My awesome page"; - var slug = testData.Page_1_Slug; - var content = "

My Awesome Page

This is my awesome page content!

"; + public async Task CreateAsync_ShouldThrowException_WithExistingSlug() + { + var title = "My awesome page"; + var slug = testData.Page_1_Slug; + var content = "

My Awesome Page

This is my awesome page content!

"; - var exception = await Should.ThrowAsync(async () => - await pageManager.CreateAsync(title, slug, content)); + var exception = await Should.ThrowAsync(async () => + await pageManager.CreateAsync(title, slug, content)); - exception.ShouldNotBeNull(); - } + exception.ShouldNotBeNull(); + } - public async Task SetSlugAsync_ShouldWorkProperly_WithNonExistingSlug() - { - var newSlug = "freshly-generated-new-slug"; - var page = await pageRepository.GetAsync(testData.Page_1_Id); + public async Task SetSlugAsync_ShouldWorkProperly_WithNonExistingSlug() + { + var newSlug = "freshly-generated-new-slug"; + var page = await pageRepository.GetAsync(testData.Page_1_Id); - await pageManager.SetSlugAsync(page, newSlug); + await pageManager.SetSlugAsync(page, newSlug); - page.Slug.ShouldBe(newSlug); - } + page.Slug.ShouldBe(newSlug); + } - public async Task SetSlugAsync_ShouldThrowException_WithExistingSlug() - { - var newSlug = testData.Page_2_Slug; - var page = await pageRepository.GetAsync(testData.Page_1_Id); + public async Task SetSlugAsync_ShouldThrowException_WithExistingSlug() + { + var newSlug = testData.Page_2_Slug; + var page = await pageRepository.GetAsync(testData.Page_1_Id); - var exception = await Should.ThrowAsync(async () => - await pageManager.SetSlugAsync(page, newSlug)); + var exception = await Should.ThrowAsync(async () => + await pageManager.SetSlugAsync(page, newSlug)); - exception.ShouldNotBeNull(); - } + exception.ShouldNotBeNull(); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Ratings/RatingManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Ratings/RatingManager_Test.cs index 35927fcb4b..caebf39271 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Ratings/RatingManager_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Ratings/RatingManager_Test.cs @@ -8,59 +8,58 @@ using Volo.CmsKit.Blogs; using Volo.CmsKit.Users; using Xunit; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public class RatingManager_Test : CmsKitDomainTestBase { - public class RatingManager_Test : CmsKitDomainTestBase - { - private readonly CmsKitTestData _cmsKitTestData; - private readonly RatingManager _ratingManager; - private readonly ICmsUserRepository _userRepository; + private readonly CmsKitTestData _cmsKitTestData; + private readonly RatingManager _ratingManager; + private readonly ICmsUserRepository _userRepository; - public RatingManager_Test() - { - _cmsKitTestData = GetRequiredService(); - _ratingManager = GetRequiredService(); - _userRepository = GetRequiredService(); - } + public RatingManager_Test() + { + _cmsKitTestData = GetRequiredService(); + _ratingManager = GetRequiredService(); + _userRepository = GetRequiredService(); + } - [Fact] - public async Task SetStarAsync_ShouldCreate_WhenFirstCall() - { - var user = await _userRepository.GetAsync(_cmsKitTestData.User1Id); - short starCount = 4; + [Fact] + public async Task SetStarAsync_ShouldCreate_WhenFirstCall() + { + var user = await _userRepository.GetAsync(_cmsKitTestData.User1Id); + short starCount = 4; - var rating = await _ratingManager.SetStarAsync(user, _cmsKitTestData.EntityType1, _cmsKitTestData.BlogPost_1_Id.ToString(), starCount); + var rating = await _ratingManager.SetStarAsync(user, _cmsKitTestData.EntityType1, _cmsKitTestData.BlogPost_1_Id.ToString(), starCount); - rating.ShouldNotBeNull(); - rating.Id.ShouldNotBe(Guid.Empty); - rating.StarCount.ShouldBe(starCount); - } + rating.ShouldNotBeNull(); + rating.Id.ShouldNotBe(Guid.Empty); + rating.StarCount.ShouldBe(starCount); + } - [Fact] - public async Task SetStarAsync_ShouldUpdate_WithExistingRating() - { - var user = await _userRepository.GetAsync(_cmsKitTestData.User1Id); - short starCount = 2; + [Fact] + public async Task SetStarAsync_ShouldUpdate_WithExistingRating() + { + var user = await _userRepository.GetAsync(_cmsKitTestData.User1Id); + short starCount = 2; - var rating = await _ratingManager.SetStarAsync(user, _cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1, starCount); + var rating = await _ratingManager.SetStarAsync(user, _cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1, starCount); - rating.ShouldNotBeNull(); - rating.Id.ShouldNotBe(Guid.Empty); - rating.StarCount.ShouldBe(starCount); - } + rating.ShouldNotBeNull(); + rating.Id.ShouldNotBe(Guid.Empty); + rating.StarCount.ShouldBe(starCount); + } - [Fact] - public async Task SetStarAsync_ShouldThrowException_WithNotConfiguredentityType() - { - var user = await _userRepository.GetAsync(_cmsKitTestData.User1Id); - var notConfiguredEntityType = "AnyOtherEntityType"; - short starCount = 3; + [Fact] + public async Task SetStarAsync_ShouldThrowException_WithNotConfiguredentityType() + { + var user = await _userRepository.GetAsync(_cmsKitTestData.User1Id); + var notConfiguredEntityType = "AnyOtherEntityType"; + short starCount = 3; - var exception = await Should.ThrowAsync(async () => - await _ratingManager.SetStarAsync(user, notConfiguredEntityType, "1", starCount)); + var exception = await Should.ThrowAsync(async () => + await _ratingManager.SetStarAsync(user, notConfiguredEntityType, "1", starCount)); - exception.ShouldNotBeNull(); - exception.EntityType.ShouldBe(notConfiguredEntityType); - } + exception.ShouldNotBeNull(); + exception.EntityType.ShouldBe(notConfiguredEntityType); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs index e9af4c3e7e..09f8a4b7fb 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs @@ -3,80 +3,79 @@ using System.Threading.Tasks; using Shouldly; using Xunit; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public class ReactionManager_Tests : CmsKitDomainTestBase { - public class ReactionManager_Tests : CmsKitDomainTestBase + private readonly CmsKitTestData _cmsKitTestData; + private readonly ReactionManager _reactionManager; + + public ReactionManager_Tests() { - private readonly CmsKitTestData _cmsKitTestData; - private readonly ReactionManager _reactionManager; + _cmsKitTestData = GetRequiredService(); + _reactionManager = GetRequiredService(); + } - public ReactionManager_Tests() - { - _cmsKitTestData = GetRequiredService(); - _reactionManager = GetRequiredService(); - } + [Fact] + public async Task GetReactionsAsync() + { + var reactions = await _reactionManager.GetReactionsAsync(_cmsKitTestData.EntityType1); - [Fact] - public async Task GetReactionsAsync() - { - var reactions = await _reactionManager.GetReactionsAsync(_cmsKitTestData.EntityType1); + reactions.Count.ShouldBe(12); - reactions.Count.ShouldBe(12); + var reactionsByEntityType = await _reactionManager.GetReactionsAsync(_cmsKitTestData.EntityType1); - var reactionsByEntityType = await _reactionManager.GetReactionsAsync(_cmsKitTestData.EntityType1); + reactionsByEntityType.Count.ShouldBe(12); + } - reactionsByEntityType.Count.ShouldBe(12); - } + [Fact] + public async Task GetSummariesAsync() + { + var summary = await _reactionManager.GetSummariesAsync( + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1 + ); - [Fact] - public async Task GetSummariesAsync() - { - var summary = await _reactionManager.GetSummariesAsync( - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1 - ); + summary.Single(s => s.Reaction.Name == StandardReactions.ThumbsUp).Count.ShouldBe(2); + summary.Single(s => s.Reaction.Name == StandardReactions.Confused).Count.ShouldBe(1); + summary.Single(s => s.Reaction.Name == StandardReactions.Rocket).Count.ShouldBe(0); + } - summary.Single(s=>s.Reaction.Name == StandardReactions.ThumbsUp).Count.ShouldBe(2); - summary.Single(s=>s.Reaction.Name == StandardReactions.Confused).Count.ShouldBe(1); - summary.Single(s=>s.Reaction.Name == StandardReactions.Rocket).Count.ShouldBe(0); - } + [Fact] + public async Task CreateAsync() + { + var reaction = await _reactionManager.GetOrCreateAsync( + _cmsKitTestData.User2Id, + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId2, + StandardReactions.Eyes + ); - [Fact] - public async Task CreateAsync() - { - var reaction = await _reactionManager.GetOrCreateAsync( - _cmsKitTestData.User2Id, - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId2, - StandardReactions.Eyes - ); + reaction.CreatorId.ShouldBe(_cmsKitTestData.User2Id); + reaction.EntityType.ShouldBe(_cmsKitTestData.EntityType1); + reaction.EntityId.ShouldBe(_cmsKitTestData.EntityId2); + reaction.ReactionName.ShouldBe(StandardReactions.Eyes); + } - reaction.CreatorId.ShouldBe(_cmsKitTestData.User2Id); - reaction.EntityType.ShouldBe(_cmsKitTestData.EntityType1); - reaction.EntityId.ShouldBe(_cmsKitTestData.EntityId2); - reaction.ReactionName.ShouldBe(StandardReactions.Eyes); - } + [Fact] + public async Task DeleteAsync() + { + await _reactionManager.DeleteAsync( + _cmsKitTestData.User1Id, + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + StandardReactions.Confused + ); - [Fact] - public async Task DeleteAsync() + UsingDbContext(context => { - await _reactionManager.DeleteAsync( - _cmsKitTestData.User1Id, - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - StandardReactions.Confused - ); - - UsingDbContext(context => - { - var reaction = context.Set().FirstOrDefault(x => - x.CreatorId == _cmsKitTestData.User1Id && - x.ReactionName == StandardReactions.Confused && - x.EntityId == _cmsKitTestData.EntityId1 && - x.EntityType == _cmsKitTestData.EntityType1); + var reaction = context.Set().FirstOrDefault(x => + x.CreatorId == _cmsKitTestData.User1Id && + x.ReactionName == StandardReactions.Confused && + x.EntityId == _cmsKitTestData.EntityId1 && + x.EntityType == _cmsKitTestData.EntityType1); - reaction.ShouldBeNull(); - }); - } + reaction.ShouldBeNull(); + }); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/EntityTagManager_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/EntityTagManager_Tests.cs index a39e6a1095..459ad6ccd3 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/EntityTagManager_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/EntityTagManager_Tests.cs @@ -5,106 +5,105 @@ using System.Threading.Tasks; using Volo.Abp.Guids; using Xunit; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class EntityTagManager_Tests : CmsKitDomainTestBase { - public class EntityTagManager_Tests : CmsKitDomainTestBase - { - private readonly CmsKitTestData _cmsKitTestData; - private readonly EntityTagManager _entityTagManager; - private readonly ITagRepository _tagRepository; - private readonly IGuidGenerator _guidGenerator; + private readonly CmsKitTestData _cmsKitTestData; + private readonly EntityTagManager _entityTagManager; + private readonly ITagRepository _tagRepository; + private readonly IGuidGenerator _guidGenerator; - public EntityTagManager_Tests() - { - _cmsKitTestData = GetRequiredService(); - _entityTagManager = GetRequiredService(); - _tagRepository = GetRequiredService(); - _guidGenerator = GetRequiredService(); - } + public EntityTagManager_Tests() + { + _cmsKitTestData = GetRequiredService(); + _entityTagManager = GetRequiredService(); + _tagRepository = GetRequiredService(); + _guidGenerator = GetRequiredService(); + } - [Fact] - public async Task AddTagToEntityAsync_ShouldAdd_WhenEverythingCorrect() - { - var tag = await _tagRepository.InsertAsync(new Tag(_guidGenerator.Create(), _cmsKitTestData.EntityType1, "My Test Tag #1")); + [Fact] + public async Task AddTagToEntityAsync_ShouldAdd_WhenEverythingCorrect() + { + var tag = await _tagRepository.InsertAsync(new Tag(_guidGenerator.Create(), _cmsKitTestData.EntityType1, "My Test Tag #1")); - var entityTag = await _entityTagManager.AddTagToEntityAsync(tag.Id, _cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); + var entityTag = await _entityTagManager.AddTagToEntityAsync(tag.Id, _cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); - entityTag.ShouldNotBeNull(); - } + entityTag.ShouldNotBeNull(); + } - [Fact] - public async Task AddTagToEntity_ShouldThrowNotTaggable_WithNotConfiguredEntityType() - { - var entityType = "Not.Configured.EntityType"; + [Fact] + public async Task AddTagToEntity_ShouldThrowNotTaggable_WithNotConfiguredEntityType() + { + var entityType = "Not.Configured.EntityType"; - var exception = Should.Throw(async () => - await _entityTagManager.AddTagToEntityAsync(_cmsKitTestData.TagId_1, entityType, _cmsKitTestData.EntityId1) - ); + var exception = Should.Throw(async () => + await _entityTagManager.AddTagToEntityAsync(_cmsKitTestData.TagId_1, entityType, _cmsKitTestData.EntityId1) + ); - exception.ShouldNotBeNull(); - exception.Data[nameof(Tag.EntityType)].ShouldBe(entityType); - } + exception.ShouldNotBeNull(); + exception.Data[nameof(Tag.EntityType)].ShouldBe(entityType); + } - [Fact] - public async Task RemoveTagFromEntityAsync_ShouldRemove_WhenEverythingCorrect() - { - var tagToDelete = (await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1)) - .First(); + [Fact] + public async Task RemoveTagFromEntityAsync_ShouldRemove_WhenEverythingCorrect() + { + var tagToDelete = (await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1)) + .First(); - await _entityTagManager.RemoveTagFromEntityAsync(tagToDelete.Id, tagToDelete.EntityType, _cmsKitTestData.EntityId1); + await _entityTagManager.RemoveTagFromEntityAsync(tagToDelete.Id, tagToDelete.EntityType, _cmsKitTestData.EntityId1); - var tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); + var tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); - tags.ShouldNotContain(x => x.Id == tagToDelete.Id); - } + tags.ShouldNotContain(x => x.Id == tagToDelete.Id); + } - [Fact] - public async Task SetEntityTagsAsync_ShouldWorkProperly_WithNonExistingTags() - { - var newTags = new List { "non-existing-awesome-tag-a", "non-existing-awesome-tag-b" }; + [Fact] + public async Task SetEntityTagsAsync_ShouldWorkProperly_WithNonExistingTags() + { + var newTags = new List { "non-existing-awesome-tag-a", "non-existing-awesome-tag-b" }; - await _entityTagManager.SetEntityTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1, newTags); + await _entityTagManager.SetEntityTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1, newTags); - var tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); + var tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); - tags.ShouldNotBeNull(); - tags.ShouldNotBeEmpty(); - tags.ForEach(tag => newTags.Contains(tag.Name)); - } + tags.ShouldNotBeNull(); + tags.ShouldNotBeEmpty(); + tags.ForEach(tag => newTags.Contains(tag.Name)); + } - [Fact] - public async Task SetEntityTagsAsync_ShouldWorkProperly_WithExistingTag() - { - var entityTags = new List + [Fact] + public async Task SetEntityTagsAsync_ShouldWorkProperly_WithExistingTag() + { + var entityTags = new List { _cmsKitTestData.TagName_1 }; - await _entityTagManager.SetEntityTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1, entityTags); + await _entityTagManager.SetEntityTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1, entityTags); - var tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); + var tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); - tags.ShouldNotBeNull(); - tags.ShouldNotBeEmpty(); - tags.ForEach(tag => entityTags.Contains(tag.Name)); - } + tags.ShouldNotBeNull(); + tags.ShouldNotBeEmpty(); + tags.ForEach(tag => entityTags.Contains(tag.Name)); + } - [Fact] - public async Task SetEntityTagsAsync_ShouldWorkProperly_WithExistingAndNonExistingTag() - { - var entityTags = new List + [Fact] + public async Task SetEntityTagsAsync_ShouldWorkProperly_WithExistingAndNonExistingTag() + { + var entityTags = new List { "New Awesome Tag", _cmsKitTestData.TagName_1 }; - await _entityTagManager.SetEntityTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1, entityTags); + await _entityTagManager.SetEntityTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1, entityTags); - var tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); + var tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1); - tags.ShouldNotBeNull(); - tags.ShouldNotBeEmpty(); - tags.ForEach(tag => entityTags.Contains(tag.Name)); - } + tags.ShouldNotBeNull(); + tags.ShouldNotBeEmpty(); + tags.ForEach(tag => entityTags.Contains(tag.Name)); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/TagEntityTypeDefinitionDictionary_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/TagEntityTypeDefinitionDictionary_Tests.cs index 2f2013cd0b..7f214a0dee 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/TagEntityTypeDefinitionDictionary_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/TagEntityTypeDefinitionDictionary_Tests.cs @@ -10,55 +10,54 @@ using Volo.Abp.Localization; using Volo.CmsKit.Localization; using Xunit; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class TagEntityTypeDefinitionDictionary_Tests : CmsKitDomainTestBase { - public class TagEntityTypeDefinitionDictionary_Tests : CmsKitDomainTestBase - { - private readonly CmsKitTagOptions cmsKitTagOptions; + private readonly CmsKitTagOptions cmsKitTagOptions; - public TagEntityTypeDefinitionDictionary_Tests() - { - var options = GetRequiredService>(); - cmsKitTagOptions = options.Value; - } + public TagEntityTypeDefinitionDictionary_Tests() + { + var options = GetRequiredService>(); + cmsKitTagOptions = options.Value; + } - [Fact] - public void ShouldAddEntityTypeProperly_WithOnlyEntityType() - { - cmsKitTagOptions.EntityTypes.Add(new TagEntityTypeDefiniton("My.Entity.Type")); - } + [Fact] + public void ShouldAddEntityTypeProperly_WithOnlyEntityType() + { + cmsKitTagOptions.EntityTypes.Add(new TagEntityTypeDefiniton("My.Entity.Type")); + } - [Fact] - public void ShouldAddEntityTypeProperly_WithEntityTypeAndDisplayName() - { - cmsKitTagOptions.EntityTypes.Add( - new TagEntityTypeDefiniton( - "My.Entity.Type", - LocalizableString.Create("MyEntity"))); - } + [Fact] + public void ShouldAddEntityTypeProperly_WithEntityTypeAndDisplayName() + { + cmsKitTagOptions.EntityTypes.Add( + new TagEntityTypeDefiniton( + "My.Entity.Type", + LocalizableString.Create("MyEntity"))); + } - [Fact] - public void ShouldAddEntityType_WithAllParameters() - { - cmsKitTagOptions.EntityTypes.Add( - new TagEntityTypeDefiniton( - "My.Entity.Type", - LocalizableString.Create("MyEntity"), - new[] { "SomeCreatePolicy" }, - new[] { "SomeUpdatePolicy" }, - new[] { "SomeDeletePolicy" } - )); - } + [Fact] + public void ShouldAddEntityType_WithAllParameters() + { + cmsKitTagOptions.EntityTypes.Add( + new TagEntityTypeDefiniton( + "My.Entity.Type", + LocalizableString.Create("MyEntity"), + new[] { "SomeCreatePolicy" }, + new[] { "SomeUpdatePolicy" }, + new[] { "SomeDeletePolicy" } + )); + } - [Fact] - public void ShouldThrowException_WhileAddingExistingType() - { - var expectedCount = cmsKitTagOptions.EntityTypes.Count + 1; + [Fact] + public void ShouldThrowException_WhileAddingExistingType() + { + var expectedCount = cmsKitTagOptions.EntityTypes.Count + 1; - cmsKitTagOptions.EntityTypes.Add(new TagEntityTypeDefiniton("My.Entity.Type")); - cmsKitTagOptions.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton("My.Entity.Type")); + cmsKitTagOptions.EntityTypes.Add(new TagEntityTypeDefiniton("My.Entity.Type")); + cmsKitTagOptions.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton("My.Entity.Type")); - cmsKitTagOptions.EntityTypes.Count.ShouldBe(expectedCount); - } + cmsKitTagOptions.EntityTypes.Count.ShouldBe(expectedCount); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/TagManager_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/TagManager_Tests.cs index 0aadc33caf..5cfb863fe9 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/TagManager_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Tags/TagManager_Tests.cs @@ -3,112 +3,111 @@ using System.Threading.Tasks; using Shouldly; using Xunit; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public class TagManager_Tests : CmsKitDomainTestBase { - public class TagManager_Tests : CmsKitDomainTestBase + private readonly CmsKitTestData _cmsKitTestData; + private readonly TagManager _tagManager; + + private readonly ITagRepository _tagRepository; + + public TagManager_Tests() + { + _cmsKitTestData = GetRequiredService(); + _tagManager = GetRequiredService(); + _tagRepository = GetRequiredService(); + } + + [Fact] + public async Task ShouldAddWhenGettingAsync() + { + var newTagEntityType = _cmsKitTestData.EntityType1; + var newTagName = "test_tag_2123"; + + var doesExist = await _tagRepository.AnyAsync(newTagEntityType, newTagName); + + doesExist.ShouldBeFalse(); + + var newTag = await _tagManager.GetOrAddAsync(newTagEntityType, newTagName); + + newTag.ShouldNotBeNull(); + + var doesExistAgain = await _tagRepository.AnyAsync(newTagEntityType, newTagName); + + doesExistAgain.ShouldBeTrue(); + } + + [Fact] + public async Task ShouldNotAddWhenGettingAsync() + { + var tagName = _cmsKitTestData.Content_1_Tags[0]; + + var tag = await _tagRepository.GetAsync(_cmsKitTestData.Content_1_EntityType, tagName); + + var newTag = await _tagManager.GetOrAddAsync(_cmsKitTestData.Content_1_EntityType, tag.Name); + + newTag.ShouldNotBeNull(); + + newTag.Id.ShouldBe(tag.Id); + } + + [Fact] + public async Task ShouldCreateAsync() { - private readonly CmsKitTestData _cmsKitTestData; - private readonly TagManager _tagManager; - - private readonly ITagRepository _tagRepository; - - public TagManager_Tests() - { - _cmsKitTestData = GetRequiredService(); - _tagManager = GetRequiredService(); - _tagRepository = GetRequiredService(); - } - - [Fact] - public async Task ShouldAddWhenGettingAsync() - { - var newTagEntityType = _cmsKitTestData.EntityType1; - var newTagName = "test_tag_2123"; - - var doesExist = await _tagRepository.AnyAsync(newTagEntityType, newTagName); - - doesExist.ShouldBeFalse(); - - var newTag = await _tagManager.GetOrAddAsync(newTagEntityType, newTagName); - - newTag.ShouldNotBeNull(); - - var doesExistAgain = await _tagRepository.AnyAsync(newTagEntityType, newTagName); - - doesExistAgain.ShouldBeTrue(); - } - - [Fact] - public async Task ShouldNotAddWhenGettingAsync() - { - var tagName = _cmsKitTestData.Content_1_Tags[0]; - - var tag = await _tagRepository.GetAsync(_cmsKitTestData.Content_1_EntityType, tagName); - - var newTag = await _tagManager.GetOrAddAsync(_cmsKitTestData.Content_1_EntityType, tag.Name); - - newTag.ShouldNotBeNull(); - - newTag.Id.ShouldBe(tag.Id); - } - - [Fact] - public async Task ShouldCreateAsync() - { - var tagName = "Freshly Created New Tag"; - var tag = await _tagManager.CreateAsync(Guid.NewGuid(), _cmsKitTestData.EntityType1, tagName); - - tag.ShouldNotBeNull(); - - tag.Id.ShouldNotBe(Guid.Empty); - } - - [Fact] - public async Task ShouldntInsertWithUnconfiguredEntityTypeAsync() - { - var notConfiguredEntityType = "My.Namespace.SomeEntity"; - - var exception = await Should.ThrowAsync(async () => - await _tagManager.CreateAsync(Guid.NewGuid(), notConfiguredEntityType, "test")); - - exception.ShouldNotBeNull(); - exception.Data[nameof(Tag.EntityType)].ShouldBe(notConfiguredEntityType); - } - - [Fact] - public async Task ShouldNotInsert() - { - var type = _cmsKitTestData.Content_1_EntityType; - var name = _cmsKitTestData.Content_1_Tags[0]; - - Should.Throw(async () => await _tagManager.CreateAsync(Guid.NewGuid(), type, name)); - } - - [Fact] - public async Task ShouldUpdate() - { - var type = _cmsKitTestData.Content_1_EntityType; - var name = _cmsKitTestData.Content_1_Tags[0]; - var newName = name + "-updated"; - - var tag = await _tagRepository.GetAsync(type, name); - - var updatedTag = await _tagManager.UpdateAsync(tag.Id, newName); - - updatedTag.Id.ShouldBe(tag.Id); - updatedTag.Name.ShouldBe(newName); - } - - [Fact] - public async Task ShouldNotUpdate() - { - var type = _cmsKitTestData.Content_1_EntityType; - var name = _cmsKitTestData.Content_1_Tags[0]; - var newName = _cmsKitTestData.Content_1_Tags[1]; - - var tag = await _tagRepository.GetAsync(type, name); - - Should.Throw(async () => await _tagManager.UpdateAsync(tag.Id, newName)); - } + var tagName = "Freshly Created New Tag"; + var tag = await _tagManager.CreateAsync(Guid.NewGuid(), _cmsKitTestData.EntityType1, tagName); + + tag.ShouldNotBeNull(); + + tag.Id.ShouldNotBe(Guid.Empty); + } + + [Fact] + public async Task ShouldntInsertWithUnconfiguredEntityTypeAsync() + { + var notConfiguredEntityType = "My.Namespace.SomeEntity"; + + var exception = await Should.ThrowAsync(async () => + await _tagManager.CreateAsync(Guid.NewGuid(), notConfiguredEntityType, "test")); + + exception.ShouldNotBeNull(); + exception.Data[nameof(Tag.EntityType)].ShouldBe(notConfiguredEntityType); + } + + [Fact] + public async Task ShouldNotInsert() + { + var type = _cmsKitTestData.Content_1_EntityType; + var name = _cmsKitTestData.Content_1_Tags[0]; + + Should.Throw(async () => await _tagManager.CreateAsync(Guid.NewGuid(), type, name)); + } + + [Fact] + public async Task ShouldUpdate() + { + var type = _cmsKitTestData.Content_1_EntityType; + var name = _cmsKitTestData.Content_1_Tags[0]; + var newName = name + "-updated"; + + var tag = await _tagRepository.GetAsync(type, name); + + var updatedTag = await _tagManager.UpdateAsync(tag.Id, newName); + + updatedTag.Id.ShouldBe(tag.Id); + updatedTag.Name.ShouldBe(newName); + } + + [Fact] + public async Task ShouldNotUpdate() + { + var type = _cmsKitTestData.Content_1_EntityType; + var name = _cmsKitTestData.Content_1_Tags[0]; + var newName = _cmsKitTestData.Content_1_Tags[1]; + + var tag = await _tagRepository.GetAsync(type, name); + + Should.Throw(async () => await _tagManager.UpdateAsync(tag.Id, newName)); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogFeatureRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogFeatureRepository_Test.cs index d6acb2b162..1ef886e871 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogFeatureRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogFeatureRepository_Test.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.EntityFrameworkCore.Blogs +namespace Volo.CmsKit.EntityFrameworkCore.Blogs; + +public class BlogFeatureRepository_Test : BlogFeatureRepository_Test { - public class BlogFeatureRepository_Test : BlogFeatureRepository_Test - { - - } + } diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogPostRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogPostRepository_Test.cs index d393ef943e..1c4ae4ab40 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogPostRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogPostRepository_Test.cs @@ -6,9 +6,8 @@ using System.Threading.Tasks; using Volo.CmsKit.Blogs; using Volo.CmsKit.Pages; -namespace Volo.CmsKit.EntityFrameworkCore.Blogs +namespace Volo.CmsKit.EntityFrameworkCore.Blogs; + +public class BlogPostRepository_Test : BlogPostRepository_Test { - public class BlogPostRepository_Test : BlogPostRepository_Test - { - } } diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogRepository_Test.cs index 40b74d4064..a3caad0879 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogRepository_Test.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.EntityFrameworkCore.Blogs +namespace Volo.CmsKit.EntityFrameworkCore.Blogs; + +public class BlogRepository_Test : BlogRepository_Test { - public class BlogRepository_Test : BlogRepository_Test - { - - } + } diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestBase.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestBase.cs index 2a4679bc09..fcabc3f1e5 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestBase.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestBase.cs @@ -1,10 +1,9 @@ -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +/* This class can be used as a base class for EF Core integration tests, + * while SampleRepository_Tests uses a different approach. + */ +public abstract class CmsKitEntityFrameworkCoreTestBase : CmsKitTestBase { - /* This class can be used as a base class for EF Core integration tests, - * while SampleRepository_Tests uses a different approach. - */ - public abstract class CmsKitEntityFrameworkCoreTestBase : CmsKitTestBase - { - } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs index b98de773ab..9b7fee252a 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs @@ -6,38 +6,37 @@ using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.Sqlite; using Volo.Abp.Modularity; -namespace Volo.CmsKit.EntityFrameworkCore +namespace Volo.CmsKit.EntityFrameworkCore; + +[DependsOn( + typeof(CmsKitTestBaseModule), + typeof(CmsKitEntityFrameworkCoreModule), + typeof(AbpEntityFrameworkCoreSqliteModule) + )] +public class CmsKitEntityFrameworkCoreTestModule : AbpModule { - [DependsOn( - typeof(CmsKitTestBaseModule), - typeof(CmsKitEntityFrameworkCoreModule), - typeof(AbpEntityFrameworkCoreSqliteModule) - )] - public class CmsKitEntityFrameworkCoreTestModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - var sqliteConnection = CreateDatabaseAndGetConnection(); + var sqliteConnection = CreateDatabaseAndGetConnection(); - Configure(options => + Configure(options => + { + options.Configure(abpDbContextConfigurationContext => { - options.Configure(abpDbContextConfigurationContext => - { - abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection); - }); + abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection); }); - } - - private static SqliteConnection CreateDatabaseAndGetConnection() - { - var connection = new SqliteConnection("Data Source=:memory:"); - connection.Open(); + }); + } + + private static SqliteConnection CreateDatabaseAndGetConnection() + { + var connection = new SqliteConnection("Data Source=:memory:"); + connection.Open(); + + new CmsKitDbContext( + new DbContextOptionsBuilder().UseSqlite(connection).Options + ).GetService().CreateTables(); - new CmsKitDbContext( - new DbContextOptionsBuilder().UseSqlite(connection).Options - ).GetService().CreateTables(); - - return connection; - } + return connection; } } diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Comments/CommentRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Comments/CommentRepository_Tests.cs index 69b3da3d9e..a305a0fee2 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Comments/CommentRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Comments/CommentRepository_Tests.cs @@ -1,9 +1,8 @@ using Volo.CmsKit.Comments; -namespace Volo.CmsKit.EntityFrameworkCore.Comments +namespace Volo.CmsKit.EntityFrameworkCore.Comments; + +public class CommentRepository_Tests : CommentRepository_Tests { - public class CommentRepository_Tests : CommentRepository_Tests - { - } } diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Menus/MenuRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Menus/MenuRepository_Test.cs index 9f0cf3db69..00d7c1ff1b 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Menus/MenuRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Menus/MenuRepository_Test.cs @@ -1,9 +1,8 @@ using Volo.CmsKit.Menus; -namespace Volo.CmsKit.EntityFrameworkCore.Menus +namespace Volo.CmsKit.EntityFrameworkCore.Menus; + +public class MenuRepository_Test : MenuItemRepository_Test { - public class MenuRepository_Test : MenuItemRepository_Test - { - - } -} \ No newline at end of file + +} diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Pages/PageRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Pages/PageRepository_Test.cs index d78d10911c..2d605d3ac1 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Pages/PageRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Pages/PageRepository_Test.cs @@ -1,9 +1,8 @@ using Volo.CmsKit.Pages; -namespace Volo.CmsKit.EntityFrameworkCore.Pages +namespace Volo.CmsKit.EntityFrameworkCore.Pages; + +public class PageRepository_Test : PageRepository_Test { - public class PageRepository_Test : PageRepository_Test - { - - } -} \ No newline at end of file + +} diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Ratings/RatingRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Ratings/RatingRepository_Tests.cs index 390ddd1cb3..97c4b764f5 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Ratings/RatingRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Ratings/RatingRepository_Tests.cs @@ -1,9 +1,8 @@ using Volo.CmsKit.Ratings; -namespace Volo.CmsKit.EntityFrameworkCore.Ratings +namespace Volo.CmsKit.EntityFrameworkCore.Ratings; + +public class RatingRepository_Tests : RatingRepository_Tests { - public class RatingRepository_Tests : RatingRepository_Tests - { - - } -} \ No newline at end of file + +} diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Reactions/UserReactionRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Reactions/UserReactionRepository_Tests.cs index 8bb4c68c8e..0d0114ca3c 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Reactions/UserReactionRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Reactions/UserReactionRepository_Tests.cs @@ -1,8 +1,7 @@ using Volo.CmsKit.Reactions; -namespace Volo.CmsKit.EntityFrameworkCore.Reactions +namespace Volo.CmsKit.EntityFrameworkCore.Reactions; + +public class UserReactionRepository_Tests : UserReactionRepository_Tests { - public class UserReactionRepository_Tests : UserReactionRepository_Tests - { - } } diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Tags/EntityTagRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Tags/EntityTagRepository_Test.cs index 01464f46e8..fac4be8de1 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Tags/EntityTagRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Tags/EntityTagRepository_Test.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Volo.CmsKit.Tags; -namespace Volo.CmsKit.EntityFrameworkCore.Tags +namespace Volo.CmsKit.EntityFrameworkCore.Tags; + +public class EntityTagRepository_Test : EntityTagRepository_Test { - public class EntityTagRepository_Test : EntityTagRepository_Test - { - - } + } diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Tags/TagRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Tags/TagRepository_Test.cs index 205379e2b3..1e8c406fd6 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Tags/TagRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Tags/TagRepository_Test.cs @@ -1,9 +1,8 @@ using Volo.CmsKit.Tags; -namespace Volo.CmsKit.EntityFrameworkCore.Tags +namespace Volo.CmsKit.EntityFrameworkCore.Tags; + +public class TagRepository_Test : TagRepository_Test { - public class TagRepository_Test : TagRepository_Test - { - - } -} \ No newline at end of file + +} diff --git a/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs b/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs index 5342fb9dee..686ae72ff9 100644 --- a/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs +++ b/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs @@ -2,19 +2,18 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class ClientDemoService : ITransientDependency { - public class ClientDemoService : ITransientDependency + public async Task RunAsync() { - public async Task RunAsync() - { - await TestWithDynamicProxiesAsync(); - } + await TestWithDynamicProxiesAsync(); + } - private async Task TestWithDynamicProxiesAsync() - { - Console.WriteLine(); - Console.WriteLine($"***** {nameof(TestWithDynamicProxiesAsync)} *****"); - } + private async Task TestWithDynamicProxiesAsync() + { + Console.WriteLine(); + Console.WriteLine($"***** {nameof(TestWithDynamicProxiesAsync)} *****"); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/CmsKitConsoleApiClientModule.cs b/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/CmsKitConsoleApiClientModule.cs index 4fb5bc91e9..51227b46f4 100644 --- a/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/CmsKitConsoleApiClientModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/CmsKitConsoleApiClientModule.cs @@ -1,14 +1,13 @@ using Volo.Abp.Http.Client.IdentityModel; using Volo.Abp.Modularity; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(CmsKitHttpApiClientModule), + typeof(AbpHttpClientIdentityModelModule) + )] +public class CmsKitConsoleApiClientModule : AbpModule { - [DependsOn( - typeof(CmsKitHttpApiClientModule), - typeof(AbpHttpClientIdentityModelModule) - )] - public class CmsKitConsoleApiClientModule : AbpModule - { - - } + } diff --git a/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs b/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs index 5fa4389192..68ef1e40d7 100644 --- a/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs +++ b/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs @@ -4,23 +4,22 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Volo.Abp; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class ConsoleTestAppHostedService : IHostedService { - public class ConsoleTestAppHostedService : IHostedService + public async Task StartAsync(CancellationToken cancellationToken) { - public async Task StartAsync(CancellationToken cancellationToken) + using (var application = AbpApplicationFactory.Create()) { - using (var application = AbpApplicationFactory.Create()) - { - application.Initialize(); + application.Initialize(); - var demo = application.ServiceProvider.GetRequiredService(); - await demo.RunAsync(); + var demo = application.ServiceProvider.GetRequiredService(); + await demo.RunAsync(); - application.Shutdown(); - } + application.Shutdown(); } - - public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; } + + public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; } diff --git a/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/Program.cs b/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/Program.cs index b6d33db416..ad5c90ea70 100644 --- a/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/Program.cs +++ b/modules/cms-kit/test/Volo.CmsKit.HttpApi.Client.ConsoleTestApp/Program.cs @@ -2,20 +2,19 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +class Program { - class Program + static async Task Main(string[] args) { - static async Task Main(string[] args) - { - await CreateHostBuilder(args).RunConsoleAsync(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureServices((hostContext, services) => - { - services.AddHostedService(); - }); + await CreateHostBuilder(args).RunConsoleAsync(); } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); } diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogFeatureRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogFeatureRepository_Test.cs index 35ccc0664c..7aa62b089a 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogFeatureRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogFeatureRepository_Test.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit.MongoDB.Blogs +namespace Volo.CmsKit.MongoDB.Blogs; + +public class BlogFeatureRepository_Test : BlogFeatureRepository_Test { - public class BlogFeatureRepository_Test : BlogFeatureRepository_Test - { - - } + } diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogPostRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogPostRepository_Test.cs index 4bdec74132..3d43e033d9 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogPostRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogPostRepository_Test.cs @@ -6,11 +6,10 @@ using System.Threading.Tasks; using Volo.CmsKit.Blogs; using Xunit; -namespace Volo.CmsKit.MongoDB.Blogs +namespace Volo.CmsKit.MongoDB.Blogs; + +[Collection(MongoTestCollection.Name)] +public class BlogPostRepository_Test : BlogPostRepository_Test { - [Collection(MongoTestCollection.Name)] - public class BlogPostRepository_Test : BlogPostRepository_Test - { - - } + } diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogRepository_Test.cs index 9cac7b473c..05987e6811 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogRepository_Test.cs @@ -6,11 +6,10 @@ using System.Threading.Tasks; using Volo.CmsKit.Blogs; using Xunit; -namespace Volo.CmsKit.MongoDB.Blogs +namespace Volo.CmsKit.MongoDB.Blogs; + +[Collection(MongoTestCollection.Name)] +public class BlogRepository_Test : BlogRepository_Test { - [Collection(MongoTestCollection.Name)] - public class BlogRepository_Test : BlogRepository_Test - { - } } diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/CmsKitMongoDbTestBase.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/CmsKitMongoDbTestBase.cs index 733ae13f0c..bc68a871ad 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/CmsKitMongoDbTestBase.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/CmsKitMongoDbTestBase.cs @@ -1,10 +1,9 @@ -namespace Volo.CmsKit.MongoDB +namespace Volo.CmsKit.MongoDB; + +/* This class can be used as a base class for MongoDB integration tests, + * while SampleRepository_Tests uses a different approach. + */ +public abstract class CmsKitMongoDbTestBase : CmsKitTestBase { - /* This class can be used as a base class for MongoDB integration tests, - * while SampleRepository_Tests uses a different approach. - */ - public abstract class CmsKitMongoDbTestBase : CmsKitTestBase - { - } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/CmsKitMongoDbTestModule.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/CmsKitMongoDbTestModule.cs index d8e781a28c..ec021f9479 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/CmsKitMongoDbTestModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/CmsKitMongoDbTestModule.cs @@ -3,25 +3,24 @@ using Volo.Abp.Data; using Volo.Abp.Modularity; using Volo.Abp.Uow; -namespace Volo.CmsKit.MongoDB +namespace Volo.CmsKit.MongoDB; + +[DependsOn( + typeof(CmsKitTestBaseModule), + typeof(CmsKitMongoDbModule) +)] +public class CmsKitMongoDbTestModule : AbpModule { - [DependsOn( - typeof(CmsKitTestBaseModule), - typeof(CmsKitMongoDbModule) - )] - public class CmsKitMongoDbTestModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - var stringArray = MongoDbFixture.ConnectionString.Split('?'); - var connectionString = stringArray[0].EnsureEndsWith('/') + - "Db_" + - Guid.NewGuid().ToString("N") + "/?" + stringArray[1]; + var stringArray = MongoDbFixture.ConnectionString.Split('?'); + var connectionString = stringArray[0].EnsureEndsWith('/') + + "Db_" + + Guid.NewGuid().ToString("N") + "/?" + stringArray[1]; - Configure(options => - { - options.ConnectionStrings.Default = connectionString; - }); - } + Configure(options => + { + options.ConnectionStrings.Default = connectionString; + }); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Comments/CommentRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Comments/CommentRepository_Tests.cs index 06a8007683..cf64dc57a4 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Comments/CommentRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Comments/CommentRepository_Tests.cs @@ -1,11 +1,10 @@ using Volo.CmsKit.Comments; using Xunit; -namespace Volo.CmsKit.MongoDB.Comments +namespace Volo.CmsKit.MongoDB.Comments; + +[Collection(MongoTestCollection.Name)] +public class CommentRepository_Tests : CommentRepository_Tests { - [Collection(MongoTestCollection.Name)] - public class CommentRepository_Tests : CommentRepository_Tests - { - } } diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Menus/MenuRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Menus/MenuRepository_Test.cs index 61f46dc8fc..acd4b793d8 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Menus/MenuRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Menus/MenuRepository_Test.cs @@ -1,11 +1,10 @@ using Xunit; using Volo.CmsKit.Menus; -namespace Volo.CmsKit.MongoDB.Menus +namespace Volo.CmsKit.MongoDB.Menus; + +[Collection(MongoTestCollection.Name)] +public class MenuRepository_Test : MenuItemRepository_Test { - [Collection(MongoTestCollection.Name)] - public class MenuRepository_Test : MenuItemRepository_Test - { - - } -} \ No newline at end of file + +} diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/MongoDbFixture.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/MongoDbFixture.cs index fd92e70e19..c19a8fec82 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/MongoDbFixture.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/MongoDbFixture.cs @@ -1,22 +1,21 @@ using System; using Mongo2Go; -namespace Volo.CmsKit.MongoDB +namespace Volo.CmsKit.MongoDB; + +public class MongoDbFixture : IDisposable { - public class MongoDbFixture : IDisposable - { - private static readonly MongoDbRunner MongoDbRunner; - public static readonly string ConnectionString; + private static readonly MongoDbRunner MongoDbRunner; + public static readonly string ConnectionString; - static MongoDbFixture() - { - MongoDbRunner = MongoDbRunner.Start(singleNodeReplSet: true, singleNodeReplSetWaitTimeout: 20); - ConnectionString = MongoDbRunner.ConnectionString; - } + static MongoDbFixture() + { + MongoDbRunner = MongoDbRunner.Start(singleNodeReplSet: true, singleNodeReplSetWaitTimeout: 20); + ConnectionString = MongoDbRunner.ConnectionString; + } - public void Dispose() - { - MongoDbRunner?.Dispose(); - } + public void Dispose() + { + MongoDbRunner?.Dispose(); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/MongoTestCollection.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/MongoTestCollection.cs index d6e7f07542..c280dce143 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/MongoTestCollection.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/MongoTestCollection.cs @@ -1,10 +1,9 @@ using Xunit; -namespace Volo.CmsKit.MongoDB +namespace Volo.CmsKit.MongoDB; + +[CollectionDefinition(Name)] +public class MongoTestCollection : ICollectionFixture { - [CollectionDefinition(Name)] - public class MongoTestCollection : ICollectionFixture - { - public const string Name = "MongoDB Collection"; - } -} \ No newline at end of file + public const string Name = "MongoDB Collection"; +} diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Pages/PageRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Pages/PageRepository_Test.cs index 1a379f4e95..340c47ec95 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Pages/PageRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Pages/PageRepository_Test.cs @@ -1,11 +1,10 @@ using Volo.CmsKit.Pages; using Xunit; -namespace Volo.CmsKit.MongoDB.Pages +namespace Volo.CmsKit.MongoDB.Pages; + +[Collection(MongoTestCollection.Name)] +public class PageRepository_Test : PageRepository_Test { - [Collection(MongoTestCollection.Name)] - public class PageRepository_Test : PageRepository_Test - { - - } -} \ No newline at end of file + +} diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Ratings/RatingRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Ratings/RatingRepository_Tests.cs index c0814253e6..24742ec93f 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Ratings/RatingRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Ratings/RatingRepository_Tests.cs @@ -1,11 +1,10 @@ using Volo.CmsKit.Ratings; using Xunit; -namespace Volo.CmsKit.MongoDB.Ratings +namespace Volo.CmsKit.MongoDB.Ratings; + +[Collection(MongoTestCollection.Name)] +public class RatingRepository_Tests : RatingRepository_Tests { - [Collection(MongoTestCollection.Name)] - public class RatingRepository_Tests : RatingRepository_Tests - { - - } -} \ No newline at end of file + +} diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Reactions/UserReactionRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Reactions/UserReactionRepository_Tests.cs index 16740a5803..6df7f3db81 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Reactions/UserReactionRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Reactions/UserReactionRepository_Tests.cs @@ -1,10 +1,9 @@ using Volo.CmsKit.Reactions; using Xunit; -namespace Volo.CmsKit.MongoDB.Reactions +namespace Volo.CmsKit.MongoDB.Reactions; + +[Collection(MongoTestCollection.Name)] +public class UserReactionRepository_Tests : UserReactionRepository_Tests { - [Collection(MongoTestCollection.Name)] - public class UserReactionRepository_Tests : UserReactionRepository_Tests - { - } } diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Tags/EntityTagRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Tags/EntityTagRepository_Test.cs index 919455b109..d2167b4ca0 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Tags/EntityTagRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Tags/EntityTagRepository_Test.cs @@ -6,11 +6,10 @@ using System.Threading.Tasks; using Volo.CmsKit.Tags; using Xunit; -namespace Volo.CmsKit.MongoDB.Tags +namespace Volo.CmsKit.MongoDB.Tags; + +[Collection(MongoTestCollection.Name)] +public class EntityTagRepository_Test : EntityTagRepository_Test { - [Collection(MongoTestCollection.Name)] - public class EntityTagRepository_Test : EntityTagRepository_Test - { - - } + } diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Tags/TagRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Tags/TagRepository_Test.cs index 1c2f063989..89d942dd18 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Tags/TagRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Tags/TagRepository_Test.cs @@ -1,11 +1,10 @@ using Volo.CmsKit.Tags; using Xunit; -namespace Volo.CmsKit.MongoDB.Tags +namespace Volo.CmsKit.MongoDB.Tags; + +[Collection(MongoTestCollection.Name)] +public class TagRepository_Test : TagRepository_Test { - [Collection(MongoTestCollection.Name)] - public class TagRepository_Test : TagRepository_Test - { - - } -} \ No newline at end of file + +} diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogFeatureRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogFeatureRepository_Test.cs index 334489a2aa..352e56a5b7 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogFeatureRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogFeatureRepository_Test.cs @@ -5,65 +5,64 @@ using System.Threading.Tasks; using Volo.Abp.Modularity; using Xunit; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public abstract class BlogFeatureRepository_Test : CmsKitTestBase + where TStartupModule : IAbpModule { - public abstract class BlogFeatureRepository_Test : CmsKitTestBase - where TStartupModule : IAbpModule + private readonly CmsKitTestData testData; + private readonly IBlogFeatureRepository blogFeatureRepository; + public BlogFeatureRepository_Test() { - private readonly CmsKitTestData testData; - private readonly IBlogFeatureRepository blogFeatureRepository; - public BlogFeatureRepository_Test() - { - testData = GetRequiredService(); - blogFeatureRepository = GetRequiredService(); - } + testData = GetRequiredService(); + blogFeatureRepository = GetRequiredService(); + } - [Fact] - public async Task GetListAsync_ShouldWorkProperly_WithBlogId() - { - var result = await blogFeatureRepository.GetListAsync(testData.Blog_Id); + [Fact] + public async Task GetListAsync_ShouldWorkProperly_WithBlogId() + { + var result = await blogFeatureRepository.GetListAsync(testData.Blog_Id); - result.ShouldNotBeNull(); - result.ShouldNotBeEmpty(); - result.Count.ShouldBe(2); - } + result.ShouldNotBeNull(); + result.ShouldNotBeEmpty(); + result.Count.ShouldBe(2); + } - [Fact] - public async Task GetListAsync_ShouldWorkProperly_WithBlogIdWithFeatureNames() - { - var result = await blogFeatureRepository.GetListAsync(testData.Blog_Id, new List { testData.BlogFeature_1_FeatureName }); + [Fact] + public async Task GetListAsync_ShouldWorkProperly_WithBlogIdWithFeatureNames() + { + var result = await blogFeatureRepository.GetListAsync(testData.Blog_Id, new List { testData.BlogFeature_1_FeatureName }); - result.ShouldNotBeNull(); - result.ShouldNotBeEmpty(); - result.Count.ShouldBe(1); - } + result.ShouldNotBeNull(); + result.ShouldNotBeEmpty(); + result.Count.ShouldBe(1); + } - [Fact] - public async Task FindAsync_ShouldWorkProperly_WithExistingFeatureName() - { - var result = await blogFeatureRepository.FindAsync(testData.Blog_Id, testData.BlogFeature_1_FeatureName); + [Fact] + public async Task FindAsync_ShouldWorkProperly_WithExistingFeatureName() + { + var result = await blogFeatureRepository.FindAsync(testData.Blog_Id, testData.BlogFeature_1_FeatureName); - result.ShouldNotBeNull(); - result.FeatureName.ShouldBe(testData.BlogFeature_1_FeatureName); - result.IsEnabled.ShouldBe(testData.BlogFeature_1_Enabled); - } + result.ShouldNotBeNull(); + result.FeatureName.ShouldBe(testData.BlogFeature_1_FeatureName); + result.IsEnabled.ShouldBe(testData.BlogFeature_1_Enabled); + } - [Fact] - public async Task FindAsync_ShouldReturnNull_WithNonExistingFeatureName() - { - var nonExistingFeatureName = "Some.Feature"; - var result = await blogFeatureRepository.FindAsync(testData.Blog_Id, nonExistingFeatureName); + [Fact] + public async Task FindAsync_ShouldReturnNull_WithNonExistingFeatureName() + { + var nonExistingFeatureName = "Some.Feature"; + var result = await blogFeatureRepository.FindAsync(testData.Blog_Id, nonExistingFeatureName); - result.ShouldBeNull(); - } + result.ShouldBeNull(); + } - [Fact] - public async Task FindAsync_ShouldReturnNull_WithNonExistingBlogId() - { - var nonExistingBlogId = Guid.NewGuid(); - var result = await blogFeatureRepository.FindAsync(nonExistingBlogId, testData.BlogFeature_1_FeatureName); + [Fact] + public async Task FindAsync_ShouldReturnNull_WithNonExistingBlogId() + { + var nonExistingBlogId = Guid.NewGuid(); + var result = await blogFeatureRepository.FindAsync(nonExistingBlogId, testData.BlogFeature_1_FeatureName); - result.ShouldBeNull(); - } + result.ShouldBeNull(); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogPostRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogPostRepository_Test.cs index 9b2b471bad..0479ce75b2 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogPostRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogPostRepository_Test.cs @@ -8,142 +8,141 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Modularity; using Xunit; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public abstract class BlogPostRepository_Test : CmsKitTestBase + where TStartupModule : IAbpModule { - public abstract class BlogPostRepository_Test : CmsKitTestBase - where TStartupModule : IAbpModule + private readonly CmsKitTestData testData; + private readonly IBlogPostRepository blogPostRepository; + + public BlogPostRepository_Test() + { + testData = GetRequiredService(); + blogPostRepository = GetRequiredService(); + } + + [Fact] + public async Task SlugExistsAsync_ShouldReturnTrue_WithExistingSlug() + { + var result = await blogPostRepository.SlugExistsAsync(testData.Blog_Id, testData.BlogPost_1_Slug); + + result.ShouldBeTrue(); + } + + [Fact] + public async Task SlugExistsAsync_ShouldReturnFalse_WithNonExistingSlug() + { + var nonExistingSlug = "any-other-url-slug"; + + var result = await blogPostRepository.SlugExistsAsync(testData.Blog_Id, nonExistingSlug); + + result.ShouldBeFalse(); + } + + [Fact] + public async Task SlugExistsAsync_ShouldReturnFalse_WithNonExistingBlogId() + { + var nonExistingBlogId = Guid.NewGuid(); + + var result = await blogPostRepository.SlugExistsAsync(nonExistingBlogId, testData.BlogPost_1_Slug); + + result.ShouldBeFalse(); + } + + [Fact] + public async Task GetBySlugAsync_ShouldWorkProperly_WithCorrectParameters() + { + var blogPost = await blogPostRepository.GetBySlugAsync(testData.Blog_Id, testData.BlogPost_1_Slug); + + blogPost.ShouldNotBeNull(); + blogPost.Id.ShouldBe(testData.BlogPost_1_Id); + blogPost.Slug.ShouldBe(testData.BlogPost_1_Slug); + } + + [Fact] + public async Task GetBySlugAsync_ShouldHaveAuthor_WithCorrectParameters() + { + var blogPost = await blogPostRepository.GetBySlugAsync(testData.Blog_Id, testData.BlogPost_1_Slug); + + blogPost.ShouldNotBeNull(); + blogPost.Id.ShouldBe(testData.BlogPost_1_Id); + blogPost.Slug.ShouldBe(testData.BlogPost_1_Slug); + blogPost.Author.ShouldNotBeNull(); + blogPost.Author.Id.ShouldBe(testData.User1Id); + } + + [Fact] + public async Task GetBySlugAsync_ShouldThrowException_WithNonExistingBlogPostSlug() { - private readonly CmsKitTestData testData; - private readonly IBlogPostRepository blogPostRepository; - - public BlogPostRepository_Test() - { - testData = GetRequiredService(); - blogPostRepository = GetRequiredService(); - } - - [Fact] - public async Task SlugExistsAsync_ShouldReturnTrue_WithExistingSlug() - { - var result = await blogPostRepository.SlugExistsAsync(testData.Blog_Id, testData.BlogPost_1_Slug); - - result.ShouldBeTrue(); - } - - [Fact] - public async Task SlugExistsAsync_ShouldReturnFalse_WithNonExistingSlug() - { - var nonExistingSlug = "any-other-url-slug"; - - var result = await blogPostRepository.SlugExistsAsync(testData.Blog_Id, nonExistingSlug); - - result.ShouldBeFalse(); - } - - [Fact] - public async Task SlugExistsAsync_ShouldReturnFalse_WithNonExistingBlogId() - { - var nonExistingBlogId = Guid.NewGuid(); - - var result = await blogPostRepository.SlugExistsAsync(nonExistingBlogId, testData.BlogPost_1_Slug); - - result.ShouldBeFalse(); - } - - [Fact] - public async Task GetBySlugAsync_ShouldWorkProperly_WithCorrectParameters() - { - var blogPost = await blogPostRepository.GetBySlugAsync(testData.Blog_Id, testData.BlogPost_1_Slug); - - blogPost.ShouldNotBeNull(); - blogPost.Id.ShouldBe(testData.BlogPost_1_Id); - blogPost.Slug.ShouldBe(testData.BlogPost_1_Slug); - } - - [Fact] - public async Task GetBySlugAsync_ShouldHaveAuthor_WithCorrectParameters() - { - var blogPost = await blogPostRepository.GetBySlugAsync(testData.Blog_Id, testData.BlogPost_1_Slug); - - blogPost.ShouldNotBeNull(); - blogPost.Id.ShouldBe(testData.BlogPost_1_Id); - blogPost.Slug.ShouldBe(testData.BlogPost_1_Slug); - blogPost.Author.ShouldNotBeNull(); - blogPost.Author.Id.ShouldBe(testData.User1Id); - } - - [Fact] - public async Task GetBySlugAsync_ShouldThrowException_WithNonExistingBlogPostSlug() - { - var nonExistingSlugUrl = "absolutely-non-existing-url"; - var exception = await Should.ThrowAsync( - async () => await blogPostRepository.GetBySlugAsync(testData.Blog_Id, nonExistingSlugUrl)); - - exception.ShouldNotBeNull(); - exception.EntityType.ShouldBe(typeof(BlogPost)); - } - - [Fact] - public async Task GetBySlugAsync_ShouldThrowException_WithNonExistingBlogId() - { - var nonExistingBlogId = Guid.NewGuid(); - var exception = await Should.ThrowAsync( - async () => await blogPostRepository.GetBySlugAsync(nonExistingBlogId, testData.BlogPost_1_Slug)); - - exception.ShouldNotBeNull(); - exception.EntityType.ShouldBe(typeof(BlogPost)); - } - - [Fact] - public async Task GetPagedListAsync_ShouldWorkProperly_WithBlogId_WhileGetting10_WithoutSorting() - { - var result = await blogPostRepository.GetListAsync(null, testData.Blog_Id); - - result.ShouldNotBeNull(); - result.ShouldNotBeEmpty(); - result.Count.ShouldBe(2); - } - - [Fact] - public async Task GetPagedListAsync_ShouldHaveAuthor_WithBlogId_WhileGetting10_WithoutSorting() - { - var result = await blogPostRepository.GetListAsync(null, testData.Blog_Id); - - result.ShouldNotBeNull(); - result.ShouldNotBeEmpty(); - result.Count.ShouldBe(2); - - result.ForEach(blogPost => blogPost.Author.ShouldNotBeNull()); - } - - [Fact] - public async Task GetPagedListAsync_ShouldWorkProperly_WithBlogId_WhileGetting1_WithoutSorting() - { - var result = await blogPostRepository.GetListAsync(blogId: testData.Blog_Id, maxResultCount: 1); - - result.ShouldNotBeNull(); - result.ShouldNotBeEmpty(); - result.Count.ShouldBe(1); - } - - [Fact] - public async Task GetPagedListAsync_ShouldWorkProperly_WithBlogId_WhileGetting1InPage2_WithoutSorting() - { - var result = await blogPostRepository.GetListAsync(blogId: testData.Blog_Id, skipCount: 1, maxResultCount: 1); - - result.ShouldNotBeNull(); - result.ShouldNotBeEmpty(); - result.Count.ShouldBe(1); - } - - [Fact] - public async Task GetPagedListAsync_ShouldWorkProperly_WithBlogId_WhileGetting10_WithSortingByTitle() - { - var result = await blogPostRepository.GetListAsync(blogId: testData.Blog_Id, sorting: $"{nameof(BlogPost.Title)} asc"); - - result.ShouldNotBeNull(); - result.ShouldNotBeEmpty(); - result.Count.ShouldBe(2); - } + var nonExistingSlugUrl = "absolutely-non-existing-url"; + var exception = await Should.ThrowAsync( + async () => await blogPostRepository.GetBySlugAsync(testData.Blog_Id, nonExistingSlugUrl)); + + exception.ShouldNotBeNull(); + exception.EntityType.ShouldBe(typeof(BlogPost)); + } + + [Fact] + public async Task GetBySlugAsync_ShouldThrowException_WithNonExistingBlogId() + { + var nonExistingBlogId = Guid.NewGuid(); + var exception = await Should.ThrowAsync( + async () => await blogPostRepository.GetBySlugAsync(nonExistingBlogId, testData.BlogPost_1_Slug)); + + exception.ShouldNotBeNull(); + exception.EntityType.ShouldBe(typeof(BlogPost)); + } + + [Fact] + public async Task GetPagedListAsync_ShouldWorkProperly_WithBlogId_WhileGetting10_WithoutSorting() + { + var result = await blogPostRepository.GetListAsync(null, testData.Blog_Id); + + result.ShouldNotBeNull(); + result.ShouldNotBeEmpty(); + result.Count.ShouldBe(2); + } + + [Fact] + public async Task GetPagedListAsync_ShouldHaveAuthor_WithBlogId_WhileGetting10_WithoutSorting() + { + var result = await blogPostRepository.GetListAsync(null, testData.Blog_Id); + + result.ShouldNotBeNull(); + result.ShouldNotBeEmpty(); + result.Count.ShouldBe(2); + + result.ForEach(blogPost => blogPost.Author.ShouldNotBeNull()); + } + + [Fact] + public async Task GetPagedListAsync_ShouldWorkProperly_WithBlogId_WhileGetting1_WithoutSorting() + { + var result = await blogPostRepository.GetListAsync(blogId: testData.Blog_Id, maxResultCount: 1); + + result.ShouldNotBeNull(); + result.ShouldNotBeEmpty(); + result.Count.ShouldBe(1); + } + + [Fact] + public async Task GetPagedListAsync_ShouldWorkProperly_WithBlogId_WhileGetting1InPage2_WithoutSorting() + { + var result = await blogPostRepository.GetListAsync(blogId: testData.Blog_Id, skipCount: 1, maxResultCount: 1); + + result.ShouldNotBeNull(); + result.ShouldNotBeEmpty(); + result.Count.ShouldBe(1); + } + + [Fact] + public async Task GetPagedListAsync_ShouldWorkProperly_WithBlogId_WhileGetting10_WithSortingByTitle() + { + var result = await blogPostRepository.GetListAsync(blogId: testData.Blog_Id, sorting: $"{nameof(BlogPost.Title)} asc"); + + result.ShouldNotBeNull(); + result.ShouldNotBeEmpty(); + result.Count.ShouldBe(2); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogRepository_Test.cs index 6d4fcd59fd..4da3cf7875 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogRepository_Test.cs @@ -8,85 +8,84 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Modularity; using Xunit; -namespace Volo.CmsKit.Blogs +namespace Volo.CmsKit.Blogs; + +public abstract class BlogRepository_Test : CmsKitTestBase + where TStartupModule : IAbpModule { - public abstract class BlogRepository_Test : CmsKitTestBase - where TStartupModule : IAbpModule + private readonly CmsKitTestData testData; + private readonly IBlogRepository blogRepository; + + public BlogRepository_Test() + { + this.testData = GetRequiredService(); + this.blogRepository = GetRequiredService(); + } + + [Fact] + public async Task GetBySlugAsync_ShouldWorkProperly_WithExistingSlug() + { + var blog = await blogRepository.GetBySlugAsync(testData.BlogSlug); + + blog.ShouldNotBeNull(); + blog.Slug.ShouldBe(testData.BlogSlug); + blog.Id.ShouldBe(testData.Blog_Id); + } + + [Fact] + public async Task GetBySlugAsync_ShouldThrowException_WithNonExistingSlug() + { + var nonExistingSlug = "some-blog-slug-that-doesnt-exist"; + + var exception = await Should.ThrowAsync( + async () => await blogRepository.GetBySlugAsync(nonExistingSlug)); + + exception.ShouldNotBeNull(); + exception.EntityType.ShouldBe(typeof(Blog)); + } + + [Fact] + public async Task ExistsAsync_ShouldReturnTrue_WithExistingId() + { + var result = await blogRepository.ExistsAsync(testData.Blog_Id); + + result.ShouldBeTrue(); + } + + [Fact] + public async Task ExistsAsync_ShouldReturnFalse_WithExistingId() + { + var nonExistingId = Guid.NewGuid(); + + var result = await blogRepository.ExistsAsync(nonExistingId); + + result.ShouldBeFalse(); + } + + [Fact] + public async Task GetList_ShouldWorkProperly() + { + var list = await blogRepository.GetListAsync(); + + list.ShouldNotBeNull(); + list.Count.ShouldBeGreaterThan(0); + } + + [Fact] + public async Task GetCount_ShouldWorkProperly() + { + var count = await blogRepository.GetCountAsync(); + + count.ShouldBeGreaterThan(0); + } + + [Fact] + public async Task SlugExistAsync_ShouldWorkProperly() { - private readonly CmsKitTestData testData; - private readonly IBlogRepository blogRepository; - - public BlogRepository_Test() - { - this.testData = GetRequiredService(); - this.blogRepository = GetRequiredService(); - } - - [Fact] - public async Task GetBySlugAsync_ShouldWorkProperly_WithExistingSlug() - { - var blog = await blogRepository.GetBySlugAsync(testData.BlogSlug); - - blog.ShouldNotBeNull(); - blog.Slug.ShouldBe(testData.BlogSlug); - blog.Id.ShouldBe(testData.Blog_Id); - } - - [Fact] - public async Task GetBySlugAsync_ShouldThrowException_WithNonExistingSlug() - { - var nonExistingSlug = "some-blog-slug-that-doesnt-exist"; - - var exception = await Should.ThrowAsync( - async () => await blogRepository.GetBySlugAsync(nonExistingSlug)); - - exception.ShouldNotBeNull(); - exception.EntityType.ShouldBe(typeof(Blog)); - } - - [Fact] - public async Task ExistsAsync_ShouldReturnTrue_WithExistingId() - { - var result = await blogRepository.ExistsAsync(testData.Blog_Id); - - result.ShouldBeTrue(); - } - - [Fact] - public async Task ExistsAsync_ShouldReturnFalse_WithExistingId() - { - var nonExistingId = Guid.NewGuid(); - - var result = await blogRepository.ExistsAsync(nonExistingId); - - result.ShouldBeFalse(); - } - - [Fact] - public async Task GetList_ShouldWorkProperly() - { - var list = await blogRepository.GetListAsync(); - - list.ShouldNotBeNull(); - list.Count.ShouldBeGreaterThan(0); - } - - [Fact] - public async Task GetCount_ShouldWorkProperly() - { - var count = await blogRepository.GetCountAsync(); - - count.ShouldBeGreaterThan(0); - } - - [Fact] - public async Task SlugExistAsync_ShouldWorkProperly() - { - var exists = await blogRepository.SlugExistsAsync(testData.BlogSlug); - var notExists = await blogRepository.SlugExistsAsync("not-existing-blog-slug"); - - exists.ShouldBeTrue(); - notExists.ShouldBeFalse(); - } + var exists = await blogRepository.SlugExistsAsync(testData.BlogSlug); + var notExists = await blogRepository.SlugExistsAsync("not-existing-blog-slug"); + + exists.ShouldBeTrue(); + notExists.ShouldBeFalse(); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs index 9383265019..13414b4573 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs @@ -19,403 +19,403 @@ using Volo.CmsKit.Reactions; using Volo.CmsKit.Tags; using Volo.CmsKit.Users; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class CmsKitDataSeedContributor : IDataSeedContributor, ITransientDependency { - public class CmsKitDataSeedContributor : IDataSeedContributor, ITransientDependency + private readonly IGuidGenerator _guidGenerator; + private readonly ICmsUserRepository _cmsUserRepository; + private readonly CmsKitTestData _cmsKitTestData; + private readonly ICommentRepository _commentRepository; + private readonly ReactionManager _reactionManager; + private readonly IRatingRepository _ratingRepository; + private readonly ICurrentTenant _currentTenant; + private readonly EntityTagManager _entityTagManager; + private readonly TagManager _tagManager; + private readonly ITagRepository _tagRepository; + private readonly IEntityTagRepository _entityTagRepository; + private readonly IPageRepository _pageRepository; + private readonly IBlogRepository _blogRepository; + private readonly IBlogFeatureRepository _blogFeatureRepository; + private readonly IBlogPostRepository _blogPostRepository; + private readonly BlogPostManager _blogPostManager; + private readonly IOptions _reactionOptions; + private readonly IOptions _tagOptions; + private readonly IMediaDescriptorRepository _mediaDescriptorRepository; + private readonly IBlobContainer _mediaBlobContainer; + private readonly BlogManager _blogManager; + private readonly IOptions _mediaOptions; + private readonly IOptions _commentsOptions; + private readonly IOptions _ratingOptions; + private readonly IMenuItemRepository _menuItemRepository; + + public CmsKitDataSeedContributor( + IGuidGenerator guidGenerator, + ICmsUserRepository cmsUserRepository, + CmsKitTestData cmsKitTestData, + ICommentRepository commentRepository, + ReactionManager reactionManager, + IRatingRepository ratingRepository, + ICurrentTenant currentTenant, + TagManager tagManager, + ITagRepository tagRepository, + IEntityTagRepository entityTagRepository, + IPageRepository pageRepository, + IBlogRepository blogRepository, + IBlogPostRepository blogPostRepository, + BlogPostManager blogPostmanager, + IBlogFeatureRepository blogFeatureRepository, + EntityTagManager entityTagManager, + IOptions reactionOptions, + IOptions tagOptions, + IMediaDescriptorRepository mediaDescriptorRepository, + IBlobContainer mediaBlobContainer, + BlogManager blogManager, + IOptions cmsMediaOptions, + IOptions commentsOptions, + IOptions ratingOptions, + IMenuItemRepository menuItemRepository) { - private readonly IGuidGenerator _guidGenerator; - private readonly ICmsUserRepository _cmsUserRepository; - private readonly CmsKitTestData _cmsKitTestData; - private readonly ICommentRepository _commentRepository; - private readonly ReactionManager _reactionManager; - private readonly IRatingRepository _ratingRepository; - private readonly ICurrentTenant _currentTenant; - private readonly EntityTagManager _entityTagManager; - private readonly TagManager _tagManager; - private readonly ITagRepository _tagRepository; - private readonly IEntityTagRepository _entityTagRepository; - private readonly IPageRepository _pageRepository; - private readonly IBlogRepository _blogRepository; - private readonly IBlogFeatureRepository _blogFeatureRepository; - private readonly IBlogPostRepository _blogPostRepository; - private readonly BlogPostManager _blogPostManager; - private readonly IOptions _reactionOptions; - private readonly IOptions _tagOptions; - private readonly IMediaDescriptorRepository _mediaDescriptorRepository; - private readonly IBlobContainer _mediaBlobContainer; - private readonly BlogManager _blogManager; - private readonly IOptions _mediaOptions; - private readonly IOptions _commentsOptions; - private readonly IOptions _ratingOptions; - private readonly IMenuItemRepository _menuItemRepository; - - public CmsKitDataSeedContributor( - IGuidGenerator guidGenerator, - ICmsUserRepository cmsUserRepository, - CmsKitTestData cmsKitTestData, - ICommentRepository commentRepository, - ReactionManager reactionManager, - IRatingRepository ratingRepository, - ICurrentTenant currentTenant, - TagManager tagManager, - ITagRepository tagRepository, - IEntityTagRepository entityTagRepository, - IPageRepository pageRepository, - IBlogRepository blogRepository, - IBlogPostRepository blogPostRepository, - BlogPostManager blogPostmanager, - IBlogFeatureRepository blogFeatureRepository, - EntityTagManager entityTagManager, - IOptions reactionOptions, - IOptions tagOptions, - IMediaDescriptorRepository mediaDescriptorRepository, - IBlobContainer mediaBlobContainer, - BlogManager blogManager, - IOptions cmsMediaOptions, - IOptions commentsOptions, - IOptions ratingOptions, - IMenuItemRepository menuItemRepository) - { - _guidGenerator = guidGenerator; - _cmsUserRepository = cmsUserRepository; - _cmsKitTestData = cmsKitTestData; - _commentRepository = commentRepository; - _reactionManager = reactionManager; - _ratingRepository = ratingRepository; - _currentTenant = currentTenant; - _tagManager = tagManager; - _tagRepository = tagRepository; - _entityTagManager = entityTagManager; - _entityTagRepository = entityTagRepository; - _pageRepository = pageRepository; - _blogRepository = blogRepository; - _blogPostRepository = blogPostRepository; - _blogPostManager = blogPostmanager; - _blogFeatureRepository = blogFeatureRepository; - _reactionOptions = reactionOptions; - _tagOptions = tagOptions; - _mediaDescriptorRepository = mediaDescriptorRepository; - _mediaBlobContainer = mediaBlobContainer; - _blogManager = blogManager; - _mediaOptions = cmsMediaOptions; - _commentsOptions = commentsOptions; - _ratingOptions = ratingOptions; - _menuItemRepository = menuItemRepository; - } + _guidGenerator = guidGenerator; + _cmsUserRepository = cmsUserRepository; + _cmsKitTestData = cmsKitTestData; + _commentRepository = commentRepository; + _reactionManager = reactionManager; + _ratingRepository = ratingRepository; + _currentTenant = currentTenant; + _tagManager = tagManager; + _tagRepository = tagRepository; + _entityTagManager = entityTagManager; + _entityTagRepository = entityTagRepository; + _pageRepository = pageRepository; + _blogRepository = blogRepository; + _blogPostRepository = blogPostRepository; + _blogPostManager = blogPostmanager; + _blogFeatureRepository = blogFeatureRepository; + _reactionOptions = reactionOptions; + _tagOptions = tagOptions; + _mediaDescriptorRepository = mediaDescriptorRepository; + _mediaBlobContainer = mediaBlobContainer; + _blogManager = blogManager; + _mediaOptions = cmsMediaOptions; + _commentsOptions = commentsOptions; + _ratingOptions = ratingOptions; + _menuItemRepository = menuItemRepository; + } - public async Task SeedAsync(DataSeedContext context) + public async Task SeedAsync(DataSeedContext context) + { + using (_currentTenant.Change(context?.TenantId)) { - using (_currentTenant.Change(context?.TenantId)) - { - await ConfigureCmsKitOptionsAsync(); + await ConfigureCmsKitOptionsAsync(); - await SeedUsersAsync(); + await SeedUsersAsync(); - await SeedCommentsAsync(); + await SeedCommentsAsync(); - await SeedReactionsAsync(); + await SeedReactionsAsync(); - await SeedRatingsAsync(); + await SeedRatingsAsync(); - await SeedTagsAsync(); + await SeedTagsAsync(); - await SeedPagesAsync(); + await SeedPagesAsync(); - await SeedBlogsAsync(); + await SeedBlogsAsync(); - await SeedBlogFeaturesAsync(); + await SeedBlogFeaturesAsync(); - await SeedMediaAsync(); + await SeedMediaAsync(); - await SeedMenusAsync(); - } + await SeedMenusAsync(); } + } - private Task ConfigureCmsKitOptionsAsync() + private Task ConfigureCmsKitOptionsAsync() + { + _tagOptions.Value.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton(_cmsKitTestData.EntityType1)); + _tagOptions.Value.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton(_cmsKitTestData.EntityType2)); + _tagOptions.Value.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton(_cmsKitTestData.Content_1_EntityType)); + _tagOptions.Value.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton(_cmsKitTestData.Content_2_EntityType)); + _tagOptions.Value.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton(_cmsKitTestData.TagDefinition_1_EntityType)); + + _mediaOptions.Value.EntityTypes.AddIfNotContains( + new MediaDescriptorDefinition( + _cmsKitTestData.Media_1_EntityType, + createPolicies: new[] { "SomeCreatePolicy" }, + deletePolicies: new[] { "SomeDeletePolicy" })); + + _commentsOptions.Value.EntityTypes.Add( + new CommentEntityTypeDefinition(_cmsKitTestData.EntityType1)); + + List reactions = new() { - _tagOptions.Value.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton(_cmsKitTestData.EntityType1)); - _tagOptions.Value.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton(_cmsKitTestData.EntityType2)); - _tagOptions.Value.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton(_cmsKitTestData.Content_1_EntityType)); - _tagOptions.Value.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton(_cmsKitTestData.Content_2_EntityType)); - _tagOptions.Value.EntityTypes.AddIfNotContains(new TagEntityTypeDefiniton(_cmsKitTestData.TagDefinition_1_EntityType)); - - _mediaOptions.Value.EntityTypes.AddIfNotContains( - new MediaDescriptorDefinition( - _cmsKitTestData.Media_1_EntityType, - createPolicies: new[] { "SomeCreatePolicy" }, - deletePolicies: new[] { "SomeDeletePolicy" })); - - _commentsOptions.Value.EntityTypes.Add( - new CommentEntityTypeDefinition(_cmsKitTestData.EntityType1)); - - List reactions = new() - { - new ReactionDefinition(StandardReactions.Smile), - new ReactionDefinition(StandardReactions.ThumbsUp), - new ReactionDefinition(StandardReactions.ThumbsDown), - new ReactionDefinition(StandardReactions.Confused), - new ReactionDefinition(StandardReactions.Eyes), - new ReactionDefinition(StandardReactions.Heart), - new ReactionDefinition(StandardReactions.HeartBroken), - new ReactionDefinition(StandardReactions.Wink), - new ReactionDefinition(StandardReactions.Pray), - new ReactionDefinition(StandardReactions.Rocket), - new ReactionDefinition(StandardReactions.Victory), - new ReactionDefinition(StandardReactions.Rock), - }; - - _reactionOptions.Value.EntityTypes.Add(new ReactionEntityTypeDefinition(_cmsKitTestData.EntityType1, reactions)); - _reactionOptions.Value.EntityTypes.Add(new ReactionEntityTypeDefinition(_cmsKitTestData.EntityType2, reactions)); - - _ratingOptions.Value.EntityTypes.Add(new RatingEntityTypeDefinition(_cmsKitTestData.EntityType1)); - _ratingOptions.Value.EntityTypes.Add(new RatingEntityTypeDefinition(_cmsKitTestData.EntityType2)); - - return Task.CompletedTask; - } + new ReactionDefinition(StandardReactions.Smile), + new ReactionDefinition(StandardReactions.ThumbsUp), + new ReactionDefinition(StandardReactions.ThumbsDown), + new ReactionDefinition(StandardReactions.Confused), + new ReactionDefinition(StandardReactions.Eyes), + new ReactionDefinition(StandardReactions.Heart), + new ReactionDefinition(StandardReactions.HeartBroken), + new ReactionDefinition(StandardReactions.Wink), + new ReactionDefinition(StandardReactions.Pray), + new ReactionDefinition(StandardReactions.Rocket), + new ReactionDefinition(StandardReactions.Victory), + new ReactionDefinition(StandardReactions.Rock), + }; + + _reactionOptions.Value.EntityTypes.Add(new ReactionEntityTypeDefinition(_cmsKitTestData.EntityType1, reactions)); + _reactionOptions.Value.EntityTypes.Add(new ReactionEntityTypeDefinition(_cmsKitTestData.EntityType2, reactions)); + + _ratingOptions.Value.EntityTypes.Add(new RatingEntityTypeDefinition(_cmsKitTestData.EntityType1)); + _ratingOptions.Value.EntityTypes.Add(new RatingEntityTypeDefinition(_cmsKitTestData.EntityType2)); + + return Task.CompletedTask; + } - private async Task SeedUsersAsync() - { - await _cmsUserRepository.InsertAsync(new CmsUser(new UserData(_cmsKitTestData.User1Id, "user1", - "user1@volo.com", - "user", "1")), - autoSave: true); - - await _cmsUserRepository.InsertAsync(new CmsUser(new UserData(_cmsKitTestData.User2Id, "user2", - "user2@volo.com", - "user", "2")), - autoSave: true); - } + private async Task SeedUsersAsync() + { + await _cmsUserRepository.InsertAsync(new CmsUser(new UserData(_cmsKitTestData.User1Id, "user1", + "user1@volo.com", + "user", "1")), + autoSave: true); + + await _cmsUserRepository.InsertAsync(new CmsUser(new UserData(_cmsKitTestData.User2Id, "user2", + "user2@volo.com", + "user", "2")), + autoSave: true); + } - private async Task SeedCommentsAsync() - { - var comment1 = await _commentRepository.InsertAsync(new Comment(_cmsKitTestData.CommentWithChildId, - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - "comment", - null, - _cmsKitTestData.User1Id - )); + private async Task SeedCommentsAsync() + { + var comment1 = await _commentRepository.InsertAsync(new Comment(_cmsKitTestData.CommentWithChildId, + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + "comment", + null, + _cmsKitTestData.User1Id + )); + + await _commentRepository.InsertAsync(new Comment(_guidGenerator.Create(), + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + "reply", + comment1.Id, + _cmsKitTestData.User2Id + )); + + await _commentRepository.InsertAsync(new Comment(_guidGenerator.Create(), + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + "reply", + comment1.Id, + _cmsKitTestData.User1Id + )); + + await _commentRepository.InsertAsync(new Comment(_guidGenerator.Create(), + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + "comment", + null, + _cmsKitTestData.User2Id + )); + + await _commentRepository.InsertAsync(new Comment(_guidGenerator.Create(), + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId2, + "comment", + null, + _cmsKitTestData.User2Id + )); + + await _commentRepository.InsertAsync(new Comment(_guidGenerator.Create(), + _cmsKitTestData.EntityType2, + _cmsKitTestData.EntityId1, + "comment", + null, + _cmsKitTestData.User2Id + )); + } - await _commentRepository.InsertAsync(new Comment(_guidGenerator.Create(), - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - "reply", - comment1.Id, - _cmsKitTestData.User2Id - )); + private async Task SeedReactionsAsync() + { + await _reactionManager.GetOrCreateAsync( + _cmsKitTestData.User1Id, + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + StandardReactions.Confused); + + await _reactionManager.GetOrCreateAsync( + _cmsKitTestData.User1Id, + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + StandardReactions.ThumbsUp); + + await _reactionManager.GetOrCreateAsync( + _cmsKitTestData.User1Id, + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId2, + StandardReactions.Heart); + + await _reactionManager.GetOrCreateAsync( + _cmsKitTestData.User1Id, + _cmsKitTestData.EntityType2, + _cmsKitTestData.EntityId1, + StandardReactions.Rocket); + + await _reactionManager.GetOrCreateAsync( + _cmsKitTestData.User2Id, + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + StandardReactions.ThumbsUp); + } - await _commentRepository.InsertAsync(new Comment(_guidGenerator.Create(), + private async Task SeedRatingsAsync() + { + await _ratingRepository.InsertAsync(new Rating(_guidGenerator.Create(), _cmsKitTestData.EntityType1, _cmsKitTestData.EntityId1, - "reply", - comment1.Id, + 4, _cmsKitTestData.User1Id )); - await _commentRepository.InsertAsync(new Comment(_guidGenerator.Create(), - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - "comment", - null, - _cmsKitTestData.User2Id - )); - - await _commentRepository.InsertAsync(new Comment(_guidGenerator.Create(), - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId2, - "comment", - null, - _cmsKitTestData.User2Id - )); - - await _commentRepository.InsertAsync(new Comment(_guidGenerator.Create(), - _cmsKitTestData.EntityType2, - _cmsKitTestData.EntityId1, - "comment", - null, - _cmsKitTestData.User2Id - )); - } - - private async Task SeedReactionsAsync() - { - await _reactionManager.GetOrCreateAsync( - _cmsKitTestData.User1Id, - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - StandardReactions.Confused); + await _ratingRepository.InsertAsync(new Rating(_guidGenerator.Create(), + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + 5, + _cmsKitTestData.User1Id + )); + + await _ratingRepository.InsertAsync(new Rating(_guidGenerator.Create(), + _cmsKitTestData.EntityType2, + _cmsKitTestData.EntityId2, + 5, + _cmsKitTestData.User2Id + )); + + await _ratingRepository.InsertAsync(new Rating(_guidGenerator.Create(), + _cmsKitTestData.EntityType2, + _cmsKitTestData.EntityId2, + 1, + _cmsKitTestData.User2Id + )); + } - await _reactionManager.GetOrCreateAsync( - _cmsKitTestData.User1Id, + private async Task SeedTagsAsync() + { + var created1 = await _tagRepository.InsertAsync( + await _tagManager.CreateAsync( + _cmsKitTestData.TagId_1, _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - StandardReactions.ThumbsUp); + _cmsKitTestData.TagName_1)); - await _reactionManager.GetOrCreateAsync( - _cmsKitTestData.User1Id, - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId2, - StandardReactions.Heart); + await _entityTagManager.AddTagToEntityAsync(created1.Id, created1.EntityType, _cmsKitTestData.EntityId1); - await _reactionManager.GetOrCreateAsync( - _cmsKitTestData.User1Id, + var created2 = await _tagRepository.InsertAsync( + await _tagManager.CreateAsync( + _cmsKitTestData.TagId_2, _cmsKitTestData.EntityType2, - _cmsKitTestData.EntityId1, - StandardReactions.Rocket); + _cmsKitTestData.TagName_2)); - await _reactionManager.GetOrCreateAsync( - _cmsKitTestData.User2Id, - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - StandardReactions.ThumbsUp); - } + await _entityTagManager.AddTagToEntityAsync(created2.Id, created2.EntityType, _cmsKitTestData.EntityId2); - private async Task SeedRatingsAsync() + foreach (var tag in _cmsKitTestData.Content_1_Tags) { - await _ratingRepository.InsertAsync(new Rating(_guidGenerator.Create(), - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - 4, - _cmsKitTestData.User1Id - )); - - await _ratingRepository.InsertAsync(new Rating(_guidGenerator.Create(), - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - 5, - _cmsKitTestData.User1Id - )); - - await _ratingRepository.InsertAsync(new Rating(_guidGenerator.Create(), - _cmsKitTestData.EntityType2, - _cmsKitTestData.EntityId2, - 5, - _cmsKitTestData.User2Id - )); + var tagEntity = await _tagRepository.InsertAsync( + await _tagManager.CreateAsync( + _guidGenerator.Create(), + _cmsKitTestData.Content_1_EntityType, + tag)); - await _ratingRepository.InsertAsync(new Rating(_guidGenerator.Create(), - _cmsKitTestData.EntityType2, - _cmsKitTestData.EntityId2, - 1, - _cmsKitTestData.User2Id - )); + await _entityTagManager.AddTagToEntityAsync(tagEntity.Id, _cmsKitTestData.Content_1_EntityType, _cmsKitTestData.Content_1_EntityId); } - private async Task SeedTagsAsync() + foreach (var tag in _cmsKitTestData.Content_2_Tags) { - var created1 = await _tagRepository.InsertAsync( + var tagEntity = await _tagRepository.InsertAsync( await _tagManager.CreateAsync( - _cmsKitTestData.TagId_1, - _cmsKitTestData.EntityType1, - _cmsKitTestData.TagName_1)); + _guidGenerator.Create(), + _cmsKitTestData.Content_2_EntityType, + tag)); - await _entityTagManager.AddTagToEntityAsync(created1.Id, created1.EntityType, _cmsKitTestData.EntityId1); - - var created2 = await _tagRepository.InsertAsync( - await _tagManager.CreateAsync( - _cmsKitTestData.TagId_2, - _cmsKitTestData.EntityType2, - _cmsKitTestData.TagName_2)); - - await _entityTagManager.AddTagToEntityAsync(created2.Id, created2.EntityType, _cmsKitTestData.EntityId2); - - foreach (var tag in _cmsKitTestData.Content_1_Tags) - { - var tagEntity = await _tagRepository.InsertAsync( - await _tagManager.CreateAsync( - _guidGenerator.Create(), - _cmsKitTestData.Content_1_EntityType, - tag)); - - await _entityTagManager.AddTagToEntityAsync(tagEntity.Id, _cmsKitTestData.Content_1_EntityType, _cmsKitTestData.Content_1_EntityId); - } - - foreach (var tag in _cmsKitTestData.Content_2_Tags) - { - var tagEntity = await _tagRepository.InsertAsync( - await _tagManager.CreateAsync( - _guidGenerator.Create(), - _cmsKitTestData.Content_2_EntityType, - tag)); - - await _entityTagManager.AddTagToEntityAsync(tagEntity.Id, _cmsKitTestData.Content_2_EntityType, _cmsKitTestData.Content_2_EntityId); - } + await _entityTagManager.AddTagToEntityAsync(tagEntity.Id, _cmsKitTestData.Content_2_EntityType, _cmsKitTestData.Content_2_EntityId); } + } - private async Task SeedPagesAsync() - { - var page1 = new Page(_cmsKitTestData.Page_1_Id, _cmsKitTestData.Page_1_Title, _cmsKitTestData.Page_1_Slug, _cmsKitTestData.Content_1); - await _pageRepository.InsertAsync(page1); + private async Task SeedPagesAsync() + { + var page1 = new Page(_cmsKitTestData.Page_1_Id, _cmsKitTestData.Page_1_Title, _cmsKitTestData.Page_1_Slug, _cmsKitTestData.Content_1); + await _pageRepository.InsertAsync(page1); - var page2 = new Page(_cmsKitTestData.Page_2_Id, _cmsKitTestData.Page_2_Title, _cmsKitTestData.Page_2_Slug, _cmsKitTestData.Content_2); - await _pageRepository.InsertAsync(page2); - } + var page2 = new Page(_cmsKitTestData.Page_2_Id, _cmsKitTestData.Page_2_Title, _cmsKitTestData.Page_2_Slug, _cmsKitTestData.Content_2); + await _pageRepository.InsertAsync(page2); + } - private async Task SeedBlogsAsync() - { - var blog = await _blogRepository.InsertAsync( - await _blogManager.CreateAsync(_cmsKitTestData.BlogName, _cmsKitTestData.BlogSlug), autoSave: true); - - _cmsKitTestData.Blog_Id = blog.Id; - - var author = await _cmsUserRepository.GetAsync(_cmsKitTestData.User1Id); - - _cmsKitTestData.BlogPost_1_Id = - (await _blogPostRepository.InsertAsync( - await _blogPostManager.CreateAsync( - author, - blog, - _cmsKitTestData.BlogPost_1_Title, - _cmsKitTestData.BlogPost_1_Slug, - "Short desc 1", - "Blog Post 1 Content"))).Id; - - _cmsKitTestData.BlogPost_2_Id = - (await _blogPostRepository.InsertAsync( - await _blogPostManager.CreateAsync( - author, - blog, - _cmsKitTestData.BlogPost_2_Title, - _cmsKitTestData.BlogPost_2_Slug, - "Short desc 2", - "Blog Post 2 Content"))).Id; - } + private async Task SeedBlogsAsync() + { + var blog = await _blogRepository.InsertAsync( + await _blogManager.CreateAsync(_cmsKitTestData.BlogName, _cmsKitTestData.BlogSlug), autoSave: true); + + _cmsKitTestData.Blog_Id = blog.Id; + + var author = await _cmsUserRepository.GetAsync(_cmsKitTestData.User1Id); + + _cmsKitTestData.BlogPost_1_Id = + (await _blogPostRepository.InsertAsync( + await _blogPostManager.CreateAsync( + author, + blog, + _cmsKitTestData.BlogPost_1_Title, + _cmsKitTestData.BlogPost_1_Slug, + "Short desc 1", + "Blog Post 1 Content"))).Id; + + _cmsKitTestData.BlogPost_2_Id = + (await _blogPostRepository.InsertAsync( + await _blogPostManager.CreateAsync( + author, + blog, + _cmsKitTestData.BlogPost_2_Title, + _cmsKitTestData.BlogPost_2_Slug, + "Short desc 2", + "Blog Post 2 Content"))).Id; + } - private async Task SeedBlogFeaturesAsync() - { - var blogFeature1 = await _blogFeatureRepository.InsertAsync( - new BlogFeature( - _cmsKitTestData.Blog_Id, - _cmsKitTestData.BlogFeature_1_FeatureName, - _cmsKitTestData.BlogFeature_1_Enabled)); + private async Task SeedBlogFeaturesAsync() + { + var blogFeature1 = await _blogFeatureRepository.InsertAsync( + new BlogFeature( + _cmsKitTestData.Blog_Id, + _cmsKitTestData.BlogFeature_1_FeatureName, + _cmsKitTestData.BlogFeature_1_Enabled)); - _cmsKitTestData.BlogFeature_1_Id = blogFeature1.Id; + _cmsKitTestData.BlogFeature_1_Id = blogFeature1.Id; - var blogFeature2 = await _blogFeatureRepository.InsertAsync( - new BlogFeature( - _cmsKitTestData.Blog_Id, - _cmsKitTestData.BlogFeature_2_FeatureName, - _cmsKitTestData.BlogFeature_2_Enabled)); + var blogFeature2 = await _blogFeatureRepository.InsertAsync( + new BlogFeature( + _cmsKitTestData.Blog_Id, + _cmsKitTestData.BlogFeature_2_FeatureName, + _cmsKitTestData.BlogFeature_2_Enabled)); - _cmsKitTestData.BlogFeature_2_Id = blogFeature2.Id; - } + _cmsKitTestData.BlogFeature_2_Id = blogFeature2.Id; + } - private async Task SeedMediaAsync() + private async Task SeedMediaAsync() + { + using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(_cmsKitTestData.Media_1_Content))) { - using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(_cmsKitTestData.Media_1_Content))) - { - var media = new MediaDescriptor(_cmsKitTestData.Media_1_Id, _cmsKitTestData.Media_1_EntityType, _cmsKitTestData.Media_1_Name, _cmsKitTestData.Media_1_ContentType, stream.Length); + var media = new MediaDescriptor(_cmsKitTestData.Media_1_Id, _cmsKitTestData.Media_1_EntityType, _cmsKitTestData.Media_1_Name, _cmsKitTestData.Media_1_ContentType, stream.Length); - await _mediaDescriptorRepository.InsertAsync(media); + await _mediaDescriptorRepository.InsertAsync(media); - await _mediaBlobContainer.SaveAsync(media.Id.ToString(), stream); - } + await _mediaBlobContainer.SaveAsync(media.Id.ToString(), stream); } + } - private async Task SeedMenusAsync() + private async Task SeedMenusAsync() + { + await _menuItemRepository.InsertManyAsync(new[] { - await _menuItemRepository.InsertManyAsync(new[] - { new MenuItem( _cmsKitTestData.MenuItem_1_Id, _cmsKitTestData.MenuItem_1_Name, @@ -430,6 +430,5 @@ namespace Volo.CmsKit _cmsKitTestData.MenuItem_3_Url) }); - } } } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitFakeCurrentUser.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitFakeCurrentUser.cs index 700a805561..f16d5b471e 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitFakeCurrentUser.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitFakeCurrentUser.cs @@ -7,47 +7,46 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Users; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class CmsKitFakeCurrentUser : ITransientDependency, ICurrentUser { - public class CmsKitFakeCurrentUser : ITransientDependency, ICurrentUser + private readonly CmsKitTestData cmsKitTestData; + + public CmsKitFakeCurrentUser(CmsKitTestData cmsKitTestData) + { + this.cmsKitTestData = cmsKitTestData; + } + + public bool IsAuthenticated { get; } + public Guid? Id => cmsKitTestData.User1Id; + public string UserName => cmsKitTestData.User1UserName; + public string Name { get; } + public string SurName { get; } + public string PhoneNumber { get; } + public bool PhoneNumberVerified { get; } + public string Email { get; } + public bool EmailVerified { get; } + public Guid? TenantId { get; } + public string[] Roles { get; } + + public Claim FindClaim(string claimType) + { + return null; + } + + public Claim[] FindClaims(string claimType) + { + return null; + } + + public Claim[] GetAllClaims() + { + return null; + } + + public bool IsInRole(string roleName) { - private readonly CmsKitTestData cmsKitTestData; - - public CmsKitFakeCurrentUser(CmsKitTestData cmsKitTestData) - { - this.cmsKitTestData = cmsKitTestData; - } - - public bool IsAuthenticated { get; } - public Guid? Id => cmsKitTestData.User1Id; - public string UserName => cmsKitTestData.User1UserName; - public string Name { get; } - public string SurName { get; } - public string PhoneNumber { get; } - public bool PhoneNumberVerified { get; } - public string Email { get; } - public bool EmailVerified { get; } - public Guid? TenantId { get; } - public string[] Roles { get; } - - public Claim FindClaim(string claimType) - { - return null; - } - - public Claim[] FindClaims(string claimType) - { - return null; - } - - public Claim[] GetAllClaims() - { - return null; - } - - public bool IsInRole(string roleName) - { - return false; - } + return false; } } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBase.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBase.cs index 0f12b87949..ca83b0438d 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBase.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBase.cs @@ -7,54 +7,53 @@ using Volo.Abp.Uow; using Volo.Abp.Testing; using Volo.Abp.GlobalFeatures; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +/* All test classes are derived from this class, directly or indirectly. */ +public abstract class CmsKitTestBase : AbpIntegratedTest + where TStartupModule : IAbpModule { - /* All test classes are derived from this class, directly or indirectly. */ - public abstract class CmsKitTestBase : AbpIntegratedTest - where TStartupModule : IAbpModule + protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) { - protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) - { - options.UseAutofac(); - } + options.UseAutofac(); + } - protected virtual Task WithUnitOfWorkAsync(Func func) - { - return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); - } + protected virtual Task WithUnitOfWorkAsync(Func func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } - protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func action) + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func action) + { + using (var scope = ServiceProvider.CreateScope()) { - using (var scope = ServiceProvider.CreateScope()) - { - var uowManager = scope.ServiceProvider.GetRequiredService(); + var uowManager = scope.ServiceProvider.GetRequiredService(); - using (var uow = uowManager.Begin(options)) - { - await action(); + using (var uow = uowManager.Begin(options)) + { + await action(); - await uow.CompleteAsync(); - } + await uow.CompleteAsync(); } } + } - protected virtual Task WithUnitOfWorkAsync(Func> func) - { - return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); - } + protected virtual Task WithUnitOfWorkAsync(Func> func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } - protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func> func) + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func> func) + { + using (var scope = ServiceProvider.CreateScope()) { - using (var scope = ServiceProvider.CreateScope()) + var uowManager = scope.ServiceProvider.GetRequiredService(); + + using (var uow = uowManager.Begin(options)) { - var uowManager = scope.ServiceProvider.GetRequiredService(); - - using (var uow = uowManager.Begin(options)) - { - var result = await func(); - await uow.CompleteAsync(); - return result; - } + var result = await func(); + await uow.CompleteAsync(); + return result; } } } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs index e29a1cc841..1c2a33ccdf 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs @@ -9,57 +9,56 @@ using Volo.Abp.GlobalFeatures; using Volo.Abp.Modularity; using Volo.Abp.Threading; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpTestBaseModule), + typeof(AbpAuthorizationModule), + typeof(CmsKitDomainModule) + )] +public class CmsKitTestBaseModule : AbpModule { - [DependsOn( - typeof(AbpAutofacModule), - typeof(AbpTestBaseModule), - typeof(AbpAuthorizationModule), - typeof(CmsKitDomainModule) - )] - public class CmsKitTestBaseModule : AbpModule - { - private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); + private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); - public override void PreConfigureServices(ServiceConfigurationContext context) + public override void PreConfigureServices(ServiceConfigurationContext context) + { + OneTimeRunner.Run(() => { - OneTimeRunner.Run(() => - { - GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll(); - }); - } + GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll(); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddSingleton(Substitute.For()); - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - context.Services.AddSingleton(Substitute.For()); - - Configure(options => + options.Containers.ConfigureAll((containerName, containerConfiguration) => { - options.Containers.ConfigureAll((containerName, containerConfiguration) => - { - containerConfiguration.ProviderType = typeof(FakeBlobProvider); - }); + containerConfiguration.ProviderType = typeof(FakeBlobProvider); }); - - context.Services.AddAlwaysAllowAuthorization(); - } + }); - public override void OnApplicationInitialization(ApplicationInitializationContext context) - { - SeedTestData(context); - } + context.Services.AddAlwaysAllowAuthorization(); + } - private static void SeedTestData(ApplicationInitializationContext context) + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + SeedTestData(context); + } + + private static void SeedTestData(ApplicationInitializationContext context) + { + AsyncHelper.RunSync(async () => { - AsyncHelper.RunSync(async () => + using (var scope = context.ServiceProvider.CreateScope()) { - using (var scope = context.ServiceProvider.CreateScope()) - { - await scope.ServiceProvider - .GetRequiredService() - .SeedAsync(); - } - }); - } + await scope.ServiceProvider + .GetRequiredService() + .SeedAsync(); + } + }); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs index 62f81b2646..d47f139560 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs @@ -3,129 +3,128 @@ using JetBrains.Annotations; using Volo.Abp.DependencyInjection; using Volo.CmsKit.Blogs; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class CmsKitTestData : ISingletonDependency { - public class CmsKitTestData : ISingletonDependency - { - public Guid User1Id { get; } = Guid.NewGuid(); + public Guid User1Id { get; } = Guid.NewGuid(); + + public string User1UserName => "fake.user"; + + public Guid User2Id { get; } = Guid.NewGuid(); + + public Guid CommentWithChildId { get; } = Guid.NewGuid(); + + + public string EntityType1 { get; } = "EntityName1"; + + public string EntityType2 { get; } = "EntityName2"; + + public string EntityId1 { get; } = "1"; - public string User1UserName => "fake.user"; + public string EntityId2 { get; } = "2"; - public Guid User2Id { get; } = Guid.NewGuid(); + public string Content_1_EntityType { get; } = "Lyrics"; - public Guid CommentWithChildId { get; } = Guid.NewGuid(); + public string Content_1 { get; } = "First things first\nI'ma say all the words inside my head\nI'm fired up and tired of the way that things have been, oh-ooh\nThe way that things have been, oh-ooh"; + public Guid Content_1_Id { get; } = Guid.NewGuid(); - public string EntityType1 { get; } = "EntityName1"; + public string Content_1_EntityId { get; } = "1"; - public string EntityType2 { get; } = "EntityName2"; + public string[] Content_1_Tags => new string[] { "Imagine Dragons", "Music" }; - public string EntityId1 { get; } = "1"; + public string Content_2_EntityType { get; } = "LyricsAlso"; - public string EntityId2 { get; } = "2"; + public string Content_2 { get; } = "Second thing second\nDon't you tell me what you think that I could be\nI'm the one at the sail, I'm the master of my sea, oh-ooh\nThe master of my sea, oh-ooh"; - public string Content_1_EntityType { get; } = "Lyrics"; + public Guid Content_2_Id { get; } = Guid.NewGuid(); - public string Content_1 { get; } = "First things first\nI'ma say all the words inside my head\nI'm fired up and tired of the way that things have been, oh-ooh\nThe way that things have been, oh-ooh"; + public string Content_2_EntityId { get; } = "2"; - public Guid Content_1_Id { get; } = Guid.NewGuid(); + public string[] Content_2_Tags => new string[] { "Imagine Dragons", "Music", "Most Loved Part" }; - public string Content_1_EntityId { get; } = "1"; + public string Page_1_Title { get; } = "Imagine Dragons - Believer Lyrics"; - public string[] Content_1_Tags => new string[] { "Imagine Dragons", "Music" }; + public string Page_1_Slug { get; } = "imagine-dragons-believer-lyrics"; - public string Content_2_EntityType { get; } = "LyricsAlso"; + public Guid Page_1_Id { get; } = Guid.NewGuid(); - public string Content_2 { get; } = "Second thing second\nDon't you tell me what you think that I could be\nI'm the one at the sail, I'm the master of my sea, oh-ooh\nThe master of my sea, oh-ooh"; + public string Page_1_Content => Content_1; - public Guid Content_2_Id { get; } = Guid.NewGuid(); + public string Page_2_Title { get; } = "Imagine Dragons - Believer Lyrics (Page 2)"; - public string Content_2_EntityId { get; } = "2"; + public string Page_2_Slug { get; } = "imagine-dragons-believer-lyrics-2"; - public string[] Content_2_Tags => new string[] { "Imagine Dragons", "Music", "Most Loved Part" }; + public Guid Page_2_Id { get; } = Guid.NewGuid(); - public string Page_1_Title { get; } = "Imagine Dragons - Believer Lyrics"; + public string Page_2_Content => Content_2; - public string Page_1_Slug { get; } = "imagine-dragons-believer-lyrics"; + public string TagDefinition_1_EntityType => "My.Namespace.CustomType"; - public Guid Page_1_Id { get; } = Guid.NewGuid(); + public Guid TagId_1 { get; } = Guid.NewGuid(); - public string Page_1_Content => Content_1; + public string TagName_1 => "Awesome"; - public string Page_2_Title { get; } = "Imagine Dragons - Believer Lyrics (Page 2)"; + public Guid TagId_2 { get; } = Guid.NewGuid(); - public string Page_2_Slug { get; } = "imagine-dragons-believer-lyrics-2"; + public string TagName_2 => "News"; - public Guid Page_2_Id { get; } = Guid.NewGuid(); + public Guid Blog_Id { get; set; } = Guid.NewGuid(); - public string Page_2_Content => Content_2; + public string BlogName => "Cms Blog"; - public string TagDefinition_1_EntityType => "My.Namespace.CustomType"; + public string BlogSlug => "cms-blog"; - public Guid TagId_1 { get; } = Guid.NewGuid(); + public Guid BlogPost_1_Id { get; internal set; } - public string TagName_1 => "Awesome"; + public string BlogPost_1_Title => "How to install CmsKit?"; - public Guid TagId_2 { get; } = Guid.NewGuid(); + public string BlogPost_1_Slug => "how-to-install-cms-kit"; - public string TagName_2 => "News"; + public Guid BlogPost_2_Id { get; internal set; } - public Guid Blog_Id { get; set; } = Guid.NewGuid(); + public string BlogPost_2_Title => "How to use CmsKit"; - public string BlogName => "Cms Blog"; + public string BlogPost_2_Slug => "how-to-use-cms-kit"; - public string BlogSlug => "cms-blog"; + public Guid BlogFeature_1_Id { get; internal set; } = Guid.NewGuid(); - public Guid BlogPost_1_Id { get; internal set; } + public string BlogFeature_1_FeatureName => "Analytics"; - public string BlogPost_1_Title => "How to install CmsKit?"; + public bool BlogFeature_1_Enabled => true; - public string BlogPost_1_Slug => "how-to-install-cms-kit"; + public Guid BlogFeature_2_Id { get; internal set; } = Guid.NewGuid(); - public Guid BlogPost_2_Id { get; internal set; } + public string BlogFeature_2_FeatureName => "Hotjar"; - public string BlogPost_2_Title => "How to use CmsKit"; + public bool BlogFeature_2_Enabled => false; - public string BlogPost_2_Slug => "how-to-use-cms-kit"; + public Guid Media_1_Id { get; } = Guid.NewGuid(); - public Guid BlogFeature_1_Id { get; internal set; } = Guid.NewGuid(); + public string Media_1_EntityType => nameof(Blog); - public string BlogFeature_1_FeatureName => "Analytics"; + public string Media_1_Content { get; } = "Hi, this is text file"; - public bool BlogFeature_1_Enabled => true; + public string Media_1_Name { get; } = "hello.txt"; - public Guid BlogFeature_2_Id { get; internal set; } = Guid.NewGuid(); + public string Media_1_ContentType { get; } = "text/plain"; - public string BlogFeature_2_FeatureName => "Hotjar"; + public Guid MenuItem_1_Id { get; } = Guid.NewGuid(); - public bool BlogFeature_2_Enabled => false; + public string MenuItem_1_Name { get; } = "About Us"; - public Guid Media_1_Id { get; } = Guid.NewGuid(); + public string MenuItem_1_Url { get; } = "/about-us"; - public string Media_1_EntityType => nameof(Blog); + public Guid MenuItem_2_Id { get; } = Guid.NewGuid(); - public string Media_1_Content { get; } = "Hi, this is text file"; + public string MenuItem_2_Name { get; } = "Our Team"; - public string Media_1_Name { get; } = "hello.txt"; + public string MenuItem_2_Url { get; } = "/team"; - public string Media_1_ContentType { get; } = "text/plain"; + public Guid MenuItem_3_Id { get; } = Guid.NewGuid(); - public Guid MenuItem_1_Id { get; } = Guid.NewGuid(); - - public string MenuItem_1_Name { get; } = "About Us"; - - public string MenuItem_1_Url { get; } = "/about-us"; + public string MenuItem_3_Name { get; } = "Products"; - public Guid MenuItem_2_Id { get; } = Guid.NewGuid(); - - public string MenuItem_2_Name { get; } = "Our Team"; - - public string MenuItem_2_Url { get; } = "/team"; - - public Guid MenuItem_3_Id { get; } = Guid.NewGuid(); - - public string MenuItem_3_Name { get; } = "Products"; - - public string MenuItem_3_Url { get; } = "/products"; - } + public string MenuItem_3_Url { get; } = "/products"; } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs index 3b166834a0..facf55f523 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs @@ -4,67 +4,66 @@ using Shouldly; using Volo.Abp.Modularity; using Xunit; -namespace Volo.CmsKit.Comments +namespace Volo.CmsKit.Comments; + +public abstract class CommentRepository_Tests : CmsKitTestBase + where TStartupModule : IAbpModule { - public abstract class CommentRepository_Tests : CmsKitTestBase - where TStartupModule : IAbpModule + private readonly CmsKitTestData _cmsKitTestData; + private readonly ICommentRepository _commentRepository; + + public CommentRepository_Tests() + { + _cmsKitTestData = GetRequiredService(); + _commentRepository = GetRequiredService(); + } + + [Fact] + public async Task GetList_ShouldWork() { - private readonly CmsKitTestData _cmsKitTestData; - private readonly ICommentRepository _commentRepository; + var comments = await _commentRepository.GetListAsync(); + + comments.ShouldNotBeNull(); + comments.Count.ShouldBe(6); - public CommentRepository_Tests() - { - _cmsKitTestData = GetRequiredService(); - _commentRepository = GetRequiredService(); - } + var headCommentId = comments.First(x => x.Comment.RepliedCommentId != null).Comment.RepliedCommentId; - [Fact] - public async Task GetList_ShouldWork() - { - var comments = await _commentRepository.GetListAsync(); + var replies = await _commentRepository.GetListAsync(repliedCommentId: headCommentId); - comments.ShouldNotBeNull(); - comments.Count.ShouldBe(6); - - var headCommentId = comments.First(x => x.Comment.RepliedCommentId != null).Comment.RepliedCommentId; - - var replies = await _commentRepository.GetListAsync(repliedCommentId: headCommentId); + replies.ShouldNotBeNull(); + replies.Count.ShouldBeLessThan(6); + replies.Count.ShouldBeGreaterThanOrEqualTo(1); + } - replies.ShouldNotBeNull(); - replies.Count.ShouldBeLessThan(6); - replies.Count.ShouldBeGreaterThanOrEqualTo(1); - } - - [Fact] - public async Task GetCount_ShouldWork() - { - var commentsCount = await _commentRepository.GetCountAsync(); + [Fact] + public async Task GetCount_ShouldWork() + { + var commentsCount = await _commentRepository.GetCountAsync(); - commentsCount.ShouldBe(6); - } + commentsCount.ShouldBe(6); + } - [Fact] - public async Task GetListWithAuthorsAsync() - { - var list = await _commentRepository.GetListWithAuthorsAsync(_cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1); + [Fact] + public async Task GetListWithAuthorsAsync() + { + var list = await _commentRepository.GetListWithAuthorsAsync(_cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1); - list.Count.ShouldBe(4); - list.Any(x=>x.Comment == null).ShouldBeFalse(); - list.Any(x=>x.Author == null).ShouldBeFalse(); - } + list.Count.ShouldBe(4); + list.Any(x => x.Comment == null).ShouldBeFalse(); + list.Any(x => x.Author == null).ShouldBeFalse(); + } - [Fact] - public async Task DeleteWithRepliesAsync() - { - var comment = await _commentRepository.GetAsync(_cmsKitTestData.CommentWithChildId); - await _commentRepository.DeleteWithRepliesAsync(comment); + [Fact] + public async Task DeleteWithRepliesAsync() + { + var comment = await _commentRepository.GetAsync(_cmsKitTestData.CommentWithChildId); + await _commentRepository.DeleteWithRepliesAsync(comment); - var list = await _commentRepository.GetListAsync(); + var list = await _commentRepository.GetListAsync(); - list.Any(x=> - x.Comment.Id == _cmsKitTestData.CommentWithChildId || x.Comment.RepliedCommentId == _cmsKitTestData.CommentWithChildId) - .ShouldBeFalse(); - } + list.Any(x => + x.Comment.Id == _cmsKitTestData.CommentWithChildId || x.Comment.RepliedCommentId == _cmsKitTestData.CommentWithChildId) + .ShouldBeFalse(); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/FakeBlobProvider.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/FakeBlobProvider.cs index 4d7ed4f127..8e8ac250df 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/FakeBlobProvider.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/FakeBlobProvider.cs @@ -2,33 +2,32 @@ using System.Threading.Tasks; using Volo.Abp.BlobStoring; -namespace Volo.CmsKit +namespace Volo.CmsKit; + +public class FakeBlobProvider : IBlobProvider { - public class FakeBlobProvider : IBlobProvider + public virtual Task SaveAsync(BlobProviderSaveArgs args) { - public virtual Task SaveAsync(BlobProviderSaveArgs args) - { - throw new System.NotImplementedException(); - } + throw new System.NotImplementedException(); + } - public virtual Task DeleteAsync(BlobProviderDeleteArgs args) - { - throw new System.NotImplementedException(); - } + public virtual Task DeleteAsync(BlobProviderDeleteArgs args) + { + throw new System.NotImplementedException(); + } - public virtual Task ExistsAsync(BlobProviderExistsArgs args) - { - throw new System.NotImplementedException(); - } + public virtual Task ExistsAsync(BlobProviderExistsArgs args) + { + throw new System.NotImplementedException(); + } - public virtual Task GetAsync(BlobProviderGetArgs args) - { - throw new System.NotImplementedException(); - } + public virtual Task GetAsync(BlobProviderGetArgs args) + { + throw new System.NotImplementedException(); + } - public virtual Task GetOrNullAsync(BlobProviderGetArgs args) - { - throw new System.NotImplementedException(); - } + public virtual Task GetOrNullAsync(BlobProviderGetArgs args) + { + throw new System.NotImplementedException(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Menus/MenuItemRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Menus/MenuItemRepository_Test.cs index 7043a2bf6d..1807f65233 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Menus/MenuItemRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Menus/MenuItemRepository_Test.cs @@ -3,19 +3,18 @@ using System.Threading.Tasks; using Shouldly; using Volo.Abp.Modularity; -namespace Volo.CmsKit.Menus +namespace Volo.CmsKit.Menus; + +public abstract class MenuItemRepository_Test : CmsKitTestBase + where TStartupModule : IAbpModule { - public abstract class MenuItemRepository_Test : CmsKitTestBase - where TStartupModule : IAbpModule - { - - private readonly CmsKitTestData testData; - private readonly IMenuItemRepository menuItemRepository; - public MenuItemRepository_Test() - { - testData = GetRequiredService(); - menuItemRepository = GetRequiredService(); - } + private readonly CmsKitTestData testData; + private readonly IMenuItemRepository menuItemRepository; + + public MenuItemRepository_Test() + { + testData = GetRequiredService(); + menuItemRepository = GetRequiredService(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Pages/PageRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Pages/PageRepository_Test.cs index c5b51c90cb..4b56f77f43 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Pages/PageRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Pages/PageRepository_Test.cs @@ -4,92 +4,91 @@ using Shouldly; using Volo.Abp.Modularity; using Xunit; -namespace Volo.CmsKit.Pages +namespace Volo.CmsKit.Pages; + +public abstract class PageRepository_Test : CmsKitTestBase + where TStartupModule : IAbpModule { - public abstract class PageRepository_Test : CmsKitTestBase - where TStartupModule : IAbpModule + private readonly CmsKitTestData _cmsKitTestData; + private readonly IPageRepository _pageRepository; + + protected PageRepository_Test() + { + _cmsKitTestData = GetRequiredService(); + _pageRepository = GetRequiredService(); + } + + [Fact] + public async Task CountAsync() + { + var totalCount = await _pageRepository.GetCountAsync(); + + totalCount.ShouldBe(2); + + var filteredCount = await _pageRepository.GetCountAsync(_cmsKitTestData.Page_2_Title); + + filteredCount.ShouldBe(1); + } + + [Fact] + public async Task GetListAsync() + { + var list = await _pageRepository.GetListAsync(); + + list.ShouldNotBeNull(); + list.Count.ShouldBe(2); + + var list_page_1 = await _pageRepository.GetListAsync(maxResultCount: 1); + var list_page_2 = await _pageRepository.GetListAsync(maxResultCount: 1, skipCount: 1); + + list_page_1.ShouldNotBeNull(); + list_page_1.Count.ShouldBe(1); + list_page_1.First().Title.ShouldBe(_cmsKitTestData.Page_1_Title); + + list_page_2.ShouldNotBeNull(); + list_page_1.Count.ShouldBe(1); + list_page_2.First().Title.ShouldBe(_cmsKitTestData.Page_2_Title); + } + + [Fact] + public async Task ShouldGetByUrlAsync() { - private readonly CmsKitTestData _cmsKitTestData; - private readonly IPageRepository _pageRepository; - - protected PageRepository_Test() - { - _cmsKitTestData = GetRequiredService(); - _pageRepository = GetRequiredService(); - } - - [Fact] - public async Task CountAsync() - { - var totalCount = await _pageRepository.GetCountAsync(); - - totalCount.ShouldBe(2); - - var filteredCount = await _pageRepository.GetCountAsync(_cmsKitTestData.Page_2_Title); - - filteredCount.ShouldBe(1); - } - - [Fact] - public async Task GetListAsync() - { - var list = await _pageRepository.GetListAsync(); - - list.ShouldNotBeNull(); - list.Count.ShouldBe(2); - - var list_page_1 = await _pageRepository.GetListAsync(maxResultCount: 1); - var list_page_2 = await _pageRepository.GetListAsync(maxResultCount: 1, skipCount: 1); - - list_page_1.ShouldNotBeNull(); - list_page_1.Count.ShouldBe(1); - list_page_1.First().Title.ShouldBe(_cmsKitTestData.Page_1_Title); - - list_page_2.ShouldNotBeNull(); - list_page_1.Count.ShouldBe(1); - list_page_2.First().Title.ShouldBe(_cmsKitTestData.Page_2_Title); - } - - [Fact] - public async Task ShouldGetByUrlAsync() - { - var page = await _pageRepository.GetBySlugAsync(_cmsKitTestData.Page_1_Slug); - - page.ShouldNotBeNull(); - page.Title.ShouldBe(_cmsKitTestData.Page_1_Title); - } - - [Fact] - public async Task ShouldFindByUrlAsync() - { - var page = await _pageRepository.FindBySlugAsync(_cmsKitTestData.Page_1_Slug); - - page.ShouldNotBeNull(); - page.Title.ShouldBe(_cmsKitTestData.Page_1_Title); - } - - [Fact] - public async Task ShouldNotFindByUrlAsync() - { - var page = await _pageRepository.FindBySlugAsync("not-exist-lyrics"); - - page.ShouldBeNull(); - } - - [Fact] - public async Task ShouldBeExistAsync() - { - var page = await _pageRepository.ExistsAsync(_cmsKitTestData.Page_1_Slug); - - page.ShouldBeTrue(); - } - - [Fact] - public async Task ShouldNotBeExistAsync() - { - var page = await _pageRepository.ExistsAsync("not-exist-lyrics"); - - page.ShouldBeFalse(); - } + var page = await _pageRepository.GetBySlugAsync(_cmsKitTestData.Page_1_Slug); + + page.ShouldNotBeNull(); + page.Title.ShouldBe(_cmsKitTestData.Page_1_Title); + } + + [Fact] + public async Task ShouldFindByUrlAsync() + { + var page = await _pageRepository.FindBySlugAsync(_cmsKitTestData.Page_1_Slug); + + page.ShouldNotBeNull(); + page.Title.ShouldBe(_cmsKitTestData.Page_1_Title); + } + + [Fact] + public async Task ShouldNotFindByUrlAsync() + { + var page = await _pageRepository.FindBySlugAsync("not-exist-lyrics"); + + page.ShouldBeNull(); + } + + [Fact] + public async Task ShouldBeExistAsync() + { + var page = await _pageRepository.ExistsAsync(_cmsKitTestData.Page_1_Slug); + + page.ShouldBeTrue(); + } + + [Fact] + public async Task ShouldNotBeExistAsync() + { + var page = await _pageRepository.ExistsAsync("not-exist-lyrics"); + + page.ShouldBeFalse(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Ratings/RatingRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Ratings/RatingRepository_Tests.cs index 19da73cf50..054f567811 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Ratings/RatingRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Ratings/RatingRepository_Tests.cs @@ -3,39 +3,38 @@ using Shouldly; using Volo.Abp.Modularity; using Xunit; -namespace Volo.CmsKit.Ratings +namespace Volo.CmsKit.Ratings; + +public abstract class RatingRepository_Tests : CmsKitTestBase + where TStartupModule : IAbpModule { - public abstract class RatingRepository_Tests : CmsKitTestBase - where TStartupModule : IAbpModule + private readonly CmsKitTestData _cmsKitTestData; + private readonly IRatingRepository _ratingRepository; + + public RatingRepository_Tests() { - private readonly CmsKitTestData _cmsKitTestData; - private readonly IRatingRepository _ratingRepository; + _cmsKitTestData = GetRequiredService(); + _ratingRepository = GetRequiredService(); + } - public RatingRepository_Tests() - { - _cmsKitTestData = GetRequiredService(); - _ratingRepository = GetRequiredService(); - } + [Fact] + public async Task GetCurrentUserRatingAsync() + { + var userRating = await _ratingRepository.GetCurrentUserRatingAsync(_cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, _cmsKitTestData.User1Id); - [Fact] - public async Task GetCurrentUserRatingAsync() - { - var userRating = await _ratingRepository.GetCurrentUserRatingAsync(_cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, _cmsKitTestData.User1Id); + userRating.ShouldNotBeNull(); + userRating.EntityId.ShouldBe(_cmsKitTestData.EntityId1); + userRating.EntityType.ShouldBe(_cmsKitTestData.EntityType1); + userRating.CreatorId.ShouldBe(_cmsKitTestData.User1Id); + } - userRating.ShouldNotBeNull(); - userRating.EntityId.ShouldBe(_cmsKitTestData.EntityId1); - userRating.EntityType.ShouldBe(_cmsKitTestData.EntityType1); - userRating.CreatorId.ShouldBe(_cmsKitTestData.User1Id); - } + [Fact] + public async Task GetGroupedStarCountsAsync() + { + var list = await _ratingRepository.GetGroupedStarCountsAsync(_cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1); - [Fact] - public async Task GetGroupedStarCountsAsync() - { - var list = await _ratingRepository.GetGroupedStarCountsAsync(_cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1); - - list.ShouldNotBeNull(); - } + list.ShouldNotBeNull(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Reactions/UserReactionRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Reactions/UserReactionRepository_Tests.cs index 0499bc264d..f7fb52558b 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Reactions/UserReactionRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Reactions/UserReactionRepository_Tests.cs @@ -8,63 +8,62 @@ using Volo.Abp.Modularity; using Volo.CmsKit.Comments; using Xunit; -namespace Volo.CmsKit.Reactions +namespace Volo.CmsKit.Reactions; + +public abstract class UserReactionRepository_Tests : CmsKitTestBase + where TStartupModule : IAbpModule { - public abstract class UserReactionRepository_Tests : CmsKitTestBase - where TStartupModule : IAbpModule - { - private readonly CmsKitTestData _cmsKitTestData; - private readonly IUserReactionRepository __userReactionRepository; + private readonly CmsKitTestData _cmsKitTestData; + private readonly IUserReactionRepository __userReactionRepository; - public UserReactionRepository_Tests() - { - _cmsKitTestData = GetRequiredService(); - __userReactionRepository = GetRequiredService(); - } + public UserReactionRepository_Tests() + { + _cmsKitTestData = GetRequiredService(); + __userReactionRepository = GetRequiredService(); + } - [Fact] - public async Task FindAsync() - { - var reaction = await __userReactionRepository.FindAsync( - _cmsKitTestData.User1Id, - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1, - StandardReactions.Confused - ); + [Fact] + public async Task FindAsync() + { + var reaction = await __userReactionRepository.FindAsync( + _cmsKitTestData.User1Id, + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1, + StandardReactions.Confused + ); - reaction.ShouldNotBeNull(); - reaction.CreatorId.ShouldBe(_cmsKitTestData.User1Id); - reaction.EntityId.ShouldBe(_cmsKitTestData.EntityId1); - reaction.EntityType.ShouldBe(_cmsKitTestData.EntityType1); - reaction.ReactionName.ShouldBe(StandardReactions.Confused); - } + reaction.ShouldNotBeNull(); + reaction.CreatorId.ShouldBe(_cmsKitTestData.User1Id); + reaction.EntityId.ShouldBe(_cmsKitTestData.EntityId1); + reaction.EntityType.ShouldBe(_cmsKitTestData.EntityType1); + reaction.ReactionName.ShouldBe(StandardReactions.Confused); + } - [Fact] - public async Task GetListForUserAsync() - { - var reactions = await __userReactionRepository.GetListForUserAsync( - _cmsKitTestData.User1Id, - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1 - ); + [Fact] + public async Task GetListForUserAsync() + { + var reactions = await __userReactionRepository.GetListForUserAsync( + _cmsKitTestData.User1Id, + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1 + ); - reactions.Count.ShouldBe(2); - reactions.Count(x=>x.ReactionName == StandardReactions.Confused).ShouldBe(1); - reactions.Count(x=>x.ReactionName == StandardReactions.ThumbsUp).ShouldBe(1); - } + reactions.Count.ShouldBe(2); + reactions.Count(x => x.ReactionName == StandardReactions.Confused).ShouldBe(1); + reactions.Count(x => x.ReactionName == StandardReactions.ThumbsUp).ShouldBe(1); + } - [Fact] - public async Task GetSummariesAsync() - { - var summaries = await __userReactionRepository.GetSummariesAsync( - _cmsKitTestData.EntityType1, - _cmsKitTestData.EntityId1 - ); + [Fact] + public async Task GetSummariesAsync() + { + var summaries = await __userReactionRepository.GetSummariesAsync( + _cmsKitTestData.EntityType1, + _cmsKitTestData.EntityId1 + ); - summaries.Count.ShouldBe(2); - summaries.First(x => x.ReactionName == StandardReactions.Confused).Count.ShouldBe(1); - summaries.First(x => x.ReactionName == StandardReactions.ThumbsUp).Count.ShouldBe(2); + summaries.Count.ShouldBe(2); + summaries.First(x => x.ReactionName == StandardReactions.Confused).Count.ShouldBe(1); + summaries.First(x => x.ReactionName == StandardReactions.ThumbsUp).Count.ShouldBe(2); - } } } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Security/FakeCurrentPrincipalAccessor.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Security/FakeCurrentPrincipalAccessor.cs index 9c79835723..297bd3df6e 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Security/FakeCurrentPrincipalAccessor.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Security/FakeCurrentPrincipalAccessor.cs @@ -3,41 +3,40 @@ using System.Security.Claims; using Volo.Abp.DependencyInjection; using Volo.Abp.Security.Claims; -namespace Volo.CmsKit.Security +namespace Volo.CmsKit.Security; + +[Dependency(ReplaceServices = true)] +public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor { - [Dependency(ReplaceServices = true)] - public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor + protected override ClaimsPrincipal GetClaimsPrincipal() { - protected override ClaimsPrincipal GetClaimsPrincipal() - { - return GetPrincipal(); - } + return GetPrincipal(); + } - private ClaimsPrincipal _principal; + private ClaimsPrincipal _principal; - private ClaimsPrincipal GetPrincipal() + private ClaimsPrincipal GetPrincipal() + { + if (_principal == null) { - if (_principal == null) + lock (this) { - lock (this) + if (_principal == null) { - if (_principal == null) - { - _principal = new ClaimsPrincipal( - new ClaimsIdentity( - new List - { + _principal = new ClaimsPrincipal( + new ClaimsIdentity( + new List + { new Claim(AbpClaimTypes.UserId,"2e701e62-0953-4dd3-910b-dc6cc93ccb0d"), new Claim(AbpClaimTypes.UserName,"admin"), new Claim(AbpClaimTypes.Email,"admin@abp.io") - } - ) - ); - } + } + ) + ); } } - - return _principal; } + + return _principal; } } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Tags/EntityTagRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Tags/EntityTagRepository_Test.cs index 3d60ac0b6a..9da9dd7710 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Tags/EntityTagRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Tags/EntityTagRepository_Test.cs @@ -7,32 +7,31 @@ using System.Threading.Tasks; using Volo.Abp.Modularity; using Xunit; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public abstract class EntityTagRepository_Test : CmsKitTestBase + where TStartupModule : IAbpModule { - public abstract class EntityTagRepository_Test : CmsKitTestBase - where TStartupModule : IAbpModule - { - private CmsKitTestData _cmsKitTestData; - private IEntityTagRepository _entityTagRepository; - private ITagRepository _tagRepository; + private CmsKitTestData _cmsKitTestData; + private IEntityTagRepository _entityTagRepository; + private ITagRepository _tagRepository; - public EntityTagRepository_Test() - { - _cmsKitTestData = GetRequiredService(); - _entityTagRepository = GetRequiredService(); - _tagRepository = GetRequiredService(); - } + public EntityTagRepository_Test() + { + _cmsKitTestData = GetRequiredService(); + _entityTagRepository = GetRequiredService(); + _tagRepository = GetRequiredService(); + } - [Fact] - public async Task DeleteManyAsync_ShouldWorkProperly_WithExistingIds() - { - var relatedTags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.Content_1_EntityType, _cmsKitTestData.Content_1_EntityId); + [Fact] + public async Task DeleteManyAsync_ShouldWorkProperly_WithExistingIds() + { + var relatedTags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.Content_1_EntityType, _cmsKitTestData.Content_1_EntityId); - await _entityTagRepository.DeleteManyAsync(relatedTags.Select(s => s.Id).ToArray()); + await _entityTagRepository.DeleteManyAsync(relatedTags.Select(s => s.Id).ToArray()); - relatedTags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.Content_1_EntityType, _cmsKitTestData.Content_1_EntityId); + relatedTags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.Content_1_EntityType, _cmsKitTestData.Content_1_EntityId); - relatedTags.ShouldBeEmpty(); - } + relatedTags.ShouldBeEmpty(); } } diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Tags/TagRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Tags/TagRepository_Test.cs index 97034f9f21..1a061b546a 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Tags/TagRepository_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Tags/TagRepository_Test.cs @@ -6,128 +6,127 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Modularity; using Xunit; -namespace Volo.CmsKit.Tags +namespace Volo.CmsKit.Tags; + +public abstract class TagRepository_Test : CmsKitTestBase + where TStartupModule : IAbpModule { - public abstract class TagRepository_Test : CmsKitTestBase - where TStartupModule : IAbpModule + private readonly CmsKitTestData _cmsKitTestData; + private readonly ITagRepository _tagRepository; + + protected TagRepository_Test() { - private readonly CmsKitTestData _cmsKitTestData; - private readonly ITagRepository _tagRepository; - - protected TagRepository_Test() - { - _cmsKitTestData = GetRequiredService(); - _tagRepository = GetRequiredService(); - } + _cmsKitTestData = GetRequiredService(); + _tagRepository = GetRequiredService(); + } - [Theory] - [InlineData("Lyrics", "Imagine Dragons")] - [InlineData("Lyrics", "Music")] - [InlineData("LyricsAlso", "Imagine Dragons")] - [InlineData("LyricsAlso", "Music")] - [InlineData("LyricsAlso", "Most Loved Part")] - public async Task ShouldGetAsync(string entityType, string name) - { - var tag = await _tagRepository.GetAsync(entityType, name); - - tag.ShouldNotBeNull(); - } - - [Fact] - public async Task ShouldNotGetAsync() - { - Should.Throw( - async () => await _tagRepository.GetAsync("not_exist_entity", Guid.NewGuid().ToString()) - ); - } - - [Theory] - [InlineData("Lyrics", "Imagine Dragons")] - [InlineData("Lyrics", "Music")] - [InlineData("LyricsAlso", "Imagine Dragons")] - [InlineData("LyricsAlso", "Music")] - [InlineData("LyricsAlso", "Most Loved Part")] - public async Task ShouldExistAsync(string entityType, string name) - { - var tag = await _tagRepository.AnyAsync(entityType, name); - - tag.ShouldBeTrue(); - } - - [Fact] - public async Task ShouldNotExistAsync() - { - var tag = await _tagRepository.AnyAsync("not_exist_entity", Guid.NewGuid().ToString()); - - tag.ShouldBeFalse(); - } - - [Theory] - [InlineData("Lyrics", "Imagine Dragons")] - [InlineData("Lyrics", "Music")] - [InlineData("LyricsAlso", "Imagine Dragons")] - [InlineData("LyricsAlso", "Music")] - [InlineData("LyricsAlso", "Most Loved Part")] - public async Task ShouldFindAsync(string entityType, string name) - { - var tag = await _tagRepository.FindAsync(entityType, name); + [Theory] + [InlineData("Lyrics", "Imagine Dragons")] + [InlineData("Lyrics", "Music")] + [InlineData("LyricsAlso", "Imagine Dragons")] + [InlineData("LyricsAlso", "Music")] + [InlineData("LyricsAlso", "Most Loved Part")] + public async Task ShouldGetAsync(string entityType, string name) + { + var tag = await _tagRepository.GetAsync(entityType, name); - tag.ShouldNotBeNull(); - } - - [Fact] - public async Task ShouldNotFindAsync() - { - var tag = await _tagRepository.FindAsync("not_exist_entity", Guid.NewGuid().ToString()); - - tag.ShouldBeNull(); - } + tag.ShouldNotBeNull(); + } + + [Fact] + public async Task ShouldNotGetAsync() + { + Should.Throw( + async () => await _tagRepository.GetAsync("not_exist_entity", Guid.NewGuid().ToString()) + ); + } + + [Theory] + [InlineData("Lyrics", "Imagine Dragons")] + [InlineData("Lyrics", "Music")] + [InlineData("LyricsAlso", "Imagine Dragons")] + [InlineData("LyricsAlso", "Music")] + [InlineData("LyricsAlso", "Most Loved Part")] + public async Task ShouldExistAsync(string entityType, string name) + { + var tag = await _tagRepository.AnyAsync(entityType, name); + + tag.ShouldBeTrue(); + } + + [Fact] + public async Task ShouldNotExistAsync() + { + var tag = await _tagRepository.AnyAsync("not_exist_entity", Guid.NewGuid().ToString()); - [Fact] - public async Task Should_Get_Related_Tags() + tag.ShouldBeFalse(); + } + + [Theory] + [InlineData("Lyrics", "Imagine Dragons")] + [InlineData("Lyrics", "Music")] + [InlineData("LyricsAlso", "Imagine Dragons")] + [InlineData("LyricsAlso", "Music")] + [InlineData("LyricsAlso", "Most Loved Part")] + public async Task ShouldFindAsync(string entityType, string name) + { + var tag = await _tagRepository.FindAsync(entityType, name); + + tag.ShouldNotBeNull(); + } + + [Fact] + public async Task ShouldNotFindAsync() + { + var tag = await _tagRepository.FindAsync("not_exist_entity", Guid.NewGuid().ToString()); + + tag.ShouldBeNull(); + } + + [Fact] + public async Task Should_Get_Related_Tags() + { + var content_1_tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.Content_1_EntityType, _cmsKitTestData.EntityId1); + + content_1_tags.Count.ShouldBe(_cmsKitTestData.Content_1_Tags.Length); + + foreach (var tag in content_1_tags) { - var content_1_tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.Content_1_EntityType, _cmsKitTestData.EntityId1); - - content_1_tags.Count.ShouldBe(_cmsKitTestData.Content_1_Tags.Length); - - foreach (var tag in content_1_tags) - { - _cmsKitTestData.Content_1_Tags.Contains(tag.Name).ShouldBeTrue(); - } - - var content_2_tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.Content_2_EntityType, _cmsKitTestData.EntityId2); - - content_2_tags.Count.ShouldBe(_cmsKitTestData.Content_2_Tags.Length); - - foreach (var tag in content_2_tags) - { - _cmsKitTestData.Content_2_Tags.Contains(tag.Name).ShouldBeTrue(); - } + _cmsKitTestData.Content_1_Tags.Contains(tag.Name).ShouldBeTrue(); } - - [Fact] - public async Task Should_Not_Get_Related_Tags() + + var content_2_tags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.Content_2_EntityType, _cmsKitTestData.EntityId2); + + content_2_tags.Count.ShouldBe(_cmsKitTestData.Content_2_Tags.Length); + + foreach (var tag in content_2_tags) { - var tags = await _tagRepository.GetAllRelatedTagsAsync("not_exist_entity", Guid.NewGuid().ToString()); - - tags.Count.ShouldBe(0); + _cmsKitTestData.Content_2_Tags.Contains(tag.Name).ShouldBeTrue(); } + } - [Fact] - public async Task Should_GetList_With_Filter() - { - var tags = await _tagRepository.GetListAsync(_cmsKitTestData.TagName_1); + [Fact] + public async Task Should_Not_Get_Related_Tags() + { + var tags = await _tagRepository.GetAllRelatedTagsAsync("not_exist_entity", Guid.NewGuid().ToString()); - tags.ShouldNotBeNull(); - tags.Count.ShouldBe(1); - } + tags.Count.ShouldBe(0); + } - [Fact] - public async Task Should_GetCount_With_Filter() - { - var count = await _tagRepository.GetCountAsync(_cmsKitTestData.TagName_1); + [Fact] + public async Task Should_GetList_With_Filter() + { + var tags = await _tagRepository.GetListAsync(_cmsKitTestData.TagName_1); - count.ShouldBe(1); - } + tags.ShouldNotBeNull(); + tags.Count.ShouldBe(1); + } + + [Fact] + public async Task Should_GetCount_With_Filter() + { + var count = await _tagRepository.GetCountAsync(_cmsKitTestData.TagName_1); + + count.ShouldBe(1); } -} \ No newline at end of file +}