-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
44 lines (28 loc) · 1.07 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
using e_commerce.Models;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
//builder.Services.AddScoped<ICategoryRepository, MockCategoryRepository>();
//builder.Services.AddScoped<IDonutRepository, MockDonutRepository>();
builder.Services.AddScoped<ICategoryRepository, CategoryRepository>();
builder.Services.AddScoped<IDonutRepository, DonutRepository>();
builder.Services.AddDbContext<DoorStepDonutsDbContext>(options =>
{
//options.UseSqlServer(
// builder.Configuration["ConnectionStrings: DoorStepDonutsDbContextConnection"]);
options.UseSqlite(builder.Configuration.GetConnectionString("SqliteConnection"));
});
builder.Services.AddControllersWithViews();
var app = builder.Build();
// Middleware pipeline
// Static files
app.UseStaticFiles();
// Exception display
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
// Default convention based routing middleware
app.MapDefaultControllerRoute();
// Seed data
DbInitializer.Seed(app);
app.Run();