38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|