Börjat på RoundBuilding avsnittet , skall ändra save-svar från bool till int
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user