Quick and Dirty Tournament Result / List

This commit is contained in:
2019-05-30 00:42:12 +02:00
parent 9b148fa571
commit 102a6af8e0
14 changed files with 407 additions and 37 deletions

View File

@@ -38,8 +38,7 @@ namespace LaDOSE.DesktopApp.ViewModels
var restService = IoC.Get<RestService>();
restService.UpdatedJwtEvent += TokenUpdate;
restService.Connect(uri, user, password);
var wordPressViewModel = new WordPressViewModel(IoC.Get<RestService>());
ActivateItem(wordPressViewModel);
base.OnInitialize();
@@ -52,7 +51,7 @@ namespace LaDOSE.DesktopApp.ViewModels
public BitmapFrame AppIcon { get; set; }
public void LoadEvent()
{
ActivateItem(new WordPressViewModel(IoC.Get<RestService>()));
@@ -64,7 +63,7 @@ namespace LaDOSE.DesktopApp.ViewModels
public void TournamentResult()
{
ActivateItem(new TournamentResultViewModel());
ActivateItem(new TournamentResultViewModel(IoC.Get<RestService>()));
}
}
}

View File

@@ -1,4 +1,10 @@
using Caliburn.Micro;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Caliburn.Micro;
using LaDOSE.DTO;
using LaDOSE.REST;
namespace LaDOSE.DesktopApp.ViewModels
{
@@ -7,5 +13,86 @@ namespace LaDOSE.DesktopApp.ViewModels
public class TournamentResultViewModel : Screen
{
public override string DisplayName => "Tournament Result";
private RestService RestService { get; set; }
public TournamentResultViewModel(RestService restService)
{
this.RestService = restService;
_selectedTournaments = new ObservableCollection<TournamentDTO>();
Tournaments = new List<TournamentDTO>();
}
private ObservableCollection<TournamentDTO> _selectedTournaments;
private TournamentsResultDTO _results;
public List<TournamentDTO> Tournaments { get; set; }
public TournamentsResultDTO Results
{
get => _results;
set
{
_results = value;
NotifyOfPropertyChange(() => Results);
}
}
public ObservableCollection<TournamentDTO> SelectedTournaments
{
get { return _selectedTournaments; }
set
{
_selectedTournaments = value;
NotifyOfPropertyChange(() => SelectedTournaments);
}
}
private GameDTO _selectedGame;
public GameDTO SelectedGame
{
get { return _selectedGame; }
set
{
_selectedGame = value;
//TODO: QUICK AND DIRTY
var resultForGame = this.Results.Results.Where(e => e.GameId == SelectedGame.Id).ToList();
First = resultForGame.OrderByDescending(e=>e.Point).First().Player;
NotifyOfPropertyChange(() => SelectedGame);
}
}
private String _first;
public String First
{
get { return _first; }
set
{
_first = value;
NotifyOfPropertyChange(() => First);
}
}
protected override void OnInitialize()
{
LoadTournaments();
base.OnInitialize();
}
public void LoadTournaments()
{
var tournamentDtos = this.RestService.GetTournaments().ToList();
this.Tournaments = tournamentDtos;
NotifyOfPropertyChange("Tournaments");
}
public void Select()
{
var tournamentsIds = SelectedTournaments.Select(e => e.Id).ToList();
var resultsDto = this.RestService.GetResults(tournamentsIds);
this.Results = resultsDto;
}
}
}

View File

@@ -13,13 +13,86 @@
d:DesignHeight="450" d:DesignWidth="800">
<Grid Row="2" Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="2*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Grid.Row="0" x:Name="LoadTournaments">Update</Button>
<ListView Grid.Row="1" ItemsSource="{Binding Tournaments}" x:Name="TournamentList" Margin="0,0,0,5"
IsTextSearchEnabled="True" TextSearch.TextPath="Name" behaviors:MultiSelectorBehaviours.SynchronizedSelectedItems="{Binding SelectedTournaments}"
SelectionMode="Multiple">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Id}" />
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
<TextBlock > - </TextBlock>
<TextBlock Margin="5,0,0,0" Text="{Binding Game.Name}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</Grid>
</ListView>
<Grid Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.ColumnSpan="3" x:Name="Select">Select</Button>
<StackPanel Grid.Row="1" Grid.ColumnSpan="3" Orientation="Horizontal">
<TextBlock> Jeux :</TextBlock>
<TextBlock Margin="5,0,0,0" Text="{Binding Results.Games.Count}" />
</StackPanel>
<ListView Grid.Row="2" ItemsSource="{Binding Results.Games}" Margin="5,5,5,5"
IsTextSearchEnabled="True" TextSearch.TextPath="Name" SelectedItem="{Binding SelectedGame, UpdateSourceTrigger=PropertyChanged}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Id}" />
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal">
<TextBlock> Participents :</TextBlock>
<TextBlock Margin="5,0,0,0" Text="{Binding Results.Participents.Count}" />
</StackPanel>
<ListView Grid.Row="2" Grid.Column="1" ItemsSource="{Binding Results.Participents}" Margin="5,5,5,5"
IsTextSearchEnabled="True" TextSearch.TextPath="Name">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackPanel Grid.Row="2" Grid.Column="2">
<TextBlock>Resultat :</TextBlock>
<StackPanel Orientation="Horizontal">
<TextBlock> First : </TextBlock>
<TextBlock Text="{Binding First,UpdateSourceTrigger=PropertyChanged}"> </TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock> Second :</TextBlock>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
</UserControl>