Files
FA_WEB/OrdersManagement/Program.cs
2025-02-21 09:59:50 +01:00

63 lines
2.0 KiB
C#

using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Components.Authorization;
using OrdersManagement;
using OrdersManagement.Components;
using OrdersManagement.Services;
using Syncfusion.Blazor;
var builder = WebApplication.CreateBuilder(args);
string faKrosnoApiUrl = builder.Configuration["FaKrosnoApiUrl"] ?? "http://localhost:5001";
builder.Services.AddSyncfusionBlazor();
builder.Services.AddBlazorBootstrap();
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = "/login";
options.LogoutPath = "/login";
});
builder.Services.AddAuthorizationCore();
builder.Services.AddScoped<AuthenticationStateProvider, CustomAuthenticationStateProvider>();
builder.Services.AddScoped<UserService>();
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(faKrosnoApiUrl) });
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
// Usługi aplikacji
builder.Services.AddScoped<ScheduleOrderService>();
builder.Services.AddScoped<ScheduleOrderDetailsService>();
builder.Services.AddScoped<EdiCustomerOrderService>();
builder.Services.AddScoped<CustomerOrderService>();
builder.Services.AddScoped<HangfireService>();
builder.Services.AddScoped<RoleService>();
builder.Services.AddScoped<FunctionService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
// Włącz autentykację i autoryzację w pipeline
app.UseAuthentication();
app.UseAuthorization();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Ngo9BigBOggjHTQxAR8/V1NMaF5cXmBCf1FpRmJGdld5fUVHYVZUTXxaS00DNHVRdkdmWX1ec3VWQmNYV01wWUE=");
app.Run();