diff options
author | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-03 18:50:00 +0200 |
---|---|---|
committer | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-03 18:50:00 +0200 |
commit | 783c339ad3c2e7d5a071fe68613f1962fb022072 (patch) | |
tree | f9ad3043e5f59a3353b5f87d8df9e3bf1b142312 | |
parent | a06cc4d120e396a5608bdab1dd1334383ddc79f9 (diff) |
resident
-rw-r--r-- | ApartmentManager/ApartmentManager/ApartmentManager.csproj | 2 | ||||
-rw-r--r-- | ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs | 19 | ||||
-rw-r--r-- | ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs | 55 | ||||
-rw-r--r-- | ApartmentManager/ApartmentManager/View/ResidentsPage.xaml | 4 | ||||
-rw-r--r-- | ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs | 18 | ||||
-rw-r--r-- | HousingDatabase.ldf | bin | 8388608 -> 8388608 bytes | |||
-rw-r--r-- | HousingDatabase.mdf | bin | 8388608 -> 8388608 bytes |
7 files changed, 66 insertions, 32 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj index 21b1952..24202c3 100644 --- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj +++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj @@ -100,7 +100,7 @@ </Compile> <Compile Include="Common\RelayCommand.cs" /> <Compile Include="Controls\NavMenuListView.cs" /> - <Compile Include="Handler\ApartmentHandler.cs" /> + <Compile Include="Handler\ResidentsHandler.cs" /> <Compile Include="Model\Apartment.cs" /> <Compile Include="Model\NavMenuItem.cs" /> <Compile Include="Model\CatalogSingleton.cs" /> diff --git a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs deleted file mode 100644 index e93d192..0000000 --- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ApartmentManager.ViewModel; - -namespace ApartmentManager.Handler -{ - public class ApartmentHandler - { - public ApartmentViewModel ApartmentViewModel { get; set; } - - public ApartmentHandler(ApartmentViewModel apartmenViewModel) - { - ApartmentViewModel = apartmenViewModel; - } - } -} diff --git a/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs b/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs new file mode 100644 index 0000000..26a4f04 --- /dev/null +++ b/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.UI.Popups; +using ApartmentManager.Model; +using ApartmentManager.ViewModel; + +namespace ApartmentManager.Handler +{ + public class ResidentsHandler + { + public ApartmentViewModel ApartmentViewModel { get; set; } + + public ResidentsHandler(ApartmentViewModel apartmenViewModel) + { + ApartmentViewModel = apartmenViewModel; + } + + public void CreateResident() + { + try + { + Resident resident = new Resident(); + resident.ApartmentNr = ApartmentViewModel.ApartmentNumber; + resident.Name = ApartmentViewModel.NewResident.Name; + resident.LastName = ApartmentViewModel.NewResident.LastName; + resident.BirthDate = ApartmentViewModel.NewResident.BirthDate; + resident.Email = ApartmentViewModel.NewResident.Email; + resident.Picture = ApartmentViewModel.NewResident.Picture; + resident.Phone = ApartmentViewModel.NewResident.Phone; + + //new PersistenceFacade().CreateHotel(hotel); + + ////HotelViewModel.Hotels.Hotels.Add(hotel); + //var hotelsFromDatabase = new PersistenceFacade().GetHotels(); + + //HotelViewModel.HotelCatalogSingleton.Hotels.Clear(); + //foreach (var hotel1 in hotelsFromDatabase) + //{ + // ApartmentViewModel.HotelCatalogSingleton.Hotels.Add(hotel1); + + //} + } + catch (Exception e) + { + new MessageDialog(e.Message).ShowAsync(); + } + + + + } + } +} diff --git a/ApartmentManager/ApartmentManager/View/ResidentsPage.xaml b/ApartmentManager/ApartmentManager/View/ResidentsPage.xaml index 383c396..268d2f7 100644 --- a/ApartmentManager/ApartmentManager/View/ResidentsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ResidentsPage.xaml @@ -14,7 +14,7 @@ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Margin="50" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="top" > - <ListView HorizontalAlignment="Left" Margin="0,0,50,0" VerticalAlignment="Top" ItemsSource="{Binding CatalogSingleton.Residents}" SelectedItem="{Binding NewResident, Mode=TwoWay}"/> + <ListView HorizontalAlignment="Left" Margin="0,50,50,0" VerticalAlignment="Top" ItemsSource="{Binding CatalogSingleton.Residents}" SelectedItem="{Binding NewResident, Mode=TwoWay}"/> <StackPanel Width="400" Margin="0,0,50,0"> <TextBlock Margin="0,10,0,10" Text="Resident Info" HorizontalAlignment="Center" FontSize="20" FontWeight="Bold"/> <TextBlock Margin="0,10,0,10" Text="Name"/> @@ -28,7 +28,7 @@ <TextBlock Margin="0,10,0,10" Text="Phone Number"/> <TextBox Text="{Binding NewResident.Phone, Mode=TwoWay}" /> <StackPanel Orientation="Horizontal"> - <Button Margin="0,10,12,10" Content="Create" Width="125"/> + <Button Margin="0,10,12,10" Content="Create" Width="125" Command="{Binding CreateResidentCommand}"/> <Button Margin="0,10,0,10" Content="Delte" Width="125"/> <Button Margin="13,10,0,10" Content="Update" Width="125"/> </StackPanel> diff --git a/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs index c3739e0..742d287 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using System.Windows.Input; using ApartmentManager.Annotations; using ApartmentManager.Common; +using ApartmentManager.Handler; using ApartmentManager.Model; namespace ApartmentManager.ViewModel @@ -19,23 +20,20 @@ namespace ApartmentManager.ViewModel private User _newUser; private Resident _newResident; public static int ApartmentNumber { get; set; } - public Handler.ApartmentHandler ApartmentHandler { get; set; } + public Handler.ResidentsHandler ResidentsHandler { get; set; } + + public ICommand CreateResidentCommand { get; set; } + - //public ICommand CreateCommand { get; set; } - //public ICommand DeleteCommand { get; set; } - //public ICommand UpdateCommand { get; set; } - //public ICommand ViewHotelRooms { get; set; } public ApartmentViewModel() { NewUser = new User(); NewResident = new Resident(); - ApartmentHandler = new Handler.ApartmentHandler(this); + ResidentsHandler = new Handler.ResidentsHandler(this); CatalogSingleton = CatalogSingleton.Instance; ApartmentNumber = CatalogSingleton.User[0].ApartmentNr; - //CreateCommand = new RelayCommand(HotelHandler.CreateHotel); - //DeleteCommand = new RelayCommand(HotelHandler.DeleteHotel); - //UpdateCommand = new RelayCommand(HotelHandler.UpdateHotel); - //ViewHotelRooms = new RelayCommand(); + CreateResidentCommand = new RelayCommand(ResidentsHandler.CreateResident); + } public User NewUser { diff --git a/HousingDatabase.ldf b/HousingDatabase.ldf Binary files differindex 234d695..80e00d5 100644 --- a/HousingDatabase.ldf +++ b/HousingDatabase.ldf diff --git a/HousingDatabase.mdf b/HousingDatabase.mdf Binary files differindex 3a64fee..9fb615b 100644 --- a/HousingDatabase.mdf +++ b/HousingDatabase.mdf |