Compare commits
No commits in common. "a902d9eb810d7ca37276eafc0eb8feb5e4549c86" and "081c814036f86cf8714d93159ca18eec3054e225" have entirely different histories.
a902d9eb81
...
081c814036
@ -2,19 +2,17 @@ name: .NET Test Pipeline
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
[master, 'release/*']
|
||||
branches: [master, 'release/*']
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up .NET Core
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
|
@ -13,10 +13,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentValidation" Version="11.9.1" />
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.1" />
|
||||
<PackageReference Include="AutoMapper" Version="12.0.1" />
|
||||
<PackageReference Include="FluentValidation" Version="11.9.0" />
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
|
||||
<PackageReference Include="MediatR" Version="12.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
28
Application/Common/Mappings/AssemblyMappingProfile.cs
Normal file
28
Application/Common/Mappings/AssemblyMappingProfile.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Application.Common.Mappings;
|
||||
|
||||
public class AssemblyMappingProfile : Profile
|
||||
{
|
||||
public AssemblyMappingProfile(Assembly assembly) =>
|
||||
ApplyMappingsFromAssembly(assembly);
|
||||
|
||||
private void ApplyMappingsFromAssembly(Assembly assembly)
|
||||
{
|
||||
var types = assembly.GetExportedTypes()
|
||||
.Where(type => type.GetInterfaces()
|
||||
.Any(i => i.IsGenericType &&
|
||||
i.GetGenericTypeDefinition() == typeof(IMapWith<>)))
|
||||
.ToList();
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
var instance = Activator.CreateInstance(type);
|
||||
var methodInfo = type.GetMethod("Mapping");
|
||||
methodInfo?.Invoke(instance, new[] { this });
|
||||
}
|
||||
}
|
||||
}
|
9
Application/Common/Mappings/IMapWith.cs
Normal file
9
Application/Common/Mappings/IMapWith.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using AutoMapper;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Application.Common.Mappings;
|
||||
|
||||
public interface IMapWith<T>
|
||||
{
|
||||
void Mapping(Profile profile) =>
|
||||
profile.CreateMap(typeof(T), GetType());
|
||||
}
|
78
Backend.sln
78
Backend.sln
@ -3,6 +3,8 @@ 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}"
|
||||
@ -17,34 +19,13 @@ 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("{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
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Migrations", "Migrations", "{79639CD4-7A16-4AB4-BBE8-672B9ACCB3F5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqliteMigrations", "SqlData\Migrations\SqliteMigrations\SqliteMigrations.csproj", "{EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{48C9998C-ECE2-407F-835F-1A7255A5C99E} = {48C9998C-ECE2-407F-835F-1A7255A5C99E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MysqlMigrations", "SqlData\Migrations\MysqlMigrations\MysqlMigrations.csproj", "{5861915B-9574-4D5D-872F-D54A09651697}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{48C9998C-ECE2-407F-835F-1A7255A5C99E} = {48C9998C-ECE2-407F-835F-1A7255A5C99E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PsqlMigrations", "SqlData\Migrations\PsqlMigrations\PsqlMigrations.csproj", "{E9E238CD-6DD8-4B29-8C36-C61F1168FCCD}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{48C9998C-ECE2-407F-835F-1A7255A5C99E} = {48C9998C-ECE2-407F-835F-1A7255A5C99E}
|
||||
EndProjectSection
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Security", "Security\Security.csproj", "{47A3C065-4E1D-4B1E-AAB4-2BB8F40E56B4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -52,10 +33,22 @@ 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
|
||||
@ -64,43 +57,10 @@ 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
|
||||
{EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5861915B-9574-4D5D-872F-D54A09651697}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5861915B-9574-4D5D-872F-D54A09651697}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5861915B-9574-4D5D-872F-D54A09651697}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5861915B-9574-4D5D-872F-D54A09651697}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E9E238CD-6DD8-4B29-8C36-C61F1168FCCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E9E238CD-6DD8-4B29-8C36-C61F1168FCCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E9E238CD-6DD8-4B29-8C36-C61F1168FCCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E9E238CD-6DD8-4B29-8C36-C61F1168FCCD}.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}
|
||||
{79639CD4-7A16-4AB4-BBE8-672B9ACCB3F5} = {7E7A63CD-547B-4FB4-A383-EB75298020A1}
|
||||
{EF5530BD-4BF4-4DD8-80BB-04C6B6623DA7} = {79639CD4-7A16-4AB4-BBE8-672B9ACCB3F5}
|
||||
{5861915B-9574-4D5D-872F-D54A09651697} = {79639CD4-7A16-4AB4-BBE8-672B9ACCB3F5}
|
||||
{E9E238CD-6DD8-4B29-8C36-C61F1168FCCD} = {79639CD4-7A16-4AB4-BBE8-672B9ACCB3F5}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E80A1224-87F5-4FEB-82AE-89006BE98B12}
|
||||
EndGlobalSection
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Attributes;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Attributes;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Interfaces;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Configuration.General.Settings;
|
||||
@ -17,15 +15,8 @@ public class DbSettings : IIsConfigured
|
||||
public DatabaseEnum TypeDatabase { get; set; }
|
||||
public required string ConnectionStringSql { get; set; }
|
||||
|
||||
public DatabaseProvider DatabaseProvider =>
|
||||
TypeDatabase switch
|
||||
public bool IsConfigured()
|
||||
{
|
||||
DatabaseEnum.PostgresSql => DatabaseProvider.Postgresql,
|
||||
DatabaseEnum.Mysql => DatabaseProvider.Mysql,
|
||||
DatabaseEnum.Sqlite => DatabaseProvider.Sqlite,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
public bool IsConfigured() =>
|
||||
!string.IsNullOrEmpty(ConnectionStringSql);
|
||||
return !string.IsNullOrEmpty(ConnectionStringSql);
|
||||
}
|
||||
}
|
@ -31,12 +31,9 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ApiDto\ApiDto.csproj" />
|
||||
<ProjectReference Include="..\SqlData\Domain\Domain.csproj" />
|
||||
<ProjectReference Include="..\SqlData\Persistence\Persistence.csproj" />
|
||||
<ProjectReference Include="..\Domain\Domain.csproj" />
|
||||
<ProjectReference Include="..\Persistence\Persistence.csproj" />
|
||||
<ProjectReference Include="..\Security\Security.csproj" />
|
||||
<ProjectReference Include="..\SqlData\Migrations\PsqlMigrations\PsqlMigrations.csproj" />
|
||||
<ProjectReference Include="..\SqlData\Migrations\SqliteMigrations\SqliteMigrations.csproj" />
|
||||
<ProjectReference Include="..\SqlData\Migrations\MysqlMigrations\MysqlMigrations.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -10,13 +10,11 @@ using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Mirea.Api.DataAccess.Application;
|
||||
using Mirea.Api.DataAccess.Persistence;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using Mirea.Api.Endpoint.Common.Interfaces;
|
||||
using Mirea.Api.Endpoint.Common.Services;
|
||||
using Mirea.Api.Endpoint.Common.Services.Security;
|
||||
using Mirea.Api.Endpoint.Configuration;
|
||||
using Mirea.Api.Endpoint.Configuration.General;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
||||
using Mirea.Api.Endpoint.Configuration.General.Validators;
|
||||
using Mirea.Api.Endpoint.Configuration.Swagger;
|
||||
using Mirea.Api.Endpoint.Middleware;
|
||||
@ -116,9 +114,8 @@ public class Program
|
||||
builder.Configuration.AddJsonFile(PathBuilder.Combine(GeneralConfig.FilePath), optional: true, reloadOnChange: true);
|
||||
builder.Services.Configure<GeneralConfig>(builder.Configuration);
|
||||
|
||||
var generalConfig = builder.Configuration.Get<GeneralConfig>();
|
||||
builder.Services.AddApplication();
|
||||
builder.Services.AddPersistence(generalConfig?.DbSettings?.DatabaseProvider ?? DatabaseProvider.Sqlite, generalConfig?.DbSettings?.ConnectionStringSql ?? string.Empty);
|
||||
builder.Services.AddPersistence(builder.Configuration.Get<GeneralConfig>()?.DbSettings?.ConnectionStringSql ?? string.Empty);
|
||||
builder.Services.AddControllers();
|
||||
|
||||
builder.Services.AddSingleton<IMaintenanceModeNotConfigureService, MaintenanceModeNotConfigureService>();
|
||||
|
@ -1,18 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using System.Reflection;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||
|
||||
public class CampusDbContext(DbContextOptions<CampusDbContext> options) : BaseDbContext<CampusDbContext>(options), ICampusDbContext
|
||||
public class CampusDbContext(DbContextOptions<CampusDbContext> options) : DbContext(options), ICampusDbContext
|
||||
{
|
||||
public DbSet<Campus> Campuses { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
modelBuilder.ApplyConfiguration(new CampusConfiguration());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using System.Reflection;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||
|
||||
public sealed class DisciplineDbContext(DbContextOptions<DisciplineDbContext> options) : BaseDbContext<DisciplineDbContext>(options), IDisciplineDbContext
|
||||
public class DisciplineDbContext(DbContextOptions<DisciplineDbContext> options) : DbContext(options), IDisciplineDbContext
|
||||
{
|
||||
public DbSet<Discipline> Disciplines { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
modelBuilder.ApplyConfiguration(new DisciplineConfiguration());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using System.Reflection;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||
|
||||
public sealed class FacultyDbContext(DbContextOptions<FacultyDbContext> options) : BaseDbContext<FacultyDbContext>(options), IFacultyDbContext
|
||||
public class FacultyDbContext(DbContextOptions<FacultyDbContext> options) : DbContext(options), IFacultyDbContext
|
||||
{
|
||||
public DbSet<Faculty> Faculties { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
modelBuilder.ApplyConfiguration(new FacultyConfiguration());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using System.Reflection;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||
|
||||
public sealed class GroupDbContext(DbContextOptions<GroupDbContext> options) : BaseDbContext<GroupDbContext>(options), IGroupDbContext
|
||||
public class GroupDbContext(DbContextOptions<GroupDbContext> options) : DbContext(options), IGroupDbContext
|
||||
{
|
||||
public DbSet<Group> Groups { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
modelBuilder.ApplyConfiguration(new GroupConfiguration());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using System.Reflection;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||
|
||||
public sealed class LectureHallDbContext(DbContextOptions<LectureHallDbContext> options) : BaseDbContext<LectureHallDbContext>(options), ILectureHallDbContext
|
||||
public class LectureHallDbContext(DbContextOptions<LectureHallDbContext> options) : DbContext(options), ILectureHallDbContext
|
||||
{
|
||||
public DbSet<LectureHall> LectureHalls { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
modelBuilder.ApplyConfiguration(new LectureHallConfiguration());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using System.Reflection;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||
|
||||
public sealed class LessonAssociationDbContext(DbContextOptions<LessonAssociationDbContext> options) : BaseDbContext<LessonAssociationDbContext>(options), ILessonAssociationDbContext
|
||||
public class LessonAssociationDbContext(DbContextOptions<LessonAssociationDbContext> options) : DbContext(options), ILessonAssociationDbContext
|
||||
{
|
||||
public DbSet<LessonAssociation> LessonAssociations { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
modelBuilder.ApplyConfiguration(new LessonAssociationConfiguration());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using System.Reflection;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||
|
||||
public sealed class LessonDbContext(DbContextOptions<LessonDbContext> options) : BaseDbContext<LessonDbContext>(options), ILessonDbContext
|
||||
public class LessonDbContext(DbContextOptions<LessonDbContext> options) : DbContext(options), ILessonDbContext
|
||||
{
|
||||
public DbSet<Lesson> Lessons { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
modelBuilder.ApplyConfiguration(new LessonConfiguration());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using System.Reflection;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||
|
||||
public sealed class ProfessorDbContext(DbContextOptions<ProfessorDbContext> options) : BaseDbContext<ProfessorDbContext>(options), IProfessorDbContext
|
||||
public class ProfessorDbContext(DbContextOptions<ProfessorDbContext> options) : DbContext(options), IProfessorDbContext
|
||||
{
|
||||
public DbSet<Professor> Professors { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
modelBuilder.ApplyConfiguration(new ProfessorConfiguration());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using System.Reflection;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||
|
||||
public sealed class SpecificWeekDbContext(DbContextOptions<SpecificWeekDbContext> options) : BaseDbContext<SpecificWeekDbContext>(options), ISpecificWeekDbContext
|
||||
public class SpecificWeekDbContext(DbContextOptions<SpecificWeekDbContext> options) : DbContext(options), ISpecificWeekDbContext
|
||||
{
|
||||
public DbSet<SpecificWeek> SpecificWeeks { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
modelBuilder.ApplyConfiguration(new SpecificWeekConfiguration());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
using Mirea.Api.DataAccess.Persistence.Common;
|
||||
using System.Reflection;
|
||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||
|
||||
public sealed class TypeOfOccupationDbContext(DbContextOptions<TypeOfOccupationDbContext> options) : BaseDbContext<TypeOfOccupationDbContext>(options), ITypeOfOccupationDbContext
|
||||
public class TypeOfOccupationDbContext(DbContextOptions<TypeOfOccupationDbContext> options) : DbContext(options), ITypeOfOccupationDbContext
|
||||
{
|
||||
public DbSet<TypeOfOccupation> TypeOfOccupations { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
@ -6,6 +6,6 @@ public static class DbInitializer
|
||||
{
|
||||
public static void Initialize(DbContext dbContext)
|
||||
{
|
||||
dbContext.Database.Migrate();
|
||||
dbContext.Database.EnsureCreated();
|
||||
}
|
||||
}
|
40
Persistence/DependencyInjection.cs
Normal file
40
Persistence/DependencyInjection.cs
Normal file
@ -0,0 +1,40 @@
|
||||
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.GetService<CampusDbContext>()!);
|
||||
services.AddScoped<IDisciplineDbContext>(provider => provider.GetService<DisciplineDbContext>()!);
|
||||
services.AddScoped<IFacultyDbContext>(provider => provider.GetService<FacultyDbContext>()!);
|
||||
services.AddScoped<IGroupDbContext>(provider => provider.GetService<GroupDbContext>()!);
|
||||
services.AddScoped<ILectureHallDbContext>(provider => provider.GetService<LectureHallDbContext>()!);
|
||||
services.AddScoped<ILessonAssociationDbContext>(provider => provider.GetService<LessonAssociationDbContext>()!);
|
||||
services.AddScoped<IProfessorDbContext>(provider => provider.GetService<ProfessorDbContext>()!);
|
||||
services.AddScoped<ILessonDbContext>(provider => provider.GetService<LessonDbContext>()!);
|
||||
services.AddScoped<ITypeOfOccupationDbContext>(provider => provider.GetService<TypeOfOccupationDbContext>()!);
|
||||
services.AddScoped<ISpecificWeekDbContext>(provider => provider.GetService<SpecificWeekDbContext>()!);
|
||||
|
||||
return services;
|
||||
|
||||
void DbConfig(DbContextOptionsBuilder options) => options.UseSqlite(connection);
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
public sealed class CampusConfiguration : IEntityTypeConfiguration<Campus>
|
||||
public class CampusConfiguration : IEntityTypeConfiguration<Campus>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Campus> builder)
|
||||
{
|
@ -2,7 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Sqlite.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.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.Sqlite.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.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.Sqlite.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.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.Sqlite.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.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.Sqlite.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.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.Sqlite.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.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.Sqlite.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.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.Sqlite.Schedule;
|
||||
namespace Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||
|
||||
public class SpecificWeekConfiguration : IEntityTypeConfiguration<SpecificWeek>
|
||||
{
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user