presence/console_ui/Program.cs
2024-11-26 08:09:12 +03:00

37 lines
1.0 KiB
C#

using console_ui.UI;
using data;
using data.Repository;
using domain.Service;
using domain.UseCase;
using Microsoft.Extensions.DependencyInjection;
namespace console_ui
{
class Program
{
static void Main(string[] args)
{
IServiceCollection services = new ServiceCollection();
services
.AddDbContext<DatabaseContext>()
.AddSingleton<IGroupRepository, SQLGroupRepository>()
.AddSingleton<IGroupUseCase, GroupService>()
.AddSingleton<GroupUI>();
var serviceProvider = services.BuildServiceProvider();
var groupUI = serviceProvider.GetService<GroupUI>();
var repo = serviceProvider.GetService<IGroupRepository>();
printAllGroups(repo!);
}
static void printAllGroups(IGroupRepository groupRepository)
{
foreach (var item in groupRepository.GetAllGroups())
{
Console.WriteLine($"{item.Id} \t {item.Name}");
}
}
}
}