From d9f021c0f17af49c6dbde338a73e0bb80fefa9cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Sat, 11 Oct 2025 01:27:06 +0300 Subject: [PATCH] =?UTF-8?q?Tenant=20Seed=20d=C3=BCzenlemesi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Blog/BlogPostDto.cs | 93 ----------- .../{About => Public}/AboutDto.cs | 2 +- .../Public/AuthorDto.cs | 10 ++ .../{Blog => Public}/BlogCategoryDto.cs | 13 +- .../BlogPostAndCategoriesDto.cs | 2 +- .../Public/BlogPostDto.cs | 37 +++++ .../Public/BlogPostListDto.cs | 35 +++++ .../{Contact => Public}/CityDto.cs | 2 +- .../{Contact => Public}/ContactDto.cs | 29 +--- .../{Contact => Public}/ContactTagDto.cs | 2 +- .../{Contact => Public}/ContactTitleDto.cs | 2 +- .../{Contact => Public}/CountryDto.cs | 2 +- .../{Contact => Public}/CountryGroupDto.cs | 2 +- .../Public/CreateUpdateBlogCategoryDto.cs | 14 ++ .../Public/CreateUpdateBlogPostDto.cs | 24 +++ .../{Demo => Public}/DemoDto.cs | 0 .../{Contact => Public}/DistrictDto.cs | 2 +- .../{Blog => Public}/IBlogAppService.cs | 2 +- .../InstallmentOptionDto.cs | 2 +- .../{Orders => Public}/OrderDto.cs | 10 +- .../Public/OrderItemDto.cs | 12 ++ .../{Orders => Public}/PaymentMethodDto.cs | 2 +- .../{Orders => Public}/ProductDto.cs | 2 +- .../{Services => Public}/ServiceDto.cs | 2 +- .../Blog/BlogAppService.cs | 2 +- .../Public/PublicAppService.cs | 5 - .../Public/PublicAutoMapperProfile.cs | 5 - .../Kurs.Platform.DbMigrator.csproj | 13 -- .../Seeds/HostDataSeeder.cs | 2 +- .../Public/BankDto.cs | 9 ++ .../Public/MapDto.cs | 13 ++ .../Public}/SectionDto.cs | 2 +- .../Public}/StatDto.cs | 2 +- .../Public/WorkHoursDto.cs | 8 + .../DatabaseMigrationEventHandlerBase.cs | 144 +++++++++--------- .../Kurs.Platform.EntityFrameworkCore.csproj | 32 +++- .../Tenants}/Seeds/TenantData.Dev.json | 0 .../Tenants}/Seeds/TenantData.Production.json | 0 .../Tenants}/Seeds/TenantData.json | 0 .../Tenants}/TenantDataSeeder.cs | 10 +- .../Tenants/TenantIdentityDataSeeder.cs | 105 +++++++++++++ .../Tenants}/TenantSeederDto.cs | 3 +- 42 files changed, 392 insertions(+), 266 deletions(-) delete mode 100644 api/src/Kurs.Platform.Application.Contracts/Blog/BlogPostDto.cs rename api/src/Kurs.Platform.Application.Contracts/{About => Public}/AboutDto.cs (97%) create mode 100644 api/src/Kurs.Platform.Application.Contracts/Public/AuthorDto.cs rename api/src/Kurs.Platform.Application.Contracts/{Blog => Public}/BlogCategoryDto.cs (54%) rename api/src/Kurs.Platform.Application.Contracts/{Blog => Public}/BlogPostAndCategoriesDto.cs (87%) create mode 100644 api/src/Kurs.Platform.Application.Contracts/Public/BlogPostDto.cs create mode 100644 api/src/Kurs.Platform.Application.Contracts/Public/BlogPostListDto.cs rename api/src/Kurs.Platform.Application.Contracts/{Contact => Public}/CityDto.cs (88%) rename api/src/Kurs.Platform.Application.Contracts/{Contact => Public}/ContactDto.cs (66%) rename api/src/Kurs.Platform.Application.Contracts/{Contact => Public}/ContactTagDto.cs (84%) rename api/src/Kurs.Platform.Application.Contracts/{Contact => Public}/ContactTitleDto.cs (84%) rename api/src/Kurs.Platform.Application.Contracts/{Contact => Public}/CountryDto.cs (93%) rename api/src/Kurs.Platform.Application.Contracts/{Contact => Public}/CountryGroupDto.cs (80%) create mode 100644 api/src/Kurs.Platform.Application.Contracts/Public/CreateUpdateBlogCategoryDto.cs create mode 100644 api/src/Kurs.Platform.Application.Contracts/Public/CreateUpdateBlogPostDto.cs rename api/src/Kurs.Platform.Application.Contracts/{Demo => Public}/DemoDto.cs (100%) rename api/src/Kurs.Platform.Application.Contracts/{Contact => Public}/DistrictDto.cs (90%) rename api/src/Kurs.Platform.Application.Contracts/{Blog => Public}/IBlogAppService.cs (98%) rename api/src/Kurs.Platform.Application.Contracts/{Orders => Public}/InstallmentOptionDto.cs (89%) rename api/src/Kurs.Platform.Application.Contracts/{Orders => Public}/OrderDto.cs (64%) create mode 100644 api/src/Kurs.Platform.Application.Contracts/Public/OrderItemDto.cs rename api/src/Kurs.Platform.Application.Contracts/{Orders => Public}/PaymentMethodDto.cs (89%) rename api/src/Kurs.Platform.Application.Contracts/{Orders => Public}/ProductDto.cs (95%) rename api/src/Kurs.Platform.Application.Contracts/{Services => Public}/ServiceDto.cs (90%) create mode 100644 api/src/Kurs.Platform.Domain.Shared/Public/BankDto.cs create mode 100644 api/src/Kurs.Platform.Domain.Shared/Public/MapDto.cs rename api/src/{Kurs.Platform.Application.Contracts/About => Kurs.Platform.Domain.Shared/Public}/SectionDto.cs (76%) rename api/src/{Kurs.Platform.Application.Contracts/About => Kurs.Platform.Domain.Shared/Public}/StatDto.cs (91%) create mode 100644 api/src/Kurs.Platform.Domain.Shared/Public/WorkHoursDto.cs rename api/src/{Kurs.Platform.DbMigrator => Kurs.Platform.EntityFrameworkCore/Tenants}/Seeds/TenantData.Dev.json (100%) rename api/src/{Kurs.Platform.DbMigrator => Kurs.Platform.EntityFrameworkCore/Tenants}/Seeds/TenantData.Production.json (100%) rename api/src/{Kurs.Platform.DbMigrator => Kurs.Platform.EntityFrameworkCore/Tenants}/Seeds/TenantData.json (100%) rename api/src/{Kurs.Platform.DbMigrator/Seeds => Kurs.Platform.EntityFrameworkCore/Tenants}/TenantDataSeeder.cs (98%) create mode 100644 api/src/Kurs.Platform.EntityFrameworkCore/Tenants/TenantIdentityDataSeeder.cs rename api/src/{Kurs.Platform.DbMigrator/Seeds => Kurs.Platform.EntityFrameworkCore/Tenants}/TenantSeederDto.cs (99%) diff --git a/api/src/Kurs.Platform.Application.Contracts/Blog/BlogPostDto.cs b/api/src/Kurs.Platform.Application.Contracts/Blog/BlogPostDto.cs deleted file mode 100644 index df0492f8..00000000 --- a/api/src/Kurs.Platform.Application.Contracts/Blog/BlogPostDto.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.Collections.Generic; -using Volo.Abp.Application.Dtos; - -namespace Kurs.Platform.Blog; - -public class BlogPostDto : FullAuditedEntityDto -{ - public Guid? TenantId { get; set; } - public string Title { get; set; } - public string Slug { get; set; } - public string ContentTr { get; set; } - public string ContentEn { get; set; } - public string Summary { get; set; } - public string CoverImage { get; set; } - - public Guid CategoryId { get; set; } - public BlogCategoryDto Category { get; set; } - - public AuthorDto Author { get; set; } - - public int ViewCount { get; set; } - public int LikeCount { get; set; } - public int CommentCount { get; set; } - - public bool IsPublished { get; set; } - public DateTime? PublishedAt { get; set; } - - public List Tags { get; set; } - public bool IsLiked { get; set; } - - public BlogPostDto() - { - Tags = []; - } -} - -public class AuthorDto -{ - public Guid Id { get; set; } - public string Name { get; set; } - public string Avatar { get; set; } -} - -public class CreateUpdateBlogPostDto -{ - public Guid? TenantId { get; set; } - public string Title { get; set; } - public string Slug { get; set; } - public string ContentTr { get; set; } - public string ContentEn { get; set; } - public string Summary { get; set; } - public string ReadTime { get; set; } - public string CoverImage { get; set; } - public Guid CategoryId { get; set; } - public List Tags { get; set; } - public bool IsPublished { get; set; } - - public CreateUpdateBlogPostDto() - { - Tags = []; - } -} - -public class BlogPostListDto : EntityDto -{ - public Guid? TenantId { get; set; } - public string Title { get; set; } - public string Slug { get; set; } - public string Summary { get; set; } - public string ReadTime { get; set; } - public string CoverImage { get; set; } - public string ContentTr { get; set; } - public string ContentEn { get; set; } - - public BlogCategoryDto Category { get; set; } - public AuthorDto Author { get; set; } - - public int ViewCount { get; set; } - public int LikeCount { get; set; } - public int CommentCount { get; set; } - - public bool IsPublished { get; set; } - public DateTime? PublishedAt { get; set; } - public DateTime CreationTime { get; set; } - - public List Tags { get; set; } - - public BlogPostListDto() - { - Tags = []; - } -} diff --git a/api/src/Kurs.Platform.Application.Contracts/About/AboutDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/AboutDto.cs similarity index 97% rename from api/src/Kurs.Platform.Application.Contracts/About/AboutDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/AboutDto.cs index a541ef0a..715c7ed2 100644 --- a/api/src/Kurs.Platform.Application.Contracts/About/AboutDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/AboutDto.cs @@ -4,7 +4,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Abouts; +namespace Kurs.Platform.Public; public class AboutDto : EntityDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/Public/AuthorDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/AuthorDto.cs new file mode 100644 index 00000000..f9223c0d --- /dev/null +++ b/api/src/Kurs.Platform.Application.Contracts/Public/AuthorDto.cs @@ -0,0 +1,10 @@ +using System; + +namespace Kurs.Platform.Public; + +public class AuthorDto +{ + public Guid Id { get; set; } + public string Name { get; set; } + public string Avatar { get; set; } +} diff --git a/api/src/Kurs.Platform.Application.Contracts/Blog/BlogCategoryDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/BlogCategoryDto.cs similarity index 54% rename from api/src/Kurs.Platform.Application.Contracts/Blog/BlogCategoryDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/BlogCategoryDto.cs index 59690f49..07a8d6f1 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Blog/BlogCategoryDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/BlogCategoryDto.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Blog; +namespace Kurs.Platform.Public; public class BlogCategoryDto : FullAuditedEntityDto { @@ -15,13 +15,4 @@ public class BlogCategoryDto : FullAuditedEntityDto public int PostCount { get; set; } } -public class CreateUpdateBlogCategoryDto -{ - public Guid? TenantId { get; set; } - public string Name { get; set; } - public string Slug { get; set; } - public string Description { get; set; } - public string Icon { get; set; } - public int DisplayOrder { get; set; } - public bool IsActive { get; set; } -} + diff --git a/api/src/Kurs.Platform.Application.Contracts/Blog/BlogPostAndCategoriesDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/BlogPostAndCategoriesDto.cs similarity index 87% rename from api/src/Kurs.Platform.Application.Contracts/Blog/BlogPostAndCategoriesDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/BlogPostAndCategoriesDto.cs index 79caa2ce..8fc7d4f3 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Blog/BlogPostAndCategoriesDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/BlogPostAndCategoriesDto.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Blog; +namespace Kurs.Platform.Public; public class BlogPostAndCategoriesDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/Public/BlogPostDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/BlogPostDto.cs new file mode 100644 index 00000000..5b706044 --- /dev/null +++ b/api/src/Kurs.Platform.Application.Contracts/Public/BlogPostDto.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using Volo.Abp.Application.Dtos; + +namespace Kurs.Platform.Public; + +public class BlogPostDto : FullAuditedEntityDto +{ + public Guid? TenantId { get; set; } + public string Title { get; set; } + public string Slug { get; set; } + public string ContentTr { get; set; } + public string ContentEn { get; set; } + public string Summary { get; set; } + public string CoverImage { get; set; } + + public Guid CategoryId { get; set; } + public BlogCategoryDto Category { get; set; } + + public AuthorDto Author { get; set; } + + public int ViewCount { get; set; } + public int LikeCount { get; set; } + public int CommentCount { get; set; } + + public bool IsPublished { get; set; } + public DateTime? PublishedAt { get; set; } + + public List Tags { get; set; } + public bool IsLiked { get; set; } + + public BlogPostDto() + { + Tags = []; + } +} + diff --git a/api/src/Kurs.Platform.Application.Contracts/Public/BlogPostListDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/BlogPostListDto.cs new file mode 100644 index 00000000..228afbcb --- /dev/null +++ b/api/src/Kurs.Platform.Application.Contracts/Public/BlogPostListDto.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using Volo.Abp.Application.Dtos; + +namespace Kurs.Platform.Public; + +public class BlogPostListDto : EntityDto +{ + public Guid? TenantId { get; set; } + public string Title { get; set; } + public string Slug { get; set; } + public string Summary { get; set; } + public string ReadTime { get; set; } + public string CoverImage { get; set; } + public string ContentTr { get; set; } + public string ContentEn { get; set; } + + public BlogCategoryDto Category { get; set; } + public AuthorDto Author { get; set; } + + public int ViewCount { get; set; } + public int LikeCount { get; set; } + public int CommentCount { get; set; } + + public bool IsPublished { get; set; } + public DateTime? PublishedAt { get; set; } + public DateTime CreationTime { get; set; } + + public List Tags { get; set; } + + public BlogPostListDto() + { + Tags = []; + } +} diff --git a/api/src/Kurs.Platform.Application.Contracts/Contact/CityDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/CityDto.cs similarity index 88% rename from api/src/Kurs.Platform.Application.Contracts/Contact/CityDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/CityDto.cs index b74b242b..5c7419bd 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Contact/CityDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/CityDto.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Contacts; +namespace Kurs.Platform.Public; public class CityDto : AuditedEntityDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/Contact/ContactDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/ContactDto.cs similarity index 66% rename from api/src/Kurs.Platform.Application.Contracts/Contact/ContactDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/ContactDto.cs index e8062aa6..ac5e60fb 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Contact/ContactDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/ContactDto.cs @@ -3,7 +3,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Contacts; +namespace Kurs.Platform.Public; public class ContactDto : EntityDto { @@ -51,31 +51,4 @@ public class ContactDto : EntityDto } set { MapJson = JsonSerializer.Serialize(value); } } -} - -public class BankDto -{ - public string AccountHolder { get; set; } - public string Branch { get; set; } - public string AccountNumber { get; set; } - public string Iban { get; set; } -} - -public class WorkHoursDto -{ - public string Weekday { get; set; } - public string Weekend { get; set; } - public string Whatsapp { get; set; } -} - -public class MapDto -{ - public string Title { get; set; } - public string Src { get; set; } - public string Width { get; set; } - public string Height { get; set; } - public string Style { get; set; } - public bool? AllowFullScreen { get; set; } - public string Loading { get; set; } - public string ReferrerPolicy { get; set; } } \ No newline at end of file diff --git a/api/src/Kurs.Platform.Application.Contracts/Contact/ContactTagDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/ContactTagDto.cs similarity index 84% rename from api/src/Kurs.Platform.Application.Contracts/Contact/ContactTagDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/ContactTagDto.cs index 026d1284..8ce3fdd0 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Contact/ContactTagDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/ContactTagDto.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Contacts; +namespace Kurs.Platform.Public; public class ContactTagDto : AuditedEntityDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/Contact/ContactTitleDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/ContactTitleDto.cs similarity index 84% rename from api/src/Kurs.Platform.Application.Contracts/Contact/ContactTitleDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/ContactTitleDto.cs index 3bfd2686..b15b70c4 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Contact/ContactTitleDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/ContactTitleDto.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Contacts; +namespace Kurs.Platform.Public; public class ContactTitleDto : AuditedEntityDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/Contact/CountryDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/CountryDto.cs similarity index 93% rename from api/src/Kurs.Platform.Application.Contracts/Contact/CountryDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/CountryDto.cs index 09801c18..05b77df3 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Contact/CountryDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/CountryDto.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Contacts; +namespace Kurs.Platform.Public; public class CountryDto : AuditedEntityDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/Contact/CountryGroupDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/CountryGroupDto.cs similarity index 80% rename from api/src/Kurs.Platform.Application.Contracts/Contact/CountryGroupDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/CountryGroupDto.cs index 8f973bc2..4fce6c65 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Contact/CountryGroupDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/CountryGroupDto.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Contacts; +namespace Kurs.Platform.Public; public class CountryGroupDto : AuditedEntityDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/Public/CreateUpdateBlogCategoryDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/CreateUpdateBlogCategoryDto.cs new file mode 100644 index 00000000..ae9ebc2e --- /dev/null +++ b/api/src/Kurs.Platform.Application.Contracts/Public/CreateUpdateBlogCategoryDto.cs @@ -0,0 +1,14 @@ +using System; + +namespace Kurs.Platform.Public; + +public class CreateUpdateBlogCategoryDto +{ + public Guid? TenantId { get; set; } + public string Name { get; set; } + public string Slug { get; set; } + public string Description { get; set; } + public string Icon { get; set; } + public int DisplayOrder { get; set; } + public bool IsActive { get; set; } +} \ No newline at end of file diff --git a/api/src/Kurs.Platform.Application.Contracts/Public/CreateUpdateBlogPostDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/CreateUpdateBlogPostDto.cs new file mode 100644 index 00000000..19715e2b --- /dev/null +++ b/api/src/Kurs.Platform.Application.Contracts/Public/CreateUpdateBlogPostDto.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; + +namespace Kurs.Platform.Public; + +public class CreateUpdateBlogPostDto +{ + public Guid? TenantId { get; set; } + public string Title { get; set; } + public string Slug { get; set; } + public string ContentTr { get; set; } + public string ContentEn { get; set; } + public string Summary { get; set; } + public string ReadTime { get; set; } + public string CoverImage { get; set; } + public Guid CategoryId { get; set; } + public List Tags { get; set; } + public bool IsPublished { get; set; } + + public CreateUpdateBlogPostDto() + { + Tags = []; + } +} \ No newline at end of file diff --git a/api/src/Kurs.Platform.Application.Contracts/Demo/DemoDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/DemoDto.cs similarity index 100% rename from api/src/Kurs.Platform.Application.Contracts/Demo/DemoDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/DemoDto.cs diff --git a/api/src/Kurs.Platform.Application.Contracts/Contact/DistrictDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/DistrictDto.cs similarity index 90% rename from api/src/Kurs.Platform.Application.Contracts/Contact/DistrictDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/DistrictDto.cs index f71b959d..203ca021 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Contact/DistrictDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/DistrictDto.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Contacts; +namespace Kurs.Platform.Public; public class DistrictDto : AuditedEntityDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/Blog/IBlogAppService.cs b/api/src/Kurs.Platform.Application.Contracts/Public/IBlogAppService.cs similarity index 98% rename from api/src/Kurs.Platform.Application.Contracts/Blog/IBlogAppService.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/IBlogAppService.cs index 702f4982..73704da6 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Blog/IBlogAppService.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/IBlogAppService.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; -namespace Kurs.Platform.Blog; +namespace Kurs.Platform.Public; public interface IBlogAppService : IApplicationService { diff --git a/api/src/Kurs.Platform.Application.Contracts/Orders/InstallmentOptionDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/InstallmentOptionDto.cs similarity index 89% rename from api/src/Kurs.Platform.Application.Contracts/Orders/InstallmentOptionDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/InstallmentOptionDto.cs index 1f7b8109..d3199f14 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Orders/InstallmentOptionDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/InstallmentOptionDto.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Orders; +namespace Kurs.Platform.Public; public class InstallmentOptionDto : EntityDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/Orders/OrderDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/OrderDto.cs similarity index 64% rename from api/src/Kurs.Platform.Application.Contracts/Orders/OrderDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/OrderDto.cs index fa7b6f84..c68f70e9 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Orders/OrderDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/OrderDto.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Kurs.Platform.Tenants; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Orders; +namespace Kurs.Platform.Public; public class OrderDto : EntityDto { @@ -21,11 +21,3 @@ public class OrderDto : EntityDto public Dictionary PaymentData { get; set; } } -public class OrderItemDto -{ - public Guid ProductId { get; set; } - public ProductDto Product { get; set; } - public string BillingCycle { get; set; } // monthly | yearly - public int Quantity { get; set; } - public decimal TotalPrice { get; set; } -} diff --git a/api/src/Kurs.Platform.Application.Contracts/Public/OrderItemDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/OrderItemDto.cs new file mode 100644 index 00000000..4f4decb1 --- /dev/null +++ b/api/src/Kurs.Platform.Application.Contracts/Public/OrderItemDto.cs @@ -0,0 +1,12 @@ +using System; + +namespace Kurs.Platform.Public; + +public class OrderItemDto +{ + public Guid ProductId { get; set; } + public ProductDto Product { get; set; } + public string BillingCycle { get; set; } // monthly | yearly + public int Quantity { get; set; } + public decimal TotalPrice { get; set; } +} diff --git a/api/src/Kurs.Platform.Application.Contracts/Orders/PaymentMethodDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/PaymentMethodDto.cs similarity index 89% rename from api/src/Kurs.Platform.Application.Contracts/Orders/PaymentMethodDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/PaymentMethodDto.cs index 896e1a50..05daa7ff 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Orders/PaymentMethodDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/PaymentMethodDto.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Orders; +namespace Kurs.Platform.Public; public class PaymentMethodDto : EntityDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/Orders/ProductDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/ProductDto.cs similarity index 95% rename from api/src/Kurs.Platform.Application.Contracts/Orders/ProductDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/ProductDto.cs index 0207ef89..471e602c 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Orders/ProductDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/ProductDto.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Orders; +namespace Kurs.Platform.Public; public class ProductDto : EntityDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/Services/ServiceDto.cs b/api/src/Kurs.Platform.Application.Contracts/Public/ServiceDto.cs similarity index 90% rename from api/src/Kurs.Platform.Application.Contracts/Services/ServiceDto.cs rename to api/src/Kurs.Platform.Application.Contracts/Public/ServiceDto.cs index dc8bdca1..e72819d7 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Services/ServiceDto.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Public/ServiceDto.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.Application.Dtos; -namespace Kurs.Platform.Services; +namespace Kurs.Platform.Public; public class ServiceDto : FullAuditedEntityDto { diff --git a/api/src/Kurs.Platform.Application/Blog/BlogAppService.cs b/api/src/Kurs.Platform.Application/Blog/BlogAppService.cs index 256a6cf6..f9ac0826 100644 --- a/api/src/Kurs.Platform.Application/Blog/BlogAppService.cs +++ b/api/src/Kurs.Platform.Application/Blog/BlogAppService.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.Localization; using Volo.Abp.Domain.Repositories; using Volo.Abp.Users; -namespace Kurs.Platform.Blog; +namespace Kurs.Platform.Public; [Authorize] public class BlogAppService : PlatformAppService, IBlogAppService diff --git a/api/src/Kurs.Platform.Application/Public/PublicAppService.cs b/api/src/Kurs.Platform.Application/Public/PublicAppService.cs index 56762a44..403d732f 100644 --- a/api/src/Kurs.Platform.Application/Public/PublicAppService.cs +++ b/api/src/Kurs.Platform.Application/Public/PublicAppService.cs @@ -2,21 +2,16 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using Kurs.Platform.Entities; -using Kurs.Platform.Services; using Volo.Abp.Domain.Repositories; using System.Text; using Kurs.Platform.Data.Seeds; using Kurs.Sender.Mail; using Volo.Abp.Settings; using Kurs.Platform.Demos; -using Kurs.Platform.Blog; using Volo.Abp.Domain.Entities; using System.Linq; using Volo.Abp.Application.Dtos; -using Kurs.Platform.Orders; using System.Text.Json; -using Kurs.Platform.Abouts; -using Kurs.Platform.Contacts; namespace Kurs.Platform.Public; diff --git a/api/src/Kurs.Platform.Application/Public/PublicAutoMapperProfile.cs b/api/src/Kurs.Platform.Application/Public/PublicAutoMapperProfile.cs index f7f16ab6..1d3fca32 100644 --- a/api/src/Kurs.Platform.Application/Public/PublicAutoMapperProfile.cs +++ b/api/src/Kurs.Platform.Application/Public/PublicAutoMapperProfile.cs @@ -1,11 +1,6 @@ using AutoMapper; -using Kurs.Platform.Abouts; -using Kurs.Platform.Blog; -using Kurs.Platform.Contacts; using Kurs.Platform.Demos; using Kurs.Platform.Entities; -using Kurs.Platform.Orders; -using Kurs.Platform.Services; namespace Kurs.Platform.Public; diff --git a/api/src/Kurs.Platform.DbMigrator/Kurs.Platform.DbMigrator.csproj b/api/src/Kurs.Platform.DbMigrator/Kurs.Platform.DbMigrator.csproj index cef4d49d..78dcc396 100644 --- a/api/src/Kurs.Platform.DbMigrator/Kurs.Platform.DbMigrator.csproj +++ b/api/src/Kurs.Platform.DbMigrator/Kurs.Platform.DbMigrator.csproj @@ -29,19 +29,6 @@ PreserveNewest Always - - - PreserveNewest - Always - - - PreserveNewest - Always - - - PreserveNewest - Always - PreserveNewest diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/HostDataSeeder.cs b/api/src/Kurs.Platform.DbMigrator/Seeds/HostDataSeeder.cs index d9fff760..1ca88dac 100644 --- a/api/src/Kurs.Platform.DbMigrator/Seeds/HostDataSeeder.cs +++ b/api/src/Kurs.Platform.DbMigrator/Seeds/HostDataSeeder.cs @@ -18,7 +18,7 @@ using Volo.Abp.PermissionManagement; using Microsoft.EntityFrameworkCore; using EFCore.BulkExtensions; using System.Collections.Generic; -using Kurs.Platform.Contacts; +using Kurs.Platform.Public; using static Kurs.Settings.SettingsConsts; namespace Kurs.Platform.Data.Seeds; diff --git a/api/src/Kurs.Platform.Domain.Shared/Public/BankDto.cs b/api/src/Kurs.Platform.Domain.Shared/Public/BankDto.cs new file mode 100644 index 00000000..abaaa6cf --- /dev/null +++ b/api/src/Kurs.Platform.Domain.Shared/Public/BankDto.cs @@ -0,0 +1,9 @@ +namespace Kurs.Platform.Public; + +public class BankDto +{ + public string AccountHolder { get; set; } + public string Branch { get; set; } + public string AccountNumber { get; set; } + public string Iban { get; set; } +} \ No newline at end of file diff --git a/api/src/Kurs.Platform.Domain.Shared/Public/MapDto.cs b/api/src/Kurs.Platform.Domain.Shared/Public/MapDto.cs new file mode 100644 index 00000000..e1e9d12c --- /dev/null +++ b/api/src/Kurs.Platform.Domain.Shared/Public/MapDto.cs @@ -0,0 +1,13 @@ +namespace Kurs.Platform.Public; + +public class MapDto +{ + public string Title { get; set; } + public string Src { get; set; } + public string Width { get; set; } + public string Height { get; set; } + public string Style { get; set; } + public bool? AllowFullScreen { get; set; } + public string Loading { get; set; } + public string ReferrerPolicy { get; set; } +} \ No newline at end of file diff --git a/api/src/Kurs.Platform.Application.Contracts/About/SectionDto.cs b/api/src/Kurs.Platform.Domain.Shared/Public/SectionDto.cs similarity index 76% rename from api/src/Kurs.Platform.Application.Contracts/About/SectionDto.cs rename to api/src/Kurs.Platform.Domain.Shared/Public/SectionDto.cs index d30b83b7..db37b73a 100644 --- a/api/src/Kurs.Platform.Application.Contracts/About/SectionDto.cs +++ b/api/src/Kurs.Platform.Domain.Shared/Public/SectionDto.cs @@ -1,4 +1,4 @@ -namespace Kurs.Platform.Abouts; +namespace Kurs.Platform.Public; public class SectionDto { diff --git a/api/src/Kurs.Platform.Application.Contracts/About/StatDto.cs b/api/src/Kurs.Platform.Domain.Shared/Public/StatDto.cs similarity index 91% rename from api/src/Kurs.Platform.Application.Contracts/About/StatDto.cs rename to api/src/Kurs.Platform.Domain.Shared/Public/StatDto.cs index f17880dd..4f9ecbe0 100644 --- a/api/src/Kurs.Platform.Application.Contracts/About/StatDto.cs +++ b/api/src/Kurs.Platform.Domain.Shared/Public/StatDto.cs @@ -1,4 +1,4 @@ -namespace Kurs.Platform.Abouts; +namespace Kurs.Platform.Public; public class StatDto { diff --git a/api/src/Kurs.Platform.Domain.Shared/Public/WorkHoursDto.cs b/api/src/Kurs.Platform.Domain.Shared/Public/WorkHoursDto.cs new file mode 100644 index 00000000..8a7223ac --- /dev/null +++ b/api/src/Kurs.Platform.Domain.Shared/Public/WorkHoursDto.cs @@ -0,0 +1,8 @@ +namespace Kurs.Platform.Public; + +public class WorkHoursDto +{ + public string Weekday { get; set; } + public string Weekend { get; set; } + public string Whatsapp { get; set; } +} \ No newline at end of file diff --git a/api/src/Kurs.Platform.EntityFrameworkCore/DatabaseMigrationEventHandlerBase.cs b/api/src/Kurs.Platform.EntityFrameworkCore/DatabaseMigrationEventHandlerBase.cs index 50d7ee9b..f7d95924 100644 --- a/api/src/Kurs.Platform.EntityFrameworkCore/DatabaseMigrationEventHandlerBase.cs +++ b/api/src/Kurs.Platform.EntityFrameworkCore/DatabaseMigrationEventHandlerBase.cs @@ -21,8 +21,6 @@ using Volo.Abp.MultiTenancy; using Volo.Abp.PermissionManagement; using Volo.Abp.TenantManagement; using Volo.Abp.Uow; -using IdentityRole = Volo.Abp.Identity.IdentityRole; -using IdentityUser = Volo.Abp.Identity.IdentityUser; using static Kurs.Settings.SettingsConsts; namespace Kurs.Platform.Migrations; @@ -90,17 +88,19 @@ public class DatabaseMigrationEventHandler : public async Task HandleEventAsync(ApplyDatabaseMigrationsEto eventData) { - var schemaMigrated = false; try { - schemaMigrated = await MigrateDatabaseSchemaAsync(eventData.TenantId); + var schemaMigrated = await MigrateDatabaseSchemaAsync(eventData.TenantId); if (schemaMigrated) { await SeedTenantDataAsync(eventData); } } - catch (Exception) + catch (Exception ex) { + Logger.LogError(ex, "Error while seeding tenant data"); + throw; + //await HandleErrorOnApplyDatabaseMigrationAsync(eventData, ex); } } @@ -189,80 +189,80 @@ public class DatabaseMigrationEventHandler : { using (CurrentTenant.Change(eventData.TenantId)) { - // await DataSeeder.SeedAsync( - // new DataSeedContext(eventData.TenantId) - // .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, eventData.Properties[IdentityDataSeedContributor.AdminEmailPropertyName]) - // .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, eventData.Properties[IdentityDataSeedContributor.AdminPasswordPropertyName]) - // .WithProperty(IdentityDataSeedContributor.AdminUserNamePropertyName, eventData.Properties[IdentityDataSeedContributor.AdminUserNamePropertyName]) - // ); + await DataSeeder.SeedAsync( + new DataSeedContext(eventData.TenantId) + .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, eventData.Properties[IdentityDataSeedContributor.AdminEmailPropertyName]) + .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, eventData.Properties[IdentityDataSeedContributor.AdminPasswordPropertyName]) + .WithProperty(IdentityDataSeedContributor.AdminUserNamePropertyName, eventData.Properties[IdentityDataSeedContributor.AdminUserNamePropertyName]) + ); - await IdentityOptions.SetAsync(); + // await IdentityOptions.SetAsync(); - var result = new IdentityDataSeedResult(); - var adminEmail = eventData.Properties[IdentityDataSeedContributor.AdminEmailPropertyName]; - var adminPassword = eventData.Properties[IdentityDataSeedContributor.AdminPasswordPropertyName]; - var adminUserName = eventData.Properties[IdentityDataSeedContributor.AdminUserNamePropertyName]; - var adminUser = await UserRepository.FindByNormalizedUserNameAsync( - LookupNormalizer.NormalizeName(adminUserName) - ); + // var result = new IdentityDataSeedResult(); + // var adminEmail = eventData.Properties[IdentityDataSeedContributor.AdminEmailPropertyName]; + // var adminPassword = eventData.Properties[IdentityDataSeedContributor.AdminPasswordPropertyName]; + // var adminUserName = eventData.Properties[IdentityDataSeedContributor.AdminUserNamePropertyName]; + // var adminUser = await UserRepository.FindByNormalizedUserNameAsync( + // LookupNormalizer.NormalizeName(adminUserName) + // ); - adminUser = new IdentityUser( - GuidGenerator.Create(), - adminUserName, - adminUserName, - eventData.TenantId - ) - { - Name = PlatformConsts.AbpIdentity.User.AdminNameDefaultValue, - Surname = PlatformConsts.AbpIdentity.User.AdminSurNameDefaultValue, - }; - adminUser.SetEmailConfirmed(true); - adminUser.SetIsVerified(true); - adminUser.SetPhoneNumber(PlatformConsts.AbpIdentity.User.AdminPhoneNumberDefaultValue, true); + // adminUser = new IdentityUser( + // GuidGenerator.Create(), + // adminUserName, + // adminUserName, + // eventData.TenantId + // ) + // { + // Name = PlatformConsts.AbpIdentity.User.AdminNameDefaultValue, + // Surname = PlatformConsts.AbpIdentity.User.AdminSurNameDefaultValue, + // }; + // adminUser.SetEmailConfirmed(true); + // adminUser.SetIsVerified(true); + // adminUser.SetPhoneNumber(PlatformConsts.AbpIdentity.User.AdminPhoneNumberDefaultValue, true); - (await UserManager.CreateAsync(adminUser, adminPassword, validatePassword: false)).CheckErrors(); - result.CreatedAdminUser = true; - var adminRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(PlatformConsts.AbpIdentity.User.AdminRoleName)); - if (adminRole is null) - { - adminRole = new IdentityRole( - GuidGenerator.Create(), - PlatformConsts.AbpIdentity.User.AdminRoleName, - eventData.TenantId - ) - { - IsStatic = true, - IsPublic = true - }; + // (await UserManager.CreateAsync(adminUser, adminPassword, validatePassword: false)).CheckErrors(); + // result.CreatedAdminUser = true; + // var adminRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(PlatformConsts.AbpIdentity.User.AdminRoleName)); + // if (adminRole is null) + // { + // adminRole = new IdentityRole( + // GuidGenerator.Create(), + // PlatformConsts.AbpIdentity.User.AdminRoleName, + // eventData.TenantId + // ) + // { + // IsStatic = true, + // IsPublic = true + // }; - (await RoleManager.CreateAsync(adminRole)).CheckErrors(); - result.CreatedAdminRole = true; - } + // (await RoleManager.CreateAsync(adminRole)).CheckErrors(); + // result.CreatedAdminRole = true; + // } - (await UserManager.AddToRoleAsync(adminUser, adminRole.Name)).CheckErrors(); + // (await UserManager.AddToRoleAsync(adminUser, adminRole.Name)).CheckErrors(); - /*admin rolüne ait yetkiler otomatik atanıyor*/ - var permissions = await PermissionGrantRepository.GetListAsync("R", PlatformConsts.AbpIdentity.User.AdminRoleName); - if (permissions.Count == 0) - { - await PermissionGrantRepository.InsertManyAsync( - [ - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Create, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Delete, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Update, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Default + ".Export", "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.ManagePermissions, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Create, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Delete, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Update, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.ManagePermissions, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Default + ".Export", "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.ManageRoles, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.UserLookup.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), - ]); - } + // /*admin rolüne ait yetkiler otomatik atanıyor*/ + // var permissions = await PermissionGrantRepository.GetListAsync("R", PlatformConsts.AbpIdentity.User.AdminRoleName); + // if (permissions.Count == 0) + // { + // await PermissionGrantRepository.InsertManyAsync( + // [ + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Create, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Delete, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Update, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Default + ".Export", "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.ManagePermissions, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Create, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Delete, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Update, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.ManagePermissions, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Default + ".Export", "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.ManageRoles, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.UserLookup.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId), + // ]); + // } } } } diff --git a/api/src/Kurs.Platform.EntityFrameworkCore/Kurs.Platform.EntityFrameworkCore.csproj b/api/src/Kurs.Platform.EntityFrameworkCore/Kurs.Platform.EntityFrameworkCore.csproj index a5972989..2f56734e 100644 --- a/api/src/Kurs.Platform.EntityFrameworkCore/Kurs.Platform.EntityFrameworkCore.csproj +++ b/api/src/Kurs.Platform.EntityFrameworkCore/Kurs.Platform.EntityFrameworkCore.csproj @@ -1,12 +1,28 @@  - + - + net9.0 Kurs.Platform - + + + + + PreserveNewest + Always + + + PreserveNewest + Always + + + PreserveNewest + Always + + + @@ -24,30 +40,30 @@ - + all runtime; build; native; contentfiles; analyzers - + - + - + - + diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/TenantData.Dev.json b/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.Dev.json similarity index 100% rename from api/src/Kurs.Platform.DbMigrator/Seeds/TenantData.Dev.json rename to api/src/Kurs.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.Dev.json diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/TenantData.Production.json b/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.Production.json similarity index 100% rename from api/src/Kurs.Platform.DbMigrator/Seeds/TenantData.Production.json rename to api/src/Kurs.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.Production.json diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/TenantData.json b/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json similarity index 100% rename from api/src/Kurs.Platform.DbMigrator/Seeds/TenantData.json rename to api/src/Kurs.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/TenantDataSeeder.cs b/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs similarity index 98% rename from api/src/Kurs.Platform.DbMigrator/Seeds/TenantDataSeeder.cs rename to api/src/Kurs.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs index 06649a21..8e93d94d 100644 --- a/api/src/Kurs.Platform.DbMigrator/Seeds/TenantDataSeeder.cs +++ b/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs @@ -144,11 +144,15 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency public async Task SeedAsync(DataSeedContext context) { + var assemblyLocation = Path.GetDirectoryName(typeof(TenantDataSeeder).Assembly.Location)!; + var basePath = Path.Combine(assemblyLocation, "Tenants", "Seeds"); + var configuration = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile(Path.Combine("Seeds", "TenantData.json")) - .AddJsonFile(Path.Combine("Seeds", $"TenantData.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? ""}.json"), true) + .SetBasePath(basePath) + .AddJsonFile("TenantData.json", optional: false, reloadOnChange: false) + .AddJsonFile($"TenantData.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? ""}.json", optional: true) .Build(); + var items = configuration.Get(); var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; diff --git a/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/TenantIdentityDataSeeder.cs b/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/TenantIdentityDataSeeder.cs new file mode 100644 index 00000000..7f2a324b --- /dev/null +++ b/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/TenantIdentityDataSeeder.cs @@ -0,0 +1,105 @@ +using System; +using System.Threading.Tasks; +using Kurs.Platform.Extensions; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Options; +using Volo.Abp; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; +using Volo.Abp.Identity; +using Volo.Abp.MultiTenancy; +using Volo.Abp.PermissionManagement; +using IdentityRole = Volo.Abp.Identity.IdentityRole; +using IdentityUser = Volo.Abp.Identity.IdentityUser; + +namespace Kurs.Platform.Data.Seeds; + +[Dependency(ReplaceServices = true)] +public class TenantIdentityDataSeeder : IdentityDataSeeder +{ + private readonly IPermissionGrantRepository permissionGrantRepository; + + public TenantIdentityDataSeeder( + IGuidGenerator guidGenerator, + IIdentityRoleRepository roleRepository, + IIdentityUserRepository userRepository, + ILookupNormalizer lookupNormalizer, + IdentityUserManager userManager, + IdentityRoleManager roleManager, + IPermissionGrantRepository permissionGrantRepository, + ICurrentTenant currentTenant, + IOptions identityOptions + ) : base(guidGenerator, roleRepository, userRepository, lookupNormalizer, userManager, roleManager, currentTenant, identityOptions) + { + this.permissionGrantRepository = permissionGrantRepository; + } + + public override async Task SeedAsync(string adminEmail, string adminPassword, Guid? tenantId = null, string adminUserName = null) + { + Check.NotNullOrWhiteSpace(adminEmail, nameof(adminEmail)); + Check.NotNullOrWhiteSpace(adminPassword, nameof(adminPassword)); + + using (CurrentTenant.Change(tenantId)) + { + await IdentityOptions.SetAsync(); + + var result = new IdentityDataSeedResult(); + + var adminRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(PlatformConsts.AbpIdentity.User.AdminRoleName)); + if (adminRole is null) + { + adminRole = new IdentityRole( + GuidGenerator.Create(), + PlatformConsts.AbpIdentity.User.AdminRoleName, + tenantId + ) + { + IsStatic = true, + IsPublic = true + }; + + (await RoleManager.CreateAsync(adminRole)).CheckErrors(); + result.CreatedAdminRole = true; + } + + adminUserName ??= PlatformConsts.AbpIdentity.User.AdminEmailDefaultValue; + var adminUser = await UserRepository.FindByNormalizedUserNameAsync( + LookupNormalizer.NormalizeName(adminUserName) + ); + + if (adminUser is null) + { + adminUser = new IdentityUser( + GuidGenerator.Create(), + adminUserName, + adminEmail, + tenantId + ) + { + Name = PlatformConsts.AbpIdentity.User.AdminNameDefaultValue, + Surname = PlatformConsts.AbpIdentity.User.AdminSurNameDefaultValue, + }; + + adminUser.SetEmailConfirmed(true); + adminUser.SetIsVerified(true); + adminUser.SetRocketUsername(PlatformConsts.AbpIdentity.User.AdminRocketUsernameDefaultValue); + adminUser.SetPhoneNumber(PlatformConsts.AbpIdentity.User.AdminPhoneNumberDefaultValue, true); + + (await UserManager.CreateAsync(adminUser, adminPassword, validatePassword: false)).CheckErrors(); + result.CreatedAdminUser = true; + + (await UserManager.AddToRoleAsync(adminUser, PlatformConsts.AbpIdentity.User.AdminRoleName)).CheckErrors(); + } + + // Grant all permission kısmı Abp tarafından otomatik çalıştırılıyor. + // Ayrıca bende çalıştırınca hata veriyor. + // Hem DbMigrator hem de burada IdentityDataSeeder var. + // Aynı Assembly'de birden fazla IdentityDataSeeder olabilir + // DbMigrator çalışınca kendi IdentityDataSeeder'ını çalıştırıyor. + // Tenant seed edilince bu IdentityDataSeeder çalışıyor. + // See: Volo.Abp.PermissionManagement.PermissionDataSeedContributor + + return result; + } + } +} diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/TenantSeederDto.cs b/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs similarity index 99% rename from api/src/Kurs.Platform.DbMigrator/Seeds/TenantSeederDto.cs rename to api/src/Kurs.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs index 4d337f96..50a25db0 100644 --- a/api/src/Kurs.Platform.DbMigrator/Seeds/TenantSeederDto.cs +++ b/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs @@ -1,8 +1,7 @@ using System; using System.Collections.Generic; -using Kurs.Platform.Abouts; -using Kurs.Platform.Contacts; using Kurs.Platform.Entities; +using Kurs.Platform.Public; namespace Kurs.Platform.Seeds;