Övergått till entity framework + lagt till ny tabell
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user