add architecture skeleton
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using GymLogAI.Application.Interfaces;
|
||||
using GymLogAI.Core.Abstractions;
|
||||
using GymLogAI.Persistence.Infrastructure;
|
||||
using GymLogAI.Persistence.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GymLogAI.Persistence;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddPersistence(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var connectionString = configuration.GetConnectionString("Postgres")
|
||||
?? "Host=localhost;Port=5432;Database=gymlogai;Username=postgres;Password=postgres";
|
||||
|
||||
services.AddDbContext<AppDbContext>(options => options.UseNpgsql(connectionString));
|
||||
|
||||
services.AddScoped<IUserRepository, UserRepository>();
|
||||
services.AddScoped<ITelegramMessageRepository, TelegramMessageRepository>();
|
||||
services.AddScoped<IWorkoutRepository, WorkoutRepository>();
|
||||
services.AddScoped<IExerciseRepository, ExerciseRepository>();
|
||||
services.AddSingleton<IClock, SystemClock>();
|
||||
services.AddSingleton<IIdGenerator, GuidIdGenerator>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user