back photo + event tags and persons

This commit is contained in:
2025-08-10 20:07:40 +02:00
parent 0cc8bddfa1
commit f61b48fa4b
46 changed files with 1438 additions and 189 deletions

View File

@@ -0,0 +1,37 @@
using back.context;
using back.Options;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
namespace back.ServicesExtensions;
public static partial class ServicesExtensions
{
private static IServiceCollection AddDatabaseContexts(this IServiceCollection services)
{
services
.AddContext<EventContext>()
.AddContext<GalleryContext>()
.AddContext<PersonContext>()
.AddContext<PhotoContext>()
.AddContext<TagContext>()
.AddContext<UserContext>()
;
return services;
}
private static IServiceCollection AddContext<T>(this IServiceCollection services)
where T : DbContext
{
var config = services
.BuildServiceProvider()
.GetRequiredService<IOptionsSnapshot<DatabaseConfig>>()
.Get(DatabaseConfig.DataStorage);
services.AddDbContext<T>(options =>
{
options.UseDatabaseConfig(config);
});
return services;
}
}