-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
65 lines (52 loc) · 1.94 KB
/
Program.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
55
56
57
58
59
60
61
62
63
64
65
using Dapper.FluentMap;
using Exam.Entities;
using Exam.Repositories;
using Exam.Services;
using Exam.Utils.Mapper;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(
policyBuilder =>
{
policyBuilder.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
});
FluentMapper.Initialize(config =>
{
config.AddMap(new AnswerOptionMapper());
config.AddMap(new AnswerResultMapper());
config.AddMap(new EntityStoreMapper());
config.AddMap(new PersonAnswerMapper());
config.AddMap(new PersonMapper());
config.AddMap(new QuestionMapper());
config.AddMap(new TestSessionMapper());
});
builder.Services.AddTransient<IAnswerOptionRepository, AnswerOptionRepository>();
builder.Services.AddTransient<IAnswerResultRepository, AnswerResultRepository>();
builder.Services.AddTransient<IPersonRepository, PersonRepository>();
builder.Services.AddTransient<IPersonAnswerRepository, PersonAnswerRepository>();
builder.Services.AddTransient<IQuestionRepository, QuestionRepository>();
builder.Services.AddTransient<ITestSessionRepository, TestSessionRepository>();
builder.Services.AddTransient<IAnswerOptionService, AnswerOptionService>();
builder.Services.AddTransient<IAnswerResultService, AnswerResultService>();
builder.Services.AddTransient<IPersonService, PersonService>();
builder.Services.AddTransient<IPersonAnswerService, PersonAnswerService>();
builder.Services.AddTransient<IQuestionService, QuestionService>();
builder.Services.AddTransient<ITestSessionService, TestSessionService>();
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseCors();
app.MapControllers();
app.Run();