-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathProgram.cs
More file actions
61 lines (46 loc) · 1.57 KB
/
Copy pathProgram.cs
File metadata and controls
61 lines (46 loc) · 1.57 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
61
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using ManagementApp.Data;
using ManagementApp.Models;
using ManagementApp.Services;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages(); // Razor Pages servisini ekle
// Configure the DbContext with PostgreSQL
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
// Add Identity services
builder.Services.AddDefaultIdentity<ApplicationUser>()
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>();
// Add custom services
builder.Services.AddScoped<IWorkOrderService, WorkOrderService>();
builder.Services.AddScoped<IWorkOrderDocumentService, WorkOrderDocumentService>();
builder.Services.AddScoped<IWorkOrderImageService, WorkOrderImageService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
// Configure the authentication
app.UseAuthentication();
app.UseAuthorization();
// Map Razor Pages
app.MapRazorPages();
// Set the default page
app.MapGet("/", () => Results.Redirect("/WorkOrders/Index"));
// Custom 404 page
app.UseStatusCodePages(async context =>
{
var statusCode = context.HttpContext.Response.StatusCode;
if (statusCode == 404)
{
context.HttpContext.Response.Redirect("/404");
}
});
app.Run();