presence_sample_v2/console_ui/Program.cs
2024-11-22 15:18:04 +03:00

32 lines
737 B
C#

using console_ui;
using data;
using data.Repository;
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, SQLGroupRepository>()
.AddSingleton<IGroupUseCase, GroupService>()
.AddSingleton<GroupUI>();
var serivceProvider = serviceCollection.BuildServiceProvider();
var groupUi = serivceProvider.GetService<GroupUI>();
groupUi?.AddGroup();