Till slut fick jag personvalet att fungera
This commit is contained in:
@ -84,13 +84,13 @@ public class ParticipantViewModel : ViewModelBase
|
||||
return false;
|
||||
}
|
||||
var tmpTask = _Repository.Save(ParticipantObject);
|
||||
bool tmp = tmpTask.GetAwaiter().GetResult();
|
||||
if (tmp)
|
||||
int tmp = tmpTask.GetAwaiter().GetResult();
|
||||
if (tmp != -1)
|
||||
{
|
||||
ParticipantObject = new Participant();
|
||||
this.Get();
|
||||
}
|
||||
return tmp;
|
||||
return tmp != -1;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@ -13,9 +13,10 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
|
||||
}
|
||||
|
||||
public RoundStartingViewModel(IRepository<GameRound> repo, IMethodSharingService<Participant> sharingService) : base()
|
||||
public RoundStartingViewModel(IRepository<GameRound> repo, IRepository<GamePoint> pointsRepo, IMethodSharingService<Participant> sharingService) : base()
|
||||
{
|
||||
_Repository = repo;
|
||||
_pointsRepo = pointsRepo;
|
||||
_sharingService = sharingService;
|
||||
_roundElements = new ObservableCollection<RoundBuilderElement>();
|
||||
}
|
||||
@ -26,6 +27,7 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
private ObservableCollection<GameRound> _GameRoundList = new();
|
||||
private ObservableCollection<Participant> _ParticipantList = new();
|
||||
private readonly IRepository<GameRound>? _Repository;
|
||||
private readonly IRepository<GamePoint> _pointsRepo;
|
||||
private readonly IMethodSharingService<Participant> _sharingService;
|
||||
private Participant _selectedItem;
|
||||
|
||||
@ -65,8 +67,38 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
GameRoundStartDate = DateTime.Now,
|
||||
GameRoundFinished = null
|
||||
};
|
||||
_Repository?.Save(GameRound).GetAwaiter().GetResult();
|
||||
var gameRoundId = _Repository?.Save(GameRound).GetAwaiter().GetResult();
|
||||
if (gameRoundId != null && gameRoundId != -1)
|
||||
{
|
||||
GameRound.GameRoundId = gameRoundId.Value;
|
||||
}
|
||||
GameRoundObject = GameRound;
|
||||
}
|
||||
|
||||
var GamePointStart = new GamePoint
|
||||
{
|
||||
ParticipantId = item.ParticipantId,
|
||||
GameRoundId = GameRoundObject?.GameRoundId ?? 0,
|
||||
GameDate = DateTime.Now,
|
||||
GameRoundRegNr = 0,
|
||||
GameRegPoints = 0,
|
||||
PointStatus = GamePointStatus.New
|
||||
};
|
||||
|
||||
var gamePointId = _pointsRepo.Save(GamePointStart).GetAwaiter().GetResult();
|
||||
GamePointStart.GamePointId = gamePointId;
|
||||
|
||||
var newElement = new RoundBuilderElement();
|
||||
newElement.ParticipantId = item.ParticipantId;
|
||||
newElement.ParticipantName = item.LastNameFirstName;
|
||||
newElement.GameRoundRegNr = GamePointStart.GameRoundRegNr;
|
||||
newElement.GameRegPoints = GamePointStart.GameRegPoints;
|
||||
newElement.Status = GamePointStart.PointStatus;
|
||||
newElement.GameRoundStartDate = GameRoundObject?.GameRoundStartDate ?? DateTime.Now;
|
||||
newElement.GameRoundId = GamePointStart.GameRoundId;
|
||||
newElement.GamePointId = GamePointStart.GamePointId;
|
||||
|
||||
_roundElements.Add(newElement);
|
||||
// Gör något med det valda objektet
|
||||
Debug.WriteLine($"Du valde: {item.LastNameFirstName}");
|
||||
}
|
||||
@ -151,7 +183,7 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
return false;
|
||||
}
|
||||
var tmpTask = _Repository.Save(GameRoundObject);
|
||||
bool tmp = tmpTask.GetAwaiter().GetResult();
|
||||
bool tmp = tmpTask.GetAwaiter().GetResult() != -1;
|
||||
if (tmp)
|
||||
{
|
||||
GameRoundObject = new GameRound();
|
||||
|
||||
Reference in New Issue
Block a user