From 6ceed6778c31307f9222de4ca3cea04481dd0b0b Mon Sep 17 00:00:00 2001 From: Donatas Adamonis Date: Wed, 3 May 2017 19:16:53 +0200 Subject: zz --- .../ApartmentManager/Handler/ResidentsHandler.cs | 61 ++++++++++++++++++++++ .../ApartmentManager/Model/Resident.cs | 4 +- .../ApartmentManager/View/ResidentsPage.xaml | 4 +- .../ViewModel/ApartmenViewModel.cs | 7 ++- 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 @@