Modification Zarghatt

This commit is contained in:
2019-03-14 01:31:56 +01:00
parent ad07674711
commit 30ec8ae90b
9 changed files with 76 additions and 27 deletions

View File

@@ -149,9 +149,15 @@ namespace LaDOSE.DesktopApp.Services
return restResponse.Data;
}
public GameDTO UpdateGame(GameDTO eventUpdate)
public GameDTO UpdateGame(GameDTO game)
{
return Post("Api/Game", eventUpdate);
return Post("Api/Game", game);
}
public bool DeleteGame(int gameId)
{
var restRequest = new RestRequest($"/api/Game/{gameId}", Method.DELETE);
var restResponse = Client.Execute(restRequest);
return restResponse.IsSuccessful;
}
#endregion

View File

@@ -49,6 +49,7 @@ namespace LaDOSE.DesktopApp.ViewModels
{
_currentGame = value;
NotifyOfPropertyChange(()=>CurrentGame);
NotifyOfPropertyChange(() => CanDeleteGame);
}
}
@@ -60,8 +61,16 @@ namespace LaDOSE.DesktopApp.ViewModels
public void AddGame()
{
var item = new GameDTO();
this.Games.Add(item);
this.CurrentGame = item;
this.RestService.UpdateGame(item);
LoadGames();
}
public void DeleteGame()
{
this.RestService.DeleteGame(this.CurrentGame.Id);
LoadGames();
}
public bool CanDeleteGame => CurrentGame != null;
}
}

View File

@@ -197,8 +197,8 @@ namespace LaDOSE.DesktopApp.ViewModels
var findUser = FindUser(SelectedWpEvent.Id, SelectedGame);
var findUser2 = FindUser(SelectedWpEvent.Id, SelectedGame,true);
findUser.ForEach((e) => this.Players.AddUI(e,()=>NotifyOfPropertyChange(() => this.CanGenerate)));
findUser2.ForEach((e) => this.PlayersOptions.AddUI(e,null));
findUser.OrderBy(e=>e.Name).ToList().ForEach((e) => this.Players.AddUI(e,()=>NotifyOfPropertyChange(() => this.CanGenerate)));
findUser2.OrderBy(e => e.Name).ToList().ForEach((e) => this.PlayersOptions.AddUI(e,null));
}
}

View File

@@ -42,7 +42,9 @@
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Button Grid.Row="0" Grid.ColumnSpan="2" x:Name="AddGame">Add Games</Button>
<Button Grid.Row="0" Grid.Column="0" x:Name="AddGame">Add Game</Button>
<Button Grid.Row="0" Grid.Column="1" x:Name="DeleteGame">Delete Game</Button>
<Label Grid.Row="1" Grid.Column="0">Id</Label>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=CurrentGame.Id,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True"></TextBox>

View File

@@ -45,7 +45,7 @@
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<ListView Grid.Column="0" ItemsSource="{Binding ElementName=EventsList,Path=SelectedItem.WpBookings}"
<ListView Grid.Column="0" ItemsSource="{Binding ElementName=EventsList,Path=SelectedItem.WpBookings}"
x:Name="BookingList" IsTextSearchEnabled="True" TextSearch.TextPath="WpUser.Name" Margin="2" KeyUp="Copy">
<ListView.ItemTemplate>
<DataTemplate>