40 lines
2.3 KiB
C#
40 lines
2.3 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
|
using Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
|
|
|
namespace Mirea.Api.DataAccess.Persistence;
|
|
|
|
public static class DependencyInjection
|
|
{
|
|
public static IServiceCollection AddPersistence(this IServiceCollection services, string connection)
|
|
{
|
|
services.AddDbContext<CampusDbContext>(DbConfig);
|
|
services.AddDbContext<DisciplineDbContext>(DbConfig);
|
|
services.AddDbContext<FacultyDbContext>(DbConfig);
|
|
services.AddDbContext<GroupDbContext>(DbConfig);
|
|
services.AddDbContext<LectureHallDbContext>(DbConfig);
|
|
services.AddDbContext<LessonAssociationDbContext>(DbConfig);
|
|
services.AddDbContext<ProfessorDbContext>(DbConfig);
|
|
services.AddDbContext<LessonDbContext>(DbConfig);
|
|
services.AddDbContext<TypeOfOccupationDbContext>(DbConfig);
|
|
services.AddDbContext<SpecificWeekDbContext>(DbConfig);
|
|
|
|
services.AddDbContext<UberDbContext>(DbConfig);
|
|
|
|
services.AddScoped<ICampusDbContext>(provider => provider.GetRequiredService<CampusDbContext>());
|
|
services.AddScoped<IDisciplineDbContext>(provider => provider.GetRequiredService<DisciplineDbContext>());
|
|
services.AddScoped<IFacultyDbContext>(provider => provider.GetRequiredService<FacultyDbContext>());
|
|
services.AddScoped<IGroupDbContext>(provider => provider.GetRequiredService<GroupDbContext>());
|
|
services.AddScoped<ILectureHallDbContext>(provider => provider.GetRequiredService<LectureHallDbContext>());
|
|
services.AddScoped<ILessonAssociationDbContext>(provider => provider.GetRequiredService<LessonAssociationDbContext>());
|
|
services.AddScoped<IProfessorDbContext>(provider => provider.GetRequiredService<ProfessorDbContext>());
|
|
services.AddScoped<ILessonDbContext>(provider => provider.GetRequiredService<LessonDbContext>());
|
|
services.AddScoped<ITypeOfOccupationDbContext>(provider => provider.GetRequiredService<TypeOfOccupationDbContext>());
|
|
services.AddScoped<ISpecificWeekDbContext>(provider => provider.GetRequiredService<SpecificWeekDbContext>());
|
|
|
|
return services;
|
|
|
|
void DbConfig(DbContextOptionsBuilder options) => options.UseSqlite(connection);
|
|
}
|
|
} |