Create Prize and create Team ready
This commit is contained in:
@ -71,7 +71,15 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Compile Include="BootStrapper.cs" />
|
<Compile Include="BootStrapper.cs" />
|
||||||
|
<Compile Include="ViewModels\CreatePrizeViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\CreateTeamViewModel.cs" />
|
||||||
<Compile Include="ViewModels\ShellViewModel.cs" />
|
<Compile Include="ViewModels\ShellViewModel.cs" />
|
||||||
|
<Compile Include="Views\CreatePrizeView.xaml.cs">
|
||||||
|
<DependentUpon>CreatePrizeView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Views\CreateTeamView.xaml.cs">
|
||||||
|
<DependentUpon>CreateTeamView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\ShellView.xaml.cs">
|
<Compile Include="Views\ShellView.xaml.cs">
|
||||||
<DependentUpon>ShellView.xaml</DependentUpon>
|
<DependentUpon>ShellView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -79,6 +87,14 @@
|
|||||||
<DependentUpon>App.xaml</DependentUpon>
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Page Include="Views\CreatePrizeView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
<Page Include="Views\CreateTeamView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\ShellView.xaml">
|
<Page Include="Views\ShellView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
104
TrackerWPFUI/ViewModels/CreatePrizeViewModel.cs
Normal file
104
TrackerWPFUI/ViewModels/CreatePrizeViewModel.cs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
using Caliburn.Micro;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TrackerLibrary;
|
||||||
|
using TrackerLibrary.Models;
|
||||||
|
|
||||||
|
namespace TrackerWPFUI.ViewModels
|
||||||
|
{
|
||||||
|
public class CreatePrizeViewModel : Screen
|
||||||
|
{
|
||||||
|
private int _placeNumber;
|
||||||
|
private string _placeName;
|
||||||
|
private decimal _prizeAmount;
|
||||||
|
private double _prizePercentage;
|
||||||
|
|
||||||
|
|
||||||
|
public int PlaceNumber
|
||||||
|
{
|
||||||
|
get { return _placeNumber; }
|
||||||
|
set {
|
||||||
|
_placeNumber = value;
|
||||||
|
NotifyOfPropertyChange(() => PlaceNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string PlaceName
|
||||||
|
{
|
||||||
|
get { return _placeName; }
|
||||||
|
set { _placeName = value;
|
||||||
|
NotifyOfPropertyChange(() => PlaceName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public decimal PrizeAmount
|
||||||
|
{
|
||||||
|
get { return _prizeAmount; }
|
||||||
|
set { _prizeAmount = value;
|
||||||
|
NotifyOfPropertyChange(() => PrizeAmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public double PrizePercentage
|
||||||
|
{
|
||||||
|
get { return _prizePercentage; }
|
||||||
|
set { _prizePercentage = value;
|
||||||
|
NotifyOfPropertyChange(() => PrizePercentage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanCreatePrize(int placeNumber, string placeName, decimal prizeAmount, double prizePercentage)
|
||||||
|
{
|
||||||
|
return ValidateForm(placeNumber, placeName, prizeAmount, prizePercentage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreatePrize(int placeNumber, string placeName, decimal prizeAmount, double prizePercentage)
|
||||||
|
{
|
||||||
|
PrizeModel model = new PrizeModel
|
||||||
|
{
|
||||||
|
PlaceNumber = placeNumber,
|
||||||
|
PlaceName = placeName,
|
||||||
|
PrizeAmount = prizeAmount,
|
||||||
|
PrizePercentage = prizePercentage
|
||||||
|
};
|
||||||
|
GlobalConfig.Connection.CreatePrize(model);
|
||||||
|
|
||||||
|
//TODO Close out the form and alert the calling form
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ValidateForm(int placeNumber, string placeName, decimal prizeAmount, double prizePercentage)
|
||||||
|
{
|
||||||
|
bool output = true;
|
||||||
|
|
||||||
|
|
||||||
|
if (placeNumber < 1)
|
||||||
|
{
|
||||||
|
output = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (placeName.Length == 0)
|
||||||
|
{
|
||||||
|
output = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prizeAmount <= 0 && prizePercentage <= 0)
|
||||||
|
{
|
||||||
|
output = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prizePercentage < 0 || prizePercentage > 100)
|
||||||
|
{
|
||||||
|
output = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
145
TrackerWPFUI/ViewModels/CreateTeamViewModel.cs
Normal file
145
TrackerWPFUI/ViewModels/CreateTeamViewModel.cs
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
using Caliburn.Micro;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TrackerLibrary;
|
||||||
|
using TrackerLibrary.Models;
|
||||||
|
|
||||||
|
namespace TrackerWPFUI.ViewModels
|
||||||
|
{
|
||||||
|
public class CreateTeamViewModel : Conductor<object>
|
||||||
|
{
|
||||||
|
private string _teamName = "";
|
||||||
|
private BindableCollection<PersonModel> _availableTeamMembers;
|
||||||
|
private PersonModel _selectedTeamMemberToAdd;
|
||||||
|
private BindableCollection<PersonModel> _selectedTeamMembers = new BindableCollection<PersonModel>();
|
||||||
|
private PersonModel _selectedTeamMemberToRemove;
|
||||||
|
|
||||||
|
public CreateTeamViewModel()
|
||||||
|
{
|
||||||
|
AvailableTeamMembers = new BindableCollection<PersonModel>(GlobalConfig.Connection.GetPerson_All());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string TeamName
|
||||||
|
{
|
||||||
|
get { return _teamName; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_teamName = value;
|
||||||
|
NotifyOfPropertyChange(() => TeamName);
|
||||||
|
NotifyOfPropertyChange(() => CanCreateTeam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BindableCollection<PersonModel> AvailableTeamMembers
|
||||||
|
{
|
||||||
|
get { return _availableTeamMembers; }
|
||||||
|
set { _availableTeamMembers = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public BindableCollection<PersonModel> SelectedTeamMembers
|
||||||
|
{
|
||||||
|
get { return _selectedTeamMembers; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_selectedTeamMembers = value;
|
||||||
|
NotifyOfPropertyChange(() => CanCreateTeam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PersonModel SelectedTeamMemberToAdd
|
||||||
|
{
|
||||||
|
get { return _selectedTeamMemberToAdd; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_selectedTeamMemberToAdd = value;
|
||||||
|
NotifyOfPropertyChange(() => SelectedTeamMemberToAdd);
|
||||||
|
NotifyOfPropertyChange(() => CanAddMember);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanAddMember
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return SelectedTeamMemberToAdd != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddMember()
|
||||||
|
{
|
||||||
|
SelectedTeamMembers.Add(SelectedTeamMemberToAdd);
|
||||||
|
AvailableTeamMembers.Remove(SelectedTeamMemberToAdd );
|
||||||
|
NotifyOfPropertyChange(() => CanCreateTeam);
|
||||||
|
}
|
||||||
|
public PersonModel SelectedTeamMemberToRemove
|
||||||
|
{
|
||||||
|
get { return _selectedTeamMemberToRemove; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_selectedTeamMemberToRemove = value;
|
||||||
|
NotifyOfPropertyChange(() => SelectedTeamMemberToRemove);
|
||||||
|
NotifyOfPropertyChange(() => CanRemoveMember);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanRemoveMember
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return SelectedTeamMemberToRemove != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveMember()
|
||||||
|
{
|
||||||
|
AvailableTeamMembers.Add(SelectedTeamMemberToRemove);
|
||||||
|
SelectedTeamMembers.Remove(SelectedTeamMemberToRemove);
|
||||||
|
NotifyOfPropertyChange(() => CanCreateTeam);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateMember()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public bool CanCreateTeam
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (SelectedTeamMembers != null)
|
||||||
|
{
|
||||||
|
if (TeamName.Length > 0 && SelectedTeamMembers.Count > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateTeam()
|
||||||
|
{
|
||||||
|
TeamModel t = new TeamModel();
|
||||||
|
t.TeamName = TeamName;
|
||||||
|
t.TeamMembers = SelectedTeamMembers.ToList();
|
||||||
|
|
||||||
|
GlobalConfig.Connection.CreateTeam(t);
|
||||||
|
|
||||||
|
//TODO - Pass the team back to the parent and close the form
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,7 +9,7 @@ using TrackerLibrary.Models;
|
|||||||
|
|
||||||
namespace TrackerWPFUI.ViewModels
|
namespace TrackerWPFUI.ViewModels
|
||||||
{
|
{
|
||||||
public class ShellViewModel : Conductor<object>
|
public class ShellViewModel : Conductor<object> //ActiveItem in Itemcontrol tells whats going on
|
||||||
{
|
{
|
||||||
|
|
||||||
public ShellViewModel()
|
public ShellViewModel()
|
||||||
@ -17,6 +17,8 @@ namespace TrackerWPFUI.ViewModels
|
|||||||
// Initialize the database connections
|
// Initialize the database connections
|
||||||
GlobalConfig.InitializeConnections(DatabaseType.Sql);
|
GlobalConfig.InitializeConnections(DatabaseType.Sql);
|
||||||
_existingTournaments = new BindableCollection<TournamentModel>(GlobalConfig.Connection.GetTournament_All());
|
_existingTournaments = new BindableCollection<TournamentModel>(GlobalConfig.Connection.GetTournament_All());
|
||||||
|
//ActivateItem(new CreatePrizeViewModel());
|
||||||
|
ActivateItem(new CreateTeamViewModel());
|
||||||
}
|
}
|
||||||
public void CreateTournament()
|
public void CreateTournament()
|
||||||
{
|
{
|
||||||
|
|||||||
51
TrackerWPFUI/Views/CreatePrizeView.xaml
Normal file
51
TrackerWPFUI/Views/CreatePrizeView.xaml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<UserControl x:Class="TrackerWPFUI.Views.CreatePrizeView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:TrackerWPFUI.Views"
|
||||||
|
mc:Ignorable="d" Background="White"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
|
<Grid>
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<TextBlock FontSize="24" Margin="0 0 0 10" >Create Prize</TextBlock>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="auto"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!--row 0-->
|
||||||
|
<TextBlock Margin="5 0 10 10" Grid.Column="0" Grid.Row="0">Place Number</TextBlock>
|
||||||
|
<TextBox x:Name="PlaceNumber" Margin="0 0 5 10" Grid.Column="1" Grid.Row="0"></TextBox>
|
||||||
|
<!--row 1-->
|
||||||
|
<TextBlock Margin="5 0 10 10" Grid.Column="0" Grid.Row="1">Place Name</TextBlock>
|
||||||
|
<TextBox x:Name="PlaceName" Margin="0 0 5 10" Grid.Column="1" Grid.Row="1"></TextBox>
|
||||||
|
<!--row 2-->
|
||||||
|
<TextBlock Margin="5 0 10 10" Grid.Column="0" Grid.Row="2">Prize Amount</TextBlock>
|
||||||
|
<TextBox x:Name="PrizeAmount" Margin="0 0 5 10" Grid.Column="2" Grid.Row="2"></TextBox>
|
||||||
|
<!--row 3-->
|
||||||
|
<TextBlock Margin="5 0 5 10" Grid.Column="0" Grid.Row="3"
|
||||||
|
HorizontalAlignment="Center" Grid.ColumnSpan="2">
|
||||||
|
-- OR --
|
||||||
|
</TextBlock>
|
||||||
|
<!--row 4-->
|
||||||
|
<TextBlock Margin="5 0 10 10" Grid.Column="0" Grid.Row="4">Prize Percentage</TextBlock>
|
||||||
|
<TextBox x:Name="PrizePercentage" Margin="0 0 5 10" Grid.Column="2" Grid.Row="4"></TextBox>
|
||||||
|
<!--row 4-->
|
||||||
|
<Button x:Name="CreatePrize" Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="2" Padding="10" Margin="5 0 ">
|
||||||
|
Create Prize
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
28
TrackerWPFUI/Views/CreatePrizeView.xaml.cs
Normal file
28
TrackerWPFUI/Views/CreatePrizeView.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace TrackerWPFUI.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for CreatePrizeView.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class CreatePrizeView : UserControl
|
||||||
|
{
|
||||||
|
public CreatePrizeView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
30
TrackerWPFUI/Views/CreateTeamView.xaml
Normal file
30
TrackerWPFUI/Views/CreateTeamView.xaml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<UserControl x:Class="TrackerWPFUI.Views.CreateTeamView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:TrackerWPFUI.Views"
|
||||||
|
mc:Ignorable="d" Background="White"
|
||||||
|
d:DesignHeight="300" d:DesignWidth="300">
|
||||||
|
<Grid>
|
||||||
|
<StackPanel Orientation="Vertical" >
|
||||||
|
<TextBlock FontSize="24">Create Team</TextBlock>
|
||||||
|
<TextBlock Margin="5 0 5 5">Team Name</TextBlock>
|
||||||
|
<TextBox x:Name="TeamName" Margin="5 0 5 10 "></TextBox>
|
||||||
|
<TextBlock Margin="5 0 5 5">Select Team Member</TextBlock>
|
||||||
|
<ComboBox x:Name="AvailableTeamMembers" Margin="5 0 5 10"
|
||||||
|
SelectedItem="{Binding Path=SelectedTeamMemberToAdd, Mode=OneWayToSource}"
|
||||||
|
DisplayMemberPath="FullName"/>
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||||
|
<Button x:Name="AddMember" Padding="5" Margin="0 0 5 0">Add Member</Button>
|
||||||
|
<Button x:Name="CreateMember" Padding="5" >Create Member</Button>
|
||||||
|
<Button x:Name="RemoveMember" Padding="5" Margin="5 0 0 0">Remove Member</Button>
|
||||||
|
</StackPanel>
|
||||||
|
<TextBlock Margin="5 0 5 10" >Selected Team Members</TextBlock>
|
||||||
|
<ListBox x:Name="SelectedTeamMembers" DisplayMemberPath="FullName"
|
||||||
|
Margin="5 0 5 0" MinHeight="20"
|
||||||
|
SelectedItem="{Binding Path=SelectedTeamMemberToRemove, Mode=TwoWay}" />
|
||||||
|
<Button x:Name="CreateTeam" Margin="5 10 5 5" Padding="5" >Create Team</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
28
TrackerWPFUI/Views/CreateTeamView.xaml.cs
Normal file
28
TrackerWPFUI/Views/CreateTeamView.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace TrackerWPFUI.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for CreateTeamView.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class CreateTeamView : UserControl
|
||||||
|
{
|
||||||
|
public CreateTeamView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -36,6 +36,6 @@
|
|||||||
<!--<TextBlock x:Name="SelectedTournament_TournamentName"/>-->
|
<!--<TextBlock x:Name="SelectedTournament_TournamentName"/>-->
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<ContentControl Grid.Row="2" Grid.Column="2"/>
|
<ContentControl x:Name="ActiveItem" Grid.Row="2" Grid.Column="2"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
Reference in New Issue
Block a user