Skapat möjlighet att spara in flera resultat per participant och round
This commit is contained in:
@ -15,9 +15,18 @@ public class CombinedRepository : ICombinedRepository
|
||||
|
||||
public IEnumerable<RoundBuilderElement> roundBuilderElements()
|
||||
{
|
||||
var result = (from gameRound in _context.GameRounds
|
||||
join gamePoint in _context.GamePoints on gameRound.GameRoundId equals gamePoint.GameRoundId
|
||||
join participant in _context.Participants on gamePoint.ParticipantId equals participant.ParticipantId
|
||||
var latestGamePoints = _context.GamePoints
|
||||
.AsEnumerable()
|
||||
.GroupBy(gp => new { gp.GameRoundId, gp.ParticipantId })
|
||||
.Select(g => g.OrderByDescending(gp => gp.GamePointId).First())
|
||||
.ToList();
|
||||
|
||||
var gamerounds = _context.GameRounds.AsEnumerable();
|
||||
var participants = _context.Participants.AsEnumerable();
|
||||
|
||||
var result = (from gameRound in gamerounds
|
||||
join gamePoint in latestGamePoints on gameRound.GameRoundId equals gamePoint.GameRoundId
|
||||
join participant in participants on gamePoint.ParticipantId equals participant.ParticipantId
|
||||
orderby gameRound.GameRoundStartDate descending, participant.LastName, participant.FirstName, gamePoint.GameRoundRegNr
|
||||
select new RoundBuilderElement
|
||||
{
|
||||
@ -33,4 +42,27 @@ public class CombinedRepository : ICombinedRepository
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<RoundBuilderElement> roundBuilderElementsTotal()
|
||||
{
|
||||
|
||||
var result = (from gameRound in _context.GameRounds
|
||||
join gamePoint in _context.GamePoints on gameRound.GameRoundId equals gamePoint.GameRoundId
|
||||
join participant in _context.Participants on gamePoint.ParticipantId equals participant.ParticipantId
|
||||
orderby gameRound.GameRoundStartDate descending, participant.LastName, participant.FirstName, gamePoint.GameRoundRegNr
|
||||
select new RoundBuilderElement
|
||||
{
|
||||
ParticipantId = participant.ParticipantId,
|
||||
ParticipantName = participant.LastNameFirstName,
|
||||
GamePointId = gamePoint.GamePointId,
|
||||
GameRoundRegNr = gamePoint.GameRoundRegNr,
|
||||
GameRegPoints = gamePoint.GameRegPoints,
|
||||
GameRoundId = gameRound.GameRoundId,
|
||||
GameRoundStartDate = gameRound.GameRoundStartDate,
|
||||
Status = gameRound.GameStatus
|
||||
}).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user