pr1/presence/console_ui/Program.cs
2024-12-19 20:36:57 +03:00

39 lines
1017 B
C#

using console_ui;
using data;
using Demo.Data.RemoteData.RemoteDataBase;
using Demo.Data.Repository;
using Demo.Domain.UseCase;
using Demo.UI;
using domain.Service;
using domain.UseCase;
using Microsoft.Extensions.DependencyInjection;
void printAllGroups(IGroupRepository groupRepository)
{
foreach (var item in groupRepository.GetAllGroup())
{
Console.WriteLine($"{item.Id} {item.Name}");
}
}
IServiceCollection serviceCollection = new ServiceCollection();
serviceCollection
.AddDbContext<RemoteDatabaseContext>()
.AddSingleton<IGroupRepository, SQLGroupRepositoryImpl>()
.AddSingleton<IUserRepository, SQLUserRepositoryImpl>()
.AddSingleton<IPresenceRepository, SQLPresenceRepositoryImpl>()
.AddSingleton<UserUseCase>()
.AddSingleton<GroupUseCase>()
.AddSingleton<PresenceUseCase>()
.AddSingleton<MainMenuUI>();
var serivceProvider = serviceCollection.BuildServiceProvider();
var groupUi = serivceProvider.GetService<GroupUI>();
groupUi?.AddGroup();