seed/data Seeder Products

This commit is contained in:
Sedat ÖZTÜRK 2026-09-04 14:32:20 +03:00
parent a0491f9db8
commit 3b93cd3895
6 changed files with 176 additions and 183 deletions

View file

@ -3437,6 +3437,8 @@ Kurallar:
- **Identity anahtarlı tablolarda satır anahtarsız yazılır.** `Id` alanı dosyada yoksa anahtar - **Identity anahtarlı tablolarda satır anahtarsız yazılır.** `Id` alanı dosyada yoksa anahtar
veritabanına bırakılır; satırın var olup olmadığı dosyadaki **tüm alan değerlerinin** veritabanına bırakılır; satırın var olup olmadığı dosyadaki **tüm alan değerlerinin**
(tenant kapsamı dahil) eşleşmesine bakılarak belirlenir. (tenant kapsamı dahil) eşleşmesine bakılarak belirlenir.
- **Dosyadaki değer varsayılanı ezer.** `InsertFieldsDefaultValueJson` yalnızca dosyada bulunmayan
alanları doldurur (audit kolonları, kapsam, anahtar); ekrandan kayıtta ise varsayılan girilen değeri ezer.
- **Uygulama yalnızca ekler:** anahtarı veritabanında bulunmayan satırlar `INSERT` edilir; var olan - **Uygulama yalnızca ekler:** anahtarı veritabanında bulunmayan satırlar `INSERT` edilir; var olan
kayıt güncellenmez (her migrate'te ekrandaki güncel değerler dosyadaki eskisiyle ezilmesin diye) kayıt güncellenmez (her migrate'te ekrandaki güncel değerler dosyadaki eskisiyle ezilmesin diye)
ve dosyada olmayan satır silinmez. ve dosyada olmayan satır silinmez.

View file

@ -7140,6 +7140,10 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency
Description = $"{listFormName}.Description", Description = $"{listFormName}.Description",
SelectCommandType = SelectCommandTypeEnum.Table, SelectCommandType = SelectCommandTypeEnum.Table,
SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Product)), SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Product)),
SeedFilePath = SeedPathResolver.GetDataFilePath(listFormName),
SeedSyncInsert = false,
SeedSyncUpdate = false,
SeedSyncDelete = false,
KeyFieldName = "Id", KeyFieldName = "Id",
KeyFieldDbSourceType = DbType.Guid, KeyFieldDbSourceType = DbType.Guid,
DefaultFilter = DefaultFilterJson, DefaultFilter = DefaultFilterJson,

View file

