diff options
author | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-03 19:16:53 +0200 |
---|---|---|
committer | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-03 19:16:53 +0200 |
commit | 6ceed6778c31307f9222de4ca3cea04481dd0b0b (patch) | |
tree | 49ff8f3fc806a48e349e6128e43877073e821f5e | |
parent | 783c339ad3c2e7d5a071fe68613f1962fb022072 (diff) |
zz
4 files changed, 71 insertions, 5 deletions
diff --git a/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs b/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs index 26a4f04..6b6395e 100644 --- a/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs @@ -47,9 +47,70 @@ namespace ApartmentManager.Handler { 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 268d2f7..020d4cc 100644 --- a/ApartmentManager/ApartmentManager/View/ResidentsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ResidentsPage.xaml @@ -29,8 +29,8 @@ <TextBox Text="{Binding NewResident.Phone, Mode=TwoWay}" /> <StackPanel Orientation="Horizontal"> <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"/> + <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 742d287..57aa003 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs @@ -23,7 +23,8 @@ namespace ApartmentManager.ViewModel public Handler.ResidentsHandler ResidentsHandler { get; set; } public ICommand CreateResidentCommand { get; set; } - + public ICommand DeleteResidentCommand { get; set; } + public ICommand UpdateResidentCommand { get; set; } public ApartmentViewModel() { @@ -33,7 +34,9 @@ namespace ApartmentManager.ViewModel CatalogSingleton = CatalogSingleton.Instance; ApartmentNumber = CatalogSingleton.User[0].ApartmentNr; CreateResidentCommand = new RelayCommand(ResidentsHandler.CreateResident); - + DeleteResidentCommand = new RelayCommand(ResidentsHandler.DeleteResident); + UpdateResidentCommand = new RelayCommand(ResidentsHandler.UpdateResident); + } public User NewUser { |