aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs61
-rw-r--r--ApartmentManager/ApartmentManager/Model/Resident.cs4
-rw-r--r--ApartmentManager/ApartmentManager/View/ResidentsPage.xaml4
-rw-r--r--ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs7
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
{