diff options
author | marcinzelent <marcin@zelent.net> | 2017-05-03 19:43:26 +0200 |
---|---|---|
committer | marcinzelent <marcin@zelent.net> | 2017-05-03 19:43:26 +0200 |
commit | 71eb55ef1f2098a5543316f34bc2d820b412fae7 (patch) | |
tree | be5f14614cb50293f9ad5175c722ac325b0820cf | |
parent | dae675ee6c2506a2f6eb3fd113646fc4602ce9f4 (diff) | |
parent | 6ceed6778c31307f9222de4ca3cea04481dd0b0b (diff) |
Merge.
-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 | 116 | ||||
-rw-r--r-- | ApartmentManager/ApartmentManager/Model/Resident.cs | 4 | ||||
-rw-r--r-- | ApartmentManager/ApartmentManager/View/ResidentsPage.xaml | 8 | ||||
-rw-r--r-- | ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs | 21 | ||||
-rw-r--r-- | HousingDatabase.ldf | bin | 8388608 -> 8388608 bytes | |||
-rw-r--r-- | HousingDatabase.mdf | bin | 8388608 -> 8388608 bytes |
8 files changed, 135 insertions, 35 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..6b6395e --- /dev/null +++ b/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs @@ -0,0 +1,116 @@ +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(); + } + } + + public void DeleteResident() + { + 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(); + } + } + public void UpdateResident() + { + 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/Model/Resident.cs b/ApartmentManager/ApartmentManager/Model/Resident.cs index 58ff5f4..5e859e6 100644 --- a/ApartmentManager/ApartmentManager/Model/Resident.cs +++ b/ApartmentManager/ApartmentManager/Model/Resident.cs @@ -16,9 +16,10 @@ namespace ApartmentManager.Model public string Email { get; set; } public Image Picture { get; set; } public int ApartmentNr { get; set; } + public int ResidentNr { get; set; } public Resident() { } - public Resident(string Name, string LastName, int Phone, DateTime BirthDate, string Email, int ApartmentNr) + public Resident(string Name, string LastName, int Phone, DateTime BirthDate, string Email, int ApartmentNr, int ResidentNr) { this.Name = Name; this.LastName = LastName; @@ -26,6 +27,7 @@ namespace ApartmentManager.Model this.BirthDate = BirthDate; this.Email = Email; this.ApartmentNr = ApartmentNr; + this.ResidentNr = ResidentNr; } public override string ToString() { diff --git a/ApartmentManager/ApartmentManager/View/ResidentsPage.xaml b/ApartmentManager/ApartmentManager/View/ResidentsPage.xaml index 383c396..020d4cc 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,9 +28,9 @@ <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,0,10" Content="Delte" Width="125"/> - <Button Margin="13,10,0,10" Content="Update" 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" Command="{Binding DeleteResidentCommand}"/> + <Button Margin="13,10,0,10" Content="Update" Width="125" Command="{Binding UpdateResidentCommand}"/> </StackPanel> </StackPanel> </StackPanel> diff --git a/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs index c3739e0..57aa003 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,23 @@ 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 DeleteResidentCommand { get; set; } + public ICommand UpdateResidentCommand { 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); + DeleteResidentCommand = new RelayCommand(ResidentsHandler.DeleteResident); + UpdateResidentCommand = new RelayCommand(ResidentsHandler.UpdateResident); + } public User NewUser { diff --git a/HousingDatabase.ldf b/HousingDatabase.ldf Binary files differindex 74f90f3..80e00d5 100644 --- a/HousingDatabase.ldf +++ b/HousingDatabase.ldf diff --git a/HousingDatabase.mdf b/HousingDatabase.mdf Binary files differindex 5bb864c..9fb615b 100644 --- a/HousingDatabase.mdf +++ b/HousingDatabase.mdf |