From 94056f5f0802dba62378ebae3d63406e0fe1075f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Sun, 17 May 2020 20:30:24 +0200 Subject: [PATCH] CreatePerson UI tillaggt --- TrackerWPFUI/EventAggregationProvider.cs | 14 ++++ TrackerWPFUI/TrackerWPFUI.csproj | 9 +++ .../ViewModels/CreatePersonViewModel.cs | 79 +++++++++++++++++++ TrackerWPFUI/ViewModels/ShellViewModel.cs | 3 +- TrackerWPFUI/Views/CreatePersonView.xaml | 46 +++++++++++ TrackerWPFUI/Views/CreatePersonView.xaml.cs | 28 +++++++ TrackerWPFUI/Views/CreatePrizeView.xaml | 2 +- TrackerWPFUI/Views/CreateTeamView.xaml | 2 +- 8 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 TrackerWPFUI/EventAggregationProvider.cs create mode 100644 TrackerWPFUI/ViewModels/CreatePersonViewModel.cs create mode 100644 TrackerWPFUI/Views/CreatePersonView.xaml create mode 100644 TrackerWPFUI/Views/CreatePersonView.xaml.cs diff --git a/TrackerWPFUI/EventAggregationProvider.cs b/TrackerWPFUI/EventAggregationProvider.cs new file mode 100644 index 0000000..0e6cc0a --- /dev/null +++ b/TrackerWPFUI/EventAggregationProvider.cs @@ -0,0 +1,14 @@ +using Caliburn.Micro; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TrackerWPFUI +{ + public static class EventAggregationProvider + { + public static EventAggregator TrackerEventAggregator { get; set; } = new EventAggregator(); + } +} diff --git a/TrackerWPFUI/TrackerWPFUI.csproj b/TrackerWPFUI/TrackerWPFUI.csproj index d88b24d..2c43595 100644 --- a/TrackerWPFUI/TrackerWPFUI.csproj +++ b/TrackerWPFUI/TrackerWPFUI.csproj @@ -71,9 +71,14 @@ Designer + + + + CreatePersonView.xaml + CreatePrizeView.xaml @@ -87,6 +92,10 @@ App.xaml Code + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/TrackerWPFUI/ViewModels/CreatePersonViewModel.cs b/TrackerWPFUI/ViewModels/CreatePersonViewModel.cs new file mode 100644 index 0000000..83f7f0c --- /dev/null +++ b/TrackerWPFUI/ViewModels/CreatePersonViewModel.cs @@ -0,0 +1,79 @@ +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 CreatePersonViewModel:Screen + { + private string _firstName=""; + private string _lastName = ""; + private string _email = ""; + private string _cellphone = ""; + + + + public string FirstName + { + get { return _firstName; } + set { _firstName = value; + NotifyOfPropertyChange(() => FirstName); + } + } + + public string LastName + { + get { return _lastName; } + set { _lastName = value; + NotifyOfPropertyChange(() => LastName); + } + } + + public string Email + { + get { return _email; } + set { _email = value; + NotifyOfPropertyChange(() => Email); + } + } + + public string Cellphone + { + get { return _cellphone; } + set { _cellphone = value; + NotifyOfPropertyChange(() => Cellphone); + } + } + + public bool CanCreatePerson(string firstName, string lastName, string email, string cellphone) + { + if(firstName.Length>0 && lastName.Length>0 && email.Length>0 && cellphone.Length > 0) + { + return true; + } + else + { + return false; + } + } + + public void CreatePerson(string firstName, string lastName, string email,string cellphone) + { + PersonModel p = new PersonModel(); + + p.FirstName = firstName; + p.LastName = lastName; + p.EmailAddress = email; + p.CellPhoneNumber = cellphone; + + GlobalConfig.Connection.CreatePerson(p); + + //TODO - Send results back to parent and close + } + } +} diff --git a/TrackerWPFUI/ViewModels/ShellViewModel.cs b/TrackerWPFUI/ViewModels/ShellViewModel.cs index 42f1553..85f0774 100644 --- a/TrackerWPFUI/ViewModels/ShellViewModel.cs +++ b/TrackerWPFUI/ViewModels/ShellViewModel.cs @@ -18,7 +18,8 @@ namespace TrackerWPFUI.ViewModels GlobalConfig.InitializeConnections(DatabaseType.Sql); _existingTournaments = new BindableCollection(GlobalConfig.Connection.GetTournament_All()); //ActivateItem(new CreatePrizeViewModel()); - ActivateItem(new CreateTeamViewModel()); + //ActivateItem(new CreateTeamViewModel()); + ActivateItem(new CreatePersonViewModel()); } public void CreateTournament() { diff --git a/TrackerWPFUI/Views/CreatePersonView.xaml b/TrackerWPFUI/Views/CreatePersonView.xaml new file mode 100644 index 0000000..b6fa05f --- /dev/null +++ b/TrackerWPFUI/Views/CreatePersonView.xaml @@ -0,0 +1,46 @@ + + + + Create Person + + + + + + + + + + + + + + + + + First Name + + + Last Name + + + Email + + + Cellphone + + + + + + + diff --git a/TrackerWPFUI/Views/CreatePersonView.xaml.cs b/TrackerWPFUI/Views/CreatePersonView.xaml.cs new file mode 100644 index 0000000..63834e4 --- /dev/null +++ b/TrackerWPFUI/Views/CreatePersonView.xaml.cs @@ -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 +{ + /// + /// Interaction logic for CreatePersonView.xaml + /// + public partial class CreatePersonView : UserControl + { + public CreatePersonView() + { + InitializeComponent(); + } + } +} diff --git a/TrackerWPFUI/Views/CreatePrizeView.xaml b/TrackerWPFUI/Views/CreatePrizeView.xaml index 3394749..2d6dddd 100644 --- a/TrackerWPFUI/Views/CreatePrizeView.xaml +++ b/TrackerWPFUI/Views/CreatePrizeView.xaml @@ -4,7 +4,7 @@ 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" + mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> diff --git a/TrackerWPFUI/Views/CreateTeamView.xaml b/TrackerWPFUI/Views/CreateTeamView.xaml index 28c87af..1e6a3a0 100644 --- a/TrackerWPFUI/Views/CreateTeamView.xaml +++ b/TrackerWPFUI/Views/CreateTeamView.xaml @@ -4,7 +4,7 @@ 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" + mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">