aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ApartmentManager/ApartmentManager/ApartmentManager.csproj26
-rw-r--r--ApartmentManager/ApartmentManager/AppShell.xaml.cs4
-rw-r--r--ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs143
-rw-r--r--ApartmentManager/ApartmentManager/Handler/LoginHandler.cs2
-rw-r--r--ApartmentManager/ApartmentManager/Model/ApartmentChange.cs50
-rw-r--r--ApartmentManager/ApartmentManager/Model/ChangeComment.cs13
-rw-r--r--ApartmentManager/ApartmentManager/Model/ChangeDocument.cs9
-rw-r--r--ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs3
-rw-r--r--ApartmentManager/ApartmentManager/View/BmChangesPage.xaml137
-rw-r--r--ApartmentManager/ApartmentManager/View/BmChangesPage.xaml.cs33
-rw-r--r--ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml97
-rw-r--r--ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml.cs30
-rw-r--r--ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml108
-rw-r--r--ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml.cs30
-rw-r--r--ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml135
-rw-r--r--ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml.cs30
-rw-r--r--ApartmentManager/ApartmentManager/ViewModel/BmChangesViewModel.cs106
-rw-r--r--ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs10
-rw-r--r--ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs10
-rw-r--r--ApartmentManager/HousingWebApi/DataModel.cs10
-rw-r--r--ApartmentManager/HousingWebApi/HousingWebApi.csproj6
-rw-r--r--ApartmentManager/HousingWebApi/Models/ApartmentChange.cs1
-rw-r--r--ApartmentManager/HousingWebApi/Models/ChangeComment.cs1
-rw-r--r--ApartmentManager/HousingWebApi/Models/ChangeDocument.cs1
24 files changed, 959 insertions, 36 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj
index 377ee1a..b3f941c 100644
--- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj
+++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj
@@ -101,12 +101,16 @@
<Compile Include="Common\RelayCommand.cs" />
<Compile Include="Controls\NavMenuListView.cs" />
<Compile Include="Handler\BmApartmentsHandler.cs" />
+ <Compile Include="Handler\BmChangesHandler.cs" />
<Compile Include="Handler\BmDefectsHandler.cs" />
<Compile Include="Handler\BmResidentsHandler.cs" />
<Compile Include="Handler\BmUsersHandler.cs" />
<Compile Include="Handler\LoginHandler.cs" />
<Compile Include="Handler\ApartmentHandler.cs" />
<Compile Include="Model\Apartment.cs" />
+ <Compile Include="Model\ApartmentChange.cs" />
+ <Compile Include="Model\ChangeComment.cs" />
+ <Compile Include="Model\ChangeDocument.cs" />
<Compile Include="Model\DefectComment.cs" />
<Compile Include="Model\DefectPicture.cs" />
<Compile Include="Persistency\ImgurPhotoUploader.cs" />
@@ -121,6 +125,7 @@
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModel\BmApartmentsViewModel.cs" />
+ <Compile Include="ViewModel\BmChangesViewModel.cs" />
<Compile Include="ViewModel\BmResidentsViewModel.cs" />
<Compile Include="ViewModel\BmUsersViewModel.cs" />
<Compile Include="ViewModel\BmDefectsViewModel.cs" />
@@ -141,12 +146,18 @@
<Compile Include="View\BmChangesPage.xaml.cs">
<DependentUpon>BmChangesPage.xaml</DependentUpon>
</Compile>
+ <Compile Include="View\BmCreateChangePage.xaml.cs">
+ <DependentUpon>BmCreateChangePage.xaml</DependentUpon>
+ </Compile>
<Compile Include="View\BmCreateDefectPage.xaml.cs">
<DependentUpon>BmCreateDefectPage.xaml</DependentUpon>
</Compile>
<Compile Include="View\BmEditApartmentPage.xaml.cs">
<DependentUpon>BmEditApartmentPage.xaml</DependentUpon>
</Compile>
+ <Compile Include="View\BmEditChangePage.xaml.cs">
+ <DependentUpon>BmEditChangePage.xaml</DependentUpon>
+ </Compile>
<Compile Include="View\BmEditDefectPage.xaml.cs">
<DependentUpon>BmEditDefectPage.xaml</DependentUpon>
</Compile>
@@ -165,6 +176,9 @@
<Compile Include="View\BmCreateApartmentPage.xaml.cs">
<DependentUpon>BmCreateApartmentPage.xaml</DependentUpon>
</Compile>
+ <Compile Include="View\BmSingleChangePage.xaml.cs">
+ <DependentUpon>BmSingleChangePage.xaml</DependentUpon>
+ </Compile>
<Compile Include="View\BmSingleDefectPage.xaml.cs">
<DependentUpon>BmSingleDefectPage.xaml</DependentUpon>
</Compile>
@@ -229,6 +243,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="View\BmCreateChangePage.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="View\BmCreateDefectPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -237,6 +255,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="View\BmEditChangePage.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="View\BmEditDefectPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -261,6 +283,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="View\BmSingleChangePage.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="View\BmSingleDefectPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
diff --git a/ApartmentManager/ApartmentManager/AppShell.xaml.cs b/ApartmentManager/ApartmentManager/AppShell.xaml.cs
index 7332ad7..c5fcfe5 100644
--- a/ApartmentManager/ApartmentManager/AppShell.xaml.cs
+++ b/ApartmentManager/ApartmentManager/AppShell.xaml.cs
@@ -69,7 +69,7 @@ namespace ApartmentManager
new NavMenuItem()
{
- Symbol = Symbol.Comment,
+ Symbol = Symbol.Bookmarks,
Label = "Apartments",
DestPage = typeof(BmApartmentsPage),
IsSelected = false
@@ -77,7 +77,7 @@ namespace ApartmentManager
new NavMenuItem()
{
- Symbol = Symbol.Comment,
+ Symbol = Symbol.Bookmarks,
Label = "Contract owners",
DestPage = typeof(BmUsersPage),
IsSelected = false
diff --git a/ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs b/ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs
new file mode 100644
index 0000000..a32bbc2
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/Handler/BmChangesHandler.cs
@@ -0,0 +1,143 @@
+using ApartmentManager.Model;
+using ApartmentManager.Persistency;
+using ApartmentManager.Singletons;
+using ApartmentManager.ViewModel;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Windows.UI.Popups;
+
+namespace ApartmentManager.Handler
+{
+ public class BmChangesHandler
+ {
+ private BmChangesViewModel _vm;
+
+ public BmChangesHandler(BmChangesViewModel vm)
+ {
+ _vm = vm;
+ }
+
+ public void GetChanges()
+ {
+ var changes = JsonConvert.DeserializeObject<ObservableCollection<ApartmentChange>>(ApiClient.GetData("api/ApartmentChanges/"));
+ BmSingleton.Instance.ApartmentChanges.Clear();
+ foreach (var change in changes)
+ {
+ change.Documents = JsonConvert.DeserializeObject<ObservableCollection<ChangeDocument>>(ApiClient.GetData("api/ChangeDocumentsById/" + change.ChangeId));
+ change.Comments = JsonConvert.DeserializeObject<ObservableCollection<ChangeComment>>(ApiClient.GetData("api/ChangeCommentsById/" + change.ChangeId));
+ BmSingleton.Instance.ApartmentChanges.Add(change);
+ }
+ }
+
+ public void CreateChange()
+ {
+ try
+ {
+ _vm.ChangeTemplate.Status = "New";
+ _vm.ChangeTemplate.UploadDate = DateTime.Now;
+ if (_vm.ChangeTemplate.Documents == null) _vm.ChangeTemplate.Documents = new ObservableCollection<ChangeDocument>();
+ var response = JsonConvert.DeserializeObject<ApartmentChange>(ApiClient.PostData("api/ApartmentChanges/", _vm.ChangeTemplate));
+ foreach (var changeDocument in _vm.ChangeTemplate.Documents)
+ {
+ changeDocument.ChangeId = response.ChangeId;
+ ApiClient.PostData("api/ChangeDocuments/", changeDocument);
+ }
+ GetChanges();
+ _vm.ChangeTemplate = new ApartmentChange();
+ }
+ catch (Exception e)
+ {
+ var msg = new MessageDialog(e.Message).ShowAsync();
+ }
+ }
+ public void UpdateChange()
+ {
+ try
+ {
+ ApiClient.PutData("api/ApartmentChanges/" + _vm.ChangeTemplate.ChangeId, _vm.ChangeTemplate);
+ var deletedChangeDocuments = new List<ChangeDocument>(_vm.DeletedChangeDocuments);
+ var addedChangeDocuments = new List<ChangeDocument>(_vm.AddedChangeDocuments);
+
+ foreach (var changeDocument in deletedChangeDocuments)
+ {
+ ApiClient.DeleteData("api/ChangeDocuments/" + changeDocument.DocumentId);
+ _vm.DeletedChangeDocuments.Remove(changeDocument);
+ }
+ foreach (var changeDocument in addedChangeDocuments)
+ {
+ changeDocument.ChangeId = _vm.ChangeTemplate.ChangeId;
+ ApiClient.PostData("api/ChangeDocuments", changeDocument);
+ _vm.AddedChangeDocuments.Remove(changeDocument);
+ }
+ GetChanges();
+ }
+ catch (Exception e)
+ {
+ var msg = new MessageDialog(e.Message).ShowAsync();
+ }
+ }
+ public void DeleteChange()
+ {
+ try
+ {
+ ApiClient.DeleteData("api/ApartmentChanges/" + _vm.ChangeTemplate.ChangeId);
+ BmSingleton.Instance.ApartmentChanges.Remove(_vm.ChangeTemplate);
+ GetChanges();
+ }
+ catch (Exception e)
+ {
+ var msg = new MessageDialog(e.Message).ShowAsync();
+ }
+ }
+
+ public void ClearChangeTemplate()
+ {
+ _vm.ChangeTemplate = new ApartmentChange();
+ }
+
+ public async void UploadChangeDocument()
+ {
+ if (_vm.ChangeTemplate.Documents == null) _vm.ChangeTemplate.Documents = new ObservableCollection<ChangeDocument>();
+ var document = new ChangeDocument() { Document = await ImgurPhotoUploader.UploadPhotoAsync() };
+ _vm.ChangeTemplate.Documents.Add(document);
+ _vm.AddedChangeDocuments.Add(document);
+ }
+
+ public void DeleteChangeDocument()
+ {
+ _vm.ChangeTemplate.Documents.Remove(_vm.SelectedChangeDocument);
+ }
+
+ public void DeleteChangeDocumentTemp()
+ {
+ _vm.DeletedChangeDocuments.Add(_vm.SelectedChangeDocument);
+ _vm.ChangeTemplate.Documents.Remove(_vm.SelectedChangeDocument);
+ }
+
+ public void CreateChangeComment()
+ {
+ try
+ {
+ var comment = new ChangeComment()
+ {
+ Comment = _vm.NewChangeComment.Comment,
+ ChangeId = _vm.ChangeTemplate.ChangeId,
+ Name = UserSingleton.Instance.CurrentUser.FirstName + " " + UserSingleton.Instance.CurrentUser.LastName,
+ Date = DateTimeOffset.Now
+ };
+ if (!string.IsNullOrEmpty(comment.Comment))
+ {
+ ApiClient.PostData("api/ChangeComments/", comment);
+ _vm.ChangeTemplate.Comments.Add(comment);
+ _vm.NewChangeComment = new ChangeComment();
+ }
+ }
+ catch (Exception e)
+ {
+ var msg = new MessageDialog(e.Message).ShowAsync();
+ }
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
index 7db0ba4..9f52a40 100644
--- a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
@@ -79,10 +79,12 @@ namespace ApartmentManager.Handler
BmUsersViewModel buvm = new BmUsersViewModel();
BmResidentsViewModel brvm = new BmResidentsViewModel();
BmDefectsViewModel bdvm = new BmDefectsViewModel();
+ BmChangesViewModel bcvm = new BmChangesViewModel();
bavm.BmApartmentsHandler.GetApartments();
buvm.BmUsersHandler.GetUsers();
brvm.BmResidentsHandler.GetResidents();
bdvm.BmDefectsHandler.GetDefects();
+ bcvm.BmChangesHandler.GetChanges();
appShell.AppFrame.Navigate(typeof(BmMainPage));
}
else
diff --git a/ApartmentManager/ApartmentManager/Model/ApartmentChange.cs b/ApartmentManager/ApartmentManager/Model/ApartmentChange.cs
new file mode 100644
index 0000000..640112c
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/Model/ApartmentChange.cs
@@ -0,0 +1,50 @@
+using ApartmentManager.Annotations;
+using ApartmentManager.Model;
+using System;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace ApartmentManager
+{
+ public class ApartmentChange
+ {
+ public int ChangeId { get; set; }
+ public int ApartmentId { get; set; }
+ public string Name { get; set; }
+ public DateTime UploadDate { get; set; }
+ public string Description { get; set; }
+ public string Status { get; set; }
+ private ObservableCollection<ChangeDocument> _documents;
+ private ObservableCollection<ChangeComment> _comments;
+
+ public ObservableCollection<ChangeDocument> Documents
+ {
+ get => _documents;
+ set
+ {
+ _documents = value;
+ OnPropertyChanged(nameof(Documents));
+ }
+ }
+
+ public ObservableCollection<ChangeComment> Comments
+ {
+ get => _comments;
+ set
+ {
+ _comments = value;
+ OnPropertyChanged(nameof(Comments));
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ [NotifyPropertyChangedInvocator]
+ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/Model/ChangeComment.cs b/ApartmentManager/ApartmentManager/Model/ChangeComment.cs
new file mode 100644
index 0000000..314cd50
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/Model/ChangeComment.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace ApartmentManager.Model
+{
+ public class ChangeComment
+ {
+ public int CommentId { get; set; }
+ public int ChangeId { get; set; }
+ public string Comment { get; set; }
+ public string Name { get; set; }
+ public DateTimeOffset Date { get; set; }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/Model/ChangeDocument.cs b/ApartmentManager/ApartmentManager/Model/ChangeDocument.cs
new file mode 100644
index 0000000..6da6a39
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/Model/ChangeDocument.cs
@@ -0,0 +1,9 @@
+namespace ApartmentManager.Model
+{
+ public class ChangeDocument
+ {
+ public int DocumentId { get; set; }
+ public int ChangeId { get; set; }
+ public string Document { get; set; }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs
index 5ee5019..c12f852 100644
--- a/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs
+++ b/ApartmentManager/ApartmentManager/Singletons/BmSingleton.cs
@@ -12,12 +12,15 @@ namespace ApartmentManager.Singletons
public ObservableCollection<User> Users { get; set; }
public ObservableCollection<Resident> Residents { get; set; }
public ObservableCollection<Defect> Defects { get; set; }
+ public ObservableCollection<ApartmentChange> ApartmentChanges { get; set; }
private BmSingleton()
{
+ Apartments = new ObservableCollection<Apartment>();
Users = new ObservableCollection<User>();
Residents = new ObservableCollection<Resident>();
Defects = new ObservableCollection<Defect>();
+ ApartmentChanges = new ObservableCollection<ApartmentChange>();
}
}
}
diff --git a/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml b/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml
index 6914288..215496b 100644
--- a/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml
+++ b/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml
@@ -2,10 +2,145 @@
x:Class="ApartmentManager.View.BmChangesPage"
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">
- <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" />
+ <Page.Resources>
+ <Style x:Key="ListItemStyle" 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:BmChangesViewModel />
+ </Page.DataContext>
+ <Page.BottomAppBar>
+ <CommandBar>
+ <CommandBar.Content>
+ <Grid />
+ </CommandBar.Content>
+ <AppBarButton
+ Click="GoToCreateChangePage"
+ Command="{Binding ClearChangeTemplateCommand}"
+ Icon="Add"
+ Label="Create Apartment">
+ <AppBarButton.DataContext>
+ <vm:BmChangesViewModel />
+ </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="Change ID: " />
+ <TextBox Height="32" />
+ <TextBlock
+ Margin="10,0"
+ VerticalAlignment="Center"
+ Text="Apartment number: " />
+ <TextBox Height="32" />
+ </StackPanel>
+ <ListView
+ x:Name="ChangesList"
+ Grid.Row="1"
+ ItemsSource="{Binding BmSingleton.ApartmentChanges}"
+ SelectedItem="{Binding ChangeTemplate, Mode=TwoWay}">
+ <ListView.ItemContainerStyle>
+ <Style BasedOn="{StaticResource ListItemStyle}" TargetType="ListViewItem" />
+ </ListView.ItemContainerStyle>
+ <ListView.ItemTemplate>
+ <DataTemplate>
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="150" />
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="50px" />
+ </Grid.ColumnDefinitions>
+ <Image
+ Margin="5"
+ Source="{Binding Documents[0].Document}"
+ Stretch="Fill" />
+ <StackPanel Grid.Column="1" Padding="10">
+ <TextBlock><Run Text="Change ID: " /><Run Text="{Binding ChangeId}" /></TextBlock>
+ <TextBlock><Run Text="Apartment number: " /><Run Text="{Binding ApartmentId}" /></TextBlock>
+ <TextBlock><Run Text="Name: " /><Run Text="{Binding Name}" /></TextBlock>
+ <TextBlock><Run Text="Status: " /><Run Text="{Binding Status}" /></TextBlock>
+ <TextBlock><Run Text="Upload date: " /><Run Text="{Binding UploadDate.Day}" /><Run Text="." /><Run Text="{Binding UploadDate.Month}" /><Run Text="." /><Run Text="{Binding UploadDate.Year}" /></TextBlock>
+ </StackPanel>
+ <Button
+ Grid.Column="2"
+ Click="SelectItem"
+ Command="{Binding DeleteChangeCommand}"
+ DataContext="{Binding ElementName=ChangesList, Path=DataContext}"
+ Style="{StaticResource ActionButtonStyle}">
+ <SymbolIcon Symbol="Clear" ToolTipService.ToolTip="Delete" />
+ </Button>
+ <Button
+ Grid.Column="2"
+ Margin="0,40,0,0"
+ Click="SelectItem"
+ DataContext="{Binding ElementName=ChangesList, Path=DataContext}"
+ Style="{StaticResource ActionButtonStyle}">
+ <SymbolIcon Symbol="Edit" ToolTipService.ToolTip="Edit" />
+
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmEditChangePage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ <Button
+ Grid.Column="2"
+ Margin="0,80,0,0"
+ Click="SelectItem"
+ DataContext="{Binding ElementName=ChangesList, Path=DataContext}"
+ Style="{StaticResource ActionButtonStyle}">
+ <SymbolIcon Symbol="View" ToolTipService.ToolTip="View" />
+
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmSingleChangePage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ </Grid>
+ </DataTemplate>
+ </ListView.ItemTemplate>
+ </ListView>
+ </Grid>
</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml.cs b/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml.cs
index c729da8..a63f85c 100644
--- a/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml.cs
+++ b/ApartmentManager/ApartmentManager/View/BmChangesPage.xaml.cs
@@ -1,30 +1,29 @@
-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;
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.
+ /// Page for managing apartment changes.
/// </summary>
public sealed partial class BmChangesPage : Page
{
public BmChangesPage()
{
- this.InitializeComponent();
+ InitializeComponent();
+ }
+
+ private void SelectItem(object sender, RoutedEventArgs e)
+ {
+ var item = ((Grid)((Button)sender).Parent).DataContext;
+ var container = (ListViewItem)ChangesList.ContainerFromItem(item);
+
+ container.IsSelected = true;
+ }
+
+ private void GoToCreateChangePage(object sender, RoutedEventArgs e)
+ {
+ Frame.Navigate(typeof(BmCreateChangePage));
}
}
}
diff --git a/ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml b/ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml
new file mode 100644
index 0000000..e2e19cd
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml
@@ -0,0 +1,97 @@
+<Page
+ x:Class="ApartmentManager.View.BmCreateChangePage"
+ 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:BmChangesViewModel />
+ </Page.DataContext>
+
+ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
+ <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+ <TextBlock
+ Margin="0,10,0,10"
+ HorizontalAlignment="Center"
+ FontSize="20"
+ FontWeight="Bold"
+ Text="Apartment change information" />
+ <StackPanel Orientation="Horizontal">
+ <StackPanel Margin="0,5,30,0">
+ <ListView
+ Width="500"
+ Height="534"
+ ItemsSource="{Binding ChangeTemplate.Documents, Mode=TwoWay}"
+ SelectedItem="{Binding SelectedChangeDocument, Mode=TwoWay}">
+ <ListView.ItemTemplate>
+ <DataTemplate>
+ <Image
+ Width="400"
+ Margin="10"
+ Source="{Binding Document}" />
+ </DataTemplate>
+ </ListView.ItemTemplate>
+ </ListView>
+ <StackPanel Margin="10" Orientation="Horizontal">
+ <Button
+ Margin="30,0,0,0"
+ Command="{Binding UploadChangeDocumentCommand}"
+ Content="Upload document" />
+ <Button
+ Margin="170,0,0,0"
+ Command="{Binding DeleteChangeDocumentCommand}"
+ Content="Delete document" />
+ </StackPanel>
+ <StackPanel Margin="0,30,0,0" Orientation="Horizontal" />
+ <StackPanel Margin="0,30,0,0" Orientation="Horizontal" />
+ </StackPanel>
+ <StackPanel Width="400" Margin="0,0,50,0">
+ <TextBlock Margin="0,10,0,10" Text="Name" />
+ <TextBox Text="{Binding ChangeTemplate.Name, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Apartment number" />
+ <TextBox Text="{Binding ChangeTemplate.ApartmentId, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Description" />
+ <TextBox
+ Height="345"
+ Text="{Binding ChangeTemplate.Description, Mode=TwoWay}"
+ TextWrapping="Wrap" />
+ <StackPanel
+ Margin="0,20,0,0"
+ HorizontalAlignment="Right"
+ Orientation="Horizontal">
+ <Button
+ Margin="0,0,20,0"
+ HorizontalAlignment="Right"
+ Content="Go back">
+
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmChangesPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ <Button
+ HorizontalAlignment="Right"
+ Background="#FF274CCD"
+ Command="{Binding CreateChangeCommand}"
+ Content="Add"
+ Foreground="White">
+
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmChangesPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ </StackPanel>
+ </StackPanel>
+ </StackPanel>
+ </StackPanel>
+ </Grid>
+</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml.cs b/ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml.cs
new file mode 100644
index 0000000..054bca6
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmCreateChangePage.xaml.cs
@@ -0,0 +1,30 @@
+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 BmCreateChangePage : Page
+ {
+ public BmCreateChangePage()
+ {
+ this.InitializeComponent();
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml b/ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml
new file mode 100644
index 0000000..6d8518a
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml
@@ -0,0 +1,108 @@
+<Page
+ x:Class="ApartmentManager.View.BmEditChangePage"
+ 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:BmChangesViewModel />
+ </Page.DataContext>
+
+ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
+ <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+ <TextBlock
+ Margin="0,10,0,10"
+ HorizontalAlignment="Center"
+ FontSize="20"
+ FontWeight="Bold"
+ Text="Apartment change information" />
+ <StackPanel Orientation="Horizontal">
+ <StackPanel Margin="0,5,30,0">
+ <ListView
+ Width="500"
+ Height="534"
+ ItemsSource="{Binding ChangeTemplate.Documents, Mode=TwoWay}"
+ SelectedItem="{Binding SelectedChangeDocument, Mode=TwoWay}">
+ <ListView.ItemTemplate>
+ <DataTemplate>
+ <Image
+ Width="400"
+ Margin="10"
+ Source="{Binding Document}" />
+ </DataTemplate>
+ </ListView.ItemTemplate>
+ </ListView>
+ <StackPanel Margin="10" Orientation="Horizontal">
+ <Button
+ Margin="30,0,0,0"
+ Command="{Binding UploadChangeDocumentCommand}"
+ Content="Upload Picture" />
+ <Button
+ Margin="170,0,0,0"
+ Command="{Binding DeleteChangeDocumentTempCommand}"
+ Content="Delete Picture" />
+ </StackPanel>
+ <StackPanel Margin="0,30,0,0" Orientation="Horizontal" />
+ <StackPanel Margin="0,30,0,0" Orientation="Horizontal" />
+ </StackPanel>
+ <StackPanel Width="400" Margin="0,0,50,0">
+ <TextBlock Margin="0,10,0,10" Text="Name" />
+ <TextBox Text="{Binding ChangeTemplate.Name, Mode=TwoWay}" />
+ <StackPanel Margin="0,10,0,10" Orientation="Horizontal">
+ <TextBlock
+ Margin="0,0,10,0"
+ VerticalAlignment="Center"
+ Text="Apartment number" />
+ <TextBox Text="{Binding ChangeTemplate.ApartmentId, Mode=TwoWay}" />
+ <TextBlock
+ Margin="20,0,10,0"
+ VerticalAlignment="Center"
+ Text="Status" />
+ <TextBox Width="128" Text="{Binding ChangeTemplate.Status, Mode=TwoWay}" />
+ </StackPanel>
+ <TextBlock Margin="0,0,0,10" Text="Description" />
+ <TextBox
+ Height="375"
+ Text="{Binding ChangeTemplate.Description, Mode=TwoWay}"
+ TextWrapping="Wrap" />
+ <StackPanel
+ Margin="0,20,0,0"
+ HorizontalAlignment="Right"
+ Orientation="Horizontal">
+ <Button
+ Margin="0,0,20,0"
+ HorizontalAlignment="Right"
+ Command="{Binding GetChangesCommand}"
+ Content="Go back">
+
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmChangesPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ <Button
+ HorizontalAlignment="Right"
+ Background="#FF274CCD"
+ Command="{Binding UpdateChangeCommand}"
+ Content="Update"
+ Foreground="White">
+
+ <interactivity:Interaction.Behaviors>
+ <core:EventTriggerBehavior EventName="Click">
+ <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmChangesPage" />
+ </core:EventTriggerBehavior>
+ </interactivity:Interaction.Behaviors>
+ </Button>
+ </StackPanel>
+ </StackPanel>
+ </StackPanel>
+ </StackPanel>
+ </Grid>
+</Page> \ No newline at end of file
diff --git a/ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml.cs b/ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml.cs
new file mode 100644
index 0000000..715f47e
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmEditChangePage.xaml.cs
@@ -0,0 +1,30 @@
+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 BmEditChangePage : Page
+ {
+ public BmEditChangePage()
+ {
+ this.InitializeComponent();
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml b/ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml
new file mode 100644
index 0000000..195095b
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml
@@ -0,0 +1,135 @@
+<Page
+ x:Class="ApartmentManager.View.BmSingleChangePage"
+ 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:BmChangesViewModel />
+ </Page.DataContext>
+
+ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
+ <ScrollViewer>
+ <StackPanel>
+ <StackPanel Margin="10,10,10,0" Orientation="Horizontal">
+ <TextBlock
+ Margin="100,0,0,0"
+ FontSize="30"
+ FontWeight="Bold"
+ Text="Name :" />
+ <TextBlock
+ Margin="10,0,0,0"
+ FontSize="30"
+ Text="{Binding ChangeTemplate.Name}" />
+ <TextBlock
+ Margin="700,0,0,0"
+ FontSize="30"
+ FontWeight="Bold"
+ Text="Status :" />
+ <TextBlock
+ Margin="10,0,0,0"
+ FontSize="30"
+ Text="{Binding ChangeTemplate.Status}" />
+ </StackPanel>
+ <StackPanel Margin="20,0,20,20" Orientation="Horizontal">
+ <StackPanel Width="620" Margin="0,50,0,0">
+ <GridView
+ Width="500"
+ Height="420"
+ ItemsSource="{Binding ChangeTemplate.Documents, Mode=TwoWay}">
+ <GridView.ItemTemplate>
+ <DataTemplate>
+ <Image
+ Width="220"
+ Margin="10,0,10,10"
+ Source="{Binding Document}" />
+ </DataTemplate>
+ </GridView.ItemTemplate>
+
+ </GridView>
+ </StackPanel>
+ <StackPanel Width="620">
+ <TextBlock
+ Margin="10,0,0,10"
+ FontSize="30"
+ FontWeight="Bold"
+ Text="Description" />
+ <Grid BorderBrush="Black" BorderThickness="1">
+ <TextBlock
+ Height="400"
+ Margin="10"
+ Text="{Binding ChangeTemplate.Description, Mode=TwoWay}"
+ TextWrapping="WrapWholeWords" />
+ </Grid>
+
+
+ </StackPanel>
+
+
+ </StackPanel>
+ <StackPanel Width="600" Margin="0,20,0,0">
+ <TextBlock
+ Margin="10,0,0,10"
+ FontSize="30"
+ FontWeight="Bold"
+ Text="Comments" />
+ <StackPanel Orientation="Horizontal">
+
+ <TextBox
+ Width="500"
+ Height="80"
+ Text="{Binding NewChangeComment.Comment, Mode=TwoWay}"
+ TextWrapping="Wrap" />
+ <Button
+ Margin="10,0,0,0"
+ Command="{Binding CreateChangeCommentCommand}"
+ Content="Comment" />
+ </StackPanel>
+
+
+ <ListView ItemsSource="{Binding ChangeTemplate.Comments}">
+ <ListView.ItemContainerStyle>
+ <Style TargetType="ListViewItem">
+ <Setter Property="HorizontalContentAlignment" Value="Stretch" />
+ </Style>
+ </ListView.ItemContainerStyle>
+
+ <ListView.ItemTemplate>
+ <DataTemplate>
+ <Grid Margin="10">
+ <StackPanel>
+ <TextBlock
+ Margin="5,0,0,0"
+ FontWeight="Bold"
+ Text="{Binding Name}" />
+ <TextBlock
+ Margin="5"
+ Text="{Binding Comment}"
+ TextWrapping="WrapWholeWords" />
+ <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
+ <TextBlock Margin="0,0,0,5">
+ <Run FontWeight="Bold" Text="{Binding Date.Year}" />
+ <Run FontWeight="Bold" Text="-" />
+ <Run FontWeight="Bold" Text="{Binding Date.Month}" />
+ <Run FontWeight="Bold" Text="-" />
+ <Run FontWeight="Bold" Text="{Binding Date.Day}" />
+ <Run FontWeight="Bold" Text=" " />
+ <Run FontWeight="Bold" Text="{Binding Date.Hour}" />
+ <Run FontWeight="Bold" Text=":" />
+ <Run FontWeight="Bold" Text="{Binding Date.Minute}" />
+ </TextBlock>
+ </StackPanel>
+ </StackPanel>
+ </Grid>
+ </DataTemplate>
+ </ListView.ItemTemplate>
+ </ListView>
+ </StackPanel>
+ </StackPanel>
+ </ScrollViewer>
+ </Grid>
+</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml.cs b/ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml.cs
new file mode 100644
index 0000000..d4bcc40
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/BmSingleChangePage.xaml.cs
@@ -0,0 +1,30 @@
+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 BmSingleChangePage : Page
+ {
+ public BmSingleChangePage()
+ {
+ this.InitializeComponent();
+ }
+ }
+}
diff --git a/ApartmentManager/ApartmentManager/ViewModel/BmChangesViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/BmChangesViewModel.cs
new file mode 100644
index 0000000..68aa14d
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/ViewModel/BmChangesViewModel.cs
@@ -0,0 +1,106 @@
+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;
+using System.Collections.Generic;
+
+namespace ApartmentManager.ViewModel
+{
+ public class BmChangesViewModel : INotifyPropertyChanged
+ {
+ public BmSingleton BmSingleton { get; } = BmSingleton.Instance;
+ public BmChangesHandler BmChangesHandler { get; }
+
+ public ICommand CreateChangeCommand { get; }
+ public ICommand DeleteChangeCommand { get; }
+ public ICommand UpdateChangeCommand { get; }
+ public ICommand ClearChangeTemplateCommand { get; }
+ public ICommand GetChangesCommand { get; }
+ public ICommand UploadChangeDocumentCommand { get; }
+ public ICommand UploadChangeDocumentTempCommand { get; }
+ public ICommand DeleteChangeDocumentCommand { get; }
+ public ICommand DeleteChangeDocumentTempCommand { get; }
+ public ICommand CreateChangeCommentCommand { get; }
+
+ private static ApartmentChange _changeTemplate = new ApartmentChange();
+ private static ChangeDocument _selectedChangeDocument = new ChangeDocument();
+ private static List<ChangeDocument> _deletedChangeDocuments = new List<ChangeDocument>();
+ private static List<ChangeDocument> _addedChangeDocuments = new List<ChangeDocument>();
+ private static ChangeComment _newChangeComment = new ChangeComment();
+
+ public BmChangesViewModel()
+ {
+ BmChangesHandler = new BmChangesHandler(this);
+
+ CreateChangeCommand = new RelayCommand(BmChangesHandler.CreateChange);
+ DeleteChangeCommand = new RelayCommand(BmChangesHandler.DeleteChange);
+ UpdateChangeCommand = new RelayCommand(BmChangesHandler.UpdateChange);
+ ClearChangeTemplateCommand = new RelayCommand(BmChangesHandler.ClearChangeTemplate);
+ UploadChangeDocumentCommand = new RelayCommand(BmChangesHandler.UploadChangeDocument);
+ DeleteChangeDocumentCommand = new RelayCommand(BmChangesHandler.DeleteChangeDocument);
+ DeleteChangeDocumentTempCommand = new RelayCommand(BmChangesHandler.DeleteChangeDocumentTemp);
+ GetChangesCommand = new RelayCommand(BmChangesHandler.GetChanges);
+ CreateChangeCommentCommand = new RelayCommand(BmChangesHandler.CreateChangeComment);
+ }
+
+ public ApartmentChange ChangeTemplate
+ {
+ get => _changeTemplate;
+ set
+ {
+ _changeTemplate = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public ChangeDocument SelectedChangeDocument
+ {
+ get => _selectedChangeDocument;
+ set
+ {
+ _selectedChangeDocument = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public List<ChangeDocument> DeletedChangeDocuments
+ {
+ get => _deletedChangeDocuments;
+ set
+ {
+ _deletedChangeDocuments = value;
+ }
+ }
+
+ public List<ChangeDocument> AddedChangeDocuments
+ {
+ get => _addedChangeDocuments;
+ set
+ {
+ _addedChangeDocuments = value;
+ }
+ }
+
+ public ChangeComment NewChangeComment
+ {
+ get => _newChangeComment;
+ set
+ {
+ _newChangeComment = 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/HousingWebApi/Controllers/ChangeCommentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs
index bebff8e..11519fd 100644
--- a/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs
+++ b/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs
@@ -16,6 +16,16 @@ namespace HousingWebApi.Controllers
{
private DataModel db = new DataModel();
+ //GET: api/ChangeCommentsById
+ [Route("api/ChangeCommentsById/{id}")]
+ public IQueryable<ChangeComment> GetChangeCommentsById(int id)
+ {
+ var commentsList = from changeComment in db.ChangeComments
+ where (changeComment.ChangeId == id)
+ select changeComment;
+ return commentsList;
+ }
+
// GET: api/ChangeComments
public IQueryable<ChangeComment> GetChangeComments()
{
diff --git a/ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs
index 406ab33..0ffaec0 100644
--- a/ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs
+++ b/ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs
@@ -16,6 +16,16 @@ namespace HousingWebApi.Controllers
{
private DataModel db = new DataModel();
+ //GET: api/ChangeDocumentsById
+ [Route("api/ChangeDocumentsById/{id}")]
+ public IQueryable<ChangeDocument> GetChangeDocumentsById(int id)
+ {
+ var documentsList = from changeDocument in db.ChangeDocuments
+ where (changeDocument.ChangeId == id)
+ select changeDocument;
+ return documentsList;
+ }
+
// GET: api/ChangeDocuments
public IQueryable<ChangeDocument> GetChangeDocuments()
{
diff --git a/ApartmentManager/HousingWebApi/DataModel.cs b/ApartmentManager/HousingWebApi/DataModel.cs
index 78fd1f2..aa2721f 100644
--- a/ApartmentManager/HousingWebApi/DataModel.cs
+++ b/ApartmentManager/HousingWebApi/DataModel.cs
@@ -106,16 +106,6 @@ namespace HousingWebApi
.Property(e => e.Status)
.IsUnicode(false);
- modelBuilder.Entity<Defect>()
- .HasMany(e => e.DefectComments)
- .WithRequired(e => e.Defect)
- .WillCascadeOnDelete(false);
-
- modelBuilder.Entity<Defect>()
- .HasMany(e => e.DefectPictures)
- .WithRequired(e => e.Defect)
- .WillCascadeOnDelete(false);
-
modelBuilder.Entity<DefectComment>()
.Property(e => e.Comment)
.IsUnicode(false);
diff --git a/ApartmentManager/HousingWebApi/HousingWebApi.csproj b/ApartmentManager/HousingWebApi/HousingWebApi.csproj
index 407d4b0..779dd08 100644
--- a/ApartmentManager/HousingWebApi/HousingWebApi.csproj
+++ b/ApartmentManager/HousingWebApi/HousingWebApi.csproj
@@ -151,10 +151,12 @@
</Reference>
</ItemGroup>
<ItemGroup>
- <Compile Include="Controllers\DefectPicturesController.cs" />
<Compile Include="Models\Apartment.cs" />
<Compile Include="Models\ApartmentChange.cs" />
<Compile Include="Models\ApartmentResident.cs" />
+ <Compile Include="Models\ChangeComment.cs" />
+ <Compile Include="Models\ChangeDocument.cs" />
+ <Compile Include="Controllers\DefectPicturesController.cs" />
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
@@ -187,8 +189,6 @@
<Compile Include="Areas\HelpPage\SampleGeneration\SampleDirection.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" />
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />
- <Compile Include="Models\ChangeComment.cs" />
- <Compile Include="Models\ChangeDocument.cs" />
<Compile Include="Controllers\ApartmentChangesController.cs" />
<Compile Include="Controllers\ApartmentsController.cs" />
<Compile Include="Controllers\ChangeCommentsController.cs" />
diff --git a/ApartmentManager/HousingWebApi/Models/ApartmentChange.cs b/ApartmentManager/HousingWebApi/Models/ApartmentChange.cs
index e14a35e..a3308f3 100644
--- a/ApartmentManager/HousingWebApi/Models/ApartmentChange.cs
+++ b/ApartmentManager/HousingWebApi/Models/ApartmentChange.cs
@@ -17,7 +17,6 @@ namespace HousingWebApi
}
[Key]
- [DatabaseGenerated(DatabaseGeneratedOption.None)]
public int ChangeId { get; set; }
public int ApartmentId { get; set; }
diff --git a/ApartmentManager/HousingWebApi/Models/ChangeComment.cs b/ApartmentManager/HousingWebApi/Models/ChangeComment.cs
index b8ee58e..954d348 100644
--- a/ApartmentManager/HousingWebApi/Models/ChangeComment.cs
+++ b/ApartmentManager/HousingWebApi/Models/ChangeComment.cs
@@ -10,7 +10,6 @@ namespace HousingWebApi
public partial class ChangeComment
{
[Key]
- [DatabaseGenerated(DatabaseGeneratedOption.None)]
public int CommentId { get; set; }
public int ChangeId { get; set; }
diff --git a/ApartmentManager/HousingWebApi/Models/ChangeDocument.cs b/ApartmentManager/HousingWebApi/Models/ChangeDocument.cs
index 7e869df..320686f 100644
--- a/ApartmentManager/HousingWebApi/Models/ChangeDocument.cs
+++ b/ApartmentManager/HousingWebApi/Models/ChangeDocument.cs
@@ -10,7 +10,6 @@ namespace HousingWebApi
public partial class ChangeDocument
{
[Key]
- [DatabaseGenerated(DatabaseGeneratedOption.None)]
public int DocumentId { get; set; }
public int ChangeId { get; set; }