From feee23f1a851d9f50c87698659af1a73fc65b341 Mon Sep 17 00:00:00 2001 From: Nikolai Papin Date: Sat, 7 Sep 2024 17:24:12 +0300 Subject: [PATCH] Services connected in Program.cs --- Program.cs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Program.cs b/Program.cs index 7dcc4a2..dc5b7f8 100644 --- a/Program.cs +++ b/Program.cs @@ -4,11 +4,39 @@ using Serilog.Exceptions; using System.Text; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; - +using Renis.Database; +using Microsoft.EntityFrameworkCore; +using Renis.Repositories; +using Renis.Services.Jwt; +using renis_backend.Services.Polis; +using renis_backend.Services; +using renis_backend.Services.UserPolises; +using renis_backend.Services.Users; var builder = WebApplication.CreateBuilder(args); -// Add services to the container. +// Database context +builder.Services.AddDbContext(x => { + var Hostname=Environment.GetEnvironmentVariable("DB_HOSTNAME") ?? "localhost"; + var Port=Environment.GetEnvironmentVariable("DB_PORT") ?? "5432"; + var Name=Environment.GetEnvironmentVariable("DB_NAME") ?? "postgres"; + var Username=Environment.GetEnvironmentVariable("DB_USERNAME") ?? "postgres"; + var Password=Environment.GetEnvironmentVariable("DB_PASSWORD") ?? "postgres"; + x.UseNpgsql($"Server={Hostname}:{Port};Database={Name};Uid={Username};Pwd={Password};"); +}); + +// Repos +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Services +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen();