aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonatas Adamonis <dona0169@edu.easj.dk>2017-06-14 21:36:14 +0200
committerDonatas Adamonis <dona0169@edu.easj.dk>2017-06-14 21:36:14 +0200
commit7653784bc7231825fde33f5d2f5c23740a27c215 (patch)
treec7e33310b28b2a9338370700d3bcc5e5c514db15
parent789102c9444786d851da2ad1e4566fbff02bf964 (diff)
changes
-rw-r--r--ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs12
-rw-r--r--ApartmentManager/ApartmentManager/Handler/BmApartmentsHandler.cs3
-rw-r--r--ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs4
-rw-r--r--ApartmentManager/ApartmentManager/Handler/BmDefectsHandler.cs4
-rw-r--r--ApartmentManager/ApartmentManager/Handler/BmResidentsHandler.cs4
-rw-r--r--ApartmentManager/ApartmentManager/Handler/BmUsersHandler.cs4
-rw-r--r--ApartmentManager/ApartmentManager/Handler/LoginHandler.cs18
-rw-r--r--ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs9
-rw-r--r--ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs3
-rw-r--r--ApartmentManager/ApartmentManager/View/Board member pages/BmUsersPage.xaml2
10 files changed, 47 insertions, 16 deletions
diff --git a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
index b89680c..086785a 100644
--- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
@@ -25,10 +25,10 @@ namespace ApartmentManager.Handler
public ApartmentHandler(ApartmentViewModel apartmenViewModel)
{
ApartmentViewModel = apartmenViewModel;
- if (CatalogSingleton.Instance.Apartment == null) GetApartment();
- if (CatalogSingleton.Instance.Residents == null) GetApartmentResidents();
- if (CatalogSingleton.Instance.Defects == null) GetApartmentDefects();
- if (CatalogSingleton.Instance.Changes == null) GetApartmentChanges();
+ GetApartment();
+ if (CatalogSingleton.Instance.Residents.Count==0) GetApartmentResidents();
+ if (CatalogSingleton.Instance.Defects.Count == 0) GetApartmentDefects();
+ if (CatalogSingleton.Instance.Changes.Count == 0) GetApartmentChanges();
}
@@ -58,7 +58,7 @@ namespace ApartmentManager.Handler
{
var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + UserSingleton.Instance.CurrentUser.ApartmentId);
var residentlist = JsonConvert.DeserializeObject<ObservableCollection<Resident>>(residentsFromDatabase);
- CatalogSingleton.Instance.Residents = new ObservableCollection<Resident>();
+ CatalogSingleton.Instance.Residents.Clear();
foreach (var resident in residentlist)
{
CatalogSingleton.Instance.Residents.Add(resident);
@@ -175,6 +175,7 @@ namespace ApartmentManager.Handler
var defectsFromDatabase = ApiClient.GetData("api/ApartmentDefects/" + Defect.ApartmentId);
var defecttlist = JsonConvert.DeserializeObject<ObservableCollection<Defect>>(defectsFromDatabase);
CatalogSingleton.Instance.Defects = new ObservableCollection<Defect>();
+ CatalogSingleton.Instance.Defects.Clear();
foreach (var defect in defecttlist)
{
defect.Pictures = JsonConvert.DeserializeObject<ObservableCollection<DefectPicture>>(ApiClient.GetData("api/DefectPicturesById/" + defect.DefectId));
@@ -278,6 +279,7 @@ namespace ApartmentManager.Handler
var changesFromDatabase = ApiClient.GetData("api/ChangesByApartmentId/" + change.ApartmentId);
var changeslist = JsonConvert.DeserializeObject<ObservableCollection<Change>>(changesFromDatabase);
CatalogSingleton.Instance.Changes = new ObservableCollection<Change>();
+ CatalogSingleton.Instance.Changes.Clear();
foreach (var apartmentChange in changeslist)
{
apartmentChange.Documents = JsonConvert.DeserializeObject<ObservableCollection<ChangeDocument>>(ApiClient.GetData("api/DocumentsByChangeId/" + apartmentChange.ChangeId));
diff --git a/ApartmentManager/ApartmentManager/Handler/BmApartmentsHandler.cs b/ApartmentManager/ApartmentManager/Handler/BmApartmentsHandler.cs
index 349f29c..de74491 100644
--- a/ApartmentManager/ApartmentManager/Handler/BmApartmentsHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/BmApartmentsHandler.cs
@@ -16,11 +16,12 @@ namespace ApartmentManager.Handler
public BmApartmentsHandler(BmApartmentsViewModel vm)
{
_vm = vm;
- if (BmSingleton.Instance.Apartments == null) GetApartments();
+ if (BmSingleton.Instance.Apartments.Count==0) GetApartments();
}
public void GetApartments()
{
+ BmSingleton.Instance.Apartments.Clear();
BmSingleton.Instance.Apartments = JsonConvert.DeserializeObject<ObservableCollection<Apartment>>(ApiClient.GetData("api/Apartments/"));
}
diff --git a/ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs b/ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs
index 87ea656..35b67e5 100644
--- a/ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs
@@ -17,13 +17,13 @@ namespace ApartmentManager.Handler
public BmChangesHandler(BmChangesViewModel vm)
{
_vm = vm;
- if (BmSingleton.Instance.Changes == null) GetChanges();
+ if (BmSingleton.Instance.Changes.Count == 0) GetChanges();
}
public void GetChanges()
{
var changes = JsonConvert.DeserializeObject<ObservableCollection<Change>>(ApiClient.GetData("api/Changes/"));
- BmSingleton.Instance.Changes = new ObservableCollection<Change>();
+ BmSingleton.Instance.Changes.Clear();
foreach (var change in changes)
{
change.Documents = JsonConvert.DeserializeObject<ObservableCollection<ChangeDocument>>(ApiClient.GetData("api/DocumentsByChangeId/" + change.ChangeId));
diff --git a/ApartmentManager/ApartmentManager/Handler/BmDefectsHandler.cs b/ApartmentManager/ApartmentManager/Handler/BmDefectsHandler.cs
index 27a9680..34a68f5 100644
--- a/ApartmentManager/ApartmentManager/Handler/BmDefectsHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/BmDefectsHandler.cs
@@ -17,13 +17,13 @@ namespace ApartmentManager.Handler
public BmDefectsHandler(BmDefectsViewModel vm)
{
_vm = vm;
- if (BmSingleton.Instance.Defects == null) GetDefects();
+ if (BmSingleton.Instance.Defects.Count == 0) GetDefects();
}
public void GetDefects()
{
var defects = JsonConvert.DeserializeObject<ObservableCollection<Defect>>(ApiClient.GetData("api/Defects/"));
- BmSingleton.Instance.Defects = new ObservableCollection<Defect>();
+ BmSingleton.Instance.Defects.Clear();
foreach (var defect in defects)
{
defect.Pictures = JsonConvert.DeserializeObject<ObservableCollection<DefectPicture>>(ApiClient.GetData("api/DefectPicturesById/" + defect.DefectId));
diff --git a/ApartmentManager/ApartmentManager/Handler/BmResidentsHandler.cs b/ApartmentManager/ApartmentManager/Handler/BmResidentsHandler.cs
index 1e43f4d..45fbb01 100644
--- a/ApartmentManager/ApartmentManager/Handler/BmResidentsHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/BmResidentsHandler.cs
@@ -16,13 +16,13 @@ namespace ApartmentManager.Handler
public BmResidentsHandler(BmResidentsViewModel vm)
{
_vm = vm;
- if (BmSingleton.Instance.Residents == null) GetResidents();
+ if (BmSingleton.Instance.Residents.Count == 0) GetResidents();
}
public void GetResidents()
{
var residents = JsonConvert.DeserializeObject<ObservableCollection<Resident>>(ApiClient.GetData("api/Residents/"));
- BmSingleton.Instance.Residents = new ObservableCollection<Resident>();
+ BmSingleton.Instance.Residents.Clear();
foreach (var resident in residents) BmSingleton.Instance.Residents.Add(resident);
}
diff --git a/ApartmentManager/ApartmentManager/Handler/BmUsersHandler.cs b/ApartmentManager/ApartmentManager/Handler/BmUsersHandler.cs
index cf07594..19a34ce 100644
--- a/ApartmentManager/ApartmentManager/Handler/BmUsersHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/BmUsersHandler.cs
@@ -20,13 +20,13 @@ namespace ApartmentManager.Handler
public BmUsersHandler(BmUsersViewModel vm)
{
_vm = vm;
- if (BmSingleton.Instance.Users == null) GetUsers();
+ if (BmSingleton.Instance.Users.Count == 0) GetUsers();
}
public void GetUsers()
{
var users = JsonConvert.DeserializeObject<ObservableCollection<User>>(ApiClient.GetData("api/Users/"));
- BmSingleton.Instance.Users = new ObservableCollection<User>();
+ BmSingleton.Instance.Users.Clear();
foreach (var user in users) BmSingleton.Instance.Users.Add(user);
}
diff --git a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
index 02e6009..f31a948 100644
--- a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
@@ -2,6 +2,7 @@
using ApartmentManager.Persistency;
using Newtonsoft.Json;
using System;
+using System.Collections.ObjectModel;
using ApartmentManager.ViewModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@@ -46,6 +47,23 @@ namespace ApartmentManager.Handler
public void LogOut()
{
+ if (UserSingleton.Instance.CurrentUser.IsBm)
+ {
+ BmSingleton.Instance.Apartments = new ObservableCollection<Apartment>();
+ BmSingleton.Instance.Users = new ObservableCollection<User>();
+ BmSingleton.Instance.Residents = new ObservableCollection<Resident>();
+ BmSingleton.Instance.Defects = new ObservableCollection<Defect>();
+ BmSingleton.Instance.Changes = new ObservableCollection<Change>();
+ }
+ else
+ {
+ CatalogSingleton.Instance.SelectedChange = new Change();
+ CatalogSingleton.Instance.Apartment = new Apartment();
+ CatalogSingleton.Instance.Changes = new ObservableCollection<Change>();
+ CatalogSingleton.Instance.Defects = new ObservableCollection<Defect>();
+ CatalogSingleton.Instance.Residents = new ObservableCollection<Resident>();
+ CatalogSingleton.Instance.SelectedDefect = new Defect();
+ }
UserSingleton.Instance.CurrentUser = null;
NavigateToLoginPage();
}
diff --git a/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs
index 255c4ce..410b938 100644
--- a/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs
+++ b/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs
@@ -14,6 +14,13 @@ namespace ApartmentManager.Singletons
public ObservableCollection<Defect> Defects { get; set; }
public ObservableCollection<Change> Changes { get; set; }
- private BmSingleton() { }
+ private BmSingleton()
+ {
+ Apartments = new ObservableCollection<Apartment>();
+ Users = new ObservableCollection<User>();
+ Residents = new ObservableCollection<Resident>();
+ Defects = new ObservableCollection<Defect>();
+ Changes = new ObservableCollection<Change>();
+ }
}
}
diff --git a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs
index f32dd7a..90e8ee0 100644
--- a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs
+++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs
@@ -25,6 +25,9 @@ namespace ApartmentManager.Singletons
////////// Constructor //////////
private CatalogSingleton()
{
+ Residents = new ObservableCollection<Resident>();
+ Defects = new ObservableCollection<Defect>();
+ Changes = new ObservableCollection<Change>();
SelectedDefect = new Defect();
SelectedChange = new Change();
}
diff --git a/ApartmentManager/ApartmentManager/View/Board member pages/BmUsersPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmUsersPage.xaml
index f5b5f3e..0f084ea 100644
--- a/ApartmentManager/ApartmentManager/View/Board member pages/BmUsersPage.xaml
+++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmUsersPage.xaml
@@ -128,7 +128,7 @@
Command="{Binding UploadUserPhotoCommand}"
Content="Upload Picture" />
<TextBlock Margin="0,5,0,1" Text="Username" />
- <TextBox IsReadOnly="True" Text="{Binding UserTemplate.Username, Mode=TwoWay}" />
+ <TextBox Text="{Binding UserTemplate.Username, Mode=TwoWay}" />
<TextBlock Margin="0,5,0,1" Text="Password" />
<PasswordBox Password="{Binding UserTemplate.Password, Mode=TwoWay}" />
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">