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 2b1cd10b896..7c3f3fd71e4 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 @@ -93,7 +93,5 @@ public virtual async Task SetAsHomePageAsync(Guid id) var page = await PageRepository.GetAsync(id); await PageManager.SetHomePageAsync(page); - - await PageRepository.UpdateAsync(page); } } 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 a2cd7a33786..96393084c91 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 @@ -56,7 +56,8 @@ public virtual async Task SetHomePageAsync(Page page) } await PageRepository.UpdateManyAsync(currentHomePages); - + await PageRepository.UpdateAsync(page); + page.SetIsHomePage(true); } 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 71d02b1a0f3..44cea7d0051 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 @@ -72,12 +72,14 @@ public async Task SetSlugAsync_ShouldThrowException_WithExistingSlug() [Fact] public async Task SetHomePageAsync_ShouldWorkProperly_IfExistHomePage() { - var page = await pageRepository.GetAsync(testData.Page_1_Id); - - await pageManager.SetHomePageAsync(page); + await WithUnitOfWorkAsync(async ()=> + { + var page = await pageRepository.GetAsync(testData.Page_1_Id); - await pageRepository.UpdateAsync(page); + await pageManager.SetHomePageAsync(page); + }); + var page = await pageRepository.GetAsync(testData.Page_1_Id); page.IsHomePage.ShouldBeTrue(); var pageSetAsHomePageAsFalse = await pageRepository.GetAsync(testData.Page_2_Id);