Files
GreadyPoang/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs
2025-09-17 12:34:10 +02:00

74 lines
2.1 KiB
C#

using Common.Library;
using GreadyPoang.DataLayer;
using GreadyPoang.EntityLayer;
using GreadyPoang.Services;
using System.Collections.ObjectModel;
using System.Diagnostics;
namespace GreadyPoang.ViewModelLayer;
public class RoundRunningViewModel : ViewModelBase
{
public RoundRunningViewModel() : base()
{
}
public RoundRunningViewModel(
IRepository<GameRound> roundsRepo,
IRepository<GamePoint> pointsRepo,
IMethodSharingService<Participant> sharingService,
ICombinedRepository combined,
IObjectMessageService objectMessage
) : base()
{
_roundsRepo = roundsRepo;
_pointsRepo = pointsRepo;
_sharingService = sharingService;
_combined = combined;
_objectMessage = objectMessage;
_roundElements = new ObservableCollection<RoundBuilderElement>();
}
private readonly IRepository<GameRound>? _roundsRepo;
private readonly IRepository<GamePoint> _pointsRepo;
private readonly IMethodSharingService<Participant> _sharingService;
private readonly ICombinedRepository _combined;
private readonly IObjectMessageService _objectMessage;
private ObservableCollection<RoundBuilderElement> _roundElements;
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
private ObservableCollection<Participant> _ParticipantList = new();
public ObservableCollection<RoundBuilderElement> RoundElements
{
get { return _roundElements; }
set
{
_roundElements = value;
RaisePropertyChanged(nameof(RoundElements));
}
}
//Ny kommentar för att testa Gitea
public ObservableCollection<RoundBuilderElement> Get()
{
if (_objectMessage.CurrentGroup != null)
{
Debug.WriteLine($"Chosen round: {_objectMessage.CurrentGroup.GameRoundId}");
if (RoundElements.Count > 0)
{
RoundElements.Clear();
}
foreach (var item in _objectMessage.CurrentGroup.Elements)
{
_roundElements.Add(item);
}
}
return RoundElements;
}
}