using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Stripe; using Syncfusion.Licensing; using WhiteLagoon.Application.Common.Interfaces; using WhiteLagoon.Application.Contract; using WhiteLagoon.Application.Services.Implementation; using WhiteLagoon.Application.Services.Interface; using WhiteLagoon.Domain.Entities; using WhiteLagoon.Infrastructure.Data; using WhiteLagoon.Infrastructure.Emails; using WhiteLagoon.Infrastructure.Repository; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); builder.Services.AddDbContext(option => option.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"))); builder.Services.AddIdentity() .AddEntityFrameworkStores(); builder.Services.ConfigureApplicationCookie(option => { option.AccessDeniedPath = "/Account/AccessDenied"; option.LoginPath = "/Account/Login"; }); builder.Services.Configure(option => { option.Password.RequiredLength = 6; }); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); var app = builder.Build(); StripeConfiguration.ApiKey=builder.Configuration.GetSection("Stripe:SecretKey").Get(); SyncfusionLicenseProvider.RegisterLicense(builder.Configuration.GetSection("Syncfusion:Licensekey").Get()); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); SeedDatabase(); app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); app.Run(); void SeedDatabase() { using (var scope = app.Services.CreateScope()) { var dbInitializer = scope.ServiceProvider.GetRequiredService(); dbInitializer.Initialize(); } }