diff options
13 files changed, 602 insertions, 52 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/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/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/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/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/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/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)); + } + } +} |