Branch Seeder Dialog
This commit is contained in:
parent
035366ab70
commit
94b0d17c26
14 changed files with 626 additions and 327 deletions
338
api/src/Kurs.Platform.Application/Branch/BranchAppService.cs
Normal file
338
api/src/Kurs.Platform.Application/Branch/BranchAppService.cs
Normal file
|
|
@ -0,0 +1,338 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Kurs.Platform.Entities;
|
||||||
|
using Kurs.Platform.Seeds;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Volo.Abp.Data;
|
||||||
|
using Volo.Abp.Domain.Repositories;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Kurs.Languages.Entities;
|
||||||
|
using Kurs.Settings.Entities;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
|
||||||
|
namespace Kurs.Platform.Branchs;
|
||||||
|
|
||||||
|
public class BranchSeedResultDto
|
||||||
|
{
|
||||||
|
public bool Success { get; set; }
|
||||||
|
public string Message { get; set; }
|
||||||
|
public int TotalInsertedCount => Details.Sum(x => x.InsertedCount);
|
||||||
|
public List<SeedDetailDto> Details { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SeedDetailDto
|
||||||
|
{
|
||||||
|
public string EntityName { get; set; } = string.Empty; // Örn: "RegistrationType"
|
||||||
|
public int InsertedCount { get; set; }
|
||||||
|
public List<string> InsertedItems { get; set; } = new(); // Eklenen kayıtların isimleri
|
||||||
|
public List<string> Warnings { get; set; } = new(); // Varsa uyarılar
|
||||||
|
public List<string> Errors { get; set; } = new(); // Varsa hatalar
|
||||||
|
}
|
||||||
|
|
||||||
|
[Authorize]
|
||||||
|
public class BranchAppService : PlatformAppService
|
||||||
|
{
|
||||||
|
private readonly IRepository<Branch, Guid> _branchRepository;
|
||||||
|
private readonly IRepository<Language, Guid> _languages;
|
||||||
|
private readonly IRepository<LanguageKey, Guid> _languageKey;
|
||||||
|
private readonly IRepository<LanguageText, Guid> _languagesText;
|
||||||
|
private readonly IRepository<DataSource, Guid> _dataSources;
|
||||||
|
private readonly IRepository<SettingDefinition, Guid> _settings;
|
||||||
|
private readonly IRepository<RegistrationType, Guid> _registrationTypeRepository;
|
||||||
|
private readonly IRepository<RegistrationMethod, Guid> _registrationMethodRepository;
|
||||||
|
private readonly IRepository<ClassType, Guid> _classTypeRepository;
|
||||||
|
private readonly IRepository<Class, Guid> _classRepository;
|
||||||
|
private readonly IRepository<Level, Guid> _levelRepository;
|
||||||
|
private readonly IRepository<LessonPeriod, Guid> _lessonPeriodRepository;
|
||||||
|
private readonly IRepository<Schedule, Guid> _scheduleRepository;
|
||||||
|
|
||||||
|
public BranchAppService(
|
||||||
|
IRepository<Branch, Guid> branchRepository,
|
||||||
|
IRepository<Language, Guid> languages,
|
||||||
|
IRepository<LanguageKey, Guid> languageKey,
|
||||||
|
IRepository<LanguageText, Guid> languagesText,
|
||||||
|
IRepository<DataSource, Guid> dataSource,
|
||||||
|
IRepository<SettingDefinition, Guid> settings,
|
||||||
|
IRepository<Schedule, Guid> scheduleRepository,
|
||||||
|
IRepository<LessonPeriod, Guid> lessonPeriodRepository,
|
||||||
|
IRepository<RegistrationType, Guid> registrationTypeRepository,
|
||||||
|
IRepository<RegistrationMethod, Guid> registrationMethodRepository,
|
||||||
|
IRepository<ClassType, Guid> classTypeRepository,
|
||||||
|
IRepository<Class, Guid> classRepository,
|
||||||
|
IRepository<Level, Guid> levelRepository
|
||||||
|
)
|
||||||
|
{
|
||||||
|
_branchRepository = branchRepository;
|
||||||
|
_languages = languages;
|
||||||
|
_languageKey = languageKey;
|
||||||
|
_languagesText = languagesText;
|
||||||
|
_dataSources = dataSource;
|
||||||
|
_settings = settings;
|
||||||
|
_registrationTypeRepository = registrationTypeRepository;
|
||||||
|
_registrationMethodRepository = registrationMethodRepository;
|
||||||
|
_classTypeRepository = classTypeRepository;
|
||||||
|
_classRepository = classRepository;
|
||||||
|
_levelRepository = levelRepository;
|
||||||
|
_lessonPeriodRepository = lessonPeriodRepository;
|
||||||
|
_scheduleRepository = scheduleRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<BranchSeedResultDto> SeedAsync(Guid branchId)
|
||||||
|
{
|
||||||
|
var settings = await _settings.GetListAsync();
|
||||||
|
var dataSources = await _dataSources.GetListAsync();
|
||||||
|
var languages = await _languages.GetListAsync();
|
||||||
|
var keys = await _languageKey.GetListAsync();
|
||||||
|
var texts = await _languagesText.GetListAsync();
|
||||||
|
|
||||||
|
var result = new BranchSeedResultDto();
|
||||||
|
var context = new DataSeedContext(branchId);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var branch = await _branchRepository.FirstOrDefaultAsync(x => x.Id == branchId);
|
||||||
|
if (branch == null)
|
||||||
|
{
|
||||||
|
result.Success = false;
|
||||||
|
result.Message = "Branch not found.";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tenantId = branch.TenantId;
|
||||||
|
var assemblyPath = Path.GetDirectoryName(typeof(BranchAppService).Assembly.Location)!;
|
||||||
|
var basePath = Path.Combine(assemblyPath, "Branch", "Seeds");
|
||||||
|
|
||||||
|
var configuration = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(basePath)
|
||||||
|
.AddJsonFile("BranchData.json")
|
||||||
|
.AddJsonFile($"BranchData.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? ""}.json", optional: true)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
||||||
|
var items = configuration.Get<BranchSeederDto>();
|
||||||
|
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
result.Success = false;
|
||||||
|
result.Message = "BranchData.json okunamadı veya format hatalı.";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Yardımcı fonksiyon: kolay log ekleme
|
||||||
|
SeedDetailDto CreateLog(string entity) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
EntityName = entity,
|
||||||
|
InsertedCount = 0,
|
||||||
|
InsertedItems = []
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var registrationTypeLog = CreateLog(nameof(RegistrationType));
|
||||||
|
foreach (var item in items.RegistrationTypes)
|
||||||
|
{
|
||||||
|
var exists = await _registrationTypeRepository.AnyAsync(x => x.Name == item.Name && x.BranchId == branchId);
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
await _registrationTypeRepository.InsertAsync(new RegistrationType
|
||||||
|
{
|
||||||
|
TenantId = tenantId,
|
||||||
|
BranchId = branchId,
|
||||||
|
Name = item.Name,
|
||||||
|
Status = item.Status
|
||||||
|
}, autoSave: true);
|
||||||
|
|
||||||
|
registrationTypeLog.InsertedCount++;
|
||||||
|
registrationTypeLog.InsertedItems.Add(item.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Details.Add(registrationTypeLog);
|
||||||
|
|
||||||
|
var registrationMethodLog = CreateLog(nameof(RegistrationMethod));
|
||||||
|
foreach (var item in items.RegistrationMethods)
|
||||||
|
{
|
||||||
|
var exists = await _registrationMethodRepository.AnyAsync(x => x.Name == item.Name && x.BranchId == branchId);
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
var registrationType = await _registrationTypeRepository.FirstOrDefaultAsync(x => x.Name == item.RegistrationTypeName);
|
||||||
|
if (registrationType != null)
|
||||||
|
{
|
||||||
|
await _registrationMethodRepository.InsertAsync(new RegistrationMethod
|
||||||
|
{
|
||||||
|
TenantId = tenantId,
|
||||||
|
BranchId = branchId,
|
||||||
|
RegistrationTypeId = registrationType.Id,
|
||||||
|
Name = item.Name,
|
||||||
|
Status = item.Status
|
||||||
|
});
|
||||||
|
|
||||||
|
registrationMethodLog.InsertedCount++;
|
||||||
|
registrationMethodLog.InsertedItems.Add(item.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Details.Add(registrationMethodLog);
|
||||||
|
|
||||||
|
var classTypeLog = CreateLog(nameof(ClassType));
|
||||||
|
foreach (var item in items.ClassTypes)
|
||||||
|
{
|
||||||
|
var exists = await _classTypeRepository.AnyAsync(x => x.Name == item.Name);
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
var registrationType = await _registrationTypeRepository.FirstOrDefaultAsync(x => x.Name == item.RegistrationTypeName && x.BranchId == branchId);
|
||||||
|
if (registrationType != null)
|
||||||
|
{
|
||||||
|
await _classTypeRepository.InsertAsync(new ClassType
|
||||||
|
{
|
||||||
|
TenantId = tenantId,
|
||||||
|
BranchId = branchId,
|
||||||
|
RegistrationTypeId = registrationType.Id,
|
||||||
|
Name = item.Name,
|
||||||
|
MinStudentCount = item.MinStudentCount,
|
||||||
|
MaxStudentCount = item.MaxStudentCount,
|
||||||
|
Status = item.Status
|
||||||
|
}, autoSave: true);
|
||||||
|
|
||||||
|
classTypeLog.InsertedCount++;
|
||||||
|
classTypeLog.InsertedItems.Add(item.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Details.Add(classTypeLog);
|
||||||
|
|
||||||
|
var classLog = CreateLog(nameof(Class));
|
||||||
|
foreach (var item in items.Classes)
|
||||||
|
{
|
||||||
|
var exists = await _classRepository.AnyAsync(x => x.Name == item.Name && x.BranchId == branchId);
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
var classType = await _classTypeRepository.FirstOrDefaultAsync(x => x.Name == item.ClassTypeName);
|
||||||
|
if (classType != null)
|
||||||
|
{
|
||||||
|
await _classRepository.InsertAsync(new()
|
||||||
|
{
|
||||||
|
TenantId = tenantId,
|
||||||
|
BranchId = branchId,
|
||||||
|
ClassTypeId = classType.Id,
|
||||||
|
Name = item.Name,
|
||||||
|
Status = item.Status,
|
||||||
|
});
|
||||||
|
|
||||||
|
classLog.InsertedCount++;
|
||||||
|
classLog.InsertedItems.Add(item.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Details.Add(classLog);
|
||||||
|
|
||||||
|
var levelLog = CreateLog(nameof(Level));
|
||||||
|
foreach (var item in items.Levels)
|
||||||
|
{
|
||||||
|
var exists = await _levelRepository.AnyAsync(x => x.Name == item.Name && x.BranchId == branchId);
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
var classType = await _classTypeRepository.FirstOrDefaultAsync(x => x.Name == item.ClassTypeName);
|
||||||
|
if (classType != null)
|
||||||
|
{
|
||||||
|
await _levelRepository.InsertAsync(new Level
|
||||||
|
{
|
||||||
|
TenantId = tenantId,
|
||||||
|
BranchId = branchId,
|
||||||
|
ClassTypeId = classType.Id,
|
||||||
|
Name = item.Name,
|
||||||
|
LevelType = item.LevelType,
|
||||||
|
LessonCount = item.LessonCount,
|
||||||
|
Status = item.Status,
|
||||||
|
LessonDuration = item.LessonDuration,
|
||||||
|
MonthlyPaymentRate = item.MonthlyPaymentRate
|
||||||
|
});
|
||||||
|
|
||||||
|
levelLog.InsertedCount++;
|
||||||
|
levelLog.InsertedItems.Add(item.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Details.Add(levelLog);
|
||||||
|
|
||||||
|
var lessonPeriodLog = CreateLog(nameof(LessonPeriod));
|
||||||
|
foreach (var item in items.LessonPeriods)
|
||||||
|
{
|
||||||
|
var exists = await _lessonPeriodRepository.AnyAsync(x => x.Name == item.Name && x.BranchId == branchId);
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
await _lessonPeriodRepository.InsertAsync(new()
|
||||||
|
{
|
||||||
|
TenantId = tenantId,
|
||||||
|
BranchId = branchId,
|
||||||
|
Name = item.Name,
|
||||||
|
Day = item.Day,
|
||||||
|
Lesson1 = item.Lesson1,
|
||||||
|
Lesson2 = item.Lesson2,
|
||||||
|
Lesson3 = item.Lesson3,
|
||||||
|
Lesson4 = item.Lesson4,
|
||||||
|
});
|
||||||
|
|
||||||
|
lessonPeriodLog.InsertedCount++;
|
||||||
|
lessonPeriodLog.InsertedItems.Add(item.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Details.Add(lessonPeriodLog);
|
||||||
|
|
||||||
|
var scheduleLog = CreateLog(nameof(Schedule));
|
||||||
|
foreach (var item in items.Schedules)
|
||||||
|
{
|
||||||
|
var exists = await _scheduleRepository.AnyAsync(x => x.Name == item.Name && x.BranchId == branchId);
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
await _scheduleRepository.InsertAsync(new()
|
||||||
|
{
|
||||||
|
TenantId = tenantId,
|
||||||
|
BranchId = branchId,
|
||||||
|
Name = item.Name,
|
||||||
|
Status = item.Status,
|
||||||
|
StartTime = item.StartTime,
|
||||||
|
EndTime = item.EndTime,
|
||||||
|
LessonMinute = item.LessonMinute,
|
||||||
|
LessonBreakMinute = item.LessonBreakMinute,
|
||||||
|
LessonCount = item.LessonCount,
|
||||||
|
LunchTime = item.LunchTime,
|
||||||
|
LunchMinute = item.LunchMinute,
|
||||||
|
IncludeLunch = item.IncludeLunch,
|
||||||
|
Monday = item.Monday,
|
||||||
|
Tuesday = item.Tuesday,
|
||||||
|
Wednesday = item.Wednesday,
|
||||||
|
Thursday = item.Thursday,
|
||||||
|
Friday = item.Friday,
|
||||||
|
Saturday = item.Saturday,
|
||||||
|
Sunday = item.Sunday,
|
||||||
|
});
|
||||||
|
|
||||||
|
scheduleLog.InsertedCount++;
|
||||||
|
scheduleLog.InsertedItems.Add(item.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Details.Add(scheduleLog);
|
||||||
|
|
||||||
|
result.Success = true;
|
||||||
|
result.Message = $"Seed işlemi başarıyla tamamlandı. Toplam {result.TotalInsertedCount} kayıt eklendi.";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Success = false;
|
||||||
|
result.Message = $"Hata: {ex.Message}";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -79,8 +79,8 @@
|
||||||
"Levels": [
|
"Levels": [
|
||||||
{
|
{
|
||||||
"ClassTypeName": "3-6 Kişilik",
|
"ClassTypeName": "3-6 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "A1",
|
||||||
"LevelType": "A1",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": 2,
|
"LessonDuration": 2,
|
||||||
|
|
@ -88,8 +88,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "3-6 Kişilik",
|
"ClassTypeName": "3-6 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "A2",
|
||||||
"LevelType": "A2",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 90,
|
"LessonCount": 90,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": 3,
|
"LessonDuration": 3,
|
||||||
|
|
@ -97,8 +97,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "3-6 Kişilik",
|
"ClassTypeName": "3-6 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "B1",
|
||||||
"LevelType": "B1",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 90,
|
"LessonCount": 90,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -106,8 +106,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "3-6 Kişilik",
|
"ClassTypeName": "3-6 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "B2",
|
||||||
"LevelType": "B2",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -115,8 +115,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "3-6 Kişilik",
|
"ClassTypeName": "3-6 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "C1",
|
||||||
"LevelType": "C1",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -124,8 +124,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "3-6 Kişilik",
|
"ClassTypeName": "3-6 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "C2",
|
||||||
"LevelType": "C2",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -133,8 +133,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "3-6 Kişilik",
|
"ClassTypeName": "3-6 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "BULATS",
|
||||||
"LevelType": "BULATS",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -142,8 +142,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "3-6 Kişilik",
|
"ClassTypeName": "3-6 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "GMAT",
|
||||||
"LevelType": "GMAT",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -151,8 +151,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "3-6 Kişilik",
|
"ClassTypeName": "3-6 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "YDS",
|
||||||
"LevelType": "YDS",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -160,8 +160,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "3-6 Kişilik",
|
"ClassTypeName": "3-6 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "ÜDS",
|
||||||
"LevelType": "ÜDS",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -169,8 +169,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "A1",
|
||||||
"LevelType": "A1",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": 3,
|
"LessonDuration": 3,
|
||||||
|
|
@ -178,8 +178,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "A2",
|
||||||
"LevelType": "A2",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -187,8 +187,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "B1",
|
||||||
"LevelType": "B1",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -196,8 +196,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "B2",
|
||||||
"LevelType": "B2",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -205,8 +205,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "C1",
|
||||||
"LevelType": "C1",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -214,8 +214,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Seviye",
|
"Name": "C2",
|
||||||
"LevelType": "C2",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -223,8 +223,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "IELTS",
|
||||||
"LevelType": "IELTS",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -232,8 +232,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "TOEFL",
|
||||||
"LevelType": "TOEFL",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -241,8 +241,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "BULATS",
|
||||||
"LevelType": "BULATS",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -250,8 +250,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "GMAT",
|
||||||
"LevelType": "GMAT",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -259,8 +259,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "YDS",
|
||||||
"LevelType": "YDS",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -268,8 +268,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "PROFICIENCY",
|
||||||
"LevelType": "PROFICIENCY",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -277,8 +277,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "SAT",
|
||||||
"LevelType": "SAT",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -286,8 +286,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "TOEIC",
|
||||||
"LevelType": "TOEIC",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -295,8 +295,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "ÜDS",
|
||||||
"LevelType": "ÜDS",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -304,8 +304,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "5-8 Kişilik",
|
"ClassTypeName": "5-8 Kişilik",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "SAT2",
|
||||||
"LevelType": "SAT2",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 50,
|
"LessonCount": 50,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -313,8 +313,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "ÖZEL",
|
"ClassTypeName": "ÖZEL",
|
||||||
"Name": "Seviye",
|
"Name": "A1",
|
||||||
"LevelType": "A1",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 60,
|
"LessonCount": 60,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -322,8 +322,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "ÖZEL",
|
"ClassTypeName": "ÖZEL",
|
||||||
"Name": "Seviye",
|
"Name": "A2",
|
||||||
"LevelType": "A2",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 70,
|
"LessonCount": 70,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -331,8 +331,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "ÖZEL",
|
"ClassTypeName": "ÖZEL",
|
||||||
"Name": "Seviye",
|
"Name": "B1",
|
||||||
"LevelType": "B1",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -340,8 +340,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "ÖZEL",
|
"ClassTypeName": "ÖZEL",
|
||||||
"Name": "Seviye",
|
"Name": "B2",
|
||||||
"LevelType": "B2",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -349,8 +349,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "ÖZEL",
|
"ClassTypeName": "ÖZEL",
|
||||||
"Name": "Seviye",
|
"Name": "C1",
|
||||||
"LevelType": "C1",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 90,
|
"LessonCount": 90,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -358,8 +358,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "ÖZEL",
|
"ClassTypeName": "ÖZEL",
|
||||||
"Name": "Seviye",
|
"Name": "C2",
|
||||||
"LevelType": "C2",
|
"LevelType": "Seviye",
|
||||||
"LessonCount": 90,
|
"LessonCount": 90,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -367,8 +367,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "ÖZEL",
|
"ClassTypeName": "ÖZEL",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "BULATS",
|
||||||
"LevelType": "BULATS",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -376,8 +376,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "ÖZEL",
|
"ClassTypeName": "ÖZEL",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "GMAT",
|
||||||
"LevelType": "GMAT",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -385,8 +385,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ClassTypeName": "ÖZEL",
|
"ClassTypeName": "ÖZEL",
|
||||||
"Name": "Sınav Eğitimi",
|
"Name": "ÜDS",
|
||||||
"LevelType": "ÜDS",
|
"LevelType": "Sınav Eğitimi",
|
||||||
"LessonCount": 80,
|
"LessonCount": 80,
|
||||||
"Status": "Aktif",
|
"Status": "Aktif",
|
||||||
"LessonDuration": null,
|
"LessonDuration": null,
|
||||||
|
|
@ -1,17 +1,24 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<Import Project="..\..\common.props" />
|
<Import Project="..\..\common.props" />
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<RootNamespace>Kurs.Platform</RootNamespace>
|
<RootNamespace>Kurs.Platform</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Branch\Seeds\BranchData*.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\modules\Kurs.Languages\Kurs.Languages.Application\Kurs.Languages.Application.csproj" />
|
<ProjectReference Include="..\..\modules\Kurs.Languages\Kurs.Languages.Application\Kurs.Languages.Application.csproj" />
|
||||||
<ProjectReference Include="..\..\modules\Kurs.Notifications\Kurs.Notifications.Application\Kurs.Notifications.Application.csproj" />
|
<ProjectReference Include="..\..\modules\Kurs.Notifications\Kurs.Notifications.Application\Kurs.Notifications.Application.csproj" />
|
||||||
|
|
@ -19,7 +26,7 @@
|
||||||
<ProjectReference Include="..\Kurs.Platform.Domain\Kurs.Platform.Domain.csproj" />
|
<ProjectReference Include="..\Kurs.Platform.Domain\Kurs.Platform.Domain.csproj" />
|
||||||
<ProjectReference Include="..\Kurs.Platform.Application.Contracts\Kurs.Platform.Application.Contracts.csproj" />
|
<ProjectReference Include="..\Kurs.Platform.Application.Contracts\Kurs.Platform.Application.Contracts.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Volo.Abp.Account.Application" Version="9.0.2" />
|
<PackageReference Include="Volo.Abp.Account.Application" Version="9.0.2" />
|
||||||
<PackageReference Include="Volo.Abp.Identity.Application" Version="9.0.2" />
|
<PackageReference Include="Volo.Abp.Identity.Application" Version="9.0.2" />
|
||||||
|
|
@ -27,5 +34,5 @@
|
||||||
<PackageReference Include="Volo.Abp.TenantManagement.Application" Version="9.0.2" />
|
<PackageReference Include="Volo.Abp.TenantManagement.Application" Version="9.0.2" />
|
||||||
<PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="9.0.2" />
|
<PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="9.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -42,19 +42,6 @@
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<None Remove="Seeds\BranchData.json" />
|
|
||||||
<Content Include="Seeds\BranchData.json">
|
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="Seeds\BranchData.Dev.json">
|
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="Seeds\BranchData.Production.json">
|
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<None Remove="Seeds\CountryGroups.json" />
|
<None Remove="Seeds\CountryGroups.json" />
|
||||||
<Content Include="Seeds\CountryGroups.json">
|
<Content Include="Seeds\CountryGroups.json">
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
|
|
||||||
|
|
@ -1,221 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Kurs.Platform.Entities;
|
|
||||||
using Kurs.Platform.Seeds;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Volo.Abp.Data;
|
|
||||||
using Volo.Abp.DependencyInjection;
|
|
||||||
using Volo.Abp.Domain.Repositories;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Kurs.Languages.Entities;
|
|
||||||
using Kurs.Settings.Entities;
|
|
||||||
|
|
||||||
namespace Kurs.Platform.Data.Seeds;
|
|
||||||
|
|
||||||
public class PlatformBranchDataSeeder : ITransientDependency
|
|
||||||
{
|
|
||||||
private readonly IRepository<Language, Guid> _languages;
|
|
||||||
private readonly IRepository<LanguageKey, Guid> _languageKey;
|
|
||||||
private readonly IRepository<LanguageText, Guid> _languagesText;
|
|
||||||
private readonly IRepository<DataSource, Guid> _dataSources;
|
|
||||||
private readonly IRepository<SettingDefinition, Guid> _settings;
|
|
||||||
private readonly IRepository<RegistrationType, Guid> _registrationTypeRepository;
|
|
||||||
private readonly IRepository<RegistrationMethod, Guid> _registrationMethodRepository;
|
|
||||||
private readonly IRepository<ClassType, Guid> _classTypeRepository;
|
|
||||||
private readonly IRepository<Class, Guid> _classRepository;
|
|
||||||
private readonly IRepository<Level, Guid> _levelRepository;
|
|
||||||
private readonly IRepository<LessonPeriod, Guid> _lessonPeriodRepository;
|
|
||||||
private readonly IRepository<Schedule, Guid> _scheduleRepository;
|
|
||||||
|
|
||||||
public PlatformBranchDataSeeder(
|
|
||||||
IRepository<Language, Guid> languages,
|
|
||||||
IRepository<LanguageKey, Guid> languageKey,
|
|
||||||
IRepository<LanguageText, Guid> languagesText,
|
|
||||||
IRepository<DataSource, Guid> dataSource,
|
|
||||||
IRepository<SettingDefinition, Guid> settings,
|
|
||||||
IRepository<Schedule, Guid> scheduleRepository,
|
|
||||||
IRepository<LessonPeriod, Guid> lessonPeriodRepository,
|
|
||||||
IRepository<RegistrationType, Guid> registrationTypeRepository,
|
|
||||||
IRepository<RegistrationMethod, Guid> registrationMethodRepository,
|
|
||||||
IRepository<ClassType, Guid> classTypeRepository,
|
|
||||||
IRepository<Class, Guid> classRepository,
|
|
||||||
IRepository<Level, Guid> levelRepository
|
|
||||||
)
|
|
||||||
{
|
|
||||||
_languages = languages;
|
|
||||||
_languageKey = languageKey;
|
|
||||||
_languagesText = languagesText;
|
|
||||||
_dataSources = dataSource;
|
|
||||||
_settings = settings;
|
|
||||||
_registrationTypeRepository = registrationTypeRepository;
|
|
||||||
_registrationMethodRepository = registrationMethodRepository;
|
|
||||||
_classTypeRepository = classTypeRepository;
|
|
||||||
_classRepository = classRepository;
|
|
||||||
_levelRepository = levelRepository;
|
|
||||||
_lessonPeriodRepository = lessonPeriodRepository;
|
|
||||||
_scheduleRepository = scheduleRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task SeedAsync(DataSeedContext context)
|
|
||||||
{
|
|
||||||
var settings = await _settings.GetListAsync();
|
|
||||||
var dataSources = await _dataSources.GetListAsync();
|
|
||||||
var languages = await _languages.GetListAsync();
|
|
||||||
var keys = await _languageKey.GetListAsync();
|
|
||||||
var texts = await _languagesText.GetListAsync();
|
|
||||||
|
|
||||||
var configuration = new ConfigurationBuilder()
|
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
|
||||||
.AddJsonFile(Path.Combine("Seeds", "BranchData.json"))
|
|
||||||
.AddJsonFile(Path.Combine("Seeds", $"BranchData.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? ""}.json"), true)
|
|
||||||
.Build();
|
|
||||||
var items = configuration.Get<BranchSeederDto>();
|
|
||||||
|
|
||||||
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
|
||||||
|
|
||||||
foreach (var item in items.RegistrationTypes)
|
|
||||||
{
|
|
||||||
var exists = await _registrationTypeRepository.AnyAsync(x => x.Name == item.Name);
|
|
||||||
|
|
||||||
if (!exists)
|
|
||||||
{
|
|
||||||
await _registrationTypeRepository.InsertAsync(new RegistrationType
|
|
||||||
{
|
|
||||||
Name = item.Name,
|
|
||||||
Status = item.Status
|
|
||||||
}, autoSave: true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in items.RegistrationMethods)
|
|
||||||
{
|
|
||||||
var exists = await _registrationMethodRepository.AnyAsync(x => x.Name == item.Name);
|
|
||||||
|
|
||||||
if (!exists)
|
|
||||||
{
|
|
||||||
var registrationType = await _registrationTypeRepository.FirstOrDefaultAsync(x => x.Name == item.RegistrationTypeName);
|
|
||||||
if (registrationType != null)
|
|
||||||
{
|
|
||||||
await _registrationMethodRepository.InsertAsync(new RegistrationMethod
|
|
||||||
{
|
|
||||||
RegistrationTypeId = registrationType.Id,
|
|
||||||
Name = item.Name,
|
|
||||||
Status = item.Status
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in items.ClassTypes)
|
|
||||||
{
|
|
||||||
var exists = await _classTypeRepository.AnyAsync(x => x.Name == item.Name);
|
|
||||||
|
|
||||||
if (!exists)
|
|
||||||
{
|
|
||||||
var registrationType = await _registrationTypeRepository.FirstOrDefaultAsync(x => x.Name == item.RegistrationTypeName);
|
|
||||||
if (registrationType != null)
|
|
||||||
{
|
|
||||||
await _classTypeRepository.InsertAsync(new ClassType
|
|
||||||
{
|
|
||||||
RegistrationTypeId = registrationType.Id,
|
|
||||||
Name = item.Name,
|
|
||||||
MinStudentCount = item.MinStudentCount,
|
|
||||||
MaxStudentCount = item.MaxStudentCount,
|
|
||||||
Status = item.Status
|
|
||||||
}, autoSave: true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in items.Classes)
|
|
||||||
{
|
|
||||||
var exists = await _classRepository.AnyAsync(x => x.Name == item.Name);
|
|
||||||
|
|
||||||
if (!exists)
|
|
||||||
{
|
|
||||||
var classType = await _classTypeRepository.FirstOrDefaultAsync(x => x.Name == item.ClassTypeName);
|
|
||||||
if (classType != null)
|
|
||||||
{
|
|
||||||
await _classRepository.InsertAsync(new()
|
|
||||||
{
|
|
||||||
ClassTypeId = classType.Id,
|
|
||||||
Name = item.Name,
|
|
||||||
Status = item.Status,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in items.Levels)
|
|
||||||
{
|
|
||||||
var exists = await _levelRepository.AnyAsync(x => x.Name == item.Name);
|
|
||||||
|
|
||||||
if (!exists)
|
|
||||||
{
|
|
||||||
var classType = await _classTypeRepository.FirstOrDefaultAsync(x => x.Name == item.ClassTypeName);
|
|
||||||
if (classType != null)
|
|
||||||
{
|
|
||||||
await _levelRepository.InsertAsync(new Level
|
|
||||||
{
|
|
||||||
ClassTypeId = classType.Id,
|
|
||||||
Name = item.Name,
|
|
||||||
LevelType = item.LevelType,
|
|
||||||
LessonCount = item.LessonCount,
|
|
||||||
Status = item.Status,
|
|
||||||
LessonDuration = item.LessonDuration,
|
|
||||||
MonthlyPaymentRate = item.MonthlyPaymentRate
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in items.LessonPeriods)
|
|
||||||
{
|
|
||||||
var exists = await _lessonPeriodRepository.AnyAsync(x => x.Name == item.Name);
|
|
||||||
|
|
||||||
if (!exists)
|
|
||||||
{
|
|
||||||
await _lessonPeriodRepository.InsertAsync(new()
|
|
||||||
{
|
|
||||||
Name = item.Name,
|
|
||||||
Day = item.Day,
|
|
||||||
Lesson1 = item.Lesson1,
|
|
||||||
Lesson2 = item.Lesson2,
|
|
||||||
Lesson3 = item.Lesson3,
|
|
||||||
Lesson4 = item.Lesson4,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in items.Schedules)
|
|
||||||
{
|
|
||||||
var exists = await _scheduleRepository.AnyAsync(x => x.Name == item.Name);
|
|
||||||
|
|
||||||
if (!exists)
|
|
||||||
{
|
|
||||||
await _scheduleRepository.InsertAsync(new()
|
|
||||||
{
|
|
||||||
Name = item.Name,
|
|
||||||
Status = item.Status,
|
|
||||||
StartTime = item.StartTime,
|
|
||||||
EndTime = item.EndTime,
|
|
||||||
LessonMinute = item.LessonMinute,
|
|
||||||
LessonBreakMinute = item.LessonBreakMinute,
|
|
||||||
LessonCount = item.LessonCount,
|
|
||||||
LunchTime = item.LunchTime,
|
|
||||||
LunchMinute = item.LunchMinute,
|
|
||||||
IncludeLunch = item.IncludeLunch,
|
|
||||||
Monday = item.Monday,
|
|
||||||
Tuesday = item.Tuesday,
|
|
||||||
Wednesday = item.Wednesday,
|
|
||||||
Thursday = item.Thursday,
|
|
||||||
Friday = item.Friday,
|
|
||||||
Saturday = item.Saturday,
|
|
||||||
Sunday = item.Sunday,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3068,8 +3068,18 @@ public class PlatformListFormsSeeder : IDataSeedContributor, ITransientDependenc
|
||||||
FieldDbType = DbType.Boolean,
|
FieldDbType = DbType.Boolean,
|
||||||
Value = "true",
|
Value = "true",
|
||||||
CustomValueType = FieldCustomValueTypeEnum.Value }
|
CustomValueType = FieldCustomValueTypeEnum.Value }
|
||||||
})
|
}),
|
||||||
|
CommandColumnJson = JsonSerializer.Serialize(new CommandColumnDto[] {
|
||||||
|
new() {
|
||||||
|
Hint = "Seed",
|
||||||
|
Text = "Seed",
|
||||||
|
AuthName = AppCodes.Branches + ".Update",
|
||||||
|
DialogName = "BranchSeed",
|
||||||
|
DialogParameters = JsonSerializer.Serialize(new {
|
||||||
|
name = "@Id",
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
14
ui/src/proxy/branch/seed.ts
Normal file
14
ui/src/proxy/branch/seed.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
export interface BranchSeedResultDto {
|
||||||
|
success: boolean
|
||||||
|
message: string
|
||||||
|
totalInsertedCount: number // backend'de => TotalInsertedCount
|
||||||
|
details: SeedDetailDto[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SeedDetailDto {
|
||||||
|
entityName: string // Örn: "RegistrationType", "Class"
|
||||||
|
insertedCount: number // Kaç kayıt eklendi
|
||||||
|
insertedItems: string[] // Eklenen kayıtların isimleri
|
||||||
|
warnings: string[] // Uyarı mesajları (örneğin eksik referans)
|
||||||
|
errors: string[] // Hatalar (örneğin ekleme başarısızlığı)
|
||||||
|
}
|
||||||
13
ui/src/services/branch.ts
Normal file
13
ui/src/services/branch.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import apiService from './api.service'
|
||||||
|
import { BranchSeedResultDto } from '@/proxy/branch/seed'
|
||||||
|
|
||||||
|
export async function runBranchSeed(branchId: string): Promise<BranchSeedResultDto> {
|
||||||
|
const response = await apiService.fetchData<BranchSeedResultDto>(
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
url: `/api/app/branch/seed/${branchId}`,
|
||||||
|
},
|
||||||
|
{ apiName: 'Default' },
|
||||||
|
)
|
||||||
|
return response.data
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import AdaptableCard from '@/components/shared/AdaptableCard'
|
|
||||||
import Container from '@/components/shared/Container'
|
import Container from '@/components/shared/Container'
|
||||||
import { Button, Checkbox, Dialog, Input, Menu, toast } from '@/components/ui'
|
import { Button, Checkbox, Dialog, Input, Menu, toast } from '@/components/ui'
|
||||||
import { useConfig } from '@/components/ui/ConfigProvider'
|
import { useConfig } from '@/components/ui/ConfigProvider'
|
||||||
|
|
|
||||||
143
ui/src/views/branch/BranchSeed.tsx
Normal file
143
ui/src/views/branch/BranchSeed.tsx
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { Button } from '@/components/ui'
|
||||||
|
import { Container } from '@/components/shared'
|
||||||
|
import { Dialog, Notification, toast } from '@/components/ui'
|
||||||
|
import type { BranchSeedResultDto } from '@/proxy/branch/seed'
|
||||||
|
import { runBranchSeed } from '@/services/branch'
|
||||||
|
|
||||||
|
function BranchSeed({
|
||||||
|
open,
|
||||||
|
onDialogClose,
|
||||||
|
name,
|
||||||
|
}: {
|
||||||
|
open: boolean
|
||||||
|
onDialogClose: () => void
|
||||||
|
name: string
|
||||||
|
}) {
|
||||||
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
|
const [result, setResult] = useState<BranchSeedResultDto | null>(null)
|
||||||
|
|
||||||
|
const handleRunSeed = async () => {
|
||||||
|
if (!name) return
|
||||||
|
setIsLoading(true)
|
||||||
|
try {
|
||||||
|
const data = await runBranchSeed(name)
|
||||||
|
setResult(data)
|
||||||
|
|
||||||
|
if (data.success) {
|
||||||
|
toast.push(<Notification title="Seed işlemi başarılı" type="success" />, {
|
||||||
|
placement: 'top-end',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
toast.push(<Notification title="Seed işlemi başarısız" type="danger" />, {
|
||||||
|
placement: 'top-end',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
setResult({
|
||||||
|
success: false,
|
||||||
|
message: 'Seed işlemi sırasında hata oluştu.',
|
||||||
|
totalInsertedCount: 0,
|
||||||
|
details: [],
|
||||||
|
})
|
||||||
|
toast.push(<Notification title="Seed işlemi sırasında hata oluştu" type="danger" />, {
|
||||||
|
placement: 'top-end',
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<Dialog
|
||||||
|
width="75%"
|
||||||
|
height="60%"
|
||||||
|
isOpen={open}
|
||||||
|
onClose={onDialogClose}
|
||||||
|
onRequestClose={onDialogClose}
|
||||||
|
>
|
||||||
|
<h5 className="mb-4 text-lg font-semibold">Branch Seed - {name}</h5>
|
||||||
|
<hr className="mb-3" />
|
||||||
|
|
||||||
|
{/* Başlat butonu */}
|
||||||
|
<div className="mb-4 flex justify-end">
|
||||||
|
<Button size='sm' variant="solid" onClick={handleRunSeed} loading={isLoading}>
|
||||||
|
{isLoading ? 'Seed Çalıştırılıyor...' : 'Seed İşlemini Başlat'}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Sonuç */}
|
||||||
|
{result && (
|
||||||
|
<div className="mt-3 space-y-4">
|
||||||
|
<div>
|
||||||
|
{result.success ? (
|
||||||
|
<span className="text-green-600 font-semibold">✅ Seed İşlemi Başarılı</span>
|
||||||
|
) : (
|
||||||
|
<span className="text-red-600 font-semibold">❌ Seed İşlemi Başarısız</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p className="font-medium text-gray-700">{result.message}</p>
|
||||||
|
|
||||||
|
<p className="text-sm text-gray-600">
|
||||||
|
Toplam eklenen kayıt:{' '}
|
||||||
|
<span className="font-bold text-blue-600">{result.totalInsertedCount}</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{/* Detay Tablosu */}
|
||||||
|
{result.details.length > 0 && (
|
||||||
|
<div className="overflow-x-auto border border-gray-200 rounded-md">
|
||||||
|
<table className="min-w-full text-sm">
|
||||||
|
<thead className="bg-gray-100 sticky top-0">
|
||||||
|
<tr>
|
||||||
|
<th className="border px-3 py-2 text-left">Entity</th>
|
||||||
|
<th className="border px-3 py-2 text-left">Eklenen</th>
|
||||||
|
<th className="border px-3 py-2 text-left">Uyarılar</th>
|
||||||
|
<th className="border px-3 py-2 text-left">Hatalar</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{result.details.map((d) => (
|
||||||
|
<tr key={d.entityName} className="hover:bg-gray-50">
|
||||||
|
<td className="border px-3 py-2 font-semibold text-gray-700">
|
||||||
|
{d.entityName}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
{/* Eklenen kolonunu tek satır formatında göster */}
|
||||||
|
<td className="border px-3 py-2">
|
||||||
|
{d.insertedCount > 0
|
||||||
|
? `${d.insertedCount} - { ${d.insertedItems.join(', ')} }`
|
||||||
|
: '—'}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td className="border px-3 py-2 text-yellow-700">
|
||||||
|
{d.warnings.length > 0
|
||||||
|
? `${d.warnings.length} - { ${d.warnings.join(', ')} }`
|
||||||
|
: '—'}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td className="border px-3 py-2 text-red-700">
|
||||||
|
{d.errors.length > 0
|
||||||
|
? `${d.errors.length} - { ${d.errors.join(', ')} }`
|
||||||
|
: '—'}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!result.details.length && (
|
||||||
|
<p className="text-gray-500 text-sm">Hiç detay bilgisi bulunamadı.</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Dialog>
|
||||||
|
</Container>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BranchSeed
|
||||||
|
|
@ -4,6 +4,7 @@ import CreateNotification from '@/views/admin/notification/CreateNotification'
|
||||||
import AuditLogDetail from '@/views/admin/auditLog/AuditLogDetail'
|
import AuditLogDetail from '@/views/admin/auditLog/AuditLogDetail'
|
||||||
import RolesPermission from '@/views/admin/role-management/RolesPermission'
|
import RolesPermission from '@/views/admin/role-management/RolesPermission'
|
||||||
import UsersPermission from '@/views/admin/user-management/UsersPermission'
|
import UsersPermission from '@/views/admin/user-management/UsersPermission'
|
||||||
|
import BranchSeed from '@/views/branch/BranchSeed'
|
||||||
|
|
||||||
const DialogShowComponent = (): JSX.Element => {
|
const DialogShowComponent = (): JSX.Element => {
|
||||||
const dialogContext: any = useDialogContext()
|
const dialogContext: any = useDialogContext()
|
||||||
|
|
@ -35,21 +36,29 @@ const DialogShowComponent = (): JSX.Element => {
|
||||||
></TenantsConnectionString>
|
></TenantsConnectionString>
|
||||||
)
|
)
|
||||||
case 'CreateNotification':
|
case 'CreateNotification':
|
||||||
return (
|
return (
|
||||||
<CreateNotification
|
<CreateNotification
|
||||||
open={true}
|
open={true}
|
||||||
onDialogClose={() => dialogContext.setConfig({})}
|
onDialogClose={() => dialogContext.setConfig({})}
|
||||||
{...dialogContext.config?.props}
|
{...dialogContext.config?.props}
|
||||||
></CreateNotification>
|
></CreateNotification>
|
||||||
)
|
)
|
||||||
case 'AuditLogDetail':
|
case 'AuditLogDetail':
|
||||||
return (
|
return (
|
||||||
<AuditLogDetail
|
<AuditLogDetail
|
||||||
open={true}
|
open={true}
|
||||||
onDialogClose={() => dialogContext.setConfig({})}
|
onDialogClose={() => dialogContext.setConfig({})}
|
||||||
{...dialogContext.config?.props}
|
{...dialogContext.config?.props}
|
||||||
></AuditLogDetail>
|
></AuditLogDetail>
|
||||||
)
|
)
|
||||||
|
case 'BranchSeed':
|
||||||
|
return (
|
||||||
|
<BranchSeed
|
||||||
|
open={true}
|
||||||
|
onDialogClose={() => dialogContext.setConfig({})}
|
||||||
|
{...dialogContext.config?.props}
|
||||||
|
></BranchSeed>
|
||||||
|
)
|
||||||
default:
|
default:
|
||||||
return <></>
|
return <></>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue