-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BackendServicesExtension.cs
54 lines (46 loc) · 1.85 KB
/
BackendServicesExtension.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using Amazon.S3;
using AkouoApi.Data;
using Microsoft.EntityFrameworkCore;
using static AkouoApi.Utility.EnvironmentHelpers;
namespace AkouoApi.Services;
public static class BackendServiceExtension
{
public static object AddApiServices(this IServiceCollection services)
{
// Add services to the container.
services.AddHttpContextAccessor();
//services.AddScoped<AppDbContextResolver>();
// Add the Entity Framework Core DbContext like you normally would.
services.AddDbContext<AppDbContext>(options => {
options.UseNpgsql(GetConnectionString());
});
services.RegisterServices();
return services;
}
public static void RegisterServices(this IServiceCollection services)
{
services.AddScoped<BibleService>();
services.AddScoped<BookService>();
services.AddScoped<LanguageService>();
services.AddScoped<MediafileService>();
/*
services.AddScoped<ArtifactCategoryService>();
services.AddScoped<GraphicService>();
services.AddScoped<IntellectualPropertyService>();
services.AddScoped<OrganizationService>();
services.AddScoped<PassageService>();
services.AddScoped<PlanService>();
services.AddScoped<ProjectService>();
services.AddScoped<SectionService>();
services.AddScoped<SharedResourceService>();
services.AddScoped<SharedResourceReferenceService>();
services.AddScoped<UserService>();
*/
services.AddSingleton<IS3Service, S3Service>();
services.AddAWSService<IAmazonS3>();
}
private static string GetConnectionString()
{
return GetVarOrDefault("SIL_TR_CONNECTIONSTRING", "");
}
}