Övergått till entity framework + lagt till ny tabell

This commit is contained in:
2025-09-02 15:07:21 +02:00
parent b04fc7e06e
commit ddb6719587
22 changed files with 1175 additions and 95 deletions

View File

@ -55,15 +55,22 @@ public class ParticipantViewModel : ViewModelBase
#endregion
#region Get Method
public async Task<ObservableCollection<Participant>> GetAsync()
public ObservableCollection<Participant> Get()
{
if (Repository != null)
{
ParticipantList = await Repository.Get();
return ParticipantList;
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);
}
}
}
_ParticipantList = new ObservableCollection<Participant>();
return ParticipantList;
}
@ -74,7 +81,7 @@ public class ParticipantViewModel : ViewModelBase
{
try
{
ParticipantObject = Repository.Get(id);
ParticipantObject = Repository?.Get(id).GetAwaiter().GetResult();
}
catch (Exception ex)
{
@ -89,11 +96,12 @@ public class ParticipantViewModel : ViewModelBase
{
return false;
}
var tmp = Repository.Save(ParticipantObject);
var tmpTask = Repository.Save(ParticipantObject);
bool tmp = tmpTask.GetAwaiter().GetResult();
if (tmp)
{
ParticipantObject = new Participant();
this.GetAsync();
this.Get();
}
return tmp;
}