-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
52 lines (39 loc) · 1.93 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
using HrAspire.DataSeeder.Services;
using HrAspire.Employees.Business.Documents;
using HrAspire.Employees.Business.Employees;
using HrAspire.Employees.Data;
using HrAspire.Employees.Data.Models;
using HrAspire.Salaries.Business.SalaryRequests;
using HrAspire.Salaries.Data;
using HrAspire.ServiceDefaults;
using HrAspire.Vacations.Business.VacationRequests;
using HrAspire.Vacations.Data;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
var builder = Host.CreateApplicationBuilder(args);
builder.AddServiceDefaults();
builder.AddNpgsqlDbContext<EmployeesDbContext>(
ResourceNames.EmployeesDb,
configureDbContextOptions: options => options.UseNpgsql(b => b.MigrationsAssembly(typeof(Program).Assembly.FullName)));
builder.AddNpgsqlDbContext<SalariesDbContext>(
ResourceNames.SalariesDb,
configureDbContextOptions: options => options.UseNpgsql(b => b.MigrationsAssembly(typeof(Program).Assembly.FullName)));
builder.AddNpgsqlDbContext<VacationsDbContext>(
ResourceNames.VacationsDb,
configureDbContextOptions: options => options.UseNpgsql(b => b.MigrationsAssembly(typeof(Program).Assembly.FullName)));
builder.AddAzureBlobClient(ResourceNames.Blobs);
builder.AddRedisClient(ResourceNames.Cache);
builder.Services
.AddIdentityCore<Employee>(options => options.User.RequireUniqueEmail = true)
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<EmployeesDbContext>();
builder.Services.AddScoped<IEmployeesService, EmployeesService>();
builder.Services.AddScoped<IDocumentsService, DocumentsService>();
builder.Services.AddScoped<ISalaryRequestsService, SalaryRequestsService>();
builder.Services.AddScoped<IVacationRequestsService, VacationRequestsService>();
builder.Services.AddScoped<EmployeesDbSeeder>();
builder.Services.AddScoped<SalariesDbSeeder>();
builder.Services.AddScoped<VacationsDbSeeder>();
builder.Services.AddHostedService<DataSeederWorker>();
var host = builder.Build();
host.Run();