Update SurveyLib and moved all AddScoped to DI methods
This commit is contained in:
parent
d73e0a104f
commit
7ccf8cb018
4 changed files with 49 additions and 20 deletions
|
|
@ -8,6 +8,7 @@ using SurveyBackend.Core.Contexts;
|
||||||
using SurveyBackend.Core.Repositories;
|
using SurveyBackend.Core.Repositories;
|
||||||
using SurveyBackend.Core.Services;
|
using SurveyBackend.Core.Services;
|
||||||
using SurveyBackend.Filters;
|
using SurveyBackend.Filters;
|
||||||
|
using SurveyBackend.Infrastructure;
|
||||||
using SurveyBackend.Infrastructure.Data;
|
using SurveyBackend.Infrastructure.Data;
|
||||||
using SurveyBackend.Infrastructure.Repositories;
|
using SurveyBackend.Infrastructure.Repositories;
|
||||||
using SurveyBackend.Middlewares;
|
using SurveyBackend.Middlewares;
|
||||||
|
|
@ -16,6 +17,7 @@ using SurveyBackend.Services.Helpers;
|
||||||
using SurveyBackend.Services.Services;
|
using SurveyBackend.Services.Services;
|
||||||
using SurveyLib.Core.Repositories;
|
using SurveyLib.Core.Repositories;
|
||||||
using SurveyLib.Core.Services;
|
using SurveyLib.Core.Services;
|
||||||
|
using SurveyLib.Infrastructure.EFCore;
|
||||||
using SurveyLib.Infrastructure.EFCore.Data;
|
using SurveyLib.Infrastructure.EFCore.Data;
|
||||||
using SurveyLib.Infrastructure.EFCore.Repositories;
|
using SurveyLib.Infrastructure.EFCore.Repositories;
|
||||||
|
|
||||||
|
|
@ -40,25 +42,9 @@ public class Program
|
||||||
|
|
||||||
builder.Services.AddScoped<IUserContext, UserContext>();
|
builder.Services.AddScoped<IUserContext, UserContext>();
|
||||||
|
|
||||||
builder.Services.AddScoped<IUserRepository, UserRepository>();
|
builder.Services.AddSurveyBackendInfrastructure();
|
||||||
builder.Services.AddScoped<IUserService, UserService>();
|
builder.Services.AddSurveyLibInfrastructure();
|
||||||
|
builder.Services.AddSurveyBackendServices();
|
||||||
builder.Services.AddScoped<IPasswordHasher, Sha256PasswordHasher>();
|
|
||||||
|
|
||||||
builder.Services.AddScoped<IAuthorizationService, AuthorizationService>();
|
|
||||||
|
|
||||||
builder.Services.AddScoped<ISurveyRepository, SurveyRepository>();
|
|
||||||
builder.Services.AddScoped<IQuestionRepository, QuestionRepository>();
|
|
||||||
builder.Services.AddScoped<IAnswerVariantsRepository, AnswerVariantsRepository>();
|
|
||||||
builder.Services.AddScoped<ICompletionRepository, CompletionRepository>();
|
|
||||||
builder.Services.AddScoped<IAnswerRepository, AnswerRepository>();
|
|
||||||
|
|
||||||
builder.Services.AddScoped<ISurveyService, SurveyService>();
|
|
||||||
builder.Services.AddScoped<IQuestionService, QuestionService>();
|
|
||||||
builder.Services.AddScoped<IAnswerVariantsService, AnswerVariantsService>();
|
|
||||||
builder.Services.AddScoped<ICompletionService, CompletionService>();
|
|
||||||
builder.Services.AddScoped<IAnswerService, AnswerService>();
|
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||||
.AddJwtBearer(options =>
|
.AddJwtBearer(options =>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using SurveyBackend.Core.Repositories;
|
||||||
|
using SurveyBackend.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
namespace SurveyBackend.Infrastructure;
|
||||||
|
|
||||||
|
public static class DependencyInjection
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddSurveyBackendInfrastructure(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddScoped<IUserRepository, UserRepository>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
27
SurveyBackend/SurveyBackend.Services/DependencyInjection.cs
Normal file
27
SurveyBackend/SurveyBackend.Services/DependencyInjection.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using SurveyBackend.Core.Services;
|
||||||
|
using SurveyBackend.Services.Helpers;
|
||||||
|
using SurveyBackend.Services.Services;
|
||||||
|
using SurveyLib.Core.Services;
|
||||||
|
|
||||||
|
namespace SurveyBackend.Services;
|
||||||
|
|
||||||
|
public static class DependencyInjection
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddSurveyBackendServices(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddScoped<IUserService, UserService>();
|
||||||
|
|
||||||
|
services.AddScoped<IPasswordHasher, Sha256PasswordHasher>();
|
||||||
|
|
||||||
|
services.AddScoped<IAuthorizationService, AuthorizationService>();
|
||||||
|
|
||||||
|
services.AddScoped<ISurveyService, SurveyService>();
|
||||||
|
services.AddScoped<IQuestionService, QuestionService>();
|
||||||
|
services.AddScoped<IAnswerVariantsService, AnswerVariantsService>();
|
||||||
|
services.AddScoped<ICompletionService, CompletionService>();
|
||||||
|
services.AddScoped<IAnswerService, AnswerService>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit f02a36dd85184c31a58e1d84081220a08b1c5d99
|
Subproject commit d9f16ee761e31bb7af7a067c38f5fa02083f9d6c
|
||||||
Loading…
Add table
Add a link
Reference in a new issue