-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
39 lines (35 loc) · 1.32 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
using Microsoft.EntityFrameworkCore;
using BankSearch.Data;
using BankSearch.BackgroundServices;
var builder = WebApplication.CreateBuilder(args);
//IAPPRepository scopeunun görüldüğü yerde AppRepository scopeunun işlevlerini gerçekleştir
builder.Services.AddScoped<IAppRepository, AppRepository>();
builder.Services.AddControllersWithViews();
//appsettings.json'daki connectionStringi çekerek EF DbContext nesnesine inject et
builder.Services.AddDbContext<BankSearchContext>(x=>
x.UseSqlServer(builder.Configuration.GetConnectionString("BankSearchConnection")));
//Arkaplanda çalışacak olan APIService'in injectonı
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddHostedService<APIService>();
services.AddScoped<IAppRepository, AppRepository>();
//appsettings.json'daki connectionStringi çekerek EF DbContext nesnesine inject et
services.AddDbContext<BankSearchContext>(x =>
x.UseSqlServer(builder.Configuration.GetConnectionString("BankSearchConnection")));
})
.Build();
host.RunAsync();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.MapControllerRoute(
name: "default",
pattern: "{controller}/{action=Index}/{id?}");
app.MapFallbackToFile("index.html"); ;
app.Run();