Börjat på RoundBuilding avsnittet , skall ändra save-svar från bool till int

This commit is contained in:
2025-09-05 14:52:08 +02:00
parent 4caeb21b0d
commit d3c9dcb208
10 changed files with 373 additions and 29 deletions

View File

@ -0,0 +1,37 @@
using Common.Library;
using GreadyPoang.EntityLayer;
using System.Collections.ObjectModel;
namespace GreadyPoang.ViewModelLayer;
public class MethodSharingService : ViewModelBase, IMethodSharingService<Participant>
{
private readonly IRepository<Participant> _repository;
public MethodSharingService(IRepository<Participant> repository)
{
_repository = repository;
}
public ObservableCollection<Participant> Get()
{
ObservableCollection<Participant> _participantList = new();
if (_repository != null)
{
var participantsTask = _repository.Get();
var participants = participantsTask is Task<IEnumerable<Participant>> task
? task.GetAwaiter().GetResult()
: (IEnumerable<Participant>)participantsTask;
foreach (var participant in participants)
{
if (!_participantList.Any(p => p.ParticipantId == participant.ParticipantId))
{
_participantList.Add(participant);
}
}
}
return _participantList;
}
}