-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
60 lines (48 loc) · 1.73 KB
/
Program.cs
File metadata and controls
60 lines (48 loc) · 1.73 KB
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
using CulinaryCommand.Data;
using CulinaryCommand.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = WebApplication.CreateBuilder(args);
// 1) Configure EF Core to use SQLite
builder.Services.AddDbContext<ApplicationDbContext>(opts =>
opts.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection"))
);
// 2) Add ASP.NET Core Identity
builder.Services
.AddDefaultIdentity<IdentityUser>(options =>
{
options.SignIn.RequireConfirmedAccount = false;
// you can tweak password, lockout, etc. here if desired
})
.AddEntityFrameworkStores<ApplicationDbContext>();
// 3) Add Razor Pages and Blazor Server
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
// 4) Register your application services
builder.Services.AddScoped<IPrepService, PrepService>();
builder.Services.AddScoped<IOrderService, OrderService>();
builder.Services.AddScoped<IEmployeeService, EmployeeService>();
var app = builder.Build();
// 5) Middleware pipeline
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
// 6) Enable authentication & authorization
app.UseAuthentication();
app.UseAuthorization();
// 7) Map endpoints
app.MapRazorPages(); // for Identity UI
app.MapBlazorHub(); // for Blazor Server
app.MapFallbackToPage("/_Host"); // for all other routes
app.Run();