diff options
author | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-06-14 17:35:34 +0200 |
---|---|---|
committer | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-06-14 17:35:34 +0200 |
commit | 789102c9444786d851da2ad1e4566fbff02bf964 (patch) | |
tree | f1e957d8f4fde3d5acf783b98322103a8fcf16db | |
parent | 8275d584dd49a8e1cd864c21237eab0e2fa22303 (diff) | |
parent | bcb90080d68d04c6ba2a1842d9d8a9177d31e9d0 (diff) |
asd
78 files changed, 641 insertions, 558 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/Model/ApartmentChange.cs b/ApartmentManager/ApartmentManager/Model/Change.cs index 608db89..466d85c 100644 --- a/ApartmentManager/ApartmentManager/Model/ApartmentChange.cs +++ b/ApartmentManager/ApartmentManager/Model/Change.cs @@ -7,7 +7,7 @@ using System.Runtime.CompilerServices; namespace ApartmentManager { - public class ApartmentChange : INotifyPropertyChanged + public class Change : INotifyPropertyChanged { public int ChangeId { get; set; } public int ApartmentId { get; set; } diff --git a/ApartmentManager/ApartmentManager/Package.appxmanifest b/ApartmentManager/ApartmentManager/Package.appxmanifest index a9692e8..52867e6 100644 --- a/ApartmentManager/ApartmentManager/Package.appxmanifest +++ b/ApartmentManager/ApartmentManager/Package.appxmanifest @@ -1,48 +1,27 @@ <?xml version="1.0" encoding="utf-8"?> - -<Package - xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" - xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" - xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" - IgnorableNamespaces="uap mp"> - - <Identity - Name="29294205-2e39-4ca5-bf9c-930cba3a4dc8" - Publisher="CN=Danix" - Version="1.0.0.0" /> - - <mp:PhoneIdentity PhoneProductId="29294205-2e39-4ca5-bf9c-930cba3a4dc8" PhonePublisherId="00000000-0000-0000-0000-000000000000"/> - +<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp"> + <Identity Name="TeamDelta.ApartmentManager" Publisher="CN=Team Delta" Version="1.0.0.0" /> + <mp:PhoneIdentity PhoneProductId="29294205-2e39-4ca5-bf9c-930cba3a4dc8" PhonePublisherId="00000000-0000-0000-0000-000000000000" /> <Properties> - <DisplayName>ApartmentManager</DisplayName> - <PublisherDisplayName>Danix</PublisherDisplayName> + <DisplayName>Apartment Manager</DisplayName> + <PublisherDisplayName>Team Delta</PublisherDisplayName> <Logo>Assets\StoreLogo.png</Logo> </Properties> - <Dependencies> <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" /> </Dependencies> - <Resources> - <Resource Language="x-generate"/> + <Resource Language="x-generate" /> </Resources> - <Applications> - <Application Id="App" - Executable="$targetnametoken$.exe" - EntryPoint="ApartmentManager.App"> - <uap:VisualElements - DisplayName="ApartmentManager" - Square150x150Logo="Assets\Square150x150Logo.png" - Square44x44Logo="Assets\Square44x44Logo.png" - Description="ApartmentManager" - BackgroundColor="transparent"> - <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/> + <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="ApartmentManager.App"> + <uap:VisualElements DisplayName="Apartment Manager" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="Apartment Manager" BackgroundColor="transparent"> + <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"> + </uap:DefaultTile> <uap:SplashScreen Image="Assets\SplashScreen.png" /> </uap:VisualElements> </Application> </Applications> - <Capabilities> <Capability Name="internetClient" /> </Capabilities> 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/View/ApartmentDefectPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml deleted file mode 100644 index cbea483..0000000 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml +++ /dev/null @@ -1,127 +0,0 @@ -<Page - x:Class="ApartmentManager.View.ApartmentDefectPage" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:ViewModel="using:ApartmentManager.ViewModel" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="using:ApartmentManager.View" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:interactivity="using:Microsoft.Xaml.Interactivity" - xmlns:core="using:Microsoft.Xaml.Interactions.Core" - mc:Ignorable="d"> - - <Page.DataContext> - <ViewModel:ApartmentViewModel/> - </Page.DataContext> - - <Page.BottomAppBar> - <CommandBar> - <CommandBar.Content> - <Grid /> - </CommandBar.Content> - <AppBarButton - Click="NavigateNewDefect" - Icon="Add" - Label="Create Defect"> - </AppBarButton> - </CommandBar> - </Page.BottomAppBar> - - <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> - <Grid.RowDefinitions> - <RowDefinition Height="45"/> - <RowDefinition/> - </Grid.RowDefinitions> - - <TextBlock Grid.Row="0" - HorizontalAlignment="Center" - FontSize="30" - FontWeight="Bold" - Text="Apartment Changes"> - </TextBlock> - - <ListView ItemsSource="{Binding CatalogSingleton.Defects}" SelectedItem="{Binding CatalogSingleton.SelectedDefect, Mode=TwoWay}" SelectionChanged="NavigateDefectViewPage" Grid.Row="1" Background="LightGray"> - <ListView.ItemContainerStyle> - <Style TargetType="ListViewItem"> - <Setter Property="HorizontalContentAlignment" Value="Stretch" /> - </Style> - </ListView.ItemContainerStyle> - - - <ListView.ItemTemplate> - <DataTemplate> - <Grid Height="200" BorderThickness ="1" Margin="12,12,12,0" BorderBrush="#DFE0E4" Background="White" > - <Grid.ColumnDefinitions> - <ColumnDefinition Width="300" /> - <ColumnDefinition/> - </Grid.ColumnDefinitions> - - <Image - Margin="5" - Source="{Binding Pictures[0].Picture}" - > - </Image> - - <StackPanel Grid.Column="1" Margin="10"> - - <StackPanel Orientation="Horizontal"> - <TextBlock - Margin="0,0,10,0" - FontSize="30" - FontWeight="Bold" - Text="Name :"> - </TextBlock> - <TextBlock - Margin="0,0,10,0" - FontSize="30" - Text="{Binding Name}"> - </TextBlock> - - </StackPanel> - - <StackPanel Orientation="Horizontal"> - <TextBlock - Width="800" - Height="108" - Margin="0,0,10,0" - FontSize="20" - Text="{Binding Description}" - TextWrapping="Wrap"> - </TextBlock> - </StackPanel> - - <StackPanel Orientation="Horizontal"> - <TextBlock - Margin="0,0,10,0" - FontSize="25" - FontWeight="Bold" - Text="Status :"> - </TextBlock> - <TextBlock - Margin="0,0,10,0" - FontSize="25" - Text="{Binding Status}"> - </TextBlock> - - <TextBlock - Margin="700,0,10,0" - HorizontalAlignment="Left" - FontSize="25" - FontWeight="Bold" - Text="Date Submitted :"> - </TextBlock> - - <TextBlock FontSize="25" Text="{Binding UploadDate.Year}" /> - <TextBlock FontSize="25" Text="-" /> - <TextBlock FontSize="25" Text="{Binding UploadDate.Month}" /> - <TextBlock FontSize="25" Text="-" /> - <TextBlock FontSize="25" Text="{Binding UploadDate.Day}" /> - </StackPanel> - </StackPanel> - </Grid> - </DataTemplate> - </ListView.ItemTemplate> - - </ListView> - </Grid> -</Page> diff --git a/ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmApartmentsPage.xaml index 78907a0..78907a0 100644 --- a/ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmApartmentsPage.xaml diff --git a/ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmApartmentsPage.xaml.cs index d7d67e6..d7d67e6 100644 --- a/ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmApartmentsPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmChangesPage.xaml index 215496b..b0e9a45 100644 --- a/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmChangesPage.xaml @@ -78,7 +78,7 @@ <ListView x:Name="ChangesList" Grid.Row="1" - ItemsSource="{Binding BmSingleton.ApartmentChanges}" + ItemsSource="{Binding BmSingleton.Changes}" SelectedItem="{Binding ChangeTemplate, Mode=TwoWay}"> <ListView.ItemContainerStyle> <Style BasedOn="{StaticResource ListItemStyle}" TargetType="ListViewItem" /> diff --git a/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmChangesPage.xaml.cs index a63f85c..a63f85c 100644 --- a/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmChangesPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateApartmentPage.xaml index 3c63754..3c63754 100644 --- a/ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateApartmentPage.xaml diff --git a/ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateApartmentPage.xaml.cs index 41c3f67..41c3f67 100644 --- a/ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateApartmentPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateChangePage.xaml index e2e19cd..e2e19cd 100644 --- a/ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateChangePage.xaml diff --git a/ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateChangePage.xaml.cs index 054bca6..054bca6 100644 --- a/ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateChangePage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmCreateDefectPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateDefectPage.xaml index e667583..e667583 100644 --- a/ApartmentManager/ApartmentManager/View/BmCreateDefectPage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateDefectPage.xaml diff --git a/ApartmentManager/ApartmentManager/View/BmCreateDefectPage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateDefectPage.xaml.cs index 62fc8d2..62fc8d2 100644 --- a/ApartmentManager/ApartmentManager/View/BmCreateDefectPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmCreateDefectPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmDefectsPage.xaml index b6c9759..b6c9759 100644 --- a/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmDefectsPage.xaml diff --git a/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmDefectsPage.xaml.cs index 8b38af0..8b38af0 100644 --- a/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmDefectsPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditApartmentPage.xaml index 46ea641..46ea641 100644 --- a/ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditApartmentPage.xaml diff --git a/ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditApartmentPage.xaml.cs index 63e71eb..63e71eb 100644 --- a/ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditApartmentPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditChangePage.xaml index 6d8518a..6d8518a 100644 --- a/ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditChangePage.xaml diff --git a/ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditChangePage.xaml.cs index 715f47e..715f47e 100644 --- a/ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditChangePage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmEditDefectPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditDefectPage.xaml index 5089904..5089904 100644 --- a/ApartmentManager/ApartmentManager/View/BmEditDefectPage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditDefectPage.xaml diff --git a/ApartmentManager/ApartmentManager/View/BmEditDefectPage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditDefectPage.xaml.cs index edba09e..edba09e 100644 --- a/ApartmentManager/ApartmentManager/View/BmEditDefectPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmEditDefectPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmMainPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmMainPage.xaml index 2fd5ab2..e812cc0 100644 --- a/ApartmentManager/ApartmentManager/View/BmMainPage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmMainPage.xaml @@ -19,6 +19,7 @@ <Grid.ColumnDefinitions> <ColumnDefinition Width="600" /> <ColumnDefinition Width="200" /> + <ColumnDefinition Width="200" /> </Grid.ColumnDefinitions> <Image Grid.Column="0" @@ -29,7 +30,7 @@ Margin="0,0,0,10" HorizontalAlignment="Stretch" FontSize="20" - Text="Manage:" /> + Text="Manage all:" /> <Button Margin="0,0,0,10" HorizontalAlignment="Stretch" @@ -81,6 +82,53 @@ </interactivity:Interaction.Behaviors> </Button> </StackPanel> + <StackPanel Grid.Column="2" Margin="20,0,0,0"> + <TextBlock + Margin="0,0,0,10" + HorizontalAlignment="Stretch" + FontSize="20" + Text="Manage your:" /> + <Button + Margin="0,0,0,10" + HorizontalAlignment="Stretch" + Content="Apartment"> + <interactivity:Interaction.Behaviors> + <core:EventTriggerBehavior EventName="Click"> + <core:NavigateToPageAction TargetPage="ApartmentManager.View.ApartmentPlanPage" /> + </core:EventTriggerBehavior> + </interactivity:Interaction.Behaviors> + </Button> + <Button + Margin="0,0,0,10" + HorizontalAlignment="Stretch" + Content="Apartment Residents"> + <interactivity:Interaction.Behaviors> + <core:EventTriggerBehavior EventName="Click"> + <core:NavigateToPageAction TargetPage="ApartmentManager.View.ApartmentResidentsPage" /> + </core:EventTriggerBehavior> + </interactivity:Interaction.Behaviors> + </Button> + <Button + Margin="0,0,0,10" + HorizontalAlignment="Stretch" + Content="Apartment Defects"> + <interactivity:Interaction.Behaviors> + <core:EventTriggerBehavior EventName="Click"> + <core:NavigateToPageAction TargetPage="ApartmentManager.View.ApartmentDefectPage" /> + </core:EventTriggerBehavior> + </interactivity:Interaction.Behaviors> + </Button> + <Button + Margin="0,0,0,10" + HorizontalAlignment="Stretch" + Content="Apartment changes"> + <interactivity:Interaction.Behaviors> + <core:EventTriggerBehavior EventName="Click"> + <core:NavigateToPageAction TargetPage="ApartmentManager.View.ApartmentChangesPage" /> + </core:EventTriggerBehavior> + </interactivity:Interaction.Behaviors> + </Button> + </StackPanel> </Grid> </Grid> </Page> diff --git a/ApartmentManager/ApartmentManager/View/BmMainPage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmMainPage.xaml.cs index 5d287f1..5d287f1 100644 --- a/ApartmentManager/ApartmentManager/View/BmMainPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmMainPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmResidentsPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmResidentsPage.xaml index 332ef2a..332ef2a 100644 --- a/ApartmentManager/ApartmentManager/View/BmResidentsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmResidentsPage.xaml diff --git a/ApartmentManager/ApartmentManager/View/BmResidentsPage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmResidentsPage.xaml.cs index 2a43996..2a43996 100644 --- a/ApartmentManager/ApartmentManager/View/BmResidentsPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmResidentsPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmSingleChangePage.xaml index 195095b..195095b 100644 --- a/ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmSingleChangePage.xaml diff --git a/ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmSingleChangePage.xaml.cs index d4bcc40..d4bcc40 100644 --- a/ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmSingleChangePage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmSingleDefectPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmSingleDefectPage.xaml index 2e7a935..2e7a935 100644 --- a/ApartmentManager/ApartmentManager/View/BmSingleDefectPage.xaml +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmSingleDefectPage.xaml diff --git a/ApartmentManager/ApartmentManager/View/BmSingleDefectPage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmSingleDefectPage.xaml.cs index 340e86a..340e86a 100644 --- a/ApartmentManager/ApartmentManager/View/BmSingleDefectPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmSingleDefectPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/BmUsersPage.xaml b/ApartmentManager/ApartmentManager/View/Board member pages/BmUsersPage.xaml index 77c60f7..f5b5f3e 100644 --- a/ApartmentManager/ApartmentManager/View/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 Text="{Binding UserTemplate.Username, Mode=TwoWay}" /> + <TextBox IsReadOnly="True" 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"> diff --git a/ApartmentManager/ApartmentManager/View/BmUsersPage.xaml.cs b/ApartmentManager/ApartmentManager/View/Board member pages/BmUsersPage.xaml.cs index de51f22..de51f22 100644 --- a/ApartmentManager/ApartmentManager/View/BmUsersPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/Board member pages/BmUsersPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/ApartmentChangesPage.xaml b/ApartmentManager/ApartmentManager/View/User pages/ApartmentChangesPage.xaml index aebe8a5..e94b0dc 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentChangesPage.xaml +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentChangesPage.xaml @@ -2,14 +2,14 @@ x:Class="ApartmentManager.View.ApartmentChangesPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:local="using:ApartmentManager.View" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="using:ApartmentManager.View" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewModel="using:ApartmentManager.ViewModel" mc:Ignorable="d"> <Page.DataContext> - <viewModel:ApartmentViewModel/> + <viewModel:ApartmentViewModel /> </Page.DataContext> <Page.BottomAppBar> @@ -17,27 +17,32 @@ <CommandBar.Content> <Grid /> </CommandBar.Content> - <AppBarButton + <AppBarButton + Click="GotoNewChangePage" Icon="Add" - Label="Create Defect" Click="GotoNewChangePage"> - </AppBarButton> + Label="Create Defect" /> </CommandBar> </Page.BottomAppBar> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.RowDefinitions> - <RowDefinition Height="45"/> - <RowDefinition/> + <RowDefinition Height="45" /> + <RowDefinition /> </Grid.RowDefinitions> - <TextBlock Grid.Row="0" - HorizontalAlignment="Center" - FontSize="30" - FontWeight="Bold" - Text="Apartment Changes"> - </TextBlock> - - <ListView ItemsSource="{Binding CatalogSingleton.ApartmentChanges}" SelectedItem="{Binding CatalogSingleton.SelectedChange, Mode=TwoWay}" Grid.Row="1" Background="LightGray" SelectionChanged="GotoApartmentChangeViewPage"> + <TextBlock + Grid.Row="0" + HorizontalAlignment="Center" + FontSize="30" + FontWeight="Bold" + Text="Apartment Changes" /> + + <ListView + Grid.Row="1" + Background="LightGray" + ItemsSource="{Binding CatalogSingleton.Changes}" + SelectedItem="{Binding CatalogSingleton.SelectedChange, Mode=TwoWay}" + SelectionChanged="GotoApartmentChangeViewPage"> <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> @@ -47,17 +52,18 @@ <ListView.ItemTemplate> <DataTemplate> - <Grid Height="200" BorderThickness ="1" Margin="12,12,12,0" BorderBrush="#DFE0E4" Background="White" > + <Grid + Height="200" + Margin="12,12,12,0" + Background="White" + BorderBrush="#DFE0E4" + BorderThickness="1"> <Grid.ColumnDefinitions> <ColumnDefinition Width="300" /> - <ColumnDefinition/> + <ColumnDefinition /> </Grid.ColumnDefinitions> - <Image - Margin="5" - Source="{Binding Documents[0].Document}" - > - </Image> + <Image Margin="5" Source="{Binding Documents[0].Document}" /> <StackPanel Grid.Column="1" Margin="10"> @@ -66,13 +72,11 @@ Margin="0,0,10,0" FontSize="30" FontWeight="Bold" - Text="Name :"> - </TextBlock> + Text="Name :" /> <TextBlock Margin="0,0,10,0" FontSize="30" - Text="{Binding Name}"> - </TextBlock> + Text="{Binding Name}" /> </StackPanel> @@ -83,8 +87,7 @@ Margin="0,0,10,0" FontSize="20" Text="{Binding Description}" - TextWrapping="Wrap"> - </TextBlock> + TextWrapping="Wrap" /> </StackPanel> <StackPanel Orientation="Horizontal"> @@ -92,21 +95,18 @@ Margin="0,0,10,0" FontSize="25" FontWeight="Bold" - Text="Status :"> - </TextBlock> + Text="Status :" /> <TextBlock Margin="0,0,10,0" FontSize="25" - Text="{Binding Status}"> - </TextBlock> + Text="{Binding Status}" /> <TextBlock Margin="700,0,10,0" HorizontalAlignment="Left" FontSize="25" FontWeight="Bold" - Text="Date Submitted :"> - </TextBlock> + Text="Date Submitted :" /> <TextBlock FontSize="25" Text="{Binding UploadDate.Year}" /> <TextBlock FontSize="25" Text="-" /> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentChangesPage.xaml.cs b/ApartmentManager/ApartmentManager/View/User pages/ApartmentChangesPage.xaml.cs index c498d1d..c498d1d 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentChangesPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentChangesPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/ApartmentChangesViewPage.xaml b/ApartmentManager/ApartmentManager/View/User pages/ApartmentChangesViewPage.xaml index 5ec7b99..dc957d1 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentChangesViewPage.xaml +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentChangesViewPage.xaml @@ -16,10 +16,10 @@ <CommandBar.Content> <Grid /> </CommandBar.Content> - <AppBarButton + <AppBarButton + Click="GotoApartmentChangesPage" Icon="back" - Label="Create Defect" Click="GotoApartmentChangesPage" > - </AppBarButton> + Label="Create Defect" /> </CommandBar> </Page.BottomAppBar> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentChangesViewPage.xaml.cs b/ApartmentManager/ApartmentManager/View/User pages/ApartmentChangesViewPage.xaml.cs index d3030ff..d3030ff 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentChangesViewPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentChangesViewPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/User pages/ApartmentDefectPage.xaml b/ApartmentManager/ApartmentManager/View/User pages/ApartmentDefectPage.xaml new file mode 100644 index 0000000..d243b85 --- /dev/null +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentDefectPage.xaml @@ -0,0 +1,129 @@ +<Page + x:Class="ApartmentManager.View.ApartmentDefectPage" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:ViewModel="using:ApartmentManager.ViewModel" + xmlns:core="using:Microsoft.Xaml.Interactions.Core" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:interactivity="using:Microsoft.Xaml.Interactivity" + xmlns:local="using:ApartmentManager.View" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="d"> + + <Page.DataContext> + <ViewModel:ApartmentViewModel /> + </Page.DataContext> + + <Page.BottomAppBar> + <CommandBar> + <CommandBar.Content> + <Grid /> + </CommandBar.Content> + <AppBarButton + Click="NavigateNewDefect" + Icon="Add" + Label="Create Defect" /> + </CommandBar> + </Page.BottomAppBar> + + <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> + <Grid.RowDefinitions> + <RowDefinition Height="45" /> + <RowDefinition /> + </Grid.RowDefinitions> + + <TextBlock + Grid.Row="0" + HorizontalAlignment="Center" + FontSize="30" + FontWeight="Bold" + Text="Apartment Changes" /> + + <ListView + Grid.Row="1" + Background="LightGray" + ItemsSource="{Binding CatalogSingleton.Defects}" + SelectedItem="{Binding CatalogSingleton.SelectedDefect, Mode=TwoWay}" + SelectionChanged="NavigateDefectViewPage"> + <ListView.ItemContainerStyle> + <Style TargetType="ListViewItem"> + <Setter Property="HorizontalContentAlignment" Value="Stretch" /> + </Style> + </ListView.ItemContainerStyle> + + + <ListView.ItemTemplate> + <DataTemplate> + <Grid + Height="200" + Margin="12,12,12,0" + Background="White" + BorderBrush="#DFE0E4" + BorderThickness="1"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="200" /> + <ColumnDefinition /> + </Grid.ColumnDefinitions> + + <Image + Margin="5" + Source="{Binding Pictures[0].Picture}" + Stretch="Fill" /> + + <StackPanel Grid.Column="1" Margin="10"> + + <StackPanel Orientation="Horizontal"> + <TextBlock + Margin="0,0,10,0" + FontSize="30" + FontWeight="Bold" + Text="Name :" /> + <TextBlock + Margin="0,0,10,0" + FontSize="30" + Text="{Binding Name}" /> + + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock + Width="800" + Height="108" + Margin="0,0,10,0" + FontSize="20" + Text="{Binding Description}" + TextWrapping="Wrap" /> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock + Margin="0,0,10,0" + FontSize="25" + FontWeight="Bold" + Text="Status :" /> + <TextBlock + Margin="0,0,10,0" + FontSize="25" + Text="{Binding Status}" /> + + <TextBlock + Margin="700,0,10,0" + HorizontalAlignment="Left" + FontSize="25" + FontWeight="Bold" + Text="Date Submitted :" /> + + <TextBlock FontSize="25" Text="{Binding UploadDate.Year}" /> + <TextBlock FontSize="25" Text="-" /> + <TextBlock FontSize="25" Text="{Binding UploadDate.Month}" /> + <TextBlock FontSize="25" Text="-" /> + <TextBlock FontSize="25" Text="{Binding UploadDate.Day}" /> + </StackPanel> + </StackPanel> + </Grid> + </DataTemplate> + </ListView.ItemTemplate> + + </ListView> + </Grid> +</Page> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs b/ApartmentManager/ApartmentManager/View/User pages/ApartmentDefectPage.xaml.cs index 9ff9dd4..9ff9dd4 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentDefectPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml b/ApartmentManager/ApartmentManager/View/User pages/ApartmentDefectViewPage.xaml index 9052d3a..9052d3a 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentDefectViewPage.xaml diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml.cs b/ApartmentManager/ApartmentManager/View/User pages/ApartmentDefectViewPage.xaml.cs index 6225ebc..6225ebc 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentDefectViewPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewChangePage.xaml b/ApartmentManager/ApartmentManager/View/User pages/ApartmentNewChangePage.xaml index 2eab16c..43f3998 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentNewChangePage.xaml +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentNewChangePage.xaml @@ -1,11 +1,11 @@ <Page + x:Class="ApartmentManager.View.ApartmentNewChangePage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:local="using:ApartmentManager.View" + xmlns:ViewModel="using:ApartmentManager.ViewModel" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="using:ApartmentManager.View" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:ViewModel="using:ApartmentManager.ViewModel" - x:Class="ApartmentManager.View.ApartmentNewChangePage" mc:Ignorable="d"> <Page.BottomAppBar> @@ -14,14 +14,15 @@ <Grid /> </CommandBar.Content> <AppBarButton + Click="BackToChangePage" Icon="Back" - Label="Create Defect" Click="BackToChangePage"/> + Label="Create Defect" /> </CommandBar> </Page.BottomAppBar> <Page.DataContext> - <ViewModel:ApartmentViewModel/> + <ViewModel:ApartmentViewModel /> </Page.DataContext> @@ -33,7 +34,7 @@ HorizontalAlignment="Center" FontSize="20" FontWeight="Bold" - Text="Change Information"/> + Text="Change Information" /> <StackPanel Orientation="Horizontal"> <StackPanel Margin="0,5,30,0"> @@ -79,8 +80,8 @@ <Button Margin="0,20,0,0" HorizontalAlignment="Stretch" - - Content="Create" Click="CreateChange" /> + Click="CreateChange" + Content="Create" /> </StackPanel> </StackPanel> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewChangePage.xaml.cs b/ApartmentManager/ApartmentManager/View/User pages/ApartmentNewChangePage.xaml.cs index 44abaf7..44abaf7 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentNewChangePage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentNewChangePage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml b/ApartmentManager/ApartmentManager/View/User pages/ApartmentNewDefect.xaml index 4743bd3..4743bd3 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentNewDefect.xaml diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs b/ApartmentManager/ApartmentManager/View/User pages/ApartmentNewDefect.xaml.cs index 31ce2a2..31ce2a2 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentNewDefect.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml b/ApartmentManager/ApartmentManager/View/User pages/ApartmentPage.xaml index 9aa8be2..481cf18 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentPage.xaml @@ -112,11 +112,11 @@ Margin="0,10,0,10" HorizontalAlignment="Stretch" Click="ResidentPage" - Content="Residents" /> + Content="Apartment Residents" /> <Button Margin="0,10,0,10" HorizontalAlignment="Stretch" - Content="Apartment ApartmentChanges" Click="GotoChangesPage" /> + Content="Apartment Changes" Click="GotoChangesPage" /> <Button Margin="0,10,0,10" HorizontalAlignment="Stretch" diff --git a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml.cs b/ApartmentManager/ApartmentManager/View/User pages/ApartmentPage.xaml.cs index b6752d9..b6752d9 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/ApartmentPlanPage.xaml b/ApartmentManager/ApartmentManager/View/User pages/ApartmentPlanPage.xaml index a9b71e5..a9b71e5 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentPlanPage.xaml +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentPlanPage.xaml diff --git a/ApartmentManager/ApartmentManager/View/ApartmentPlanPage.xaml.cs b/ApartmentManager/ApartmentManager/View/User pages/ApartmentPlanPage.xaml.cs index 45feb63..45feb63 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentPlanPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentPlanPage.xaml.cs diff --git a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml b/ApartmentManager/ApartmentManager/View/User pages/ApartmentResidentsPage.xaml index 00b6a75..00b6a75 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentResidentsPage.xaml diff --git a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml.cs b/ApartmentManager/ApartmentManager/View/User pages/ApartmentResidentsPage.xaml.cs index b1272bb..b1272bb 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/User pages/ApartmentResidentsPage.xaml.cs 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 diff --git a/ApartmentManager/HousingWebApi/App_Data/housingdb.mdf b/ApartmentManager/HousingWebApi/App_Data/housingdb.mdf Binary files differnew file mode 100644 index 0000000..6fb4146 --- /dev/null +++ b/ApartmentManager/HousingWebApi/App_Data/housingdb.mdf diff --git a/ApartmentManager/HousingWebApi/App_Data/housingdb_log.ldf b/ApartmentManager/HousingWebApi/App_Data/housingdb_log.ldf Binary files differnew file mode 100644 index 0000000..b33338f --- /dev/null +++ b/ApartmentManager/HousingWebApi/App_Data/housingdb_log.ldf diff --git a/ApartmentManager/HousingWebApi/Controllers/ApartmentChangesController.cs b/ApartmentManager/HousingWebApi/Controllers/ApartmentChangesController.cs deleted file mode 100644 index eadd910..0000000 --- a/ApartmentManager/HousingWebApi/Controllers/ApartmentChangesController.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Entity; -using System.Data.Entity.Infrastructure; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Web.Http; -using System.Web.Http.Description; -using HousingWebApi; - -namespace HousingWebApi.Controllers -{ - public class ApartmentChangesController : ApiController - { - private DataModel db = new DataModel(); - - // GET: api/ApartmentChanges - public IQueryable<ApartmentChange> GetApartmentChanges() - { - return db.ApartmentChanges; - } - [Route("api/ApartmentChangesByid/{id}")] - public IQueryable<ApartmentChange> GetApartmentChangesByid(int id) - { - var changetlist = from change in db.ApartmentChanges - where (change.ApartmentId == id) - orderby change.ChangeId descending - select change; - return changetlist; - } - // GET: api/ApartmentChanges/5 - [ResponseType(typeof(ApartmentChange))] - public IHttpActionResult GetApartmentChange(int id) - { - ApartmentChange apartmentChange = db.ApartmentChanges.Find(id); - if (apartmentChange == null) - { - return NotFound(); - } - - return Ok(apartmentChange); - } - - // PUT: api/ApartmentChanges/5 - [ResponseType(typeof(void))] - public IHttpActionResult PutApartmentChange(int id, ApartmentChange apartmentChange) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - if (id != apartmentChange.ChangeId) - { - return BadRequest(); - } - - db.Entry(apartmentChange).State = EntityState.Modified; - - try - { - db.SaveChanges(); - } - catch (DbUpdateConcurrencyException) - { - if (!ApartmentChangeExists(id)) - { - return NotFound(); - } - else - { - throw; - } - } - - return StatusCode(HttpStatusCode.NoContent); - } - - // POST: api/ApartmentChanges - [ResponseType(typeof(ApartmentChange))] - public IHttpActionResult PostApartmentChange(ApartmentChange apartmentChange) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - db.ApartmentChanges.Add(apartmentChange); - - try - { - db.SaveChanges(); - } - catch (DbUpdateException) - { - if (ApartmentChangeExists(apartmentChange.ChangeId)) - { - return Conflict(); - } - else - { - throw; - } - } - - return CreatedAtRoute("DefaultApi", new { id = apartmentChange.ChangeId }, apartmentChange); - } - - // DELETE: api/ApartmentChanges/5 - [ResponseType(typeof(ApartmentChange))] - public IHttpActionResult DeleteApartmentChange(int id) - { - ApartmentChange apartmentChange = db.ApartmentChanges.Find(id); - if (apartmentChange == null) - { - return NotFound(); - } - - db.ApartmentChanges.Remove(apartmentChange); - db.SaveChanges(); - - return Ok(apartmentChange); - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - db.Dispose(); - } - base.Dispose(disposing); - } - - private bool ApartmentChangeExists(int id) - { - return db.ApartmentChanges.Count(e => e.ChangeId == id) > 0; - } - } -}
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs index 6026938..ef90861 100644 --- a/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs @@ -16,18 +16,6 @@ namespace HousingWebApi.Controllers { private DataModel db = new DataModel(); - //GET: api/ChangeCommentsById - [Route("api/ChangeCommentsById/{id}")] - public IQueryable<ChangeComment> GetChangeCommentsById(int id) - { - var commentsList = from changeComment in db.ChangeComments - where (changeComment.ChangeId == id) - orderby changeComment.CommentId descending - - select changeComment; - return commentsList; - } - // GET: api/ChangeComments public IQueryable<ChangeComment> GetChangeComments() { @@ -47,6 +35,18 @@ namespace HousingWebApi.Controllers return Ok(changeComment); } + //GET: api/CommentsByChangeId + [Route("api/CommentsByChangeId/{id}")] + public IQueryable<ChangeComment> GetCommentsByChangeId(int id) + { + var commentsList = from changeComment in db.ChangeComments + where (changeComment.ChangeId == id) + orderby changeComment.CommentId descending + + select changeComment; + return commentsList; + } + // PUT: api/ChangeComments/5 [ResponseType(typeof(void))] public IHttpActionResult PutChangeComment(int id, ChangeComment changeComment) @@ -92,22 +92,7 @@ namespace HousingWebApi.Controllers } db.ChangeComments.Add(changeComment); - - try - { - db.SaveChanges(); - } - catch (DbUpdateException) - { - if (ChangeCommentExists(changeComment.CommentId)) - { - return Conflict(); - } - else - { - throw; - } - } + db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = changeComment.CommentId }, changeComment); } diff --git a/ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs index 0ffaec0..ae5ff81 100644 --- a/ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs @@ -16,16 +16,6 @@ namespace HousingWebApi.Controllers { private DataModel db = new DataModel(); - //GET: api/ChangeDocumentsById - [Route("api/ChangeDocumentsById/{id}")] - public IQueryable<ChangeDocument> GetChangeDocumentsById(int id) - { - var documentsList = from changeDocument in db.ChangeDocuments - where (changeDocument.ChangeId == id) - select changeDocument; - return documentsList; - } - // GET: api/ChangeDocuments public IQueryable<ChangeDocument> GetChangeDocuments() { @@ -45,6 +35,17 @@ namespace HousingWebApi.Controllers return Ok(changeDocument); } + //GET: api/DocumentsByChangeId + [Route("api/DocumentsByChangeId/{id}")] + public IQueryable<ChangeDocument> GetDocumentsByChangeId(int id) + { + var documentsList = from changeDocument in db.ChangeDocuments + where (changeDocument.ChangeId == id) + select changeDocument; + return documentsList; + } + + // PUT: api/ChangeDocuments/5 [ResponseType(typeof(void))] public IHttpActionResult PutChangeDocument(int id, ChangeDocument changeDocument) @@ -90,22 +91,7 @@ namespace HousingWebApi.Controllers } db.ChangeDocuments.Add(changeDocument); - - try - { - db.SaveChanges(); - } - catch (DbUpdateException) - { - if (ChangeDocumentExists(changeDocument.DocumentId)) - { - return Conflict(); - } - else - { - throw; - } - } + db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = changeDocument.DocumentId }, changeDocument); } diff --git a/ApartmentManager/HousingWebApi/Controllers/ChangesController.cs b/ApartmentManager/HousingWebApi/Controllers/ChangesController.cs new file mode 100644 index 0000000..55096b7 --- /dev/null +++ b/ApartmentManager/HousingWebApi/Controllers/ChangesController.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Entity; +using System.Data.Entity.Infrastructure; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using System.Web.Http.Description; +using HousingWebApi; + +namespace HousingWebApi.Controllers +{ + public class ChangesController : ApiController + { + private DataModel db = new DataModel(); + + // GET: api/Changes + public IQueryable<Change> GetChanges() + { + return db.Changes; + } + + // GET: api/Changes/5 + [ResponseType(typeof(Change))] + public IHttpActionResult GetChange(int id) + { + Change change = db.Changes.Find(id); + if (change == null) + { + return NotFound(); + } + + return Ok(change); + } + + [Route("api/ChangesByApartmentId/{id}")] + public IQueryable<Change> GetChangesByApartmentId(int id) + { + var changesList = from change in db.Changes + where (change.ApartmentId == id) + orderby change.ChangeId descending + select change; + return changesList; + } + + // PUT: api/Changes/5 + [ResponseType(typeof(void))] + public IHttpActionResult PutChange(int id, Change change) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != change.ChangeId) + { + return BadRequest(); + } + + db.Entry(change).State = EntityState.Modified; + + try + { + db.SaveChanges(); + } + catch (DbUpdateConcurrencyException) + { + if (!ChangeExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return StatusCode(HttpStatusCode.NoContent); + } + + // POST: api/Changes + [ResponseType(typeof(Change))] + public IHttpActionResult PostChange(Change change) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + db.Changes.Add(change); + db.SaveChanges(); + + return CreatedAtRoute("DefaultApi", new { id = change.ChangeId }, change); + } + + // DELETE: api/Changes/5 + [ResponseType(typeof(Change))] + public IHttpActionResult DeleteChange(int id) + { + Change change = db.Changes.Find(id); + if (change == null) + { + return NotFound(); + } + + db.Changes.Remove(change); + db.SaveChanges(); + + return Ok(change); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + db.Dispose(); + } + base.Dispose(disposing); + } + + private bool ChangeExists(int id) + { + return db.Changes.Count(e => e.ChangeId == id) > 0; + } + } +}
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/DataModel.cs b/ApartmentManager/HousingWebApi/DataModel.cs index aa2721f..2e60842 100644 --- a/ApartmentManager/HousingWebApi/DataModel.cs +++ b/ApartmentManager/HousingWebApi/DataModel.cs @@ -14,7 +14,7 @@ namespace HousingWebApi } public virtual DbSet<Apartment> Apartments { get; set; } - public virtual DbSet<ApartmentChange> ApartmentChanges { get; set; } + public virtual DbSet<Change> Changes { get; set; } public virtual DbSet<ChangeComment> ChangeComments { get; set; } public virtual DbSet<ChangeDocument> ChangeDocuments { get; set; } public virtual DbSet<Defect> Defects { get; set; } @@ -36,7 +36,7 @@ namespace HousingWebApi .IsUnicode(false); modelBuilder.Entity<Apartment>() - .HasMany(e => e.ApartmentChanges) + .HasMany(e => e.Changes) .WithRequired(e => e.Apartment) .WillCascadeOnDelete(false); @@ -60,28 +60,18 @@ namespace HousingWebApi .WithRequired(e => e.Apartment) .WillCascadeOnDelete(false); - modelBuilder.Entity<ApartmentChange>() + modelBuilder.Entity<Change>() .Property(e => e.Name) .IsUnicode(false); - modelBuilder.Entity<ApartmentChange>() + modelBuilder.Entity<Change>() .Property(e => e.Description) .IsUnicode(false); - modelBuilder.Entity<ApartmentChange>() + modelBuilder.Entity<Change>() .Property(e => e.Status) .IsUnicode(false); - modelBuilder.Entity<ApartmentChange>() - .HasMany(e => e.ChangeComments) - .WithRequired(e => e.ApartmentChange) - .WillCascadeOnDelete(false); - - modelBuilder.Entity<ApartmentChange>() - .HasMany(e => e.ChangeDocuments) - .WithRequired(e => e.ApartmentChange) - .WillCascadeOnDelete(false); - modelBuilder.Entity<ChangeComment>() .Property(e => e.Comment) .IsUnicode(false); @@ -209,6 +199,10 @@ namespace HousingWebApi modelBuilder.Entity<ApartmentResident>() .Property(e => e.Email) .IsUnicode(false); + + modelBuilder.Entity<ApartmentResident>() + .Property(e => e.Picture) + .IsUnicode(false); } } } diff --git a/ApartmentManager/HousingWebApi/HousingWebApi.csproj b/ApartmentManager/HousingWebApi/HousingWebApi.csproj index 779dd08..7ea765b 100644 --- a/ApartmentManager/HousingWebApi/HousingWebApi.csproj +++ b/ApartmentManager/HousingWebApi/HousingWebApi.csproj @@ -152,10 +152,14 @@ </ItemGroup>
<ItemGroup>
<Compile Include="Models\Apartment.cs" />
- <Compile Include="Models\ApartmentChange.cs" />
<Compile Include="Models\ApartmentResident.cs" />
+ <Compile Include="Models\Change.cs" />
<Compile Include="Models\ChangeComment.cs" />
<Compile Include="Models\ChangeDocument.cs" />
+ <Compile Include="Controllers\ApartmentsController.cs" />
+ <Compile Include="Controllers\ChangeCommentsController.cs" />
+ <Compile Include="Controllers\ChangeDocumentsController.cs" />
+ <Compile Include="Controllers\ChangesController.cs" />
<Compile Include="Controllers\DefectPicturesController.cs" />
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
@@ -189,10 +193,6 @@ <Compile Include="Areas\HelpPage\SampleGeneration\SampleDirection.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" />
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />
- <Compile Include="Controllers\ApartmentChangesController.cs" />
- <Compile Include="Controllers\ApartmentsController.cs" />
- <Compile Include="Controllers\ChangeCommentsController.cs" />
- <Compile Include="Controllers\ChangeDocumentsController.cs" />
<Compile Include="Controllers\DefectCommentsController.cs" />
<Compile Include="Controllers\DefectsController.cs" />
<Compile Include="Controllers\HomeController.cs" />
@@ -212,6 +212,10 @@ <Compile Include="Models\User.cs" />
</ItemGroup>
<ItemGroup>
+ <Content Include="App_Data\housingdb.mdf" />
+ <Content Include="App_Data\housingdb_log.ldf">
+ <DependentUpon>housingdb.mdf</DependentUpon>
+ </Content>
<Content Include="Areas\HelpPage\HelpPage.css" />
<Content Include="Content\bootstrap.css" />
<Content Include="Content\bootstrap.min.css" />
@@ -265,9 +269,7 @@ <Content Include="Views\Shared\Error.cshtml" />
<Content Include="Views\Shared\_Layout.cshtml" />
</ItemGroup>
- <ItemGroup>
- <Folder Include="App_Data\" />
- </ItemGroup>
+ <ItemGroup />
<ItemGroup>
<Content Include="fonts\glyphicons-halflings-regular.woff" />
</ItemGroup>
diff --git a/ApartmentManager/HousingWebApi/Models/Apartment.cs b/ApartmentManager/HousingWebApi/Models/Apartment.cs index 9e703bd..c114d09 100644 --- a/ApartmentManager/HousingWebApi/Models/Apartment.cs +++ b/ApartmentManager/HousingWebApi/Models/Apartment.cs @@ -12,7 +12,7 @@ namespace HousingWebApi [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public Apartment() { - ApartmentChanges = new HashSet<ApartmentChange>(); + Changes = new HashSet<Change>(); Defects = new HashSet<Defect>(); PastUsers = new HashSet<PastUser>(); Residents = new HashSet<Resident>(); @@ -36,7 +36,7 @@ namespace HousingWebApi public string PlanPicture { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection<ApartmentChange> ApartmentChanges { get; set; } + public virtual ICollection<Change> Changes { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection<Defect> Defects { get; set; } diff --git a/ApartmentManager/HousingWebApi/Models/ApartmentResident.cs b/ApartmentManager/HousingWebApi/Models/ApartmentResident.cs index 9936a5e..e4d3fed 100644 --- a/ApartmentManager/HousingWebApi/Models/ApartmentResident.cs +++ b/ApartmentManager/HousingWebApi/Models/ApartmentResident.cs @@ -27,6 +27,6 @@ namespace HousingWebApi [StringLength(50)] public string Email { get; set; } - public byte[] Picture { get; set; } + public string Picture { get; set; } } } diff --git a/ApartmentManager/HousingWebApi/Models/ApartmentChange.cs b/ApartmentManager/HousingWebApi/Models/Change.cs index a3308f3..de7eef7 100644 --- a/ApartmentManager/HousingWebApi/Models/ApartmentChange.cs +++ b/ApartmentManager/HousingWebApi/Models/Change.cs @@ -6,17 +6,16 @@ namespace HousingWebApi using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.Spatial; - [Table("ApartmentChange")] - public partial class ApartmentChange + [Table("Change")] + public partial class Change { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] - public ApartmentChange() + public Change() { ChangeComments = new HashSet<ChangeComment>(); ChangeDocuments = new HashSet<ChangeDocument>(); } - [Key] public int ChangeId { get; set; } public int ApartmentId { get; set; } diff --git a/ApartmentManager/HousingWebApi/Models/ChangeComment.cs b/ApartmentManager/HousingWebApi/Models/ChangeComment.cs index 954d348..83b205f 100644 --- a/ApartmentManager/HousingWebApi/Models/ChangeComment.cs +++ b/ApartmentManager/HousingWebApi/Models/ChangeComment.cs @@ -21,6 +21,6 @@ namespace HousingWebApi public DateTime? Date { get; set; } - public virtual ApartmentChange ApartmentChange { get; set; } + public virtual Change Change { get; set; } } } diff --git a/ApartmentManager/HousingWebApi/Models/ChangeDocument.cs b/ApartmentManager/HousingWebApi/Models/ChangeDocument.cs index 320686f..31b6437 100644 --- a/ApartmentManager/HousingWebApi/Models/ChangeDocument.cs +++ b/ApartmentManager/HousingWebApi/Models/ChangeDocument.cs @@ -17,6 +17,6 @@ namespace HousingWebApi [StringLength(50)] public string Document { get; set; } - public virtual ApartmentChange ApartmentChange { get; set; } + public virtual Change Change { get; set; } } } diff --git a/ApartmentManager/HousingWebApi/Web.config b/ApartmentManager/HousingWebApi/Web.config index d4ce313..ce7b94a 100644 --- a/ApartmentManager/HousingWebApi/Web.config +++ b/ApartmentManager/HousingWebApi/Web.config @@ -80,5 +80,6 @@ </providers> </entityFramework> <connectionStrings> - <add name="DataModel" connectionString="data source=housingdb.database.windows.net;initial catalog=housingdb;persist security info=True;user id=deltaadmin;password=Delta123!;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /></connectionStrings> + <add name="DataModel" connectionString="data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\housingdb.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /> +</connectionStrings> </configuration>
\ No newline at end of file diff --git a/Exam presentation.docx b/Exam presentation.docx Binary files differnew file mode 100644 index 0000000..6f8135d --- /dev/null +++ b/Exam presentation.docx diff --git a/FinalReportDelta.odt b/FinalReportDelta.odt Binary files differnew file mode 100644 index 0000000..8dceff6 --- /dev/null +++ b/FinalReportDelta.odt diff --git a/Query.sql b/Query.sql new file mode 100644 index 0000000..5ca9c02 --- /dev/null +++ b/Query.sql @@ -0,0 +1,116 @@ +CREATE TABLE [dbo].[Apartment] ( + [ApartmentId] INT NOT NULL, + [Size] FLOAT (53) NULL, + [NumberOfRooms] INT NULL, + [MonthlyCharge] FLOAT (53) NULL, + [Floor] INT NULL, + [Address] VARCHAR (100) NULL, + [PlanPicture] VARCHAR (MAX) NULL, + PRIMARY KEY CLUSTERED ([ApartmentId] ASC) +); + +CREATE TABLE [dbo].[Change] ( + [ChangeId] INT IDENTITY (0, 1) NOT NULL, + [ApartmentId] INT NOT NULL, + [Name] VARCHAR (50) NULL, + [UploadDate] DATE NULL, + [Description] VARCHAR (MAX) NULL, + [Status] VARCHAR (50) NULL, + PRIMARY KEY CLUSTERED ([ChangeId] ASC), + CONSTRAINT [FK_Change_ToApartment] FOREIGN KEY ([ApartmentId]) REFERENCES [dbo].[Apartment] ([ApartmentId]) +); + +CREATE TABLE [dbo].[ChangeComment] ( + [CommentId] INT IDENTITY (0, 1) NOT NULL, + [ChangeId] INT NOT NULL, + [Comment] VARCHAR (MAX) NULL, + [Name] VARCHAR (50) NULL, + [Date] DATETIME NULL, + PRIMARY KEY CLUSTERED ([CommentId] ASC), + CONSTRAINT [FK_ChangeComment_ToChange] FOREIGN KEY ([ChangeId]) REFERENCES [dbo].[Change] ([ChangeId]) ON DELETE CASCADE +); + +CREATE TABLE [dbo].[ChangeDocument] ( + [DocumentId] INT IDENTITY (0, 1) NOT NULL, + [ChangeId] INT NOT NULL, + [Document] VARCHAR (50) NULL, + PRIMARY KEY CLUSTERED ([DocumentId] ASC), + CONSTRAINT [FK_ChangeDocument_ToChange] FOREIGN KEY ([ChangeId]) REFERENCES [dbo].[Change] ([ChangeId]) ON DELETE CASCADE +); + +CREATE TABLE [dbo].[Defect] ( + [DefectId] INT IDENTITY (0, 1) NOT NULL, + [ApartmentId] INT NOT NULL, + [Name] VARCHAR (50) NULL, + [UploadDate] DATE NULL, + [Description] VARCHAR (MAX) NULL, + [Status] VARCHAR (50) NULL, + PRIMARY KEY CLUSTERED ([DefectId] ASC), + CONSTRAINT [FK_Defect_ToApartment] FOREIGN KEY ([ApartmentId]) REFERENCES [dbo].[Apartment] ([ApartmentId]) +); + +CREATE TABLE [dbo].[DefectComment] ( + [CommentId] INT IDENTITY (0, 1) NOT NULL, + [DefectId] INT NOT NULL, + [Comment] VARCHAR (MAX) NULL, + [Name] VARCHAR (50) NULL, + [Date] DATETIME NULL, + PRIMARY KEY CLUSTERED ([CommentId] ASC), + CONSTRAINT [FK_DefectComment_ToDefect] FOREIGN KEY ([DefectId]) REFERENCES [dbo].[Defect] ([DefectId]) ON DELETE CASCADE +); + +CREATE TABLE [dbo].[DefectPicture] ( + [PictureId] INT IDENTITY (0, 1) NOT NULL, + [DefectId] INT NOT NULL, + [Picture] VARCHAR (MAX) NULL, + PRIMARY KEY CLUSTERED ([PictureId] ASC), + CONSTRAINT [FK_DefectPicture_ToDefect] FOREIGN KEY ([DefectId]) REFERENCES [dbo].[Defect] ([DefectId]) ON DELETE CASCADE +); + +CREATE TABLE [dbo].[PastUser] ( + [Username] VARCHAR (30) NOT NULL, + [ApartmentId] INT NOT NULL, + [Password] VARCHAR (30) NOT NULL, + [IsBm] BIT NOT NULL, + [FirstName] VARCHAR (30) NULL, + [LastName] VARCHAR (30) NULL, + [BirthDate] DATE NULL, + [Phone] VARCHAR (20) NULL, + [Email] VARCHAR (50) NULL, + [Picture] VARCHAR (50) NULL, + [MoveInDate] DATE NULL, + [MoveOutDate] DATE NULL, + PRIMARY KEY CLUSTERED ([Username] ASC), + CONSTRAINT [FK_PastUser_ToApartment] FOREIGN KEY ([ApartmentId]) REFERENCES [dbo].[Apartment] ([ApartmentId]) +); + +CREATE TABLE [dbo].[Resident] ( + [ResidentId] INT IDENTITY (0, 1) NOT NULL, + [ApartmentId] INT NOT NULL, + [FirstName] VARCHAR (30) NULL, + [LastName] VARCHAR (30) NULL, + [BirthDate] DATE NULL, + [Phone] VARCHAR (20) NULL, + [Email] VARCHAR (50) NULL, + [Picture] VARCHAR (MAX) NULL, + PRIMARY KEY CLUSTERED ([ResidentId] ASC), + CONSTRAINT [FK_Resident_ToApartment] FOREIGN KEY ([ApartmentId]) REFERENCES [dbo].[Apartment] ([ApartmentId]) +); + +CREATE TABLE [dbo].[User] ( + [Username] VARCHAR (30) NOT NULL, + [ApartmentId] INT NOT NULL, + [Password] VARCHAR (30) NOT NULL, + [IsBm] BIT NOT NULL, + [FirstName] VARCHAR (30) NULL, + [LastName] VARCHAR (30) NULL, + [BirthDate] DATE NULL, + [Phone] VARCHAR (20) NULL, + [Email] VARCHAR (50) NULL, + [Picture] VARCHAR (MAX) NULL, + [MoveInDate] DATE NULL, + [MoveOutDate] DATE NULL, + PRIMARY KEY CLUSTERED ([Username] ASC), + CONSTRAINT [FK_User_ToApartment] FOREIGN KEY ([ApartmentId]) REFERENCES [dbo].[Apartment] ([ApartmentId]) +); + |