Compare commits
10 Commits
43b6ab7934
...
8a103831eb
Author | SHA1 | Date | |
---|---|---|---|
8a103831eb | |||
62ccf94222 | |||
271df127a6 | |||
7c79f7d840 | |||
b8728cd490 | |||
7db4dc2c86 | |||
348b78b84e | |||
4c93ed282d | |||
1bdf40f31f | |||
31c36443e1 |
45
Backend.sln
45
Backend.sln
@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34330.188
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain", "Domain\Domain.csproj", "{C27FB5CD-6A70-4FB2-847A-847B34806902}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Endpoint", "Endpoint\Endpoint.csproj", "{F3A1D12E-F5B2-4339-9966-DBF869E78357}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Elements of the solution", "Elements of the solution", "{3E087889-A4A0-4A55-A07D-7D149A5BC928}"
|
||||
@ -19,13 +17,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Elements of the solution",
|
||||
.gitea\workflows\test.yaml = .gitea\workflows\test.yaml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application", "Application\Application.csproj", "{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence", "Persistence\Persistence.csproj", "{4C1E558F-633F-438E-AC3A-61CDDED917C5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiDto", "ApiDto\ApiDto.csproj", "{0335FA36-E137-453F-853B-916674C168FE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Security", "Security\Security.csproj", "{47A3C065-4E1D-4B1E-AAB4-2BB8F40E56B4}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Security", "Security\Security.csproj", "{47A3C065-4E1D-4B1E-AAB4-2BB8F40E56B4}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SqlData", "SqlData", "{7E7A63CD-547B-4FB4-A383-EB75298020A1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain", "SqlData\Domain\Domain.csproj", "{3BFD6180-7CA7-4E85-A379-225B872439A1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application", "SqlData\Application\Application.csproj", "{0B1F3656-E5B3-440C-961F-A7D004FBE9A8}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence", "SqlData\Persistence\Persistence.csproj", "{48C9998C-ECE2-407F-835F-1A7255A5C99E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -33,22 +35,10 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C27FB5CD-6A70-4FB2-847A-847B34806902}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C27FB5CD-6A70-4FB2-847A-847B34806902}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C27FB5CD-6A70-4FB2-847A-847B34806902}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C27FB5CD-6A70-4FB2-847A-847B34806902}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F3A1D12E-F5B2-4339-9966-DBF869E78357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F3A1D12E-F5B2-4339-9966-DBF869E78357}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F3A1D12E-F5B2-4339-9966-DBF869E78357}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F3A1D12E-F5B2-4339-9966-DBF869E78357}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4C1E558F-633F-438E-AC3A-61CDDED917C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4C1E558F-633F-438E-AC3A-61CDDED917C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4C1E558F-633F-438E-AC3A-61CDDED917C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4C1E558F-633F-438E-AC3A-61CDDED917C5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0335FA36-E137-453F-853B-916674C168FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0335FA36-E137-453F-853B-916674C168FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0335FA36-E137-453F-853B-916674C168FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -57,10 +47,27 @@ Global
|
||||
{47A3C065-4E1D-4B1E-AAB4-2BB8F40E56B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{47A3C065-4E1D-4B1E-AAB4-2BB8F40E56B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{47A3C065-4E1D-4B1E-AAB4-2BB8F40E56B4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3BFD6180-7CA7-4E85-A379-225B872439A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3BFD6180-7CA7-4E85-A379-225B872439A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3BFD6180-7CA7-4E85-A379-225B872439A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3BFD6180-7CA7-4E85-A379-225B872439A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0B1F3656-E5B3-440C-961F-A7D004FBE9A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0B1F3656-E5B3-440C-961F-A7D004FBE9A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0B1F3656-E5B3-440C-961F-A7D004FBE9A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0B1F3656-E5B3-440C-961F-A7D004FBE9A8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{48C9998C-ECE2-407F-835F-1A7255A5C99E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{48C9998C-ECE2-407F-835F-1A7255A5C99E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{48C9998C-ECE2-407F-835F-1A7255A5C99E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48C9998C-ECE2-407F-835F-1A7255A5C99E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{3BFD6180-7CA7-4E85-A379-225B872439A1} = {7E7A63CD-547B-4FB4-A383-EB75298020A1}
|
||||
{0B1F3656-E5B3-440C-961F-A7D004FBE9A8} = {7E7A63CD-547B-4FB4-A383-EB75298020A1}
|
||||
{48C9998C-ECE2-407F-835F-1A7255A5C99E} = {7E7A63CD-547B-4FB4-A383-EB75298020A1}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E80A1224-87F5-4FEB-82AE-89006BE98B12}
|
||||
EndGlobalSection
|
||||
|
@ -1,4 +1,6 @@
|
||||
using Mirea.Api.Endpoint.Configuration.General.Attributes;
|
||||
using System;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Attributes;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Interfaces;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Configuration.General.Settings;
|
||||
@ -15,8 +17,15 @@ public class DbSettings : IIsConfigured
|
||||
public DatabaseEnum TypeDatabase { get; set; }
|
||||
public required string ConnectionStringSql { get; set; }
|
||||
|
||||
public bool IsConfigured()
|
||||
public DatabaseProvider DatabaseProvider =>
|
||||
TypeDatabase switch
|
||||
{
|
||||
return !string.IsNullOrEmpty(ConnectionStringSql);
|
||||
}
|
||||
DatabaseEnum.PostgresSql => DatabaseProvider.Postgresql,
|
||||
DatabaseEnum.Mysql => DatabaseProvider.Mysql,
|
||||
DatabaseEnum.Sqlite => DatabaseProvider.Sqlite,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
public bool IsConfigured() =>
|
||||
!string.IsNullOrEmpty(ConnectionStringSql);
|
||||
}
|
@ -115,7 +115,7 @@ public class Program
|
||||
builder.Services.Configure<GeneralConfig>(builder.Configuration);
|
||||
|
||||
builder.Services.AddApplication();
|
||||
builder.Services.AddPersistence(builder.Configuration.Get<GeneralConfig>()?.DbSettings?.ConnectionStringSql ?? string.Empty);
|
||||
builder.Services.AddPersistence(generalConfig?.DbSettings?.DatabaseProvider ?? DatabaseProvider.Sqlite, generalConfig?.DbSettings?.ConnectionStringSql ?? string.Empty);
|
||||
builder.Services.AddControllers();
|
||||
|
||||
builder.Services.AddSingleton<IMaintenanceModeNotConfigureService, MaintenanceModeNotConfigureService>();
|
||||
|
23
SqlData/Persistence/Common/ConfigurationResolver.cs
Normal file
23
SqlData/Persistence/Common/ConfigurationResolver.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Common;
|
||||
|
||||
public static class ConfigurationResolver
|
||||
{
|
||||
public static Type GetConfigurationType<TEntity>(DatabaseProvider provider)
|
||||
where TEntity : class
|
||||
{
|
||||
var entityType = typeof(TEntity);
|
||||
var providerNamespace = typeof(Mark).Namespace + "." + Enum.GetName(provider);
|
||||
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var configurationType = assembly.GetTypes()
|
||||
.FirstOrDefault(t => t.Namespace != null && t.Namespace.StartsWith(providerNamespace) && t.Name == $"{entityType.Name}Configuration");
|
||||
|
||||
return configurationType ??
|
||||
throw new InvalidOperationException($"Configuration type not found for entity {entityType.Name} and provider {provider}.");
|
||||
}
|
||||
}
|
22
SqlData/Persistence/Common/DbContextFactory.cs
Normal file
22
SqlData/Persistence/Common/DbContextFactory.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Common;
|
||||
|
||||
public static class DbContextFactory
|
||||
{
|
||||
public static DbContextOptionsBuilder CreateDbContext<TDbContext, TEntity>(this DbContextOptionsBuilder options, DatabaseProvider provider)
|
||||
where TDbContext : BaseDbContext<TDbContext>
|
||||
where TEntity : class
|
||||
{
|
||||
var dbContext = (TDbContext)Activator.CreateInstance(typeof(TDbContext), (DbContextOptions<TDbContext>)options.Options)!;
|
||||
var configurationType = ConfigurationResolver.GetConfigurationType<TEntity>(provider);
|
||||
var configurationInstance = (IEntityTypeConfiguration<TEntity>)Activator.CreateInstance(configurationType)!;
|
||||
|
||||
var modelBuilder = new ModelBuilder();
|
||||
modelBuilder.ApplyConfiguration(configurationInstance);
|
||||
dbContext.ApplyConfigurations(modelBuilder);
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
22
SqlData/Persistence/Common/ModelBuilderExtensions.cs
Normal file
22
SqlData/Persistence/Common/ModelBuilderExtensions.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Common;
|
||||
|
||||
public static class ModelBuilderExtensions
|
||||
{
|
||||
public static void ApplyConfiguration(this ModelBuilder modelBuilder, object configuration)
|
||||
{
|
||||
var applyGenericMethod = typeof(ModelBuilder)
|
||||
.GetMethods()
|
||||
.First(m => m.Name == "ApplyConfiguration" &&
|
||||
m.GetParameters().Any(p => p.ParameterType.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>)));
|
||||
|
||||
var entityType = configuration.GetType().GetInterfaces()
|
||||
.First(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>))
|
||||
.GetGenericArguments()[0];
|
||||
|
||||
var applyConcreteMethod = applyGenericMethod.MakeGenericMethod(entityType);
|
||||
applyConcreteMethod.Invoke(modelBuilder, [configuration]);
|
||||
}
|
||||
}
|
@ -1,26 +1,63 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddPersistence(this IServiceCollection services, string connection)
|
||||
public static IServiceCollection AddPersistence(this IServiceCollection services, DatabaseProvider dbProvider, 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<CampusDbContext>(options =>
|
||||
UseDatabase(options).CreateDbContext<CampusDbContext, Campus>(dbProvider));
|
||||
services.AddDbContext<DisciplineDbContext>(options =>
|
||||
UseDatabase(options).CreateDbContext<DisciplineDbContext, Discipline>(dbProvider));
|
||||
services.AddDbContext<FacultyDbContext>(options =>
|
||||
UseDatabase(options).CreateDbContext<FacultyDbContext, Faculty>(dbProvider));
|
||||
services.AddDbContext<GroupDbContext>(options =>
|
||||
UseDatabase(options).CreateDbContext<GroupDbContext, Group>(dbProvider));
|
||||
services.AddDbContext<LectureHallDbContext>(options =>
|
||||
UseDatabase(options).CreateDbContext<LectureHallDbContext, LectureHall>(dbProvider));
|
||||
services.AddDbContext<LessonAssociationDbContext>(options =>
|
||||
UseDatabase(options).CreateDbContext<LessonAssociationDbContext, LessonAssociation>(dbProvider));
|
||||
services.AddDbContext<ProfessorDbContext>(options =>
|
||||
UseDatabase(options).CreateDbContext<ProfessorDbContext, Professor>(dbProvider));
|
||||
services.AddDbContext<LessonDbContext>(options =>
|
||||
UseDatabase(options).CreateDbContext<LessonDbContext, Lesson>(dbProvider));
|
||||
services.AddDbContext<TypeOfOccupationDbContext>(options =>
|
||||
UseDatabase(options).CreateDbContext<TypeOfOccupationDbContext, TypeOfOccupation>(dbProvider));
|
||||
services.AddDbContext<SpecificWeekDbContext>(options =>
|
||||
UseDatabase(options).CreateDbContext<SpecificWeekDbContext, SpecificWeek>(dbProvider));
|
||||
|
||||
services.AddDbContext<UberDbContext>(DbConfig);
|
||||
services.AddDbContext<UberDbContext>(options =>
|
||||
{
|
||||
var providerNamespace = typeof(Mark).Namespace + "." + Enum.GetName(dbProvider);
|
||||
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var configurationTypes = assembly.GetTypes()
|
||||
.Where(t =>
|
||||
t is { IsNested: false, IsAbstract: false, Namespace: not null } &&
|
||||
t.Namespace.StartsWith(providerNamespace) &&
|
||||
t.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>)));
|
||||
|
||||
var modelBuilder = new ModelBuilder();
|
||||
|
||||
foreach (var configurationType in configurationTypes)
|
||||
{
|
||||
var configurationInstance = Activator.CreateInstance(configurationType)!;
|
||||
modelBuilder.ApplyConfiguration(configurationInstance);
|
||||
}
|
||||
|
||||
var dbContext = (UberDbContext)Activator.CreateInstance(typeof(UberDbContext), (DbContextOptions<UberDbContext>)UseDatabase(options).Options)!;
|
||||
dbContext.ApplyConfigurations(modelBuilder);
|
||||
});
|
||||
|
||||
services.AddScoped<ICampusDbContext>(provider => provider.GetRequiredService<CampusDbContext>());
|
||||
services.AddScoped<IDisciplineDbContext>(provider => provider.GetRequiredService<DisciplineDbContext>());
|
||||
@ -35,6 +72,15 @@ public static class DependencyInjection
|
||||
|
||||
return services;
|
||||
|
||||
void DbConfig(DbContextOptionsBuilder options) => options.UseSqlite(connection);
|
||||
DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder options)
|
||||
{
|
||||
return dbProvider switch
|
||||
{
|
||||
DatabaseProvider.Sqlite => options.UseSqlite(connection),
|
||||
DatabaseProvider.Mysql => options.UseMySql(connection, ServerVersion.AutoDetect(connection)),
|
||||
DatabaseProvider.Postgresql => options.UseNpgsql(connection),
|
||||
_ => throw new ArgumentException("Unsupported database provider", Enum.GetName(dbProvider))
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -2,13 +2,13 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
|
||||
public class CampusConfiguration : IEntityTypeConfiguration<Campus>
|
||||
public sealed class CampusConfiguration : IEntityTypeConfiguration<Campus>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Campus> builder)
|
||||
{
|
||||
builder.ToTable(nameof(Campus));
|
||||
builder.ToTable("MyCampusName");
|
||||
builder.HasKey(c => c.Id);
|
||||
builder.HasIndex(c => c.Id).IsUnique();
|
||||
builder.Property(c => c.Id).HasColumnType("INTEGER").IsRequired().ValueGeneratedOnAdd();
|
@ -2,7 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
|
||||
public class DisciplineConfiguration : IEntityTypeConfiguration<Discipline>
|
||||
{
|
@ -2,7 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
|
||||
public class FacultyConfiguration : IEntityTypeConfiguration<Faculty>
|
||||
{
|
@ -2,7 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
|
||||
public class GroupConfiguration : IEntityTypeConfiguration<Group>
|
||||
{
|
@ -2,7 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
|
||||
public class LectureHallConfiguration : IEntityTypeConfiguration<LectureHall>
|
||||
{
|
@ -2,7 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
|
||||
public class LessonAssociationConfiguration : IEntityTypeConfiguration<LessonAssociation>
|
||||
{
|
@ -2,7 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
|
||||
public class LessonConfiguration : IEntityTypeConfiguration<Lesson>
|
||||
{
|
@ -2,7 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
|
||||
public class ProfessorConfiguration : IEntityTypeConfiguration<Professor>
|
||||
{
|
@ -2,7 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
|
||||
public class SpecificWeekConfiguration : IEntityTypeConfiguration<SpecificWeek>
|
||||
{
|
@ -2,7 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
|
||||
public class TypeOfOccupationConfiguration : IEntityTypeConfiguration<TypeOfOccupation>
|
||||
{
|
@ -1,10 +1,11 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence;
|
||||
|
||||
public class UberDbContext(DbContextOptions<UberDbContext> options) : DbContext(options)
|
||||
public class UberDbContext(DbContextOptions<UberDbContext> options) : BaseDbContext<UberDbContext>(options)
|
||||
{
|
||||
public DbSet<Campus> Campuses { get; set; } = null!;
|
||||
public DbSet<Discipline> Disciplines { get; set; } = null!;
|
||||
@ -19,17 +20,7 @@ public class UberDbContext(DbContextOptions<UberDbContext> options) : DbContext(
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfiguration(new CampusConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new DisciplineConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new FacultyConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new GroupConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new LectureHallConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new LessonConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new ProfessorConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new LessonAssociationConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new SpecificWeekConfiguration());
|
||||
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user