29 lines
945 B
C#
29 lines
945 B
C#
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.Runtime.InteropServices.Marshalling;
|
|
|
|
namespace OpenArchival.DataAccess;
|
|
|
|
public static class HomepageConfigurationSeeder
|
|
{
|
|
public static async Task SeedHomepageConfig(IServiceProvider serviceProvider)
|
|
{
|
|
var contextFactory = serviceProvider.GetRequiredService<IDbContextFactory<ApplicationDbContext>>();
|
|
await using var context = await contextFactory.CreateDbContextAsync();
|
|
|
|
HomePageConfiguration? existingConfig = await context.HomePageConfiguration.FirstOrDefaultAsync();
|
|
if (existingConfig == null)
|
|
{
|
|
var config = new HomePageConfiguration() {
|
|
Content = "<p>No homepage content configured</p>",
|
|
HomePageBanner = null,
|
|
SliderEntries = null
|
|
};
|
|
|
|
context.HomePageConfiguration.Add(config);
|
|
await context.SaveChangesAsync();
|
|
|
|
}
|
|
}
|
|
}
|