2024-12-04 23:32:04 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using data.RemoteData.RemoteDataBase;
|
|
|
|
|
using System;
|
2024-12-01 16:16:14 +00:00
|
|
|
|
|
|
|
|
|
namespace Presence.Desktop.ViewModels
|
|
|
|
|
{
|
2024-12-04 23:32:04 +00:00
|
|
|
|
public class MainWindowViewModel
|
2024-12-01 16:16:14 +00:00
|
|
|
|
{
|
2024-12-04 23:32:04 +00:00
|
|
|
|
public ObservableCollection<string> GroupNames { get; set; } = new ObservableCollection<string>();
|
|
|
|
|
|
|
|
|
|
private readonly IServiceProvider _services;
|
|
|
|
|
|
|
|
|
|
public MainWindowViewModel(IServiceProvider services)
|
|
|
|
|
{
|
|
|
|
|
_services = services;
|
|
|
|
|
GroupNames.Add("Group 1");
|
|
|
|
|
GroupNames.Add("Group 2");
|
|
|
|
|
GroupNames.Add("Group 3");
|
|
|
|
|
LoadGroupNames();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadGroupNames()
|
2024-12-01 16:16:14 +00:00
|
|
|
|
{
|
2024-12-04 23:32:04 +00:00
|
|
|
|
using (var context = _services.GetRequiredService<RemoteDatabaseContext>())
|
|
|
|
|
{
|
|
|
|
|
var groupNames = context.Groups.Select(g => g.Name).ToList();
|
|
|
|
|
foreach (var name in groupNames)
|
|
|
|
|
{
|
|
|
|
|
GroupNames.Add(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-01 16:16:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|