2024-01-26 19:39:59 +03:00
|
|
|
|
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
|
|
|
|
|
{
|
2024-05-28 06:43:24 +03:00
|
|
|
|
public static IServiceCollection AddPersistence(this IServiceCollection services, string connection)
|
2024-01-26 19:39:59 +03:00
|
|
|
|
{
|
2024-05-28 06:43:24 +03:00
|
|
|
|
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);
|
2024-01-26 19:39:59 +03:00
|
|
|
|
|
2024-05-28 06:43:24 +03:00
|
|
|
|
services.AddDbContext<UberDbContext>(DbConfig);
|
2024-01-26 19:39:59 +03:00
|
|
|
|
|
2024-05-30 20:07:20 +03:00
|
|
|
|
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>());
|
2024-01-26 19:39:59 +03:00
|
|
|
|
|
|
|
|
|
return services;
|
2024-05-28 06:43:24 +03:00
|
|
|
|
|
|
|
|
|
void DbConfig(DbContextOptionsBuilder options) => options.UseSqlite(connection);
|
2024-01-26 19:39:59 +03:00
|
|
|
|
}
|
|
|
|
|
}
|