aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ApartmentManager/ApartmentManager.sln6
-rw-r--r--ApartmentManager/ApartmentManager/ApartmentManager.csproj60
-rw-r--r--ApartmentManager/ApartmentManager/AppShell.xaml.cs28
-rw-r--r--ApartmentManager/ApartmentManager/Handler/BmHandler.cs75
-rw-r--r--ApartmentManager/ApartmentManager/Handler/BoardMemberHandler.cs128
-rw-r--r--ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs132
-rw-r--r--ApartmentManager/ApartmentManager/Handler/LoginHandler.cs100
-rw-r--r--ApartmentManager/ApartmentManager/Model/Apartment.cs45
-rw-r--r--ApartmentManager/ApartmentManager/Model/User.cs20
-rw-r--r--ApartmentManager/ApartmentManager/Persistency/ImgurPhotoUploader.cs12
-rw-r--r--ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs18
-rw-r--r--ApartmentManager/ApartmentManager/Singletons/BoardMemberCatalogSingleton.cs46
-rw-r--r--ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs24
-rw-r--r--ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml134
-rw-r--r--ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml.cs29
-rw-r--r--ApartmentManager/ApartmentManager/View/BmChangesPage.xaml11
-rw-r--r--ApartmentManager/ApartmentManager/View/BmChangesPage.xaml.cs (renamed from ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml.cs)4
-rw-r--r--ApartmentManager/ApartmentManager/View/BmContractOwnersPage.xaml11
-rw-r--r--ApartmentManager/ApartmentManager/View/BmContractOwnersPage.xaml.cs (renamed from ApartmentManager/ApartmentManager/View/DefectsPicturesBoard.xaml.cs)4
-rw-r--r--ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml81
-rw-r--r--ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml.cs15
-rw-r--r--ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml16
-rw-r--r--ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml.cs16
-rw-r--r--ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml87
-rw-r--r--ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml.cs15
-rw-r--r--ApartmentManager/ApartmentManager/View/BmMainPage.xaml89
-rw-r--r--ApartmentManager/ApartmentManager/View/BmMainPage.xaml.cs16
-rw-r--r--ApartmentManager/ApartmentManager/View/BmResidentsPage.xaml11
-rw-r--r--ApartmentManager/ApartmentManager/View/BmResidentsPage.xaml.cs (renamed from ApartmentManager/ApartmentManager/View/BoardMemberCreateApartmentPage.xaml.cs)4
-rw-r--r--ApartmentManager/ApartmentManager/View/BoardMemberCreateApartmentPage.xaml35
-rw-r--r--ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml33
-rw-r--r--ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs56
-rw-r--r--ApartmentManager/ApartmentManager/View/BoardMembersDefectsPage.xaml30
-rw-r--r--ApartmentManager/ApartmentManager/View/BoardMembersDefectsPage.xaml.cs35
-rw-r--r--ApartmentManager/ApartmentManager/View/BoardMembersMainPage.xaml29
-rw-r--r--ApartmentManager/ApartmentManager/View/BoardMembersMainPage.xaml.cs45
-rw-r--r--ApartmentManager/ApartmentManager/View/DefectsPicturesBoard.xaml30
-rw-r--r--ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml48
-rw-r--r--ApartmentManager/ApartmentManager/ViewModel/BmViewModel.cs61
-rw-r--r--ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs104
-rw-r--r--ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs96
41 files changed, 888 insertions, 951 deletions
diff --git a/ApartmentManager/ApartmentManager.sln b/ApartmentManager/ApartmentManager.sln
index 3cb16cf..86bb4ee 100644
--- a/ApartmentManager/ApartmentManager.sln
+++ b/ApartmentManager/ApartmentManager.sln
@@ -1,9 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
-VisualStudioVersion = 15.0.26403.7
+VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApartmentManager", "ApartmentManager\ApartmentManager.csproj", "{95401ED6-D03C-417D-8897-81B5454D2426}"
+ ProjectSection(ProjectDependencies) = postProject
+ {D777744A-9676-4193-BD59-6F30C724C87A} = {D777744A-9676-4193-BD59-6F30C724C87A}
+ EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HousingWebApi", "HousingWebApi\HousingWebApi.csproj", "{D777744A-9676-4193-BD59-6F30C724C87A}"
EndProject
@@ -42,7 +45,6 @@ Global
{95401ED6-D03C-417D-8897-81B5454D2426}.Release|x86.Build.0 = Release|x86
{95401ED6-D03C-417D-8897-81B5454D2426}.Release|x86.Deploy.0 = Release|x86
{D777744A-9676-4193-BD59-6F30C724C87A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D777744A-9676-4193-BD59-6F30C724C87A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D777744A-9676-4193-BD59-6F30C724C87A}.Debug|ARM.ActiveCfg = Debug|Any CPU
{D777744A-9676-4193-BD59-6F30C724C87A}.Debug|ARM.Build.0 = Debug|Any CPU
{D777744A-9676-4193-BD59-6F30C724C87A}.Debug|x64.ActiveCfg = Debug|Any CPU
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj
index 81f44b5..2a04477 100644
--- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj
+++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj
@@ -100,15 +100,14 @@
</Compile>
<Compile Include="Common\RelayCommand.cs" />
<Compile Include="Controls\NavMenuListView.cs" />
- <Compile Include="Handler\BoardMemberHandler.cs" />
- <Compile Include="Handler\BoardResidentsHandler.cs" />
+ <Compile Include="Handler\BmHandler.cs" />
<Compile Include="Handler\LoginHandler.cs" />
<Compile Include="Handler\ApartmentHandler.cs" />
<Compile Include="Model\Apartment.cs" />
<Compile Include="Model\DefectComments.cs" />
<Compile Include="Model\DefectPicture.cs" />
<Compile Include="Persistency\ImgurPhotoUploader.cs" />
- <Compile Include="Singletons\BoardMemberCatalogSingleton.cs" />
+ <Compile Include="Singletons\BmSingleton.cs" />
<Compile Include="Model\Defect.cs" />
<Compile Include="Model\NavMenuItem.cs" />
<Compile Include="Singletons\CatalogSingleton.cs" />
@@ -119,7 +118,7 @@
<Compile Include="Persistency\PersistenceFacade.cs" />
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="ViewModel\BoardMemberViewModel.cs" />
+ <Compile Include="ViewModel\BmViewModel.cs" />
<Compile Include="ViewModel\ApartmentViewModel.cs" />
<Compile Include="ViewModel\LoginViewModel.cs" />
<Compile Include="View\ApartmentDefectPage.xaml.cs">
@@ -134,23 +133,29 @@
<Compile Include="View\ApartmentPage.xaml.cs">
<DependentUpon>ApartmentPage.xaml</DependentUpon>
</Compile>
- <Compile Include="View\BoardMemberManageApartment.xaml.cs">
- <DependentUpon>BoardMemberManageApartment.xaml</DependentUpon>
+ <Compile Include="View\BmChangesPage.xaml.cs">
+ <DependentUpon>BmChangesPage.xaml</DependentUpon>
</Compile>
- <Compile Include="View\BoardMembersDefectsPage.xaml.cs">
- <DependentUpon>BoardMembersDefectsPage.xaml</DependentUpon>
+ <Compile Include="View\BmContractOwnersPage.xaml.cs">
+ <DependentUpon>BmContractOwnersPage.xaml</DependentUpon>
</Compile>
- <Compile Include="View\BoardMembersMainPage.xaml.cs">
- <DependentUpon>BoardMembersMainPage.xaml</DependentUpon>
+ <Compile Include="View\BmEditApartmentPage.xaml.cs">
+ <DependentUpon>BmEditApartmentPage.xaml</DependentUpon>
</Compile>
- <Compile Include="View\BoardMemberCreateApartmentPage.xaml.cs">
- <DependentUpon>BoardMemberCreateApartmentPage.xaml</DependentUpon>
+ <Compile Include="View\BmResidentsPage.xaml.cs">
+ <DependentUpon>BmResidentsPage.xaml</DependentUpon>
</Compile>
- <Compile Include="View\DefectsPicturesBoard.xaml.cs">
- <DependentUpon>DefectsPicturesBoard.xaml</DependentUpon>
+ <Compile Include="View\BmApartmentsPage.xaml.cs">
+ <DependentUpon>BmApartmentsPage.xaml</DependentUpon>
</Compile>
- <Compile Include="View\InfoForBoardMembers.xaml.cs">
- <DependentUpon>InfoForBoardMembers.xaml</DependentUpon>
+ <Compile Include="View\BmDefectsPage.xaml.cs">
+ <DependentUpon>BmDefectsPage.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="View\BmMainPage.xaml.cs">
+ <DependentUpon>BmMainPage.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="View\BmCreateApartmentPage.xaml.cs">
+ <DependentUpon>BmCreateApartmentPage.xaml</DependentUpon>
</Compile>
<Compile Include="View\LoginPage.xaml.cs">
<DependentUpon>LoginPage.xaml</DependentUpon>
@@ -210,27 +215,35 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="View\BoardMemberManageApartment.xaml">
+ <Page Include="View\BmChangesPage.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="View\BmContractOwnersPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="View\BoardMembersDefectsPage.xaml">
+ <Page Include="View\BmEditApartmentPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="View\BoardMembersMainPage.xaml">
+ <Page Include="View\BmResidentsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="View\BoardMemberCreateApartmentPage.xaml">
+ <Page Include="View\BmApartmentsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="View\DefectsPicturesBoard.xaml">
+ <Page Include="View\BmDefectsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="View\InfoForBoardMembers.xaml">
+ <Page Include="View\BmMainPage.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="View\BmCreateApartmentPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@@ -261,6 +274,9 @@
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>5.3.3</Version>
</PackageReference>
+ <PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed">
+ <Version>2.0.0</Version>
+ </PackageReference>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
diff --git a/ApartmentManager/ApartmentManager/AppShell.xaml.cs b/ApartmentManager/ApartmentManager/AppShell.xaml.cs
index b1a88c6..dbe9c89 100644
--- a/ApartmentManager/ApartmentManager/AppShell.xaml.cs
+++ b/ApartmentManager/ApartmentManager/AppShell.xaml.cs
@@ -63,15 +63,23 @@ namespace ApartmentManager
{
Symbol = Symbol.Home,
Label = "Home",
- DestPage = typeof(BoardMembersMainPage),
+ DestPage = typeof(BmMainPage),
IsSelected = true
},
new NavMenuItem()
{
Symbol = Symbol.Comment,
- Label = "Defects",
- DestPage = typeof(BoardMembersDefectsPage),
+ Label = "Apartments",
+ DestPage = typeof(BmApartmentsPage),
+ IsSelected = false
+ },
+
+ new NavMenuItem()
+ {
+ Symbol = Symbol.Comment,
+ Label = "Contract owners",
+ DestPage = typeof(BmContractOwnersPage),
IsSelected = false
},
@@ -79,15 +87,23 @@ namespace ApartmentManager
{
Symbol = Symbol.Bookmarks,
Label = "Residents",
- DestPage = typeof(InfoForBoardMembers),
+ DestPage = typeof(BmResidentsPage),
IsSelected = false
},
new NavMenuItem()
{
Symbol = Symbol.Bookmarks,
- Label = "Apartments",
- DestPage = typeof(BoardMembersMainPage),
+ Label = "Defects",
+ DestPage = typeof(BmDefectsPage),
+ IsSelected = false
+ },
+
+ new NavMenuItem()
+ {
+ Symbol = Symbol.Bookmarks,
+ Label = "Changes",
+ DestPage = typeof(BmChangesPage),
IsSelected = false
}
});
diff --git a/ApartmentManager/ApartmentManager/Handler/BmHandler.cs b/ApartmentManager/ApartmentManager/Handler/BmHandler.cs
new file mode 100644
index 0000000..2b6b5b0
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/Handler/BmHandler.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.ObjectModel;
+using Windows.UI.Popups;
+using ApartmentManager.Model;
+using ApartmentManager.Persistency;
+using ApartmentManager.ViewModel;
+using Newtonsoft.Json;
+using ApartmentManager.Singletons;
+
+namespace ApartmentManager.Handler
+{
+ public class BmHandler
+ {
+ private BmViewModel _vm;
+
+ public BmHandler(BmViewModel vm)
+ {
+ _vm = vm;
+ }
+
+ public void GetApartments()
+ {
+ BmSingleton.Instance.Apartments = JsonConvert.DeserializeObject<ObservableCollection<Apartment>> (ApiClient.GetData("api/Apartments/"));
+ }
+
+ public void CreateApartment()
+ {
+ try
+ {
+ ApiClient.PostData("api/Apartments/", _vm.ApartmentTemplate);
+ GetApartments();
+ _vm.ApartmentTemplate = new Apartment();
+ }
+ catch (Exception e)
+ {
+ var msg = new MessageDialog(e.Message).ShowAsync();
+ }
+ }
+ public void UpdateApartment()
+ {
+ try
+ {
+ ApiClient.PutData("api/Apartments/" + _vm.ApartmentTemplate.ApartmentId, _vm.ApartmentTemplate);
+ GetApartments();
+ }
+ catch (Exception e)
+ {
+ var msg = new MessageDialog(e.Message).ShowAsync();
+ }
+ }
+ public void DeleteApartment()
+ {
+ try
+ {
+ ApiClient.DeleteData("api/Apartments/" + _vm.ApartmentTemplate.ApartmentId);
+ BmSingleton.Instance.Apartments.Remove(_vm.ApartmentTemplate);
+ GetApartments();
+ }
+ catch (Exception e)
+ {
+ var msg = new MessageDialog(e.Message).ShowAsync();
+ }
+ }
+
+ public async void UploadApartmentPlan()
+ {
+ _vm.ApartmentTemplate.PlanPicture = await ImgurPhotoUploader.UploadPhotoAsync();
+ }
+
+ public void ClearApartmentTemplate()
+ {
+ _vm.ApartmentTemplate = new Apartment();
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/Handler/BoardMemberHandler.cs b/ApartmentManager/ApartmentManager/Handler/BoardMemberHandler.cs
deleted file mode 100644
index c642b02..0000000
--- a/ApartmentManager/ApartmentManager/Handler/BoardMemberHandler.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Text;
-using System.Threading.Tasks;
-using Windows.UI.Popups;
-using ApartmentManager.Model;
-using ApartmentManager.Persistency;
-using ApartmentManager.ViewModel;
-using Newtonsoft.Json;
-
-namespace ApartmentManager.Handler
-{
- public class BoardMemberHandler
- {
- public BoardMemberViewModel BoardMemberViewModel { get; set; }
-
- public BoardMemberHandler(BoardMemberViewModel boardMemberViewModel)
- {
- BoardMemberViewModel = boardMemberViewModel;
- }
-
- public void GetApartments()
- {
- Apartment apartment= new Apartment();
- apartment.ApartmentId = BoardMemberViewModel.ApartmentsNumber;
-
- var apartmentsFromDatabase = ApiClient.GetData("api/Apartments/");
- IEnumerable<Apartment> apartmentslist = JsonConvert.DeserializeObject<IEnumerable<Apartment>>(apartmentsFromDatabase);
-
- BoardMemberViewModel.BoardMemberCatalogSingleton.Apartment.Clear();
- BoardMemberViewModel.NewApartment = new Apartment();
- foreach (var apartment2 in apartmentslist)
- {
- BoardMemberViewModel.BoardMemberCatalogSingleton.Apartment.Add(apartment2);
- }
- }
-
- public void CreateApartment()
- {
- try
- {
- Apartment apartment = new Apartment();
- apartment.ApartmentId = BoardMemberViewModel.ApartmentsNumber;
- apartment.Address = BoardMemberViewModel.NewApartment.Address;
- apartment.Floor = BoardMemberViewModel.NewApartment.Floor;
- apartment.MonthlyCharge = BoardMemberViewModel.NewApartment.MonthlyCharge;
- apartment.NumberOfRooms = BoardMemberViewModel.NewApartment.NumberOfRooms;
- apartment.Size = BoardMemberViewModel.NewApartment.Size;
-
- ApiClient.PostData("api/Apartments/", apartment);
-
- var apartmentsFromDatabase = ApiClient.GetData("api/Apartments/" + apartment.ApartmentId);
- IEnumerable<Apartment> apartmentlist = JsonConvert.DeserializeObject<IEnumerable<Apartment>>(apartmentsFromDatabase);
-
- BoardMemberViewModel.BoardMemberCatalogSingleton.Apartment.Clear();
- BoardMemberViewModel.NewApartment = new Apartment();
- foreach (var apartment2 in apartmentlist)
- {
- BoardMemberViewModel.BoardMemberCatalogSingleton.Apartment.Add(apartment2);
- }
- }
- catch (Exception e)
- {
- new MessageDialog(e.Message).ShowAsync();
- }
- }
- public void UpdateApartment()
- {
- try
- {
- Apartment apartment = new Apartment();
- apartment.ApartmentId = BoardMemberViewModel.ApartmentsNumber;
- apartment.Address = BoardMemberViewModel.NewApartment.Address;
- apartment.Floor = BoardMemberViewModel.NewApartment.Floor;
- apartment.MonthlyCharge = BoardMemberViewModel.NewApartment.MonthlyCharge;
- apartment.NumberOfRooms = BoardMemberViewModel.NewApartment.NumberOfRooms;
- apartment.Size = BoardMemberViewModel.NewApartment.Size;
-
- ApiClient.PutData("api/Apartments/" + apartment.ApartmentId, apartment);
- var apartmentsFromDatabase = ApiClient.GetData("api/Apartments/" + apartment.ApartmentId);
- IEnumerable<Apartment> apartmentslist = JsonConvert.DeserializeObject<IEnumerable<Apartment>>(apartmentsFromDatabase);
-
- BoardMemberViewModel.BoardMemberCatalogSingleton.Apartment.Clear();
- BoardMemberViewModel.NewApartment = new Apartment();
- foreach (var apartment2 in apartmentslist)
- {
- BoardMemberViewModel.BoardMemberCatalogSingleton.Apartment.Add(apartment2);
- }
- }
- catch (Exception e)
- {
- new MessageDialog(e.Message).ShowAsync();
- }
- }
- public void DeleteApartment()
- {
- try
- {
- Apartment apartment = new Apartment();
- apartment.ApartmentId = BoardMemberViewModel.ApartmentsNumber;
- apartment.Address = BoardMemberViewModel.NewApartment.Address;
- apartment.Floor = BoardMemberViewModel.NewApartment.Floor;
- apartment.MonthlyCharge = BoardMemberViewModel.NewApartment.MonthlyCharge;
- apartment.NumberOfRooms = BoardMemberViewModel.NewApartment.NumberOfRooms;
- apartment.Size = BoardMemberViewModel.NewApartment.Size;
-
- ApiClient.DeleteData("api/Apartments/" + apartment.ApartmentId);
-
- var apartmentsFromDatabase = ApiClient.GetData("api/Apartments/" + apartment.ApartmentId);
- IEnumerable<Apartment> apartmentslist = JsonConvert.DeserializeObject<IEnumerable<Apartment>>(apartmentsFromDatabase);
-
- BoardMemberViewModel.BoardMemberCatalogSingleton.Apartment.Clear();
- BoardMemberViewModel.NewApartment = new Apartment();
- foreach (var apartment2 in apartmentslist)
- {
- BoardMemberViewModel.BoardMemberCatalogSingleton.Apartment.Add(apartment2);
- }
- }
- catch (Exception e)
- {
- new MessageDialog(e.Message).ShowAsync();
- }
- }
- }
-}
diff --git a/ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs b/ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs
deleted file mode 100644
index 3f6086e..0000000
--- a/ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Windows.UI.Popups;
-using ApartmentManager.Model;
-using ApartmentManager.Persistency;
-using ApartmentManager.ViewModel;
-using Newtonsoft.Json;
-
-namespace ApartmentManager.Handler
-{
- public class BoardResidentsHandler
- {
- public BoardMemberViewModel BoardMemberViewModel { get; set; }
-
- public BoardResidentsHandler(BoardMemberViewModel boardMemberViewModel)
- {
- BoardMemberViewModel = boardMemberViewModel;
- }
- public void GetApartmentsResidents()
- {
- Resident resident = new Resident();
- resident.ApartmentId = BoardMemberViewModel.ApartmentsNumber;
-
- var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId);
- IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase);
-
- BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Clear();
- BoardMemberViewModel.NewResident = new Resident();
- foreach (var resident2 in residentlist)
- {
- BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Add(resident2);
- }
- }
-
- public void CreateResident()
- {
- try
- {
- Resident resident = new Resident();
-
- resident.ApartmentId = BoardMemberViewModel.ApartmentsNumber;
- resident.FirstName = BoardMemberViewModel.NewResident.FirstName;
- resident.LastName = BoardMemberViewModel.NewResident.LastName;
- resident.BirthDate = BoardMemberViewModel.NewResident.BirthDate;
- resident.Email = BoardMemberViewModel.NewResident.Email;
- resident.Picture = BoardMemberViewModel.NewResident.Picture;
- resident.Phone = BoardMemberViewModel.NewResident.Phone;
-
- ApiClient.PostData("api/residents/", resident);
-
- var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId);
- IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase);
-
- BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Clear();
- BoardMemberViewModel.NewResident = new Resident();
- foreach (var resident2 in residentlist)
- {
- BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Add(resident2);
- }
- }
- catch (Exception e)
- {
- new MessageDialog(e.Message).ShowAsync();
- }
- }
-
- public void DeleteResident()
- {
- try
- {
- Resident resident = new Resident();
- resident.ResidentId = BoardMemberViewModel.NewResident.ResidentId;
- resident.ApartmentId = BoardMemberViewModel.ApartmentsNumber;
- resident.FirstName = BoardMemberViewModel.NewResident.FirstName;
- resident.LastName = BoardMemberViewModel.NewResident.LastName;
- resident.BirthDate = BoardMemberViewModel.NewResident.BirthDate;
- resident.Email = BoardMemberViewModel.NewResident.Email;
- resident.Picture = BoardMemberViewModel.NewResident.Picture;
- resident.Phone = BoardMemberViewModel.NewResident.Phone;
-
- ApiClient.DeleteData("api/residents/" + resident.ResidentId);
-
- var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId);
- IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase);
-
- BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Clear();
- BoardMemberViewModel.NewResident = new Resident();
- foreach (var resident2 in residentlist)
- {
- BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Add(resident2);
- }
- }
- catch (Exception e)
- {
- new MessageDialog(e.Message).ShowAsync();
- }
- }
- public void UpdateResident()
- {
- try
- {
- Resident resident = new Resident();
- resident.ResidentId = BoardMemberViewModel.NewResident.ResidentId;
- resident.ApartmentId = BoardMemberViewModel.ApartmentsNumber;
- resident.FirstName = BoardMemberViewModel.NewResident.FirstName;
- resident.LastName = BoardMemberViewModel.NewResident.LastName;
- resident.BirthDate = BoardMemberViewModel.NewResident.BirthDate;
- resident.Email = BoardMemberViewModel.NewResident.Email;
- resident.Picture = BoardMemberViewModel.NewResident.Picture;
- resident.Phone = BoardMemberViewModel.NewResident.Phone;
-
- ApiClient.PutData("api/residents/" + resident.ResidentId, resident);
- var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId);
- IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase);
-
- BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Clear();
- BoardMemberViewModel.NewResident = new Resident();
- foreach (var resident2 in residentlist)
- {
- BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Add(resident2);
- }
- }
- catch (Exception e)
- {
- new MessageDialog(e.Message).ShowAsync();
- }
- }
- }
-} \ No newline at end of file
diff --git a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
index 65efeca..d0088d9 100644
--- a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
@@ -2,34 +2,114 @@
using ApartmentManager.Persistency;
using Newtonsoft.Json;
using System;
-using ApartmentManager.Singletons;
using ApartmentManager.ViewModel;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using ApartmentManager.View;
+using Windows.UI.Popups;
+using ApartmentManager.Singletons;
namespace ApartmentManager.Handler
{
- public static class LoginHandler
+ public class LoginHandler
{
- public static void LogIn(string username, string password)
+
+ private LoginViewModel _vm;
+
+ public LoginHandler(LoginViewModel vm)
+ {
+ _vm = vm;
+ }
+
+ public void LogIn()
{
- string serializedUser = ApiClient.GetData($"api/Users/{username}");
+ try
+ {
+ string serializedUser = ApiClient.GetData($"api/Users/{_vm.Username}");
if (serializedUser != null)
{
User user = JsonConvert.DeserializeObject<User>(serializedUser);
- if (user.Password == password)
+ if (user.Password == _vm.Password)
{
UserSingleton.Instance.CurrentUser = user;
-
-
- }
+ NavigateToMainPage();
+ }
else throw new Exception("Wrong password!");
}
else throw new Exception("Wrong username!");
-
+ }
+ catch (Exception ex)
+ {
+ var msg = new MessageDialog(ex.Message).ShowAsync();
+ }
}
- public static void LogOut()
+ public void LogOut()
{
UserSingleton.Instance.CurrentUser = null;
+ NavigateToLoginPage();
+ }
+
+ private void NavigateToMainPage()
+ {
+ AppShell appShell = Window.Current.Content as AppShell;
+
+ // Do not repeat app initialization when the Window already has content,
+ // just ensure that the window is active
+ if (appShell == null)
+ {
+ // Create a AppShell to act as the navigation context and navigate to the first page
+ appShell = new AppShell();
+
+ // Set the default language
+ appShell.Language = Windows.Globalization.ApplicationLanguages.Languages[0];
+
+ }
+
+ // Place our app shell in the current Window
+ Window.Current.Content = appShell;
+
+ if (appShell.AppFrame.Content == null)
+ {
+ // When the navigation stack isn't restored, navigate to the first page
+ // suppressing the initial entrance animation.
+ if (UserSingleton.Instance.CurrentUser.IsBm)
+ {
+ BmViewModel bvm = new BmViewModel();
+ bvm.BmHandler.GetApartments();
+ appShell.AppFrame.Navigate(typeof(BmMainPage));
+ }
+ else
+ {
+ ApartmentViewModel avm = new ApartmentViewModel();
+ avm.ApartmentHandler.GetApartmentResidents();
+ avm.ApartmentHandler.GetApartment();
+ avm.ApartmentHandler.GetApartmentDefects();
+ appShell.AppFrame.Navigate(typeof(ApartmentPage));
+ }
+ }
+
+ // Ensure the current window is active
+ Window.Current.Activate();
+ }
+
+ private void NavigateToLoginPage()
+ {
+ Frame rootFrame = Window.Current.Content as Frame;
+
+ // Do not repeat app initialization when the Window already has content,
+ // just ensure that the window is active
+ if (rootFrame == null)
+ {
+ // Create a Frame to act as the navigation context and navigate to the first page
+ rootFrame = new Frame();
+
+ // Place the frame in the current Window
+ Window.Current.Content = rootFrame;
+ }
+
+ rootFrame.Navigate(typeof(LoginPage));
+ Window.Current.Activate();
}
}
}
diff --git a/ApartmentManager/ApartmentManager/Model/Apartment.cs b/ApartmentManager/ApartmentManager/Model/Apartment.cs
index 74fe410..a32c081 100644
--- a/ApartmentManager/ApartmentManager/Model/Apartment.cs
+++ b/ApartmentManager/ApartmentManager/Model/Apartment.cs
@@ -1,37 +1,38 @@
-namespace ApartmentManager.Model
+using ApartmentManager.Annotations;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace ApartmentManager.Model
{
- public class Apartment
+ public class Apartment : INotifyPropertyChanged
{
public int ApartmentId { get; set; }
- public double? Size { get; set; }
- public int? NumberOfRooms { get; set; }
- public double? MonthlyCharge { get; set; }
- public int? Floor { get; set; }
+ public double Size { get; set; }
+ public int NumberOfRooms { get; set; }
+ public double MonthlyCharge { get; set; }
+ public int Floor { get; set; }
public string Address { get; set; }
- public string PlanPicture { get; set; }
+ private string _planPicture;
public Apartment() { }
- public Apartment(int apartmentId, double? size, int? numberOfRooms, double? monthlyCharge, int? floor, string address)
+ public string PlanPicture
{
- ApartmentId = apartmentId;
- Size = size;
- NumberOfRooms = numberOfRooms;
- MonthlyCharge = monthlyCharge;
- Floor = floor;
- Address = address;
+ get => _planPicture;
+ set
+ {
+ _planPicture = value;
+ OnPropertyChanged(nameof(PlanPicture));
+ }
}
- //public override string ToString()
- //{
- // return string.Format(
- // "Apartment No: {0} Size: {1} NoOfRooms: {2} MonthlyCharge: {3} Floor: {4} Address: {5}",
- // ApartmentNumber, Size, NumberOfRooms, MonthlyCharge, Floor, Address);
- //}
+ public event PropertyChangedEventHandler PropertyChanged;
- public override string ToString()
+ [NotifyPropertyChangedInvocator]
+ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
- return string.Format($"Apartment number: {ApartmentId}, Size: {Size} Number of rooms: {NumberOfRooms}, Monthly charge: {MonthlyCharge}, Floor: {Floor}, Address: {Address}");
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+
}
}
}
diff --git a/ApartmentManager/ApartmentManager/Model/User.cs b/ApartmentManager/ApartmentManager/Model/User.cs
index e7e43ec..f5da6fd 100644
--- a/ApartmentManager/ApartmentManager/Model/User.cs
+++ b/ApartmentManager/ApartmentManager/Model/User.cs
@@ -25,18 +25,6 @@ namespace ApartmentManager.Model
public DateTime? MoveInDate { get; set; }
public DateTime? MoveOutDate { get; set; }
-
- public User() { }
-
- public User(string FirstName, string LastName, string Phone, DateTime BirthDate, string Email)
- {
- this.FirstName = FirstName;
- this.LastName = LastName;
- this.BirthDate = BirthDate;
- this.Phone = Phone;
- this.Email = Email;
- }
-
public string Picture
{
get => _picture;
@@ -46,13 +34,7 @@ namespace ApartmentManager.Model
OnPropertyChanged(nameof(Picture));
}
}
- public override string ToString()
- {
- return string.Format($"First name {FirstName} Last name {LastName} Phone {Phone}");
- }
-
-
-
+
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
diff --git a/ApartmentManager/ApartmentManager/Persistency/ImgurPhotoUploader.cs b/ApartmentManager/ApartmentManager/Persistency/ImgurPhotoUploader.cs
index 7e9ebf2..ed0041e 100644
--- a/ApartmentManager/ApartmentManager/Persistency/ImgurPhotoUploader.cs
+++ b/ApartmentManager/ApartmentManager/Persistency/ImgurPhotoUploader.cs
@@ -39,10 +39,14 @@ namespace ApartmentManager.Persistency
StorageFile file = await fp.PickSingleFileAsync();
//Upload to Imgur and return link
- var client = new ImgurClient("7b05a61ed8df74f", "ade6f79163e19f92f852bc553bbe399d7d4218fe");
- var endpoint = new ImageEndpoint(client);
- IImage image = await endpoint.UploadImageStreamAsync(await file.OpenStreamForReadAsync());
- return image.Link;
+ if (file != null)
+ {
+ var client = new ImgurClient("7b05a61ed8df74f", "ade6f79163e19f92f852bc553bbe399d7d4218fe");
+ var endpoint = new ImageEndpoint(client);
+ IImage image = await endpoint.UploadImageStreamAsync(await file.OpenStreamForReadAsync());
+ return image.Link;
+ }
+ else return "";
}
}
} \ No newline at end of file
diff --git a/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs
new file mode 100644
index 0000000..966390c
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs
@@ -0,0 +1,18 @@
+using ApartmentManager.Model;
+using System.Collections.ObjectModel;
+
+namespace ApartmentManager.Singletons
+{
+ public class BmSingleton
+ {
+ private static BmSingleton _instance;
+ public static BmSingleton Instance => _instance ?? (_instance = new BmSingleton());
+
+ public ObservableCollection<Apartment> Apartments { get; set; }
+ public ObservableCollection<User> Users { get; set; }
+ public ObservableCollection<Resident> Residents { get; set; }
+ public ObservableCollection<Defect> Defects { get; set; }
+
+ private BmSingleton() { }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/Singletons/BoardMemberCatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/BoardMemberCatalogSingleton.cs
deleted file mode 100644
index 1a563ef..0000000
--- a/ApartmentManager/ApartmentManager/Singletons/BoardMemberCatalogSingleton.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Media;
-using Windows.UI.Xaml.Media.Imaging;
-
-namespace ApartmentManager.Model
-{
- public class BoardMemberCatalogSingleton
- {
- private static BoardMemberCatalogSingleton instance = new BoardMemberCatalogSingleton();
-
- public static BoardMemberCatalogSingleton Instance => instance;
-
- public ObservableCollection<Apartment> Apartment { get; set; }
- public ObservableCollection<User> User { get; set; }
- public ObservableCollection<Resident> Residents { get; set; }
- public ObservableCollection<Defect> Defects { get; set; }
- private BoardMemberCatalogSingleton()
- {
- Apartment = new ObservableCollection<Apartment>();
-
- User = new ObservableCollection<User>();
- //User.Add(new User("Bibis", "Kiausiai", "3214568", new DateTime(2017, 1, 5, 2, 27, 0), "Bibis@mail.com", 1));
- //Apartment = new ObservableCollection<Apartment>();
- //Apartment.Add(new Apartment(1, "30 Square meters", 2, "200", 0, "adresas"));
- //Apartment.Add(new Apartment(2, "40 Square meters", 4, "300", 1, "kvaerkebyvej"));
- //Apartment.Add(new Apartment(3, "28 Square meters", 1, "125", 0, "ugandavej"));
-
- Residents = new ObservableCollection<Resident>();
- //Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1));
- //Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1));
- //Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1));
- //Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1));
-
- Defects = new ObservableCollection<Defect>();
- //Defects.Add(new Defect(1, 2, "Leaking downpipe", DateTime.Now, new Image(), new Image(), new Image(), "downpipe will explode, do something!", "hello", "Not fixed"));
- //Defects.Add(new Defect(1, 2, "Leaking downpipe", DateTime.Now, new Image(), new Image(), new Image(), "downpipe will explode, do something!", "hello", "Not fixed"));
- //Defects.Add(new Defect(1, 2, "Leaking downpipe", DateTime.Now, new Image(), new Image(), new Image(), "downpipe will explode, do something!", "hello", "Fixed"));
- }
- }
-}
diff --git a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs
index e5ca71e..1f291c9 100644
--- a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs
+++ b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs
@@ -1,28 +1,14 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using ApartmentManager.Model;
-namespace ApartmentManager.Model
+namespace ApartmentManager.Singletons
{
public class UserSingleton
{
- private static UserSingleton instance;
+ private static UserSingleton _instance;
+ public static UserSingleton Instance => _instance ?? (_instance = new UserSingleton());
+
public User CurrentUser { get; set; }
private UserSingleton() { }
-
- public static UserSingleton Instance
- {
- get
- {
- if (instance == null)
- {
- instance = new UserSingleton();
- }
- return instance;
- }
- }
}
}
diff --git a/ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml b/ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml
new file mode 100644
index 0000000..ffc28c2
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml
@@ -0,0 +1,134 @@
+<Page
+ x:Class="ApartmentManager.View.BmApartmentsPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ 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"
+ xmlns:vm="using:ApartmentManager.ViewModel"
+ mc:Ignorable="d">
+
+ <Page.Resources>
+ <Style x:Key="ApartmentsListItemStyle" TargetType="ListViewItem">
+ <Setter Property="Background" Value="White" />
+ <Setter Property="Padding" Value="0" />
+ <Setter Property="Margin" Value="12,12,12,0" />
+ <Setter Property="BorderThickness" Value="1" />
+ <Setter Property="BorderBrush" Value="#DFE0E4" />
+ <Setter Property="HorizontalContentAlignment" Value="Stretch" />
+ <Setter Property="VerticalContentAlignment" Value="Center" />
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="ListViewItem">
+ <ListViewItemPresenter />
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ <Style x:Key="TextBlockStyle" TargetType="TextBlock">
+ <Setter Property="Margin" Value="0,0,0,10" />
+ <Setter Property="Foreground" Value="White" />
+ </Style>
+ <Style x:Key="ActionButtonStyle" TargetType="Button">
+ <Setter Property="Background" Value="Transparent" />
+ <Setter Property="Height" Value="40" />
+ <Setter Property="Width" Value="40" />
+ <Setter Property="HorizontalAlignment" Value="Right" />
+ <Setter Property="VerticalAlignment" Value="Top" />
+ </Style>
+ </Page.Resources>
+ <Page.DataContext>
+ <vm:BmViewModel />
+ </Page.DataContext>
+ <Page.BottomAppBar>
+ <CommandBar>
+ <CommandBar.Content>
+ <Grid />
+ </CommandBar.Content>
+ <AppBarButton
+ Click="GoToCreateApartmentPage"
+ Icon="Add"
+ Label="Create Apartment"
+ Command="{Binding ClearApartmentTemplateCommand}">
+ <AppBarButton.DataContext>
+ <vm:BmViewModel/>
+ </AppBarButton.DataContext>
+ </AppBarButton>
+ </CommandBar>
+ </Page.BottomAppBar>
+ <Grid Background="#E9EBEE">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="40" />
+ <RowDefinition />
+ </Grid.RowDefinitions>
+ <StackPanel Background="{StaticResource AppBarBackgroundThemeBrush}" Orientation="Horizontal">
+ <TextBlock
+ Margin="40,0,10,0"
+ VerticalAlignment="Center"
+ Text="Floor: " />
+ <ComboBox
+ VerticalAlignment="Center"
+ ItemsSource="{Binding FloorNumbers}"
+ SelectedItem="{Binding SelectedFloor, Mode=TwoWay}" />
+ <TextBlock
+ Margin="10,0"
+ VerticalAlignment="Center"
+ Text="Apartment number: " />
+ <TextBox Height="32" />
+ </StackPanel>
+ <ListView
+ x:Name="ApartmentsList"
+ Grid.Row="1"
+ ItemsSource="{Binding BmSingleton.Apartments}"
+ SelectedItem="{Binding ApartmentTemplate, Mode=TwoWay}">
+ <ListView.ItemContainerStyle>
+ <Style BasedOn="{StaticResource ApartmentsListItemStyle}" TargetType="ListViewItem" />
+ </ListView.ItemContainerStyle>
+ <ListView.ItemTemplate>
+ <DataTemplate>
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition />
+ <RowDefinition />
+ </Grid.RowDefinitions>
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="50px" />
+ </Grid.ColumnDefinitions>
+ <StackPanel Padding="10">
+ <TextBlock><Run Text="Apartment number: " /><Run Text="{Binding ApartmentId}" /></TextBlock>
+ <TextBlock><Run Text="Floor: " /><Run Text="{Binding Floor}" /></TextBlock>
+ <TextBlock><Run Text="Address: " /><Run Text="{Binding Address}" /></TextBlock>
+ </StackPanel>
+ <Button
+ Grid.Column="1"
+ Click="SelectApartment"
+ Command="{Binding DeleteApartmentCommand}"
+ DataContext="{Binding ElementName=ApartmentsList, Path=DataContext}"
+ Style="{StaticResource ActionButtonStyle}">
+ <SymbolIcon Symbol="Clear" ToolTipService.ToolTip="Delete" />
+ </Button>
+ <Button
+ Grid.Column="1"
+ Margin="0,40,0,0"
+ Click="SelectApartment"
+ DataContext="{Binding ElementName=ApartmentsList, Path=DataContext}"
+ Style="{StaticResource ActionButtonStyle}">
+ <SymbolIcon Symbol="Edit" ToolTipService.ToolTip="Edit" />
+
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmEditApartmentPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ </Grid>
+ </Grid>
+ </DataTemplate>
+ </ListView.ItemTemplate>
+ </ListView>
+ </Grid>
+</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml.cs b/ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml.cs
new file mode 100644
index 0000000..d7adedb
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmApartmentsPage.xaml.cs
@@ -0,0 +1,29 @@
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+
+namespace ApartmentManager.View
+{
+ /// <summary>
+ /// Page for managing apartments.
+ /// </summary>
+ public sealed partial class BmApartmentsPage : Page
+ {
+ public BmApartmentsPage()
+ {
+ InitializeComponent();
+ }
+
+ private void SelectApartment(object sender, RoutedEventArgs e)
+ {
+ var item = ((Grid)((Button)sender).Parent).DataContext;
+ var container = (ListViewItem)ApartmentsList.ContainerFromItem(item);
+
+ container.IsSelected = true;
+ }
+
+ private void GoToCreateApartmentPage(object sender, RoutedEventArgs e)
+ {
+ Frame.Navigate(typeof(BmCreateApartmentPage));
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml b/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml
new file mode 100644
index 0000000..6914288
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml
@@ -0,0 +1,11 @@
+<Page
+ x:Class="ApartmentManager.View.BmChangesPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:local="using:ApartmentManager.View"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ mc:Ignorable="d">
+
+ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" />
+</Page>
diff --git a/ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml.cs b/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml.cs
index ebefddc..c729da8 100644
--- a/ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml.cs
+++ b/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml.cs
@@ -20,9 +20,9 @@ namespace ApartmentManager.View
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
- public sealed partial class InfoForBoardMembers : Page
+ public sealed partial class BmChangesPage : Page
{
- public InfoForBoardMembers()
+ public BmChangesPage()
{
this.InitializeComponent();
}
diff --git a/ApartmentManager/ApartmentManager/View/BmContractOwnersPage.xaml b/ApartmentManager/ApartmentManager/View/BmContractOwnersPage.xaml
new file mode 100644
index 0000000..eed56f1
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmContractOwnersPage.xaml
@@ -0,0 +1,11 @@
+<Page
+ x:Class="ApartmentManager.View.BmContractOwnersPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:local="using:ApartmentManager.View"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ mc:Ignorable="d">
+
+ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" />
+</Page>
diff --git a/ApartmentManager/ApartmentManager/View/DefectsPicturesBoard.xaml.cs b/ApartmentManager/ApartmentManager/View/BmContractOwnersPage.xaml.cs
index de9332c..389ee44 100644
--- a/ApartmentManager/ApartmentManager/View/DefectsPicturesBoard.xaml.cs
+++ b/ApartmentManager/ApartmentManager/View/BmContractOwnersPage.xaml.cs
@@ -20,9 +20,9 @@ namespace ApartmentManager.View
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
- public sealed partial class DefectsPicturesBoard : Page
+ public sealed partial class BmContractOwnersPage : Page
{
- public DefectsPicturesBoard()
+ public BmContractOwnersPage()
{
this.InitializeComponent();
}
diff --git a/ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml b/ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml
new file mode 100644
index 0000000..dd19315
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml
@@ -0,0 +1,81 @@
+<Page
+ x:Class="ApartmentManager.View.BmCreateApartmentPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ 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"
+ xmlns:vm="using:ApartmentManager.ViewModel"
+ mc:Ignorable="d">
+
+ <Page.DataContext>
+ <vm:BmViewModel />
+ </Page.DataContext>
+
+ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="600" />
+ <ColumnDefinition Width="300"/>
+ </Grid.ColumnDefinitions>
+ <Button
+ Margin="0,20,20,0"
+ HorizontalAlignment="Right"
+ VerticalAlignment="Top"
+ Command="{Binding UploadApartmentPlanCommand}"
+ Content="Add plan" />
+ <Image
+ Margin="20,80"
+ VerticalAlignment="Top"
+ Source="{Binding ApartmentTemplate.PlanPicture}" />
+ <StackPanel
+ Grid.Column="1"
+ Margin="20,0,0,0"
+ VerticalAlignment="Top"
+ Orientation="Vertical">
+ <TextBlock
+ Margin="0,10,0,10"
+ HorizontalAlignment="Center"
+ FontSize="20"
+ FontWeight="Bold"
+ Text="Apartment information:" />
+ <TextBlock Margin="0,10,0,10" Text="Apartment number:" />
+ <TextBox Text="{Binding ApartmentTemplate.ApartmentId, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Square meters:" />
+ <TextBox Text="{Binding ApartmentTemplate.Size, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Number of rooms:" />
+ <TextBox Text="{Binding ApartmentTemplate.NumberOfRooms, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Monthly charge:" />
+ <TextBox Text="{Binding ApartmentTemplate.MonthlyCharge, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Floor:" />
+ <TextBox Text="{Binding ApartmentTemplate.Floor, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Address:" />
+ <TextBox Text="{Binding ApartmentTemplate.Address, Mode=TwoWay}" />
+ <StackPanel Margin="0,20,0,0" Orientation="Horizontal" Width="150" HorizontalAlignment="Right">
+ <Button
+ Margin="0,0,20,0"
+ Content="Go back" HorizontalAlignment="Right">
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmApartmentsPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ <Button
+ Background="#FF274CCD"
+ Command="{Binding CreateApartmentCommand}"
+ Content="Add"
+ Foreground="White" HorizontalAlignment="Right">
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmApartmentsPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ </StackPanel>
+ </StackPanel>
+ </Grid>
+ </Grid>
+</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml.cs b/ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml.cs
new file mode 100644
index 0000000..41c3f67
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmCreateApartmentPage.xaml.cs
@@ -0,0 +1,15 @@
+using Windows.UI.Xaml.Controls;
+
+namespace ApartmentManager.View
+{
+ /// <summary>
+ /// Page for adding new apartment.
+ /// </summary>
+ public sealed partial class BmCreateApartmentPage : Page
+ {
+ public BmCreateApartmentPage()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml b/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml
new file mode 100644
index 0000000..5cc0506
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml
@@ -0,0 +1,16 @@
+<Page
+ x:Class="ApartmentManager.View.BmDefectsPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:local="using:ApartmentManager.View"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:vm="using:ApartmentManager.ViewModel"
+ mc:Ignorable="d">
+
+ <Page.DataContext>
+ <vm:BmViewModel />
+ </Page.DataContext>
+
+ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" />
+</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml.cs b/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml.cs
new file mode 100644
index 0000000..638cc3d
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml.cs
@@ -0,0 +1,16 @@
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+
+namespace ApartmentManager.View
+{
+ /// <summary>
+ /// Page for managing defects.
+ /// </summary>
+ public sealed partial class BmDefectsPage : Page
+ {
+ public BmDefectsPage()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml b/ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml
new file mode 100644
index 0000000..d52cdaa
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml
@@ -0,0 +1,87 @@
+<Page
+ x:Class="ApartmentManager.View.BmEditApartmentPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ 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"
+ xmlns:vm="using:ApartmentManager.ViewModel"
+ mc:Ignorable="d">
+ <Page.DataContext>
+ <vm:BmViewModel />
+ </Page.DataContext>
+
+ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="600" />
+ <ColumnDefinition Width="300" />
+ </Grid.ColumnDefinitions>
+ <Button
+ Margin="0,20,20,0"
+ HorizontalAlignment="Right"
+ VerticalAlignment="Top"
+ Command="{Binding UploadApartmentPlanCommand}"
+ Content="Add plan" />
+ <Image
+ Margin="20,80"
+ VerticalAlignment="Top"
+ Source="{Binding ApartmentTemplate.PlanPicture}" />
+ <StackPanel
+ Grid.Column="1"
+ Margin="20,0,0,0"
+ VerticalAlignment="Top"
+ Orientation="Vertical">
+ <TextBlock
+ Margin="0,10,0,10"
+ HorizontalAlignment="Center"
+ FontSize="20"
+ FontWeight="Bold"
+ Text="Apartment information:" />
+ <TextBlock Margin="0,10,0,10" Text="Apartment number:" />
+ <TextBox Text="{Binding ApartmentTemplate.ApartmentId, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Square meters:" />
+ <TextBox Text="{Binding ApartmentTemplate.Size, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Number of rooms:" />
+ <TextBox Text="{Binding ApartmentTemplate.NumberOfRooms, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Monthly charge:" />
+ <TextBox Text="{Binding ApartmentTemplate.MonthlyCharge, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Floor:" />
+ <TextBox Text="{Binding ApartmentTemplate.Floor, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Address:" />
+ <TextBox Text="{Binding ApartmentTemplate.Address, Mode=TwoWay}" />
+ <StackPanel
+ Width="170"
+ Margin="0,20,0,0"
+ HorizontalAlignment="Right"
+ Orientation="Horizontal">
+ <Button
+ Margin="0,0,20,0"
+ HorizontalAlignment="Right"
+ Content="Go back"
+ Command="{Binding GetApartmentsCommand}">
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmApartmentsPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ <Button
+ HorizontalAlignment="Right"
+ Background="#FF274CCD"
+ Command="{Binding UpdateApartmentCommand}"
+ Content="Update"
+ Foreground="White">
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmApartmentsPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ </StackPanel>
+ </StackPanel>
+ </Grid>
+ </Grid>
+</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml.cs b/ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml.cs
new file mode 100644
index 0000000..63e71eb
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmEditApartmentPage.xaml.cs
@@ -0,0 +1,15 @@
+using Windows.UI.Xaml.Controls;
+
+namespace ApartmentManager.View
+{
+ /// <summary>
+ /// Page for editing apartment.
+ /// </summary>
+ public sealed partial class BmEditApartmentPage : Page
+ {
+ public BmEditApartmentPage()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/View/BmMainPage.xaml b/ApartmentManager/ApartmentManager/View/BmMainPage.xaml
new file mode 100644
index 0000000..77abf21
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmMainPage.xaml
@@ -0,0 +1,89 @@
+<Page
+ x:Class="ApartmentManager.View.BmMainPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ 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"
+ xmlns:vm="using:ApartmentManager.ViewModel"
+ mc:Ignorable="d">
+ <Page.DataContext>
+ <vm:BmViewModel />
+ </Page.DataContext>
+
+ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
+ <TextBlock
+ Margin="80,30,0,0"
+ FontSize="36"
+ Text="Welcome, board member!" />
+ <Grid Margin="100,100,0,0">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="600" />
+ <ColumnDefinition Width="200" />
+ </Grid.ColumnDefinitions>
+ <Image
+ Grid.Column="0"
+ VerticalAlignment="Top"
+ Source="ms-appx:///Assets/Ostbanehus.jpg" />
+ <StackPanel Grid.Column="1" Margin="20,0,0,0">
+ <TextBlock
+ Margin="0,0,0,10"
+ HorizontalAlignment="Stretch"
+ FontSize="20"
+ Text="Manage:" />
+ <Button
+ Margin="0,0,0,10"
+ HorizontalAlignment="Stretch"
+ Content="Apartments">
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmApartmentsPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ <Button
+ Margin="0,0,0,10"
+ HorizontalAlignment="Stretch"
+ Content="Contract owners">
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmContractOwnersPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ <Button
+ Margin="0,0,0,10"
+ HorizontalAlignment="Stretch"
+ Content="Residents">
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmResidentsPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ <Button
+ Margin="0,0,0,10"
+ HorizontalAlignment="Stretch"
+ Content="Defects">
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmDefectsPage" />
+ </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.BmChangesPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ </StackPanel>
+ </Grid>
+ </Grid>
+</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BmMainPage.xaml.cs b/ApartmentManager/ApartmentManager/View/BmMainPage.xaml.cs
new file mode 100644
index 0000000..5d287f1
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmMainPage.xaml.cs
@@ -0,0 +1,16 @@
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+
+namespace ApartmentManager.View
+{
+ /// <summary>
+ /// Main page for board members.
+ /// </summary>
+ public sealed partial class BmMainPage : Page
+ {
+ public BmMainPage()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/View/BmResidentsPage.xaml b/ApartmentManager/ApartmentManager/View/BmResidentsPage.xaml
new file mode 100644
index 0000000..7607d86
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmResidentsPage.xaml
@@ -0,0 +1,11 @@
+<Page
+ x:Class="ApartmentManager.View.BmResidentsPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:local="using:ApartmentManager.View"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ mc:Ignorable="d">
+
+ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" />
+</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BoardMemberCreateApartmentPage.xaml.cs b/ApartmentManager/ApartmentManager/View/BmResidentsPage.xaml.cs
index 8098474..2a43996 100644
--- a/ApartmentManager/ApartmentManager/View/BoardMemberCreateApartmentPage.xaml.cs
+++ b/ApartmentManager/ApartmentManager/View/BmResidentsPage.xaml.cs
@@ -20,9 +20,9 @@ namespace ApartmentManager.View
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
- public sealed partial class BoardMemberCreateApartmentPage : Page
+ public sealed partial class BmResidentsPage : Page
{
- public BoardMemberCreateApartmentPage()
+ public BmResidentsPage()
{
this.InitializeComponent();
}
diff --git a/ApartmentManager/ApartmentManager/View/BoardMemberCreateApartmentPage.xaml b/ApartmentManager/ApartmentManager/View/BoardMemberCreateApartmentPage.xaml
deleted file mode 100644
index d243381..0000000
--- a/ApartmentManager/ApartmentManager/View/BoardMemberCreateApartmentPage.xaml
+++ /dev/null
@@ -1,35 +0,0 @@
-<Page
- 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:ViewModel="using:ApartmentManager.ViewModel"
- x:Class="ApartmentManager.View.BoardMemberCreateApartmentPage"
- mc:Ignorable="d">
-
-
- <Page.DataContext>
- <ViewModel:BoardMemberViewModel/>
- </Page.DataContext>
-
-
- <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
- <StackPanel HorizontalAlignment="Center" Orientation="Vertical" VerticalAlignment="Center">
- <TextBlock Margin="0,10,0,10" Text="Apartment information:" HorizontalAlignment="Center" FontSize="20" FontWeight="Bold"/>
- <TextBlock Margin="0,10,0,10" Text="Apartment number:"/>
- <TextBox Text="{Binding NewApartment.ApartmentNumber, Mode=TwoWay}" />
- <TextBlock Margin="0,10,0,10" Text="Square meters:"/>
- <TextBox Text="{Binding NewApartment.Size, Mode=TwoWay}" />
- <TextBlock Margin="0,10,0,10" Text="Number of rooms:"/>
- <TextBox Text="{Binding NewApartment.NumberOfRooms}"></TextBox>
- <TextBlock Margin="0,10,0,10" Text="Monthly charge:"/>
- <TextBox Text="{Binding NewApartment.MonthlyCharge, Mode=TwoWay}" />
- <TextBlock Margin="0,10,0,10" Text="Floor:"/>
- <TextBox Text="{Binding NewApartment.Floor, Mode=TwoWay}" />
- <TextBlock Margin="0,10,0,10" Text="Address:" ></TextBlock>
- <TextBox Text="{Binding NewApartment.Floor, Mode=TwoWay}"></TextBox>
- <Button Content="Add" Width="225" Margin="0 20" Command="{Binding CreateApartmentCommand}"></Button>
- </StackPanel>
- </Grid>
-</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml b/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml
deleted file mode 100644
index 7e164a5..0000000
--- a/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml
+++ /dev/null
@@ -1,33 +0,0 @@
-<Page
- 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:ViewModel="using:ApartmentManager.ViewModel"
- x:Class="ApartmentManager.View.BoardMemberManageApartment"
- mc:Ignorable="d">
-
-
- <Page.DataContext>
- <ViewModel:BoardMemberViewModel/>
- </Page.DataContext>
-
- <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
-
- <StackPanel Margin="0 0" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="top" Width="1100" >
- <StackPanel Orientation="Vertical">
- <Frame Background="Bisque">
- <ListView FontSize="20" FontWeight="Bold" FontFamily="Georgia" HorizontalAlignment="Left" VerticalAlignment="Top" Width="1100" ItemsSource="{Binding BoardMemberCatalogSingleton.Apartment}" SelectedItem="{Binding NewApartment, Mode=TwoWay}" Height="567"/>
- </Frame>
- <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 0">
- <Button Width="150" Margin="50 0" Content="View residents" Click="ButtonBase_OnClick"></Button>
- <Button Width="150" Content="Add apartment" Click="CreateApartment" VerticalAlignment="Bottom" HorizontalAlignment="Center"></Button>
- <Button Width="150" Margin="50 0" Content="Delete apartment" Command="{Binding DeleteApartmentCommand}" VerticalAlignment="Bottom" HorizontalAlignment="Center"></Button>
- <Button Width="150" Content="Update apartment" VerticalAlignment="Bottom" HorizontalAlignment="Center"></Button>
- <TextBox Width="150" Text="Filter apartments" Margin="50 0" Name="TextFilter"></TextBox>
- </StackPanel>
- </StackPanel>
- </StackPanel>
- </Grid>
-</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs b/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs
deleted file mode 100644
index bbda517..0000000
--- a/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices.WindowsRuntime;
-using Windows.Foundation;
-using Windows.Foundation.Collections;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Controls.Primitives;
-using Windows.UI.Xaml.Data;
-using Windows.UI.Xaml.Input;
-using Windows.UI.Xaml.Media;
-using Windows.UI.Xaml.Navigation;
-using ApartmentManager.Model;
-using ApartmentManager.Singletons;
-
-// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
-
-namespace ApartmentManager.View
-{
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public sealed partial class BoardMemberManageApartment : Page
- {
- public BoardMemberManageApartment()
- {
- this.InitializeComponent();
- }
-
- private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
- {
- this.Frame.Navigate(typeof(InfoForBoardMembers));
- }
-
- private void CreateApartment(object sender, RoutedEventArgs e)
- {
- this.Frame.Navigate(typeof(BoardMemberCreateApartmentPage));
- }
-
- //private bool ApartmentFilter(object item)
- //{
- // if (String.IsNullOrEmpty(TextFilter.Text))
- // return true;
- // else
- // return BoardMemberCatalogSingleton.Instance.Apartment.IndexOf(TextFilter.Text));
- //}
-
- //private void txtFilter_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
- //{
- // CollectionViewSource.GetDefaultView(lvUsers.ItemsSource).Refresh();
- //}
- }
-}
diff --git a/ApartmentManager/ApartmentManager/View/BoardMembersDefectsPage.xaml b/ApartmentManager/ApartmentManager/View/BoardMembersDefectsPage.xaml
deleted file mode 100644
index 28766d5..0000000
--- a/ApartmentManager/ApartmentManager/View/BoardMembersDefectsPage.xaml
+++ /dev/null
@@ -1,30 +0,0 @@
-<Page
- 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:ViewModel="using:ApartmentManager.ViewModel"
- x:Class="ApartmentManager.View.BoardMembersDefectsPage"
- mc:Ignorable="d">
-
- <Page.DataContext>
- <ViewModel:BoardMemberViewModel/>
- </Page.DataContext>
-
- <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
- <StackPanel>
- <ListView Margin="100" ItemsSource="{Binding BoardMemberCatalogSingleton.Defects}" SelectedItem="{Binding NewDefect, Mode=TwoWay}"/>
- <StackPanel Margin="100 0" >
- <TextBlock Text="{Binding BoardMemberCatalogSingleton.Defects[0].ApartmentNumber}" FontSize="20"/>
- <TextBlock Text="{Binding BoardMemberCatalogSingleton.Defects[0].Name}"></TextBlock>
- <TextBlock Text="{Binding BoardMemberCatalogSingleton.Defects[0].DateUploaded}"></TextBlock>
- <TextBlock Text="{Binding BoardMemberCatalogSingleton.Defects[0].Comment}"></TextBlock>
- <TextBlock Text="{Binding BoardMemberCatalogSingleton.Defects[0].DefectNumber}"></TextBlock>
- <TextBlock Text="{Binding BoardMemberCatalogSingleton.Defects[0].Description}"></TextBlock>
- <TextBlock Text="{Binding BoardMemberCatalogSingleton.Defects[0].Status}"></TextBlock>
- </StackPanel>
- <Button Content="View pictures" Margin="100 40" Click="PicturesDefects"></Button>
- </StackPanel>
- </Grid>
-</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BoardMembersDefectsPage.xaml.cs b/ApartmentManager/ApartmentManager/View/BoardMembersDefectsPage.xaml.cs
deleted file mode 100644
index d910d39..0000000
--- a/ApartmentManager/ApartmentManager/View/BoardMembersDefectsPage.xaml.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices.WindowsRuntime;
-using Windows.Foundation;
-using Windows.Foundation.Collections;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Controls.Primitives;
-using Windows.UI.Xaml.Data;
-using Windows.UI.Xaml.Input;
-using Windows.UI.Xaml.Media;
-using Windows.UI.Xaml.Navigation;
-
-// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
-
-namespace ApartmentManager.View
-{
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public sealed partial class BoardMembersDefectsPage : Page
- {
- public BoardMembersDefectsPage()
- {
- this.InitializeComponent();
- }
-
- private void PicturesDefects(object sender, RoutedEventArgs e)
- {
- this.Frame.Navigate(typeof(DefectsPicturesBoard));
- }
- }
-}
diff --git a/ApartmentManager/ApartmentManager/View/BoardMembersMainPage.xaml b/ApartmentManager/ApartmentManager/View/BoardMembersMainPage.xaml
deleted file mode 100644
index 0cc58ab..0000000
--- a/ApartmentManager/ApartmentManager/View/BoardMembersMainPage.xaml
+++ /dev/null
@@ -1,29 +0,0 @@
-<Page
- 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:ViewModel="using:ApartmentManager.ViewModel"
- x:Class="ApartmentManager.View.BoardMembersMainPage"
- mc:Ignorable="d">
- <Page.DataContext>
- <ViewModel:BoardMemberViewModel/>
- </Page.DataContext>
-
-
- <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
- <StackPanel Orientation="Vertical">
- <TextBlock Text="Welcome to board memeber page" HorizontalAlignment="Center" FontSize="30" Margin="0 10"></TextBlock>
- <StackPanel Orientation="Vertical" HorizontalAlignment="Right" VerticalAlignment="top" >
- <Image Source="../Assets/Ostbanehus.jpg" Margin="0 0 0 40" Width="600"/>
- <TextBlock Text="Manage:" FontSize="30" HorizontalAlignment="Center" Margin="0 20"></TextBlock>
- <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="270 0">
- <!--<Button Width="150" Height="80" Content="Residents" Click="Residents" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>-->
- <Button Width="150" Height="80" Margin="150 0" Content="Defects" Click="Defects" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
- <Button Width="150" Height="80" Margin="100 0" Content="Apartments" Click="Apartments" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
- </StackPanel>
- </StackPanel>
- </StackPanel>
- </Grid>
-</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BoardMembersMainPage.xaml.cs b/ApartmentManager/ApartmentManager/View/BoardMembersMainPage.xaml.cs
deleted file mode 100644
index 3cde697..0000000
--- a/ApartmentManager/ApartmentManager/View/BoardMembersMainPage.xaml.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices.WindowsRuntime;
-using Windows.Foundation;
-using Windows.Foundation.Collections;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Controls.Primitives;
-using Windows.UI.Xaml.Data;
-using Windows.UI.Xaml.Input;
-using Windows.UI.Xaml.Media;
-using Windows.UI.Xaml.Navigation;
-
-// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
-
-namespace ApartmentManager.View
-{
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public sealed partial class BoardMembersMainPage : Page
- {
- public BoardMembersMainPage()
- {
- this.InitializeComponent();
- }
-
- private void Defects(object sender, RoutedEventArgs e)
- {
- Frame.Navigate(typeof(BoardMembersDefectsPage));
- }
-
- private void Apartments(object sender, RoutedEventArgs e)
- {
- this.Frame.Navigate(typeof(BoardMemberManageApartment));
- }
-
- private void Residents(object sender, RoutedEventArgs e)
- {
- this.Frame.Navigate(typeof(ApartmentResidentsPage));
- }
- }
-}
diff --git a/ApartmentManager/ApartmentManager/View/DefectsPicturesBoard.xaml b/ApartmentManager/ApartmentManager/View/DefectsPicturesBoard.xaml
deleted file mode 100644
index aea4544..0000000
--- a/ApartmentManager/ApartmentManager/View/DefectsPicturesBoard.xaml
+++ /dev/null
@@ -1,30 +0,0 @@
-<Page
- 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:ViewModel="using:ApartmentManager.ViewModel"
- x:Class="ApartmentManager.View.DefectsPicturesBoard"
- mc:Ignorable="d">
-
- <Page.DataContext>
- <ViewModel:BoardMemberViewModel/>
- </Page.DataContext>
-
- <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
- <StackPanel Orientation="Vertical">
- <StackPanel Margin="0 50" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center">
- <Image Width="500" Source="../Assets/Person3.jpg"></Image>
- <Image Width="500" Source="../Assets/Person1.jpg" Height="309"></Image>
- <Image Width="500" Source="../Assets/Person2.jpg"></Image>
- </StackPanel>
- <StackPanel Orientation="Vertical">
- <TextBlock Text="Description of the deffect:" HorizontalAlignment="Center" FontSize="20"></TextBlock>
- <TextBlock Text="{Binding BoardMemberCatalogSingleton.Defects[0].Description}" TextWrapping="Wrap" Margin="0 10" Width="400"></TextBlock>
- <TextBlock Text="Comment" HorizontalAlignment="Center" FontSize="20"></TextBlock>
- <TextBlock Text="{Binding BoardMemberCatalogSingleton.Defects[0].Comment}" TextWrapping="Wrap" Margin="0 10" Width="400"></TextBlock>
- </StackPanel>
- </StackPanel>
- </Grid>
-</Page>
diff --git a/ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml b/ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml
deleted file mode 100644
index e5400a1..0000000
--- a/ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml
+++ /dev/null
@@ -1,48 +0,0 @@
-<Page
- 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:ViewModel="using:ApartmentManager.ViewModel"
- x:Class="ApartmentManager.View.InfoForBoardMembers"
- mc:Ignorable="d">
-
- <Page.DataContext>
- <ViewModel:BoardMemberViewModel/>
- </Page.DataContext>
-
- <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
- <StackPanel Margin="50" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="top" >
- <StackPanel Width="650">
- <StackPanel>
- <ListView ItemsSource="{Binding BoardMemberCatalogSingleton.Residents}" SelectedItem="{Binding NewResident, Mode=TwoWay}"></ListView>
- </StackPanel>
- </StackPanel>
- <StackPanel Margin="50" Orientation="Horizontal" HorizontalAlignment="Right">
- <StackPanel Width="400" Margin="0,0,50,0">
- <StackPanel Orientation="Vertical" HorizontalAlignment="Left">
- <Image Source="../Assets/Person1.jpg"></Image>
- <TextBlock Margin="0,10,0,10" Text="Resident Info" HorizontalAlignment="Center" FontSize="20" FontWeight="Bold"/>
- <TextBlock Margin="0,10,0,10" Text="Name"/>
- <TextBox Text="{Binding NewResident.Name, Mode=TwoWay}" />
- <TextBlock Margin="0,10,0,10" Text="Last Name"/>
- <TextBox Text="{Binding NewResident.LastName, Mode=TwoWay}" />
- <TextBlock Margin="0,10,0,10" Text="Birthdate"/>
- <DatePicker HorizontalAlignment="Stretch" Date="{Binding NewResident.BirthDate, Mode=TwoWay}"/>
- <TextBlock Margin="0,10,0,10" Text="Email Address"/>
- <TextBox Text="{Binding NewResident.Email, Mode=TwoWay}" />
- <TextBlock Margin="0,10,0,10" Text="Phone Number"/>
- <TextBox Text="{Binding NewResident.Phone, Mode=TwoWay}" />
- <StackPanel Orientation="Horizontal">
- <Button Margin="0,10,12,10" Content="Create" Width="125"/>
- <Button Margin="0,10,0,10" Content="Delte" Width="125"/>
- <Button Margin="13,10,0,10" Content="Update" Width="125"/>
- </StackPanel>
- </StackPanel>
- </StackPanel>
- </StackPanel>
- </StackPanel>
-
- </Grid>
-</Page>
diff --git a/ApartmentManager/ApartmentManager/ViewModel/BmViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/BmViewModel.cs
new file mode 100644
index 0000000..9faf80e
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/ViewModel/BmViewModel.cs
@@ -0,0 +1,61 @@
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Windows.Input;
+using ApartmentManager.Annotations;
+using ApartmentManager.Common;
+using ApartmentManager.Model;
+using ApartmentManager.Singletons;
+using ApartmentManager.Handler;
+
+namespace ApartmentManager.ViewModel
+{
+ public class BmViewModel : INotifyPropertyChanged
+ {
+ public BmSingleton BmSingleton { get; } = BmSingleton.Instance;
+ public BmHandler BmHandler { get; }
+
+ public int[] FloorNumbers { get; } = new int[] { 0, 1, 2, 3, 4 };
+ public int SelectedFloor { get; set; }
+
+ public ICommand CreateApartmentCommand { get; }
+ public ICommand DeleteApartmentCommand { get; }
+ public ICommand UpdateApartmentCommand { get; }
+ public ICommand UploadApartmentPlanCommand { get; }
+ public ICommand ClearApartmentTemplateCommand { get; }
+ public ICommand GetApartmentsCommand { get; }
+
+ public ICommand DeleteDefectCommand { get; }
+
+ private static Apartment _apartmentTemplate = new Apartment();
+
+ public BmViewModel()
+ {
+ BmHandler = new BmHandler(this);
+
+ CreateApartmentCommand = new RelayCommand(BmHandler.CreateApartment);
+ DeleteApartmentCommand = new RelayCommand(BmHandler.DeleteApartment);
+ UpdateApartmentCommand = new RelayCommand(BmHandler.UpdateApartment);
+ UploadApartmentPlanCommand = new RelayCommand(BmHandler.UploadApartmentPlan);
+ ClearApartmentTemplateCommand = new RelayCommand(BmHandler.ClearApartmentTemplate);
+ GetApartmentsCommand = new RelayCommand(BmHandler.GetApartments);
+ }
+
+ public Apartment ApartmentTemplate
+ {
+ get => _apartmentTemplate;
+ set
+ {
+ _apartmentTemplate = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs
deleted file mode 100644
index db80503..0000000
--- a/ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Input;
-using ApartmentManager.Annotations;
-using ApartmentManager.Common;
-using ApartmentManager.Model;
-using ApartmentManager.Singletons;
-
-namespace ApartmentManager.ViewModel
-{
- public class BoardMemberViewModel : INotifyPropertyChanged
- {
- public BoardMemberCatalogSingleton BoardMemberCatalogSingleton { get; set; }
-
- public UserSingleton UserSingleton { get; set; }
- private User _newUser;
- private Resident _newResident;
- private Apartment _newApartment;
- private Defect _newDefect;
-
- public static int ApartmentsNumber { get; set; }
- public Handler.BoardMemberHandler BoardMemberHandler { get; set; }
-
- public Handler.BoardResidentsHandler BoardResidentsHandler { get; set; }
-
- public ICommand CreateApartmentCommand { get; set; }
- public ICommand DeleteApartmentCommand { get; set; }
- public ICommand UpdateApartmentCommand { get; set; }
-
- public ICommand DeleteDefectCommand { get; set; }
-
- public BoardMemberViewModel()
- {
- NewUser = new User();
- NewResident = new Resident();
- NewApartment = new Apartment();
- NewDefect = new Defect();
-
- BoardResidentsHandler = new Handler.BoardResidentsHandler(this);
- BoardMemberHandler = new Handler.BoardMemberHandler(this);
- BoardMemberCatalogSingleton = BoardMemberCatalogSingleton.Instance;
- UserSingleton = UserSingleton.Instance;
- ApartmentsNumber = UserSingleton.CurrentUser.ApartmentId;
-
- CreateApartmentCommand = new RelayCommand(BoardMemberHandler.CreateApartment);
- DeleteApartmentCommand = new RelayCommand(BoardMemberHandler.DeleteApartment);
- UpdateApartmentCommand = new RelayCommand(BoardMemberHandler.UpdateApartment);
- BoardMemberHandler.GetApartments();
- BoardResidentsHandler.GetApartmentsResidents();
- }
-
- public User NewUser
- {
- get => _newUser;
- set
- {
- _newUser = value;
- OnPropertyChanged();
- }
- }
- public Resident NewResident
- {
- get => _newResident;
- set
- {
- _newResident = value;
- OnPropertyChanged();
- }
- }
-
- public Apartment NewApartment
- {
- get => _newApartment;
- set
- {
- _newApartment = value;
- OnPropertyChanged();
- }
- }
-
- public Defect NewDefect
- {
- get => _newDefect;
- set
- {
- _newDefect = value;
- OnPropertyChanged();
- }
- }
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- [NotifyPropertyChangedInvocator]
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- }
-}
diff --git a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs
index 0031061..82b7f97 100644
--- a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs
+++ b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs
@@ -1,106 +1,22 @@
using ApartmentManager.Common;
using ApartmentManager.Handler;
-using ApartmentManager.Model;
-using ApartmentManager.View;
-using System;
using System.Windows.Input;
-using Windows.UI.Popups;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using ApartmentManager.Singletons;
namespace ApartmentManager.ViewModel
{
public class LoginViewModel
{
- public static string Username { get; set; }
- public static string Password { get; set; }
+ public string Username { get; set; }
+ public string Password { get; set; }
public ICommand LogInCommand { get; set; }
public ICommand LogOutCommand { get; set; }
+ private LoginHandler loginHandler;
public LoginViewModel()
{
- LogInCommand = new RelayCommand(LogIn);
- LogOutCommand = new RelayCommand(LogOut);
- }
-
- private void LogIn()
- {
- try
- {
- LoginHandler.LogIn(Username, Password);
- NavigateToMainPage();
- }
- catch(Exception ex)
- {
- var msg = new MessageDialog(ex.Message);
- msg.ShowAsync();
- }
- }
-
- private void LogOut()
- {
- LoginHandler.LogOut();
- NavigateToLoginPage();
- Username = null;
- Password = null;
- }
-
- private void NavigateToMainPage()
- {
- AppShell appShell = Window.Current.Content as AppShell;
-
- // Do not repeat app initialization when the Window already has content,
- // just ensure that the window is active
- if (appShell == null)
- {
- // Create a AppShell to act as the navigation context and navigate to the first page
- appShell = new AppShell();
-
- // Set the default language
- appShell.Language = Windows.Globalization.ApplicationLanguages.Languages[0];
-
- }
-
- // Place our app shell in the current Window
- Window.Current.Content = appShell;
-
- if (appShell.AppFrame.Content == null)
- {
- // When the navigation stack isn't restored, navigate to the first page
- // suppressing the initial entrance animation.
- if (UserSingleton.Instance.CurrentUser.IsBm) appShell.AppFrame.Navigate(typeof(BoardMembersMainPage));
- else
- {
- ApartmentViewModel asd = new ApartmentViewModel();
- asd.ApartmentHandler.GetApartmentResidents();
- asd.ApartmentHandler.GetApartment();
- asd.ApartmentHandler.GetApartmentDefects();
- appShell.AppFrame.Navigate(typeof(ApartmentPage));
- }
- }
-
- // Ensure the current window is active
- Window.Current.Activate();
- }
-
- private void NavigateToLoginPage()
- {
- Frame rootFrame = Window.Current.Content as Frame;
-
- // Do not repeat app initialization when the Window already has content,
- // just ensure that the window is active
- if (rootFrame == null)
- {
- // Create a Frame to act as the navigation context and navigate to the first page
- rootFrame = new Frame();
-
- // Place the frame in the current Window
- Window.Current.Content = rootFrame;
- }
-
- rootFrame.Navigate(typeof(LoginPage));
- Window.Current.Activate();
+ loginHandler = new LoginHandler(this);
+ LogInCommand = new RelayCommand(loginHandler.LogIn);
+ LogOutCommand = new RelayCommand(loginHandler.LogOut);
}
}
}