diff options
20 files changed, 765 insertions, 97 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj index 426f616..d9da403 100644 --- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj +++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj @@ -131,12 +131,21 @@ <Compile Include="ViewModel\BmDefectsViewModel.cs" /> <Compile Include="ViewModel\ApartmentViewModel.cs" /> <Compile Include="ViewModel\LoginViewModel.cs" /> + <Compile Include="View\ApartmentChangesPage.xaml.cs"> + <DependentUpon>ApartmentChangesPage.xaml</DependentUpon> + </Compile> + <Compile Include="View\ApartmentChangesViewPage.xaml.cs"> + <DependentUpon>ApartmentChangesViewPage.xaml</DependentUpon> + </Compile> <Compile Include="View\ApartmentDefectPage.xaml.cs"> <DependentUpon>ApartmentDefectPage.xaml</DependentUpon> </Compile> <Compile Include="View\ApartmentDefectViewPage.xaml.cs"> <DependentUpon>ApartmentDefectViewPage.xaml</DependentUpon> </Compile> + <Compile Include="View\ApartmentNewChangePage.xaml.cs"> + <DependentUpon>ApartmentNewChangePage.xaml</DependentUpon> + </Compile> <Compile Include="View\ApartmentNewDefect.xaml.cs"> <DependentUpon>ApartmentNewDefect.xaml</DependentUpon> </Compile> @@ -223,6 +232,14 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="View\ApartmentChangesPage.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="View\ApartmentChangesViewPage.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="View\ApartmentDefectPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -231,6 +248,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="View\ApartmentNewChangePage.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="View\ApartmentNewDefect.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> diff --git a/ApartmentManager/ApartmentManager/AppShell.xaml.cs b/ApartmentManager/ApartmentManager/AppShell.xaml.cs index c5fcfe5..6da842b 100644 --- a/ApartmentManager/ApartmentManager/AppShell.xaml.cs +++ b/ApartmentManager/ApartmentManager/AppShell.xaml.cs @@ -102,7 +102,7 @@ namespace ApartmentManager new NavMenuItem() { Symbol = Symbol.Bookmarks, - Label = "Changes", + Label = "ApartmentChanges", DestPage = typeof(BmChangesPage), IsSelected = false } diff --git a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs index 41b9cda..b5ea6d2 100644 --- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs @@ -79,7 +79,7 @@ namespace ApartmentManager.Handler } if (!string.IsNullOrEmpty(resident.FirstName) && !string.IsNullOrEmpty(resident.LastName)) { - var response = ApiClient.PostData("api/residents/", resident); + var response = ApiClient.PostData("api/residents/", resident); } GetApartmentResidents(); } @@ -194,9 +194,9 @@ namespace ApartmentManager.Handler { try { - if (ApartmentViewModel.NewDefect.Pictures == null) ApartmentViewModel.NewDefect.Pictures = new ObservableCollection<DefectPicture>(); + if (ApartmentViewModel.NewDefect.Pictures == null) ApartmentViewModel.NewDefect.Pictures = new ObservableCollection<DefectPicture>(); var picture = new DefectPicture() { Picture = await ImgurPhotoUploader.UploadPhotoAsync() }; - ApartmentViewModel.NewDefect.Pictures.Add(picture); + ApartmentViewModel.NewDefect.Pictures.Add(picture); } catch (Exception e) { @@ -226,7 +226,7 @@ namespace ApartmentManager.Handler { new MessageDialog(e.Message).ShowAsync(); } - + } /////////////////////////////////////////////////////////////////////////////////////////////////// public bool CreateDefect_CanExecute() @@ -235,7 +235,7 @@ namespace ApartmentManager.Handler return false; else return true; - } + } /////////////////////////////////////////////////////////////////////////////////////////////////// public void CreateDefectComment() { @@ -262,8 +262,109 @@ namespace ApartmentManager.Handler catch (Exception e) { new MessageDialog(e.Message).ShowAsync(); - } + } } - /////////////////////////////////////////////////////////////////////////////////////////////////// + /// <summary> + /// Defect HANDLERS + /// </summary> + public void GetApartmentChanges() + { + ApartmentChange change = new ApartmentChange(); + change.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; + var changesFromDatabase = ApiClient.GetData("api/ApartmentChangesByid/" + change.ApartmentId); + var changeslist = JsonConvert.DeserializeObject<ObservableCollection<ApartmentChange>>(changesFromDatabase); + CatalogSingleton.Instance.ApartmentChanges.Clear(); + foreach (var apartmentChange in changeslist) + { + apartmentChange.Documents = JsonConvert.DeserializeObject<ObservableCollection<ChangeDocument>>(ApiClient.GetData("api/ChangeDocumentsById/" + apartmentChange.ChangeId)); + apartmentChange.Comments = JsonConvert.DeserializeObject<ObservableCollection<ChangeComment>>(ApiClient.GetData("api/ChangeCommentsById/" + apartmentChange.ChangeId)); + CatalogSingleton.Instance.ApartmentChanges.Add(apartmentChange); + } + } + public void CreateChangeComment() + { + try + { + ChangeComment Comment = new ChangeComment(); + Comment.Comment = ApartmentViewModel.NewChangeComment.Comment; + Comment.ChangeId = CatalogSingleton.Instance.SelectedChange.ChangeId; + Comment.Name = UserSingleton.Instance.CurrentUser.FirstName + " " + UserSingleton.Instance.CurrentUser.LastName; + Comment.Date = DateTimeOffset.Now; + if (!string.IsNullOrEmpty(Comment.Comment)) + { + var asd =ApiClient.PostData("api/ChangeComments/", Comment); + } + var response = ApiClient.GetData("api/ChangeCommentsById/" + CatalogSingleton.Instance.SelectedChange.ChangeId); + var commentlist = JsonConvert.DeserializeObject<ObservableCollection<ChangeComment>>(response); + + CatalogSingleton.Instance.SelectedChange.Comments.Clear(); + foreach (var comment in commentlist) + { + CatalogSingleton.Instance.SelectedChange.Comments.Add(comment); + } + } + catch (Exception e) + { + new MessageDialog(e.Message).ShowAsync(); + } + } + public void DeleteChangePicture() + { + try + { + ApartmentViewModel.NewChange.Documents.Remove(ApartmentViewModel.SelectedChangeDocument); + } + catch (Exception e) + { + new MessageDialog(e.Message).ShowAsync(); + } + } + public async void UploadChangePicture() + { + try + { + if (ApartmentViewModel.NewChange.Documents == null) ApartmentViewModel.NewChange.Documents = new ObservableCollection<ChangeDocument>(); + var picture = new ChangeDocument() { Document = await ImgurPhotoUploader.UploadPhotoAsync() }; + ApartmentViewModel.NewChange.Documents.Add(picture); + } + catch (Exception e) + { + new MessageDialog(e.Message).ShowAsync(); + } + } + public void CreateChange() + { + try + { + ApartmentChange change = ApartmentViewModel.NewChange; + change.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; + change.Status = "New"; + change.UploadDate = DateTime.Now; + var response = ApiClient.PostData("api/ApartmentChanges/", change); + var changeResponse = JsonConvert.DeserializeObject<ApartmentChange>(response); + change.ChangeId = changeResponse.ChangeId; + if (change.Documents !=null) + { + foreach (var document in change.Documents) + { + document.ChangeId = change.ChangeId; + ApiClient.PostData("api/ChangeDocuments/", document); + } + } + GetApartmentChanges(); + } + catch (Exception e) + { + new MessageDialog(e.Message).ShowAsync(); + } + } + public bool CreateChange_CanExecute() + { + if (string.IsNullOrEmpty(ApartmentViewModel.NewChange.Description) || string.IsNullOrEmpty(ApartmentViewModel.NewChange.Name)) + return false; + else + return true; + } + } } diff --git a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs index 9f52a40..9360f97 100644 --- a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs @@ -93,6 +93,7 @@ namespace ApartmentManager.Handler avm.ApartmentHandler.GetApartmentResidents(); avm.ApartmentHandler.GetApartment(); avm.ApartmentHandler.GetApartmentDefects(); + avm.ApartmentHandler.GetApartmentChanges(); appShell.AppFrame.Navigate(typeof(ApartmentPage)); } } diff --git a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs index a05c01a..ee101c6 100644 --- a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs @@ -18,13 +18,18 @@ namespace ApartmentManager.Singletons public ObservableCollection<Resident> Residents { get; set; } ////////// For Defects ////////// public ObservableCollection<Defect> Defects { get; set; } + public ApartmentChange SelectedChange { get; set; } + ////////// For Defects ////////// + public ObservableCollection<ApartmentChange> ApartmentChanges { get; set; } public Defect SelectedDefect { get; set; } ////////// Constructor ////////// private CatalogSingleton() - { + { + ApartmentChanges = new ObservableCollection<ApartmentChange>(); Residents = new ObservableCollection<Resident>(); Defects = new ObservableCollection<Defect>(); - SelectedDefect = new Defect(); + SelectedDefect = new Defect(); + SelectedChange = new ApartmentChange(); } } } diff --git a/ApartmentManager/ApartmentManager/View/ApartmentChangesPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentChangesPage.xaml new file mode 100644 index 0000000..9a7ddb1 --- /dev/null +++ b/ApartmentManager/ApartmentManager/View/ApartmentChangesPage.xaml @@ -0,0 +1,124 @@ +<Page + x:Class="ApartmentManager.View.ApartmentChangesPage" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="using:ApartmentManager.View" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:viewModel="using:ApartmentManager.ViewModel" + mc:Ignorable="d"> + + <Page.DataContext> + <viewModel:ApartmentViewModel/> + </Page.DataContext> + + <Page.BottomAppBar> + <CommandBar> + <CommandBar.Content> + <Grid /> + </CommandBar.Content> + <AppBarButton + Icon="Add" + Label="Create Defect" Click="GotoNewChangePage"> + </AppBarButton> + </CommandBar> + </Page.BottomAppBar> + + <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> + <Grid.RowDefinitions> + <RowDefinition Height="45"/> + <RowDefinition/> + </Grid.RowDefinitions> + + <TextBlock Grid.Row="0" + HorizontalAlignment="Center" + FontSize="30" + FontWeight="Bold" + Text="Apartment Defects"> + </TextBlock> + + <ListView ItemsSource="{Binding CatalogSingleton.ApartmentChanges}" SelectedItem="{Binding CatalogSingleton.SelectedChange, Mode=TwoWay}" Grid.Row="1" Background="LightGray" SelectionChanged="GotoApartmentChangeViewPage"> + <ListView.ItemContainerStyle> + <Style TargetType="ListViewItem"> + <Setter Property="HorizontalContentAlignment" Value="Stretch" /> + </Style> + </ListView.ItemContainerStyle> + + + <ListView.ItemTemplate> + <DataTemplate> + <Grid Height="200" BorderThickness ="1" Margin="12,12,12,0" BorderBrush="#DFE0E4" Background="White" > + <Grid.ColumnDefinitions> + <ColumnDefinition Width="300" /> + <ColumnDefinition/> + </Grid.ColumnDefinitions> + + <Image + Margin="5" + Source="{Binding Documents[0].Document}" + > + </Image> + + <StackPanel Grid.Column="1" Margin="10"> + + <StackPanel Orientation="Horizontal"> + <TextBlock + Margin="0,0,10,0" + FontSize="30" + FontWeight="Bold" + Text="Name :"> + </TextBlock> + <TextBlock + Margin="0,0,10,0" + FontSize="30" + Text="{Binding Name}"> + </TextBlock> + + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock + Width="800" + Height="108" + Margin="0,0,10,0" + FontSize="20" + Text="{Binding Description}" + TextWrapping="Wrap"> + </TextBlock> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock + Margin="0,0,10,0" + FontSize="25" + FontWeight="Bold" + Text="Status :"> + </TextBlock> + <TextBlock + Margin="0,0,10,0" + FontSize="25" + Text="{Binding Status}"> + </TextBlock> + + <TextBlock + Margin="700,0,10,0" + HorizontalAlignment="Left" + FontSize="25" + FontWeight="Bold" + Text="Date Submitted :"> + </TextBlock> + + <TextBlock FontSize="25" Text="{Binding UploadDate.Year}" /> + <TextBlock FontSize="25" Text="-" /> + <TextBlock FontSize="25" Text="{Binding UploadDate.Month}" /> + <TextBlock FontSize="25" Text="-" /> + <TextBlock FontSize="25" Text="{Binding UploadDate.Day}" /> + </StackPanel> + </StackPanel> + </Grid> + </DataTemplate> + </ListView.ItemTemplate> + + </ListView> + </Grid> +</Page> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentChangesPage.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentChangesPage.xaml.cs new file mode 100644 index 0000000..c498d1d --- /dev/null +++ b/ApartmentManager/ApartmentManager/View/ApartmentChangesPage.xaml.cs @@ -0,0 +1,40 @@ +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 ApartmentChangesPage : Page + { + public ApartmentChangesPage() + { + this.InitializeComponent(); + } + + private void GotoApartmentChangeViewPage(object sender, SelectionChangedEventArgs e) + { + Frame.Navigate(typeof(ApartmentChangesViewPage)); + } + + private void GotoNewChangePage(object sender, RoutedEventArgs e) + { + Frame.Navigate(typeof(ApartmentNewChangePage)); + } + } +} diff --git a/ApartmentManager/ApartmentManager/View/ApartmentChangesViewPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentChangesViewPage.xaml new file mode 100644 index 0000000..5ec7b99 --- /dev/null +++ b/ApartmentManager/ApartmentManager/View/ApartmentChangesViewPage.xaml @@ -0,0 +1,147 @@ +<Page + x:Class="ApartmentManager.View.ApartmentChangesViewPage" + 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:viewModel="using:ApartmentManager.ViewModel" + mc:Ignorable="d"> + + <Page.DataContext> + <viewModel:ApartmentViewModel /> + </Page.DataContext> + + <Page.BottomAppBar> + <CommandBar> + <CommandBar.Content> + <Grid /> + </CommandBar.Content> + <AppBarButton + Icon="back" + Label="Create Defect" Click="GotoApartmentChangesPage" > + </AppBarButton> + </CommandBar> + </Page.BottomAppBar> + + <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 CatalogSingleton.SelectedChange.Name}" /> + <TextBlock + Margin="700,0,0,0" + FontSize="30" + FontWeight="Bold" + Text="Status :" /> + <TextBlock + Margin="10,0,0,0" + FontSize="30" + Text="{Binding CatalogSingleton.SelectedChange.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 CatalogSingleton.SelectedChange.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 CatalogSingleton.SelectedChange.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 CreateChangeComment}" + Content="Comment" /> + </StackPanel> + + + <ListView ItemsSource="{Binding CatalogSingleton.SelectedChange.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/ApartmentChangesViewPage.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentChangesViewPage.xaml.cs new file mode 100644 index 0000000..d3030ff --- /dev/null +++ b/ApartmentManager/ApartmentManager/View/ApartmentChangesViewPage.xaml.cs @@ -0,0 +1,35 @@ +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 ApartmentChangesViewPage : Page + { + public ApartmentChangesViewPage() + { + this.InitializeComponent(); + } + + private void GotoApartmentChangesPage(object sender, RoutedEventArgs e) + { + Frame.Navigate(typeof(ApartmentChangesPage)); + } + } +} diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml index f2f0755..a102840 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml @@ -20,13 +20,9 @@ <Grid /> </CommandBar.Content> <AppBarButton - Click="NavigateNewDefect" - Command="{Binding ClearDefectTemplateCommand}" + Click="NavigateNewDefect" Icon="Add" Label="Create Defect"> - <AppBarButton.DataContext> - <ViewModel:BmDefectsViewModel /> - </AppBarButton.DataContext> </AppBarButton> </CommandBar> </Page.BottomAppBar> @@ -41,96 +37,91 @@ HorizontalAlignment="Center" FontSize="30" FontWeight="Bold" - Text="Apartment Defects"> + Text="Apartment Changes"> </TextBlock> - - <ListView ItemsSource="{Binding CatalogSingleton.Defects}" SelectedItem="{Binding CatalogSingleton.SelectedDefect, Mode=TwoWay}" SelectionChanged="NavigateDefectViewPage" Grid.Row="1" Background="LightGray"> - <ListView.ItemContainerStyle> - <Style TargetType="ListViewItem"> - <Setter Property="HorizontalContentAlignment" Value="Stretch" /> - </Style> - </ListView.ItemContainerStyle> + <ListView ItemsSource="{Binding CatalogSingleton.Defects}" SelectedItem="{Binding CatalogSingleton.SelectedDefect, Mode=TwoWay}" SelectionChanged="NavigateDefectViewPage" Grid.Row="1" Background="LightGray"> + <ListView.ItemContainerStyle> + <Style TargetType="ListViewItem"> + <Setter Property="HorizontalContentAlignment" Value="Stretch" /> + </Style> + </ListView.ItemContainerStyle> - <ListView.ItemTemplate> - <DataTemplate> - <Grid Height="200" BorderThickness ="1" Margin="12,12,12,0" BorderBrush="#DFE0E4" Background="White" > - <Grid.ColumnDefinitions> - <ColumnDefinition Width="200" /> - <ColumnDefinition/> - </Grid.ColumnDefinitions> - <Image + <ListView.ItemTemplate> + <DataTemplate> + <Grid Height="200" BorderThickness ="1" Margin="12,12,12,0" BorderBrush="#DFE0E4" Background="White" > + <Grid.ColumnDefinitions> + <ColumnDefinition Width="200" /> + <ColumnDefinition/> + </Grid.ColumnDefinitions> + + <Image Margin="5" Source="{Binding Pictures[0].Picture}" Stretch="Fill"> - </Image> + </Image> - <StackPanel Grid.Column="1" Margin="10"> + <StackPanel Grid.Column="1" Margin="10"> - <StackPanel Orientation="Horizontal"> - <TextBlock + <StackPanel Orientation="Horizontal"> + <TextBlock Margin="0,0,10,0" FontSize="30" FontWeight="Bold" Text="Name :"> - </TextBlock> - <TextBlock + </TextBlock> + <TextBlock Margin="0,0,10,0" FontSize="30" Text="{Binding Name}"> - </TextBlock> + </TextBlock> - </StackPanel> + </StackPanel> - <StackPanel Orientation="Horizontal"> - <TextBlock + <StackPanel Orientation="Horizontal"> + <TextBlock Width="800" Height="108" Margin="0,0,10,0" FontSize="20" Text="{Binding Description}" TextWrapping="Wrap"> - </TextBlock> - </StackPanel> - - + </TextBlock> + </StackPanel> - <StackPanel Orientation="Horizontal"> - <TextBlock + <StackPanel Orientation="Horizontal"> + <TextBlock Margin="0,0,10,0" FontSize="25" FontWeight="Bold" Text="Status :"> - </TextBlock> - <TextBlock + </TextBlock> + <TextBlock Margin="0,0,10,0" FontSize="25" Text="{Binding Status}"> - </TextBlock> + </TextBlock> - <TextBlock + <TextBlock Margin="700,0,10,0" HorizontalAlignment="Left" FontSize="25" FontWeight="Bold" Text="Date Submitted :"> - </TextBlock> - - <TextBlock FontSize="25" Text="{Binding UploadDate.Year}" /> - <TextBlock FontSize="25" Text="-" /> - <TextBlock FontSize="25" Text="{Binding UploadDate.Month}" /> - <TextBlock FontSize="25" Text="-" /> - <TextBlock FontSize="25" Text="{Binding UploadDate.Day}" /> - </StackPanel> - </StackPanel> - </Grid> - </DataTemplate> - </ListView.ItemTemplate> - - </ListView> - - - + </TextBlock> + + <TextBlock FontSize="25" Text="{Binding UploadDate.Year}" /> + <TextBlock FontSize="25" Text="-" /> + <TextBlock FontSize="25" Text="{Binding UploadDate.Month}" /> + <TextBlock FontSize="25" Text="-" /> + <TextBlock FontSize="25" Text="{Binding UploadDate.Day}" /> + </StackPanel> + </StackPanel> + </Grid> + </DataTemplate> + </ListView.ItemTemplate> + + </ListView> </Grid> </Page> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml index b14dc99..9052d3a 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml @@ -18,13 +18,8 @@ <Grid /> </CommandBar.Content> <AppBarButton - - Command="{Binding ClearDefectTemplateCommand}" Icon="back" Label="Create Defect" Click="BackToDefectPage" > - <AppBarButton.DataContext> - <ViewModel:BmDefectsViewModel /> - </AppBarButton.DataContext> </AppBarButton> </CommandBar> </Page.BottomAppBar> @@ -99,7 +94,7 @@ <TextBox Width="500" Height="80" - Text="{Binding NewDefectComment.Comment, Mode=TwoWay}" + Text="{Binding NewChangeComment.Comment, Mode=TwoWay}" TextWrapping="Wrap" /> <Button Margin="10,0,0,0" diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewChangePage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentNewChangePage.xaml new file mode 100644 index 0000000..2eab16c --- /dev/null +++ b/ApartmentManager/ApartmentManager/View/ApartmentNewChangePage.xaml @@ -0,0 +1,89 @@ +<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.ApartmentNewChangePage" + mc:Ignorable="d"> + + <Page.BottomAppBar> + <CommandBar> + <CommandBar.Content> + <Grid /> + </CommandBar.Content> + <AppBarButton + Icon="Back" + Label="Create Defect" Click="BackToChangePage"/> + </CommandBar> + </Page.BottomAppBar> + + + <Page.DataContext> + <ViewModel:ApartmentViewModel/> + </Page.DataContext> + + + <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> + <StackPanel HorizontalAlignment="Center" Orientation="Vertical"> + + <TextBlock + Margin="0,10,0,10" + HorizontalAlignment="Center" + FontSize="20" + FontWeight="Bold" + Text="Change Information"/> + + <StackPanel Orientation="Horizontal"> + <StackPanel Margin="0,5,30,0"> + <ListView + Width="500" + Height="600" + ItemsSource="{Binding NewChange.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 UploadChangePicture}" + Content="Upload Picture" /> + <Button + Margin="170,0,0,0" + Command="{Binding DeleteChangePicture}" + 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 NewChange.Name, Mode=TwoWay}" /> + <TextBlock Margin="0,10,0,10" Text="Description" /> + <TextBox + Height="417" + Text="{Binding NewChange.Description, Mode=TwoWay}" + TextWrapping="Wrap" /> + <Button + Margin="0,20,0,0" + HorizontalAlignment="Stretch" + + Content="Create" Click="CreateChange" /> + </StackPanel> + + </StackPanel> + </StackPanel> + </Grid> +</Page> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewChangePage.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentNewChangePage.xaml.cs new file mode 100644 index 0000000..44abaf7 --- /dev/null +++ b/ApartmentManager/ApartmentManager/View/ApartmentNewChangePage.xaml.cs @@ -0,0 +1,51 @@ +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; +using ApartmentManager.ViewModel; + +// 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 ApartmentNewChangePage : Page + { + private ApartmentViewModel vm; + public ApartmentNewChangePage() + { + this.InitializeComponent(); + vm = new ApartmentViewModel(); + DataContext = vm; + } + + private void BackToChangePage(object sender, RoutedEventArgs e) + { + Frame.Navigate(typeof(ApartmentChangesPage)); + } + + private void CreateChange(object sender, RoutedEventArgs e) + { + + + vm.CreateChange.Execute(null); + if (vm.CreateChange.CanExecute(null)) + { + Frame.Navigate(typeof(ApartmentChangesPage)); + } + + } + } +} diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml index 22c169c..4743bd3 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml @@ -14,13 +14,8 @@ <Grid /> </CommandBar.Content> <AppBarButton - - Command="{Binding ClearDefectTemplateCommand}" Icon="back" Label="Create Defect" Click="BackToDefectPage"> - <AppBarButton.DataContext> - <ViewModel:BmDefectsViewModel /> - </AppBarButton.DataContext> </AppBarButton> </CommandBar> </Page.BottomAppBar> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml index 06bf787..9aa8be2 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml @@ -101,7 +101,7 @@ <Button Margin="0,10,0,10" HorizontalAlignment="Stretch" - Click="click" + Click="GotoApartmentPlanPage" Content="Apartment Plan" /> <Button Margin="0,10,0,10" @@ -116,7 +116,7 @@ <Button Margin="0,10,0,10" HorizontalAlignment="Stretch" - Content="Apartment Changes" /> + Content="Apartment ApartmentChanges" Click="GotoChangesPage" /> <Button Margin="0,10,0,10" HorizontalAlignment="Stretch" diff --git a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml.cs index e24ad53..b6752d9 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml.cs @@ -27,7 +27,7 @@ namespace ApartmentManager.View this.InitializeComponent(); } - private void click(object sender, RoutedEventArgs e) + private void GotoApartmentPlanPage(object sender, RoutedEventArgs e) { Frame.Navigate(typeof(ApartmentPlanPage)); } @@ -46,5 +46,10 @@ namespace ApartmentManager.View { Frame.Navigate(typeof(ApartmentDefectPage)); } + + private void GotoChangesPage(object sender, RoutedEventArgs e) + { + Frame.Navigate(typeof(ApartmentChangesPage)); + } } } diff --git a/ApartmentManager/ApartmentManager/View/BmMainPage.xaml b/ApartmentManager/ApartmentManager/View/BmMainPage.xaml index 2fd5ab2..3cf03a3 100644 --- a/ApartmentManager/ApartmentManager/View/BmMainPage.xaml +++ b/ApartmentManager/ApartmentManager/View/BmMainPage.xaml @@ -76,7 +76,7 @@ Content="Apartment changes"> <interactivity:Interaction.Behaviors> <core:EventTriggerBehavior EventName="Click"> - <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmChangesPage" /> + <core:NavigateToPageAction TargetPage="ApartmentManager.View.BmApartmentChangesPage" /> </core:EventTriggerBehavior> </interactivity:Interaction.Behaviors> </Button> diff --git a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs index ae0919d..bb126b4 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs @@ -25,9 +25,14 @@ namespace ApartmentManager.ViewModel ////////// Store Data From Interface////////// private User _newUser; private Resident _newResident; + //// For defect/// private Defect _newDefect; private DefectPicture _selectedDefectPicture; private DefectComment _newDefectComment; + //// For Changes/// + private ChangeComment _newChangeComment; + private ApartmentChange _newApartmentChange; + private ChangeDocument _selectedChangeDocument; ////////// Resident relay commands////////// public ICommand CreateResidentCommand { get; set; } public ICommand DeleteResidentCommand { get; set; } @@ -39,22 +44,32 @@ namespace ApartmentManager.ViewModel ////////// Defect relay commands////////// public ICommand DeleteDefectPicture { get; set; } public ICommand UploadDefectPicture { get; set; } - public ICommand CreateDefect { get; set; } + public ICommand CreateDefect { get; set; } public ICommand CreateDefectComment { get; set; } + ////////// Change relay commands////////// + public ICommand DeleteChangePicture { get; set; } + public ICommand UploadChangePicture { get; set; } + public ICommand CreateChangeComment { get; set; } + public ICommand CreateChange { get; set; } ////////// Constructor ////////// public ApartmentViewModel() { ////////// Store Data From Interface instance ////////// NewUser = new User(); NewResident = new Resident(); + NewDefect = new Defect(); NewDefectComment = new DefectComment(); SelectedDefectPicture = new DefectPicture(); + + NewChangeComment = new ChangeComment(); + SelectedChangeDocument = new ChangeDocument(); + NewChange = new ApartmentChange(); ////////// Handler ////////// ApartmentHandler = new ApartmentHandler(this); ////////// Singletons ////////// CatalogSingleton = CatalogSingleton.Instance; - UserSingleton = UserSingleton.Instance; + UserSingleton = UserSingleton.Instance; ////////// User relay commands////////// UpdateUser = new RelayCommand(ApartmentHandler.UpdateUser); UploadUserPhoto = new RelayCommand(ApartmentHandler.UploadUserPhoto); @@ -66,10 +81,15 @@ namespace ApartmentManager.ViewModel ////////// Defect relay commands////////// UploadDefectPicture = new RelayCommand(ApartmentHandler.UploadDefectPhoto); DeleteDefectPicture = new RelayCommand(ApartmentHandler.DeleteDefectPicture); - CreateDefect = new RelayCommand(ApartmentHandler.CreateDefect, ApartmentHandler.CreateDefect_CanExecute); + CreateDefect = new RelayCommand(ApartmentHandler.CreateDefect, ApartmentHandler.CreateDefect_CanExecute); CreateDefectComment = new RelayCommand(ApartmentHandler.CreateDefectComment); + ////////// changes relay commands////////// + CreateChangeComment = new RelayCommand(ApartmentHandler.CreateChangeComment); + DeleteChangePicture = new RelayCommand(ApartmentHandler.DeleteChangePicture); + UploadChangePicture = new RelayCommand(ApartmentHandler.UploadChangePicture); + CreateChange = new RelayCommand(ApartmentHandler.CreateChange, ApartmentHandler.CreateChange_CanExecute); } - ////////// Store Data From Interface////////// + ////////// Store Data From Interface for defects////////// public DefectComment NewDefectComment { get => _newDefectComment; @@ -88,33 +108,71 @@ namespace ApartmentManager.ViewModel OnPropertyChanged(); } } - public User NewUser + public DefectPicture SelectedDefectPicture { - get => _newUser; + get => _selectedDefectPicture; set { - _newUser = value; + _selectedDefectPicture = value; OnPropertyChanged(); } } - public Resident NewResident + ////////// Store Data From Interface for Changes////////// + public ChangeComment NewChangeComment { - get => _newResident; + get => _newChangeComment; set { - _newResident = value; + _newChangeComment = value; OnPropertyChanged(); } } - public DefectPicture SelectedDefectPicture + public ChangeDocument SelectedChangeDocument { - get => _selectedDefectPicture; + get => _selectedChangeDocument; set { - _selectedDefectPicture = value; + _selectedChangeDocument = value; + OnPropertyChanged(); + } + } + public ApartmentChange NewChange + { + get => _newApartmentChange; + set + { + _newApartmentChange = value; OnPropertyChanged(); } } + + + + + + + + + + public User NewUser + { + get => _newUser; + set + { + _newUser = value; + OnPropertyChanged(); + } + } + public Resident NewResident + { + get => _newResident; + set + { + _newResident = value; + OnPropertyChanged(); + } + } + ////////// INotifyPropertyChanged ////////// public event PropertyChangedEventHandler PropertyChanged; [NotifyPropertyChangedInvocator] diff --git a/ApartmentManager/HousingWebApi/Controllers/ApartmentChangesController.cs b/ApartmentManager/HousingWebApi/Controllers/ApartmentChangesController.cs index f96385a..eadd910 100644 --- a/ApartmentManager/HousingWebApi/Controllers/ApartmentChangesController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/ApartmentChangesController.cs @@ -21,7 +21,15 @@ namespace HousingWebApi.Controllers { return db.ApartmentChanges; } - + [Route("api/ApartmentChangesByid/{id}")] + public IQueryable<ApartmentChange> GetApartmentChangesByid(int id) + { + var changetlist = from change in db.ApartmentChanges + where (change.ApartmentId == id) + orderby change.ChangeId descending + select change; + return changetlist; + } // GET: api/ApartmentChanges/5 [ResponseType(typeof(ApartmentChange))] public IHttpActionResult GetApartmentChange(int id) diff --git a/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs index 11519fd..6026938 100644 --- a/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs @@ -22,6 +22,8 @@ namespace HousingWebApi.Controllers { var commentsList = from changeComment in db.ChangeComments where (changeComment.ChangeId == id) + orderby changeComment.CommentId descending + select changeComment; return commentsList; } |