@ -181,8 +181,8 @@ public class ListFormSeedDataApplier(
if (hasKey) if (hasKey)
{ {
// Insert varsayilanlari anahtari @NEWID ile uretir; dosyadaki anahtar korunmazsa ayni // Anahtar alan ekranin alan listesinde olmasa bile dosyadaki deger yazilir; aksi halde
// dosya her uygulandiginda yeni kayit olusurdu. // @NEWID devreye girer ve ayni dosya her uygulandiginda yeni kayit olusur.
insertParameters[keyFieldName] = keyValue; insertParameters[keyFieldName] = keyValue;
} }
else else
@ -214,8 +214,9 @@ public class ListFormSeedDataApplier(
} }
/// <summary> /// <summary>
/// Ekran tanimindaki varsayilan alanlari (audit, anahtar, tenant) parametrelere ekler — /// Ekran tanimindaki varsayilan alanlari (audit, anahtar, tenant) parametrelere ekler.
/// <c>ListFormManager.GetParametersAsync</c> ile ayni sozlesme. /// Ekran uzerinden kayitta varsayilan girilen degeri ezer; seed'de tersi gecerlidir: dosyadaki
/// deger kaynaktir, yalnizca dosyada olmayan alanlar varsayilandan doldurulur.
/// </summary> /// </summary>
private async Task MergeDefaultsAsync( private async Task MergeDefaultsAsync(
ListForm listForm, ListForm listForm,
@ -232,7 +233,10 @@ public class ListFormSeedDataApplier(
var defaults = await defaultValueManager.GenerateDefaultValuesAsync(listForm, fields, op, keys); var defaults = await defaultValueManager.GenerateDefaultValuesAsync(listForm, fields, op, keys);
foreach (var item in defaults) foreach (var item in defaults)
{ {
parameters[item.Key] = item.Value.CustomValue; if (!parameters.ContainsKey(item.Key))
{
parameters[item.Key] = item.Value.CustomValue;
}
} }
} }

View file

@ -362,148 +362,6 @@
] ]
} }
], ],
"Products": [
{
"name": "App.PublicProducts.BranchHosting",
"description": "App.ProductsBranchHosting.BranchHostingDesc",
"category": "App.ProductsCategories.Uyelik",
"order": 1,
"monthlyPrice": 850,
"yearlyPrice": 3400,
"isQuantityBased": true,
"imageUrl": "https://images.pexels.com/photos/1181673/pexels-photo-1181673.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.BackupService",
"description": "App.ProductsBackupService.BackupServiceDesc",
"category": "App.ProductsCategories.Uyelik",
"order": 2,
"monthlyPrice": 2100,
"yearlyPrice": 2100,
"isQuantityBased": false,
"imageUrl": "https://images.pexels.com/photos/442150/pexels-photo-442150.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.RemoteSupportContract",
"description": "App.ProductsRemoteSupportContract.RemoteSupportContractDesc",
"category": "App.ProductsCategories.Uyelik",
"order": 3,
"monthlyPrice": 5000,
"yearlyPrice": 5000,
"isQuantityBased": false,
"imageUrl": "https://images.pexels.com/photos/3184465/pexels-photo-3184465.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.UserLicense",
"description": "App.ProductsUserLicense.UserLicenseDesc",
"category": "App.ProductsCategories.Lisans",
"order": 4,
"monthlyPrice": 900,
"yearlyPrice": 3500,
"isQuantityBased": true,
"imageUrl": "https://images.pexels.com/photos/3184360/pexels-photo-3184360.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.TeacherLicense",
"description": "App.ProductsTeacherLicense.TeacherLicenseDesc",
"category": "App.ProductsCategories.Lisans",
"order": 5,
"monthlyPrice": 500,
"yearlyPrice": 1700,
"isQuantityBased": true,
"imageUrl": "https://images.pexels.com/photos/5212345/pexels-photo-5212345.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.MobileReporting",
"description": "App.ProductsMobileReporting.MobileReportingDesc",
"category": "App.ProductsCategories.Lisans",
"order": 6,
"monthlyPrice": 400,
"yearlyPrice": 1400,
"isQuantityBased": false,
"imageUrl": "https://images.pexels.com/photos/1092644/pexels-photo-1092644.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.RemoteBranchTraining",
"description": "App.ProductsRemoteBranchTraining.RemoteBranchTrainingDesc",
"category": "App.ProductsCategories.EkHizmetler",
"order": 7,
"monthlyPrice": 3700,
"yearlyPrice": 3700,
"isQuantityBased": true,
"imageUrl": "https://images.pexels.com/photos/3184339/pexels-photo-3184339.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.ExtraHourlyService",
"description": "App.ProductsExtraHourlyService.ExtraHourlyServiceDesc",
"order": 8,
"category": "App.ProductsCategories.EkHizmetler",
"monthlyPrice": 2000,
"yearlyPrice": 2000,
"isQuantityBased": true,
"imageUrl": "https://images.pexels.com/photos/3184291/pexels-photo-3184291.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.Sms5k",
"description": "App.ProductsSms.SmsDesc",
"category": "App.ProductsCategories.EkHizmetler",
"order": 9,
"monthlyPrice": 750,
"yearlyPrice": 750,
"isQuantityBased": true,
"imageUrl": "https://images.pexels.com/photos/404280/pexels-photo-404280.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.Sms10k",
"description": "App.ProductsSms.SmsDesc",
"category": "App.ProductsCategories.EkHizmetler",
"order": 10,
"monthlyPrice": 1350,
"yearlyPrice": 1350,
"isQuantityBased": true,
"imageUrl": "https://images.pexels.com/photos/404280/pexels-photo-404280.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.Sms25k",
"description": "App.ProductsSms.SmsDesc",
"category": "App.ProductsCategories.EkHizmetler",
"order": 11,
"monthlyPrice": 2900,
"yearlyPrice": 2900,
"isQuantityBased": true,
"imageUrl": "https://images.pexels.com/photos/404280/pexels-photo-404280.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.Sms50k",
"description": "App.ProductsSms.SmsDesc",
"category": "App.ProductsCategories.EkHizmetler",
"order": 12,
"monthlyPrice": 5100,
"yearlyPrice": 5100,
"isQuantityBased": true,
"imageUrl": "https://images.pexels.com/photos/404280/pexels-photo-404280.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.Sms100k",
"description": "App.ProductsSms.SmsDesc",
"category": "App.ProductsCategories.EkHizmetler",
"order": 13,
"monthlyPrice": 8800,
"yearlyPrice": 8800,
"isQuantityBased": true,
"imageUrl": "https://images.pexels.com/photos/404280/pexels-photo-404280.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"name": "App.PublicProducts.SmsBlocking",
"description": "App.ProductsSmsBlocking.SmsBlockingDesc",
"category": "App.ProductsCategories.EkHizmetler",
"order": 14,
"monthlyPrice": 880,
"yearlyPrice": 880,
"isQuantityBased": true,
"imageUrl": "https://images.pexels.com/photos/1591061/pexels-photo-1591061.jpeg?auto=compress&cs=tinysrgb&w=300"
}
],
"PaymentMethods": [ "PaymentMethods": [
{ {
"name": "Kredi Kartı", "name": "Kredi Kartı",

View file

@ -39,7 +39,6 @@ public class TenantSeederDto
public List<ServiceSeedDto> Services { get; set; } public List<ServiceSeedDto> Services { get; set; }
public List<PaymentMethodSeedDto> PaymentMethods { get; set; } public List<PaymentMethodSeedDto> PaymentMethods { get; set; }
public List<InstallmentOptionSeedDto> InstallmentOptions { get; set; } public List<InstallmentOptionSeedDto> InstallmentOptions { get; set; }
public List<ProductSeedDto> Products { get; set; }
public List<ContactSeedDto> Contacts { get; set; } public List<ContactSeedDto> Contacts { get; set; }
//Report Templates //Report Templates
@ -391,18 +390,6 @@ public class ContactSeedDto
public MapDto Map { get; set; } public MapDto Map { get; set; }
} }
public class ProductSeedDto
{
public string Name { get; set; }
public string Description { get; set; }
public string Category { get; set; }
public int Order { get; set; }
public decimal? MonthlyPrice { get; set; }
public decimal? YearlyPrice { get; set; }
public bool IsQuantityBased { get; set; }
public string ImageUrl { get; set; }
}
public class TenantDataSeeder : IDataSeedContributor, ITransientDependency public class TenantDataSeeder : IDataSeedContributor, ITransientDependency
{ {
private readonly ILookupNormalizer _lookupNormalizer; private readonly ILookupNormalizer _lookupNormalizer;
@ -423,7 +410,6 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency
private readonly IRepository<ForumCategory, Guid> _forumCategoryRepository; private readonly IRepository<ForumCategory, Guid> _forumCategoryRepository;
private readonly IRepository<WorkHour, Guid> _workHourRepository; private readonly IRepository<WorkHour, Guid> _workHourRepository;
private readonly IIdentityUserRepository _repositoryUser; private readonly IIdentityUserRepository _repositoryUser;
private readonly IRepository<Product, Guid> _productRepository;
private readonly IRepository<Department, Guid> _departmentRepository; private readonly IRepository<Department, Guid> _departmentRepository;
private readonly IRepository<JobPosition, Guid> _jobPositionRepository; private readonly IRepository<JobPosition, Guid> _jobPositionRepository;
private readonly IRepository<Announcement, Guid> _announcementRepository; private readonly IRepository<Announcement, Guid> _announcementRepository;
@ -456,7 +442,6 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency
IRepository<Home, Guid> homeRepository, IRepository<Home, Guid> homeRepository,
IRepository<About, Guid> aboutRepository, IRepository<About, Guid> aboutRepository,
IRepository<Service, Guid> servicesRepository, IRepository<Service, Guid> servicesRepository,
IRepository<Product, Guid> productRepository,
IRepository<PaymentMethod, Guid> paymentMethodRepository, IRepository<PaymentMethod, Guid> paymentMethodRepository,
IRepository<InstallmentOption, Guid> installmentOptionRepository, IRepository<InstallmentOption, Guid> installmentOptionRepository,
IRepository<Contact, Guid> contactRepository, IRepository<Contact, Guid> contactRepository,
@ -488,7 +473,6 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency
_skillTypeRepository = skillTypeRepository; _skillTypeRepository = skillTypeRepository;
_skillRepository = skillRepository; _skillRepository = skillRepository;
_skillLevelRepository = skillLevelRepository; _skillLevelRepository = skillLevelRepository;
_productRepository = productRepository;
_paymentMethodRepository = paymentMethodRepository; _paymentMethodRepository = paymentMethodRepository;
_installmentOptionRepository = installmentOptionRepository; _installmentOptionRepository = installmentOptionRepository;
_reportCategoriesRepository = reportCategoriesRepository; _reportCategoriesRepository = reportCategoriesRepository;
@ -645,26 +629,6 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency
} }
} }
foreach (var item in items.Products)
{
var exists = await _productRepository.AnyAsync(x => x.Name == item.Name);
if (!exists)
{
await _productRepository.InsertAsync(new Product
{
Name = item.Name,
Description = item.Description,
Category = item.Category,
Order = item.Order,
MonthlyPrice = item.MonthlyPrice,
YearlyPrice = item.YearlyPrice,
IsQuantityBased = item.IsQuantityBased,
ImageUrl = item.ImageUrl
});
}
}
foreach (var item in items.InstallmentOptions) foreach (var item in items.InstallmentOptions)
{ {
var exists = await _installmentOptionRepository.AnyAsync(x => x.Installment == item.Installment); var exists = await _installmentOptionRepository.AnyAsync(x => x.Installment == item.Installment);

View file

@ -0,0 +1,161 @@
{
"ListFormCode": "App.Orders.Products",
"KeyFieldName": "Id",
"GeneratedAt": "2026-09-04T00:00:00Z",
"Rows": [
{
"Id": "287ad415-dd06-52f3-9a76-10795658a4f6",
"Name": "App.PublicProducts.BranchHosting",
"Description": "App.ProductsBranchHosting.BranchHostingDesc",
"Category": "App.ProductsCategories.Uyelik",
"Order": 1,
"MonthlyPrice": 850,
"YearlyPrice": 3400,
"IsQuantityBased": true,
"ImageUrl": "https://images.pexels.com/photos/1181673/pexels-photo-1181673.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "3ced7419-b72a-5bd5-b587-b76cc9778460",
"Name": "App.PublicProducts.BackupService",
"Description": "App.ProductsBackupService.BackupServiceDesc",
"Category": "App.ProductsCategories.Uyelik",
"Order": 2,
"MonthlyPrice": 2100,
"YearlyPrice": 2100,
"IsQuantityBased": false,
"ImageUrl": "https://images.pexels.com/photos/442150/pexels-photo-442150.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "22d113c5-94ad-5002-8e1f-79a622ca1ac6",
"Name": "App.PublicProducts.RemoteSupportContract",
"Description": "App.ProductsRemoteSupportContract.RemoteSupportContractDesc",
"Category": "App.ProductsCategories.Uyelik",
"Order": 3,
"MonthlyPrice": 5000,
"YearlyPrice": 5000,
"IsQuantityBased": false,
"ImageUrl": "https://images.pexels.com/photos/3184465/pexels-photo-3184465.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "39999ed6-7115-5816-bd32-5a786d68e356",
"Name": "App.PublicProducts.UserLicense",
"Description": "App.ProductsUserLicense.UserLicenseDesc",
"Category": "App.ProductsCategories.Lisans",
"Order": 4,
"MonthlyPrice": 900,
"YearlyPrice": 3500,
"IsQuantityBased": true,
"ImageUrl": "https://images.pexels.com/photos/3184360/pexels-photo-3184360.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "c2cf95b8-f63b-5ad4-9e5e-edbb8901da82",
"Name": "App.PublicProducts.TeacherLicense",
"Description": "App.ProductsTeacherLicense.TeacherLicenseDesc",
"Category": "App.ProductsCategories.Lisans",
"Order": 5,
"MonthlyPrice": 500,
"YearlyPrice": 1700,
"IsQuantityBased": true,
"ImageUrl": "https://images.pexels.com/photos/5212345/pexels-photo-5212345.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "8c231f32-2709-54f7-8607-35e63e9b4a4e",
"Name": "App.PublicProducts.MobileReporting",
"Description": "App.ProductsMobileReporting.MobileReportingDesc",
"Category": "App.ProductsCategories.Lisans",
"Order": 6,
"MonthlyPrice": 400,
"YearlyPrice": 1400,
"IsQuantityBased": false,
"ImageUrl": "https://images.pexels.com/photos/1092644/pexels-photo-1092644.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "0c927e71-0c51-5a2d-899c-c22302b563a0",
"Name": "App.PublicProducts.RemoteBranchTraining",
"Description": "App.ProductsRemoteBranchTraining.RemoteBranchTrainingDesc",
"Category": "App.ProductsCategories.EkHizmetler",
"Order": 7,
"MonthlyPrice": 3700,
"YearlyPrice": 3700,
"IsQuantityBased": true,
"ImageUrl": "https://images.pexels.com/photos/3184339/pexels-photo-3184339.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "37d1aefa-cbfe-5251-9525-ca17becb596f",
"Name": "App.PublicProducts.ExtraHourlyService",
"Description": "App.ProductsExtraHourlyService.ExtraHourlyServiceDesc",
"Category": "App.ProductsCategories.EkHizmetler",
"Order": 8,
"MonthlyPrice": 2000,
"YearlyPrice": 2000,
"IsQuantityBased": true,
"ImageUrl": "https://images.pexels.com/photos/3184291/pexels-photo-3184291.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "591e9307-c825-521e-bf06-d6f647708ca4",
"Name": "App.PublicProducts.Sms5k",
"Description": "App.ProductsSms.SmsDesc",
"Category": "App.ProductsCategories.EkHizmetler",
"Order": 9,
"MonthlyPrice": 750,
"YearlyPrice": 750,
"IsQuantityBased": true,
"ImageUrl": "https://images.pexels.com/photos/404280/pexels-photo-404280.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "8ff856d2-30d5-5f5e-b38e-f6cebee76421",
"Name": "App.PublicProducts.Sms10k",
"Description": "App.ProductsSms.SmsDesc",
"Category": "App.ProductsCategories.EkHizmetler",
"Order": 10,
"MonthlyPrice": 1350,
"YearlyPrice": 1350,
"IsQuantityBased": true,
"ImageUrl": "https://images.pexels.com/photos/404280/pexels-photo-404280.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "bfa0964b-e8cb-5739-8b4a-d44773553f0a",
"Name": "App.PublicProducts.Sms25k",
"Description": "App.ProductsSms.SmsDesc",
"Category": "App.ProductsCategories.EkHizmetler",
"Order": 11,
"MonthlyPrice": 2900,
"YearlyPrice": 2900,
"IsQuantityBased": true,
"ImageUrl": "https://images.pexels.com/photos/404280/pexels-photo-404280.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "2b675f5f-320f-5424-8393-3dc0363ad27e",
"Name": "App.PublicProducts.Sms50k",
"Description": "App.ProductsSms.SmsDesc",
"Category": "App.ProductsCategories.EkHizmetler",
"Order": 12,
"MonthlyPrice": 5100,
"YearlyPrice": 5100,
"IsQuantityBased": true,
"ImageUrl": "https://images.pexels.com/photos/404280/pexels-photo-404280.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "730c2dbf-c700-506d-b216-a169cbd85a15",
"Name": "App.PublicProducts.Sms100k",
"Description": "App.ProductsSms.SmsDesc",
"Category": "App.ProductsCategories.EkHizmetler",
"Order": 13,
"MonthlyPrice": 8800,
"YearlyPrice": 8800,
"IsQuantityBased": true,
"ImageUrl": "https://images.pexels.com/photos/404280/pexels-photo-404280.jpeg?auto=compress&cs=tinysrgb&w=300"
},
{
"Id": "53ae0678-3c01-5887-89e9-12a45bcc188f",
"Name": "App.PublicProducts.SmsBlocking",
"Description": "App.ProductsSmsBlocking.SmsBlockingDesc",
"Category": "App.ProductsCategories.EkHizmetler",
"Order": 14,
"MonthlyPrice": 880,
"YearlyPrice": 880,
"IsQuantityBased": true,
"ImageUrl": "https://images.pexels.com/photos/1591061/pexels-photo-1591061.jpeg?auto=compress&cs=tinysrgb&w=300"
}
]
}