| | 1 | | using LGDXRobotCloud.Data.DbContexts; |
| | 2 | | using LGDXRobotCloud.Data.Entities; |
| | 3 | | using LGDXRobotCloud.Data.Services; |
| | 4 | | using Microsoft.EntityFrameworkCore; |
| | 5 | |
|
| | 6 | |
|
| 0 | 7 | | var builder = WebApplication.CreateBuilder(args); |
| 0 | 8 | | builder.Services.AddDbContextPool<LgdxContext>(cfg => |
| 0 | 9 | | cfg.UseNpgsql(builder.Configuration["PGSQLConnectionString"]) |
| 0 | 10 | | .LogTo(Console.WriteLine, LogLevel.Information) |
| 0 | 11 | | .EnableSensitiveDataLogging() |
| 0 | 12 | | .EnableDetailedErrors() |
| 0 | 13 | | ); |
| | 14 | |
|
| 0 | 15 | | bool initializeData = bool.Parse(builder.Configuration["initialiseData"] ?? "false"); |
| 0 | 16 | | if (initializeData) |
| 0 | 17 | | { |
| | 18 | | // Check connfig |
| 0 | 19 | | if (string.IsNullOrEmpty(builder.Configuration["email"]) || |
| 0 | 20 | | string.IsNullOrEmpty(builder.Configuration["fullName"]) || |
| 0 | 21 | | string.IsNullOrEmpty(builder.Configuration["userName"]) || |
| 0 | 22 | | string.IsNullOrEmpty(builder.Configuration["password"])) |
| 0 | 23 | | { |
| 0 | 24 | | Console.WriteLine("Please provide the following configurations for the first user: Email, Full Name, userName, passw |
| 0 | 25 | | Environment.Exit(1); |
| 0 | 26 | | } |
| | 27 | |
|
| 0 | 28 | | builder.Services.AddIdentity<LgdxUser, LgdxRole>() |
| 0 | 29 | | .AddEntityFrameworkStores<LgdxContext>(); |
| 0 | 30 | | builder.Services.AddHostedService<InitialiseDataRunner>(); |
| 0 | 31 | | } |
| | 32 | |
|
| 0 | 33 | | var app = builder.Build(); |
| 0 | 34 | | app.Run(); |