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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,4 +6,5 @@ namespace GreadyPoang.DataLayer;
|
||||
public interface ICombinedRepository
|
||||
{
|
||||
IEnumerable<RoundBuilderElement> roundBuilderElements();
|
||||
IEnumerable<RoundBuilderElement> roundBuilderElementsTotal();
|
||||
}
|
||||
@ -4,6 +4,13 @@
|
||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
|
||||
|
||||
<Style x:Key="ScoreCellStyle" TargetType="Border">
|
||||
<Setter Property="Stroke" Value="Gray" />
|
||||
<Setter Property="StrokeThickness" Value="1" />
|
||||
<Setter Property="Padding" Value="5" />
|
||||
<Setter Property="BackgroundColor" Value="LightGray" />
|
||||
</Style>
|
||||
|
||||
<x:String x:Key="ApplicationTitle">
|
||||
Gready Poäng
|
||||
</x:String>
|
||||
|
||||
@ -98,9 +98,9 @@
|
||||
<ScrollView Grid.Row="4">
|
||||
<Grid
|
||||
x:Name="ScoreGrid"
|
||||
ColumnSpacing="10"
|
||||
RowSpacing="10"
|
||||
Padding="10"
|
||||
ColumnSpacing="5"
|
||||
RowSpacing="5"
|
||||
Padding="3"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand" />
|
||||
</ScrollView>
|
||||
|
||||
@ -20,44 +20,66 @@ public partial class RoundRunningView : ContentPage
|
||||
|
||||
}
|
||||
public RoundRunningViewModelCommands ViewModel { get; set; }
|
||||
//public int GameRoundId { get; set; }
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
private void BuildScoreGrid(IEnumerable<PlayerColumn> columns)
|
||||
{
|
||||
ScoreGrid.ColumnDefinitions.Clear();
|
||||
ScoreGrid.RowDefinitions.Clear();
|
||||
ScoreGrid.Children.Clear();
|
||||
|
||||
int maxRows = columns.Max(c => c.Values.Count);
|
||||
|
||||
// Skapa rader
|
||||
for (int row = 0; row < maxRows + 1; row++) // +1 f<>r rubrikraden
|
||||
{
|
||||
ScoreGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
}
|
||||
|
||||
int colIndex = 0;
|
||||
foreach (var column in columns)
|
||||
{
|
||||
ScoreGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
|
||||
var stack = new VerticalStackLayout();
|
||||
var headerCell = CreateCell(column.PlayerName, isHeader: true);
|
||||
ScoreGrid.Children.Add(headerCell);
|
||||
Grid.SetRow(headerCell, 0);
|
||||
Grid.SetColumn(headerCell, colIndex);
|
||||
|
||||
stack.Children.Add(new Label
|
||||
// V<>rdeceller
|
||||
for (int rowIndex = 0; rowIndex < column.Values.Count; rowIndex++)
|
||||
{
|
||||
Text = column.PlayerName,
|
||||
FontAttributes = FontAttributes.Bold,
|
||||
HorizontalOptions = LayoutOptions.Center
|
||||
});
|
||||
|
||||
foreach (var value in column.Values)
|
||||
{
|
||||
stack.Children.Add(new Label
|
||||
{
|
||||
Text = value,
|
||||
HorizontalOptions = LayoutOptions.Center
|
||||
});
|
||||
var value = column.Values[rowIndex];
|
||||
var cell = CreateCell(value);
|
||||
ScoreGrid.Children.Add(cell);
|
||||
Grid.SetRow(cell, rowIndex + 1); // +1 f<>r att hoppa <20>ver rubrikraden
|
||||
Grid.SetColumn(cell, colIndex);
|
||||
}
|
||||
|
||||
ScoreGrid.Children.Add(stack);
|
||||
Grid.SetColumn(stack, colIndex++);
|
||||
colIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
private View CreateCell(string text, bool isHeader = false)
|
||||
{
|
||||
return new Border
|
||||
{
|
||||
Stroke = Colors.Gray,
|
||||
StrokeThickness = 1,
|
||||
BackgroundColor = isHeader ? Colors.DarkGray : Colors.Yellow,
|
||||
Margin = 1,
|
||||
Padding = 2,
|
||||
Content = new Label
|
||||
{
|
||||
Text = text,
|
||||
FontAttributes = isHeader ? FontAttributes.Bold : FontAttributes.None,
|
||||
TextColor = isHeader ? Colors.White : Colors.Black,
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
VerticalOptions = LayoutOptions.Center
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user