SES-67 Add config to repositories

This commit is contained in:
Karol Górzyński 2020-12-03 18:52:53 +01:00
parent e3bcf28f46
commit dfc3cdac98
2 changed files with 111 additions and 80 deletions

View File

@ -0,0 +1,28 @@
using Microsoft.Extensions.DependencyInjection;
using SessionCompanion.Database.Repositories;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SessionCompanion.Configurations
{
public static class RepositoryConfiguration
{
public static IServiceCollection AddRepositories(this IServiceCollection services)
{
services.AddScoped<IRepository<Alignment>, AlignmentRepository>();
services.AddScoped<IRepository<Background>, BackgroundRepository>();
services.AddScoped<IRepository<Biography>, BiographyRepository>();
services.AddScoped<IRepository<Character>, CharacterRepository>();
services.AddScoped<IRepository<Class>, ClassRepository>();
services.AddScoped<IRepository<Race>, RaceRepository>();
services.AddScoped<IRepository<Statistics>, StatisticsRepository>();
services.AddScoped<IRepository<User>, UserRepository>();
return services;
}
}
}

View File

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using SessionCompanion.Configurations;
using SessionCompanion.Database; using SessionCompanion.Database;
namespace SessionCompanion namespace SessionCompanion
@ -27,6 +28,8 @@ namespace SessionCompanion
services.AddDbContext<ApplicationDbContext>(options => services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer( options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection"))); Configuration.GetConnectionString("DefaultConnection")));
services.AddRepositories();
// In production, the Angular files will be served from this directory // In production, the Angular files will be served from this directory
services.AddSpaStaticFiles(configuration => services.AddSpaStaticFiles(configuration =>
{ {