diff options
12 files changed, 104 insertions, 121 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj index d9da403..dd57ae5 100644 --- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj +++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj @@ -18,6 +18,7 @@ <ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <WindowsXamlEnableOverview>true</WindowsXamlEnableOverview> <PackageCertificateKeyFile>ApartmentManager_TemporaryKey.pfx</PackageCertificateKeyFile> + <PackageCertificateThumbprint>B7E9DDD60132C6D61DA845D26A66BC87426041DD</PackageCertificateThumbprint> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <DebugSymbols>true</DebugSymbols> @@ -108,7 +109,7 @@ <Compile Include="Handler\LoginHandler.cs" /> <Compile Include="Handler\ApartmentHandler.cs" /> <Compile Include="Model\Apartment.cs" /> - <Compile Include="Model\ApartmentChange.cs" /> + <Compile Include="Model\Change.cs" /> <Compile Include="Model\ChangeComment.cs" /> <Compile Include="Model\ChangeDocument.cs" /> <Compile Include="Model\DefectComment.cs" /> @@ -131,67 +132,67 @@ <Compile Include="ViewModel\BmDefectsViewModel.cs" /> <Compile Include="ViewModel\ApartmentViewModel.cs" /> <Compile Include="ViewModel\LoginViewModel.cs" /> - <Compile Include="View\ApartmentChangesPage.xaml.cs"> + <Compile Include="View\User pages\ApartmentChangesPage.xaml.cs"> <DependentUpon>ApartmentChangesPage.xaml</DependentUpon> </Compile> - <Compile Include="View\ApartmentChangesViewPage.xaml.cs"> + <Compile Include="View\User pages\ApartmentChangesViewPage.xaml.cs"> <DependentUpon>ApartmentChangesViewPage.xaml</DependentUpon> </Compile> - <Compile Include="View\ApartmentDefectPage.xaml.cs"> + <Compile Include="View\User pages\ApartmentDefectPage.xaml.cs"> <DependentUpon>ApartmentDefectPage.xaml</DependentUpon> </Compile> - <Compile Include="View\ApartmentDefectViewPage.xaml.cs"> + <Compile Include="View\User pages\ApartmentDefectViewPage.xaml.cs"> <DependentUpon>ApartmentDefectViewPage.xaml</DependentUpon> </Compile> - <Compile Include="View\ApartmentNewChangePage.xaml.cs"> + <Compile Include="View\User pages\ApartmentNewChangePage.xaml.cs"> <DependentUpon>ApartmentNewChangePage.xaml</DependentUpon> </Compile> - <Compile Include="View\ApartmentNewDefect.xaml.cs"> + <Compile Include="View\User pages\ApartmentNewDefect.xaml.cs"> <DependentUpon>ApartmentNewDefect.xaml</DependentUpon> </Compile> - <Compile Include="View\ApartmentPage.xaml.cs"> + <Compile Include="View\User pages\ApartmentPage.xaml.cs"> <DependentUpon>ApartmentPage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmChangesPage.xaml.cs"> + <Compile Include="View\Board member pages\BmChangesPage.xaml.cs"> <DependentUpon>BmChangesPage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmCreateChangePage.xaml.cs"> + <Compile Include="View\Board member pages\BmCreateChangePage.xaml.cs"> <DependentUpon>BmCreateChangePage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmCreateDefectPage.xaml.cs"> + <Compile Include="View\Board member pages\BmCreateDefectPage.xaml.cs"> <DependentUpon>BmCreateDefectPage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmEditApartmentPage.xaml.cs"> + <Compile Include="View\Board member pages\BmEditApartmentPage.xaml.cs"> <DependentUpon>BmEditApartmentPage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmEditChangePage.xaml.cs"> + <Compile Include="View\Board member pages\BmEditChangePage.xaml.cs"> <DependentUpon>BmEditChangePage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmEditDefectPage.xaml.cs"> + <Compile Include="View\Board member pages\BmEditDefectPage.xaml.cs"> <DependentUpon>BmEditDefectPage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmResidentsPage.xaml.cs"> + <Compile Include="View\Board member pages\BmResidentsPage.xaml.cs"> <DependentUpon>BmResidentsPage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmApartmentsPage.xaml.cs"> + <Compile Include="View\Board member pages\BmApartmentsPage.xaml.cs"> <DependentUpon>BmApartmentsPage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmDefectsPage.xaml.cs"> + <Compile Include="View\Board member pages\BmDefectsPage.xaml.cs"> <DependentUpon>BmDefectsPage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmMainPage.xaml.cs"> + <Compile Include="View\Board member pages\BmMainPage.xaml.cs"> <DependentUpon>BmMainPage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmCreateApartmentPage.xaml.cs"> + <Compile Include="View\Board member pages\BmCreateApartmentPage.xaml.cs"> <DependentUpon>BmCreateApartmentPage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmSingleChangePage.xaml.cs"> + <Compile Include="View\Board member pages\BmSingleChangePage.xaml.cs"> <DependentUpon>BmSingleChangePage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmSingleDefectPage.xaml.cs"> + <Compile Include="View\Board member pages\BmSingleDefectPage.xaml.cs"> <DependentUpon>BmSingleDefectPage.xaml</DependentUpon> </Compile> - <Compile Include="View\BmUsersPage.xaml.cs"> + <Compile Include="View\Board member pages\BmUsersPage.xaml.cs"> <DependentUpon>BmUsersPage.xaml</DependentUpon> </Compile> <Compile Include="View\LoginPage.xaml.cs"> @@ -200,10 +201,10 @@ <Compile Include="View\PersonalInfoPage.xaml.cs"> <DependentUpon>PersonalInfoPage.xaml</DependentUpon> </Compile> - <Compile Include="View\ApartmentPlanPage.xaml.cs"> + <Compile Include="View\User pages\ApartmentPlanPage.xaml.cs"> <DependentUpon>ApartmentPlanPage.xaml</DependentUpon> </Compile> - <Compile Include="View\ApartmentResidentsPage.xaml.cs"> + <Compile Include="View\User pages\ApartmentResidentsPage.xaml.cs"> <DependentUpon>ApartmentResidentsPage.xaml</DependentUpon> </Compile> </ItemGroup> @@ -232,87 +233,87 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> - <Page Include="View\ApartmentChangesPage.xaml"> + <Page Include="View\User pages\ApartmentChangesPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\ApartmentChangesViewPage.xaml"> + <Page Include="View\User pages\ApartmentChangesViewPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\ApartmentDefectPage.xaml"> + <Page Include="View\User pages\ApartmentDefectPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\ApartmentDefectViewPage.xaml"> + <Page Include="View\User pages\ApartmentDefectViewPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\ApartmentNewChangePage.xaml"> + <Page Include="View\User pages\ApartmentNewChangePage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\ApartmentNewDefect.xaml"> + <Page Include="View\User pages\ApartmentNewDefect.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\ApartmentPage.xaml"> + <Page Include="View\User pages\ApartmentPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmChangesPage.xaml"> + <Page Include="View\Board member pages\BmChangesPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmCreateChangePage.xaml"> + <Page Include="View\Board member pages\BmCreateChangePage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmCreateDefectPage.xaml"> + <Page Include="View\Board member pages\BmCreateDefectPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmEditApartmentPage.xaml"> + <Page Include="View\Board member pages\BmEditApartmentPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmEditChangePage.xaml"> + <Page Include="View\Board member pages\BmEditChangePage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmEditDefectPage.xaml"> + <Page Include="View\Board member pages\BmEditDefectPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmResidentsPage.xaml"> + <Page Include="View\Board member pages\BmResidentsPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmApartmentsPage.xaml"> + <Page Include="View\Board member pages\BmApartmentsPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmDefectsPage.xaml"> + <Page Include="View\Board member pages\BmDefectsPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmMainPage.xaml"> + <Page Include="View\Board member pages\BmMainPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmCreateApartmentPage.xaml"> + <Page Include="View\Board member pages\BmCreateApartmentPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmSingleChangePage.xaml"> + <Page Include="View\Board member pages\BmSingleChangePage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmSingleDefectPage.xaml"> + <Page Include="View\Board member pages\BmSingleDefectPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\BmUsersPage.xaml"> + <Page Include="View\Board member pages\BmUsersPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> @@ -324,11 +325,11 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\ApartmentPlanPage.xaml"> + <Page Include="View\User pages\ApartmentPlanPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="View\ApartmentResidentsPage.xaml"> + <Page Include="View\User pages\ApartmentResidentsPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> @@ -352,7 +353,9 @@ <SubType>Designer</SubType> </AppxManifest> </ItemGroup> - <ItemGroup /> + <ItemGroup> + <None Include="ApartmentManager_TemporaryKey.pfx" /> + </ItemGroup> <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' "> <VisualStudioVersion>14.0</VisualStudioVersion> </PropertyGroup> diff --git a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs index b5ea6d2..b89680c 100644 --- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs @@ -25,6 +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(); } @@ -36,9 +40,9 @@ namespace ApartmentManager.Handler { try { - string serializedApartment = ApiClient.GetData("api/Apartments/" + ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId); + string serializedApartment = ApiClient.GetData("api/Apartments/" + UserSingleton.Instance.CurrentUser.ApartmentId); Apartment apartment = JsonConvert.DeserializeObject<Apartment>(serializedApartment); - ApartmentViewModel.CatalogSingleton.Apartment = apartment; + CatalogSingleton.Instance.Apartment = apartment; } catch (Exception e) { @@ -54,10 +58,10 @@ namespace ApartmentManager.Handler { var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + UserSingleton.Instance.CurrentUser.ApartmentId); var residentlist = JsonConvert.DeserializeObject<ObservableCollection<Resident>>(residentsFromDatabase); - ApartmentViewModel.CatalogSingleton.Residents.Clear(); + CatalogSingleton.Instance.Residents = new ObservableCollection<Resident>(); foreach (var resident in residentlist) { - ApartmentViewModel.CatalogSingleton.Residents.Add(resident); + CatalogSingleton.Instance.Residents.Add(resident); } } catch (Exception e) @@ -167,10 +171,10 @@ namespace ApartmentManager.Handler public void GetApartmentDefects() { Defect Defect = new Defect(); - Defect.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; + Defect.ApartmentId = UserSingleton.Instance.CurrentUser.ApartmentId; var defectsFromDatabase = ApiClient.GetData("api/ApartmentDefects/" + Defect.ApartmentId); var defecttlist = JsonConvert.DeserializeObject<ObservableCollection<Defect>>(defectsFromDatabase); - CatalogSingleton.Instance.Defects.Clear(); + CatalogSingleton.Instance.Defects = new ObservableCollection<Defect>(); foreach (var defect in defecttlist) { defect.Pictures = JsonConvert.DeserializeObject<ObservableCollection<DefectPicture>>(ApiClient.GetData("api/DefectPicturesById/" + defect.DefectId)); @@ -269,16 +273,16 @@ namespace ApartmentManager.Handler /// </summary> public void GetApartmentChanges() { - ApartmentChange change = new ApartmentChange(); - change.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; - var changesFromDatabase = ApiClient.GetData("api/ApartmentChangesByid/" + change.ApartmentId); - var changeslist = JsonConvert.DeserializeObject<ObservableCollection<ApartmentChange>>(changesFromDatabase); - CatalogSingleton.Instance.ApartmentChanges.Clear(); + Change change = new Change(); + change.ApartmentId = UserSingleton.Instance.CurrentUser.ApartmentId; + var changesFromDatabase = ApiClient.GetData("api/ChangesByApartmentId/" + change.ApartmentId); + var changeslist = JsonConvert.DeserializeObject<ObservableCollection<Change>>(changesFromDatabase); + CatalogSingleton.Instance.Changes = new ObservableCollection<Change>(); foreach (var apartmentChange in changeslist) { - apartmentChange.Documents = JsonConvert.DeserializeObject<ObservableCollection<ChangeDocument>>(ApiClient.GetData("api/ChangeDocumentsById/" + apartmentChange.ChangeId)); - apartmentChange.Comments = JsonConvert.DeserializeObject<ObservableCollection<ChangeComment>>(ApiClient.GetData("api/ChangeCommentsById/" + apartmentChange.ChangeId)); - CatalogSingleton.Instance.ApartmentChanges.Add(apartmentChange); + apartmentChange.Documents = JsonConvert.DeserializeObject<ObservableCollection<ChangeDocument>>(ApiClient.GetData("api/DocumentsByChangeId/" + apartmentChange.ChangeId)); + apartmentChange.Comments = JsonConvert.DeserializeObject<ObservableCollection<ChangeComment>>(ApiClient.GetData("api/CommentsByChangeId/" + apartmentChange.ChangeId)); + CatalogSingleton.Instance.Changes.Add(apartmentChange); } } public void CreateChangeComment() @@ -294,7 +298,7 @@ namespace ApartmentManager.Handler { var asd =ApiClient.PostData("api/ChangeComments/", Comment); } - var response = ApiClient.GetData("api/ChangeCommentsById/" + CatalogSingleton.Instance.SelectedChange.ChangeId); + var response = ApiClient.GetData("api/CommentsByChangeId/" + CatalogSingleton.Instance.SelectedChange.ChangeId); var commentlist = JsonConvert.DeserializeObject<ObservableCollection<ChangeComment>>(response); CatalogSingleton.Instance.SelectedChange.Comments.Clear(); @@ -336,12 +340,12 @@ namespace ApartmentManager.Handler { try { - ApartmentChange change = ApartmentViewModel.NewChange; + Change change = ApartmentViewModel.NewChange; change.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; change.Status = "New"; change.UploadDate = DateTime.Now; - var response = ApiClient.PostData("api/ApartmentChanges/", change); - var changeResponse = JsonConvert.DeserializeObject<ApartmentChange>(response); + var response = ApiClient.PostData("api/Changes/", change); + var changeResponse = JsonConvert.DeserializeObject<Change>(response); change.ChangeId = changeResponse.ChangeId; if (change.Documents !=null) { diff --git a/ApartmentManager/ApartmentManager/Handler/BmApartmentsHandler.cs b/ApartmentManager/ApartmentManager/Handler/BmApartmentsHandler.cs index 48a60e2..349f29c 100644 --- a/ApartmentManager/ApartmentManager/Handler/BmApartmentsHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/BmApartmentsHandler.cs @@ -16,6 +16,7 @@ namespace ApartmentManager.Handler public BmApartmentsHandler(BmApartmentsViewModel vm) { _vm = vm; + if (BmSingleton.Instance.Apartments == null) GetApartments(); } public void GetApartments() diff --git a/ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs b/ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs index a32bbc2..87ea656 100644 --- a/ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs @@ -17,17 +17,18 @@ namespace ApartmentManager.Handler public BmChangesHandler(BmChangesViewModel vm) { _vm = vm; + if (BmSingleton.Instance.Changes == null) GetChanges(); } public void GetChanges() { - var changes = JsonConvert.DeserializeObject<ObservableCollection<ApartmentChange>>(ApiClient.GetData("api/ApartmentChanges/")); - BmSingleton.Instance.ApartmentChanges.Clear(); + var changes = JsonConvert.DeserializeObject<ObservableCollection<Change>>(ApiClient.GetData("api/Changes/")); + BmSingleton.Instance.Changes = new ObservableCollection<Change>(); foreach (var change in changes) { - change.Documents = JsonConvert.DeserializeObject<ObservableCollection<ChangeDocument>>(ApiClient.GetData("api/ChangeDocumentsById/" + change.ChangeId)); - change.Comments = JsonConvert.DeserializeObject<ObservableCollection<ChangeComment>>(ApiClient.GetData("api/ChangeCommentsById/" + change.ChangeId)); - BmSingleton.Instance.ApartmentChanges.Add(change); + change.Documents = JsonConvert.DeserializeObject<ObservableCollection<ChangeDocument>>(ApiClient.GetData("api/DocumentsByChangeId/" + change.ChangeId)); + change.Comments = JsonConvert.DeserializeObject<ObservableCollection<ChangeComment>>(ApiClient.GetData("api/CommentsByChangeId/" + change.ChangeId)); + BmSingleton.Instance.Changes.Add(change); } } @@ -38,14 +39,14 @@ namespace ApartmentManager.Handler _vm.ChangeTemplate.Status = "New"; _vm.ChangeTemplate.UploadDate = DateTime.Now; if (_vm.ChangeTemplate.Documents == null) _vm.ChangeTemplate.Documents = new ObservableCollection<ChangeDocument>(); - var response = JsonConvert.DeserializeObject<ApartmentChange>(ApiClient.PostData("api/ApartmentChanges/", _vm.ChangeTemplate)); + var response = JsonConvert.DeserializeObject<Change>(ApiClient.PostData("api/Changes/", _vm.ChangeTemplate)); foreach (var changeDocument in _vm.ChangeTemplate.Documents) { changeDocument.ChangeId = response.ChangeId; ApiClient.PostData("api/ChangeDocuments/", changeDocument); } GetChanges(); - _vm.ChangeTemplate = new ApartmentChange(); + _vm.ChangeTemplate = new Change(); } catch (Exception e) { @@ -56,7 +57,7 @@ namespace ApartmentManager.Handler { try { - ApiClient.PutData("api/ApartmentChanges/" + _vm.ChangeTemplate.ChangeId, _vm.ChangeTemplate); + ApiClient.PutData("api/Changes/" + _vm.ChangeTemplate.ChangeId, _vm.ChangeTemplate); var deletedChangeDocuments = new List<ChangeDocument>(_vm.DeletedChangeDocuments); var addedChangeDocuments = new List<ChangeDocument>(_vm.AddedChangeDocuments); @@ -82,8 +83,8 @@ namespace ApartmentManager.Handler { try { - ApiClient.DeleteData("api/ApartmentChanges/" + _vm.ChangeTemplate.ChangeId); - BmSingleton.Instance.ApartmentChanges.Remove(_vm.ChangeTemplate); + ApiClient.DeleteData("api/Changes/" + _vm.ChangeTemplate.ChangeId); + BmSingleton.Instance.Changes.Remove(_vm.ChangeTemplate); GetChanges(); } catch (Exception e) @@ -94,7 +95,7 @@ namespace ApartmentManager.Handler public void ClearChangeTemplate() { - _vm.ChangeTemplate = new ApartmentChange(); + _vm.ChangeTemplate = new Change(); } public async void UploadChangeDocument() diff --git a/ApartmentManager/ApartmentManager/Handler/BmDefectsHandler.cs b/ApartmentManager/ApartmentManager/Handler/BmDefectsHandler.cs index 919d026..27a9680 100644 --- a/ApartmentManager/ApartmentManager/Handler/BmDefectsHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/BmDefectsHandler.cs @@ -17,12 +17,13 @@ namespace ApartmentManager.Handler public BmDefectsHandler(BmDefectsViewModel vm) { _vm = vm; + if (BmSingleton.Instance.Defects == null) GetDefects(); } public void GetDefects() { var defects = JsonConvert.DeserializeObject<ObservableCollection<Defect>>(ApiClient.GetData("api/Defects/")); - BmSingleton.Instance.Defects.Clear(); + BmSingleton.Instance.Defects = new ObservableCollection<Defect>(); 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 7e93393..1e43f4d 100644 --- a/ApartmentManager/ApartmentManager/Handler/BmResidentsHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/BmResidentsHandler.cs @@ -4,11 +4,7 @@ using ApartmentManager.Singletons; using ApartmentManager.ViewModel; using Newtonsoft.Json; using System; -using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Windows.UI.Popups; namespace ApartmentManager.Handler @@ -20,12 +16,13 @@ namespace ApartmentManager.Handler public BmResidentsHandler(BmResidentsViewModel vm) { _vm = vm; + if (BmSingleton.Instance.Residents == null) GetResidents(); } public void GetResidents() { var residents = JsonConvert.DeserializeObject<ObservableCollection<Resident>>(ApiClient.GetData("api/Residents/")); - BmSingleton.Instance.Residents.Clear(); + BmSingleton.Instance.Residents = new ObservableCollection<Resident>(); 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 5fe3a92..cf07594 100644 --- a/ApartmentManager/ApartmentManager/Handler/BmUsersHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/BmUsersHandler.cs @@ -20,12 +20,13 @@ namespace ApartmentManager.Handler public BmUsersHandler(BmUsersViewModel vm) { _vm = vm; + if (BmSingleton.Instance.Users == null) GetUsers(); } public void GetUsers() { var users = JsonConvert.DeserializeObject<ObservableCollection<User>>(ApiClient.GetData("api/Users/")); - BmSingleton.Instance.Users.Clear(); + BmSingleton.Instance.Users = new ObservableCollection<User>(); 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 9360f97..02e6009 100644 --- a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs @@ -75,25 +75,10 @@ namespace ApartmentManager.Handler // suppressing the initial entrance animation. if (UserSingleton.Instance.CurrentUser.IsBm) { - BmApartmentsViewModel bavm = new BmApartmentsViewModel(); - BmUsersViewModel buvm = new BmUsersViewModel(); - BmResidentsViewModel brvm = new BmResidentsViewModel(); - BmDefectsViewModel bdvm = new BmDefectsViewModel(); - BmChangesViewModel bcvm = new BmChangesViewModel(); - bavm.BmApartmentsHandler.GetApartments(); - buvm.BmUsersHandler.GetUsers(); - brvm.BmResidentsHandler.GetResidents(); - bdvm.BmDefectsHandler.GetDefects(); - bcvm.BmChangesHandler.GetChanges(); appShell.AppFrame.Navigate(typeof(BmMainPage)); } else { - ApartmentViewModel avm = new ApartmentViewModel(); - avm.ApartmentHandler.GetApartmentResidents(); - avm.ApartmentHandler.GetApartment(); - avm.ApartmentHandler.GetApartmentDefects(); - avm.ApartmentHandler.GetApartmentChanges(); appShell.AppFrame.Navigate(typeof(ApartmentPage)); } } diff --git a/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs index c12f852..255c4ce 100644 --- a/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs @@ -12,15 +12,8 @@ namespace ApartmentManager.Singletons public ObservableCollection<User> Users { get; set; } public ObservableCollection<Resident> Residents { get; set; } public ObservableCollection<Defect> Defects { get; set; } - public ObservableCollection<ApartmentChange> ApartmentChanges { get; set; } + public ObservableCollection<Change> Changes { get; set; } - private BmSingleton() - { - Apartments = new ObservableCollection<Apartment>(); - Users = new ObservableCollection<User>(); - Residents = new ObservableCollection<Resident>(); - Defects = new ObservableCollection<Defect>(); - ApartmentChanges = new ObservableCollection<ApartmentChange>(); - } + private BmSingleton() { } } } diff --git a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs index ee101c6..f32dd7a 100644 --- a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs @@ -18,18 +18,15 @@ namespace ApartmentManager.Singletons public ObservableCollection<Resident> Residents { get; set; } ////////// For Defects ////////// public ObservableCollection<Defect> Defects { get; set; } - public ApartmentChange SelectedChange { get; set; } + public Change SelectedChange { get; set; } ////////// For Defects ////////// - public ObservableCollection<ApartmentChange> ApartmentChanges { get; set; } + public ObservableCollection<Change> Changes { get; set; } public Defect SelectedDefect { get; set; } ////////// Constructor ////////// private CatalogSingleton() { - ApartmentChanges = new ObservableCollection<ApartmentChange>(); - Residents = new ObservableCollection<Resident>(); - Defects = new ObservableCollection<Defect>(); SelectedDefect = new Defect(); - SelectedChange = new ApartmentChange(); + SelectedChange = new Change(); } } } diff --git a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs index bb126b4..dad1ad8 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs @@ -31,7 +31,7 @@ namespace ApartmentManager.ViewModel private DefectComment _newDefectComment; //// For Changes/// private ChangeComment _newChangeComment; - private ApartmentChange _newApartmentChange; + private Change _newChange; private ChangeDocument _selectedChangeDocument; ////////// Resident relay commands////////// public ICommand CreateResidentCommand { get; set; } @@ -64,7 +64,7 @@ namespace ApartmentManager.ViewModel NewChangeComment = new ChangeComment(); SelectedChangeDocument = new ChangeDocument(); - NewChange = new ApartmentChange(); + NewChange = new Change(); ////////// Handler ////////// ApartmentHandler = new ApartmentHandler(this); ////////// Singletons ////////// @@ -136,12 +136,12 @@ namespace ApartmentManager.ViewModel OnPropertyChanged(); } } - public ApartmentChange NewChange + public Change NewChange { - get => _newApartmentChange; + get => _newChange; set { - _newApartmentChange = value; + _newChange = value; OnPropertyChanged(); } } diff --git a/ApartmentManager/ApartmentManager/ViewModel/BmChangesViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/BmChangesViewModel.cs index 68aa14d..990b367 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/BmChangesViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/BmChangesViewModel.cs @@ -26,7 +26,7 @@ namespace ApartmentManager.ViewModel public ICommand DeleteChangeDocumentTempCommand { get; } public ICommand CreateChangeCommentCommand { get; } - private static ApartmentChange _changeTemplate = new ApartmentChange(); + private static Change _changeTemplate = new Change(); private static ChangeDocument _selectedChangeDocument = new ChangeDocument(); private static List<ChangeDocument> _deletedChangeDocuments = new List<ChangeDocument>(); private static List<ChangeDocument> _addedChangeDocuments = new List<ChangeDocument>(); @@ -47,7 +47,7 @@ namespace ApartmentManager.ViewModel CreateChangeCommentCommand = new RelayCommand(BmChangesHandler.CreateChangeComment); } - public ApartmentChange ChangeTemplate + public Change ChangeTemplate { get => _changeTemplate; set |