diff options
| author | marcinzelent <marcin@zelent.net> | 2017-05-31 10:51:21 +0200 | 
|---|---|---|
| committer | marcinzelent <marcin@zelent.net> | 2017-05-31 10:51:21 +0200 | 
| commit | fadcb1fa5e19a23ef172735bbaae2569f648c3d1 (patch) | |
| tree | e6919284d90a611164e102de0eef4f4b3778db4a | |
| parent | 89f3006ea4c2be7f49a3302c055020d3682a6b05 (diff) | |
| parent | 029b44754ce2efe44cc7f1d359f8726718cce7e5 (diff) | |
Merge branch 'master' of https://github.com/marcinzelent/ApartmentAdmin
31 files changed, 875 insertions, 202 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 4cfa4fd..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();              } @@ -170,24 +170,20 @@ namespace ApartmentManager.Handler              Defect.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId;              var defectsFromDatabase = ApiClient.GetData("api/ApartmentDefects/" + Defect.ApartmentId);              var defecttlist = JsonConvert.DeserializeObject<ObservableCollection<Defect>>(defectsFromDatabase); +            CatalogSingleton.Instance.Defects.Clear();              foreach (var defect in defecttlist)              { -                var picturesFromDatabase = ApiClient.GetData("api/DefectPicturesById/" + defect.DefectId); -                if (picturesFromDatabase != "[]") -                { -                    ApartmentViewModel.CatalogSingleton.DefectPictures = JsonConvert.DeserializeObject<ObservableCollection<DefectPicture>>(picturesFromDatabase); -                    defect.MainPicture = ApartmentViewModel.CatalogSingleton.DefectPictures[0].Picture; -                } +                defect.Pictures = JsonConvert.DeserializeObject<ObservableCollection<DefectPicture>>(ApiClient.GetData("api/DefectPicturesById/" + defect.DefectId)); +                defect.Comments = JsonConvert.DeserializeObject<ObservableCollection<DefectComment>>(ApiClient.GetData("api/DefectComments/" + defect.DefectId)); +                CatalogSingleton.Instance.Defects.Add(defect);              } -            ApartmentViewModel.CatalogSingleton.Defects = defecttlist; -            ApartmentViewModel.CatalogSingleton.DefectPictures.Clear();          }          ///////////////////////////////////////////////////////////////////////////////////////////////////          public void DeleteDefectPicture()          {              try              { -                ApartmentViewModel.CatalogSingleton.DefectPictures.Remove(ApartmentViewModel.SelectedDefectPicture); +                ApartmentViewModel.NewDefect.Pictures.Remove(ApartmentViewModel.SelectedDefectPicture);              }              catch (Exception e)              { @@ -198,8 +194,9 @@ namespace ApartmentManager.Handler          {              try              { -                ApartmentViewModel.SelectedDefectPicture.Picture = await ImgurPhotoUploader.UploadPhotoAsync(); -                ApartmentViewModel.CatalogSingleton.DefectPictures.Add(ApartmentViewModel.SelectedDefectPicture); +                if (ApartmentViewModel.NewDefect.Pictures == null) ApartmentViewModel.NewDefect.Pictures = new ObservableCollection<DefectPicture>(); +                var picture = new DefectPicture() { Picture = await ImgurPhotoUploader.UploadPhotoAsync() }; +                ApartmentViewModel.NewDefect.Pictures.Add(picture);              }              catch (Exception e)              { @@ -218,7 +215,7 @@ namespace ApartmentManager.Handler                  var response = ApiClient.PostData("api/defects/", defect);                  var defectResponse = JsonConvert.DeserializeObject<Defect>(response);                  defect.DefectId = defectResponse.DefectId; -                foreach (var picture in ApartmentViewModel.CatalogSingleton.DefectPictures) +                foreach (var picture in defect.Pictures)                  {                      picture.DefectId = defect.DefectId;                      ApiClient.PostData("api/defectpictures/", picture); @@ -229,7 +226,7 @@ namespace ApartmentManager.Handler              {                  new MessageDialog(e.Message).ShowAsync();              } -             +          }          ///////////////////////////////////////////////////////////////////////////////////////////////////          public bool CreateDefect_CanExecute() @@ -240,51 +237,134 @@ namespace ApartmentManager.Handler                  return true;          }          /////////////////////////////////////////////////////////////////////////////////////////////////// -        public void GetDefectInfo() +        public void CreateDefectComment()          {              try              { -                var defectFromDatabase = ApiClient.GetData("api/defects/" + ApartmentViewModel.NewDefect.DefectId); -                ApartmentViewModel.CatalogSingleton.Defect = JsonConvert.DeserializeObject<Defect>(defectFromDatabase); -                var picturesFromDatabase = ApiClient.GetData("api/DefectPicturesById/" + ApartmentViewModel.NewDefect.DefectId); -                ApartmentViewModel.CatalogSingleton.DefectPictures = JsonConvert.DeserializeObject<ObservableCollection<DefectPicture>>(picturesFromDatabase); -                var defectComments = ApiClient.GetData("api/Defectcomments/" + ApartmentViewModel.NewDefect.DefectId); -                ApartmentViewModel.CatalogSingleton.DefectComments = JsonConvert.DeserializeObject<ObservableCollection<DefectComment>>(defectComments); -                CatalogSingleton.Instance.DefectId = ApartmentViewModel.NewDefect.DefectId; +                DefectComment Comment = new DefectComment(); +                Comment.Comment = ApartmentViewModel.NewDefectComment.Comment; +                Comment.DefectId = CatalogSingleton.Instance.SelectedDefect.DefectId; +                Comment.Name = UserSingleton.Instance.CurrentUser.FirstName + " " + UserSingleton.Instance.CurrentUser.LastName; +                Comment.Date = DateTimeOffset.Now; +                if (!string.IsNullOrEmpty(Comment.Comment)) +                { +                    ApiClient.PostData("api/Defectcomments/", Comment); +                } +                var response = ApiClient.GetData("api/Defectcomments/" + CatalogSingleton.Instance.SelectedDefect.DefectId); +                var commentlist = JsonConvert.DeserializeObject<ObservableCollection<DefectComment>>(response); + +                CatalogSingleton.Instance.SelectedDefect.Comments.Clear(); +                foreach (var comment in commentlist) +                { +                    CatalogSingleton.Instance.SelectedDefect.Comments.Add(comment); +                }              }              catch (Exception e)              {                  new MessageDialog(e.Message).ShowAsync();              } -                      } -        /////////////////////////////////////////////////////////////////////////////////////////////////// -        public void CreateDefectComment() +        /// <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              { -                DefectComment Comment = new DefectComment(); -                Comment.Comment = ApartmentViewModel.NewDefectComment.Comment; -                Comment.DefectId = CatalogSingleton.Instance.Defect.DefectId; +                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))                  { -                    ApiClient.PostData("api/Defectcomments/", Comment); +                    var asd =ApiClient.PostData("api/ChangeComments/", Comment);                  } -                var response = ApiClient.GetData("api/Defectcomments/" + CatalogSingleton.Instance.DefectId); -                var commentlist = JsonConvert.DeserializeObject<ObservableCollection<DefectComment>>(response); -                CatalogSingleton.Instance.DefectComments.Clear(); +                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.DefectComments.Add(comment); +                    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 6baa647..ee101c6 100644 --- a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs @@ -18,17 +18,18 @@ namespace ApartmentManager.Singletons          public ObservableCollection<Resident> Residents { get; set; }          ////////// For Defects //////////          public ObservableCollection<Defect> Defects { get; set; } -        public ObservableCollection<DefectPicture> DefectPictures { get; set; }         -        public ObservableCollection<DefectComment> DefectComments { get; set; } -        public Defect Defect { get; set; } -        public int DefectId { get; set; } +        public ApartmentChange SelectedChange { get; set; } +        ////////// For Defects ////////// +        public ObservableCollection<ApartmentChange> ApartmentChanges { get; set; } +        public Defect SelectedDefect { get; set; }               ////////// Constructor //////////          private CatalogSingleton()          { -            DefectComments = new ObservableCollection<DefectComment>(); +            ApartmentChanges = new ObservableCollection<ApartmentChange>();              Residents = new ObservableCollection<Resident>();              Defects = new ObservableCollection<Defect>(); -            DefectPictures = new ObservableCollection<DefectPicture>();     +            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 7b4a853..a102840 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml @@ -6,141 +6,122 @@      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"      xmlns:local="using:ApartmentManager.View"      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" +    xmlns:interactivity="using:Microsoft.Xaml.Interactivity" +    xmlns:core="using:Microsoft.Xaml.Interactions.Core"      mc:Ignorable="d"> -    <!--<Page.DataContext> +    <Page.DataContext>          <ViewModel:ApartmentViewModel/> -    </Page.DataContext>--> +    </Page.DataContext> + +    <Page.BottomAppBar> +        <CommandBar> +            <CommandBar.Content> +                <Grid /> +            </CommandBar.Content> +            <AppBarButton +                Click="NavigateNewDefect"                +                Icon="Add" +                Label="Create Defect"> +            </AppBarButton> +        </CommandBar> +    </Page.BottomAppBar>      <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> -        <StackPanel Margin="10"> -            <TextBlock +        <Grid.RowDefinitions> +            <RowDefinition Height="45"/> +            <RowDefinition/> +        </Grid.RowDefinitions> +         +            <TextBlock Grid.Row="0"                  HorizontalAlignment="Center"                  FontSize="30"                  FontWeight="Bold" -                Text="Apartment Defects" /> -            <ListView -                Height="550" -                ItemsSource="{Binding CatalogSingleton.Defects}" -                SelectedItem="{Binding NewDefect, Mode=TwoWay}"> -                <ListView.ItemContainerStyle> -                    <Style TargetType="ListViewItem"> -                        <Setter Property="HorizontalContentAlignment" Value="Stretch" /> -                    </Style> -                </ListView.ItemContainerStyle> - -                <ListView.ItemTemplate> - -                    <DataTemplate> -                        <Grid -                            Height="200" -                            Margin="0,0,0,5" -                            Background="LightGray"> -                            <Grid.ColumnDefinitions> -                                <ColumnDefinition Width="200" /> -                                <ColumnDefinition /> -                            </Grid.ColumnDefinitions> -                            <Grid -                                Grid.Column="0" -                                Background="Gray" -                                BorderBrush="#CCFFFFFF" -                                BorderThickness="0,0,2,0"> -                                <Image Source="{Binding MainPicture}" Stretch="Fill" /> -                            </Grid> -                            <Grid Grid.Column="1" Margin="2"> -                                <StackPanel Margin="10"> - -                                    <StackPanel Orientation="Horizontal"> -                                        <TextBlock -                                            Margin="0,0,10,0" -                                            FontSize="30" -                                            FontWeight="Bold" -                                            Text="Name :" /> -                                        <TextBlock -                                            Margin="0,0,10,0" -                                            FontSize="30" -                                            Text="{Binding Name}" /> - -                                    </StackPanel> - -                                    <StackPanel Orientation="Horizontal"> -                                        <TextBlock -                                            Width="800" -                                            Height="108" -                                            Margin="0,0,10,0" -                                            FontSize="20" -                                            Text="{Binding Description}" -                                            TextWrapping="Wrap" /> -                                    </StackPanel> - -                                    <StackPanel Orientation="Horizontal" /> - -                                    <StackPanel Orientation="Horizontal"> -                                        <TextBlock -                                            Margin="0,0,10,0" -                                            FontSize="25" -                                            FontWeight="Bold" -                                            Text="Status :" /> -                                        <TextBlock -                                            Margin="0,0,10,0" -                                            FontSize="25" -                                            Text="{Binding Status}" /> - -                                        <TextBlock -                                            Margin="700,0,10,0" -                                            HorizontalAlignment="Left" -                                            FontSize="25" -                                            FontWeight="Bold" -                                            Text="Date Submitted :" /> -                                        <TextBlock FontSize="25" Text="{Binding UploadDate.Year}" /> -                                        <TextBlock FontSize="25" Text="-" /> -                                        <TextBlock FontSize="25" Text="{Binding UploadDate.Month}" /> -                                        <TextBlock FontSize="25" Text="-" /> -                                        <TextBlock FontSize="25" Text="{Binding UploadDate.Day}" /> - -                                    </StackPanel> - -                                </StackPanel> - - -                            </Grid> -                        </Grid> -                    </DataTemplate> -                </ListView.ItemTemplate> -            </ListView> -            <StackPanel -                Margin="0,15,0,0" -                HorizontalAlignment="Right" -                Orientation="Horizontal"> -                <Button -                    Width="200" -                    Margin="0,0,100,0" -                    Click="NavigateNewDefect" -                    Content="New Defect" /> -                <Button -                    Width="200" -                    Margin="0,0,100,0" -                    Click="NavigateDefect" -                    Content="View Defect" /> -            </StackPanel> - -        </StackPanel> - - - - - - - - - - - - - - - - - +                Text="Apartment Changes"> +            </TextBlock> + +        <ListView ItemsSource="{Binding CatalogSingleton.Defects}" SelectedItem="{Binding CatalogSingleton.SelectedDefect, Mode=TwoWay}" SelectionChanged="NavigateDefectViewPage" Grid.Row="1" Background="LightGray"> +            <ListView.ItemContainerStyle> +                <Style TargetType="ListViewItem"> +                    <Setter Property="HorizontalContentAlignment" Value="Stretch" /> +                </Style> +            </ListView.ItemContainerStyle> + + +            <ListView.ItemTemplate> +                <DataTemplate> +                    <Grid Height="200" BorderThickness ="1" Margin="12,12,12,0" BorderBrush="#DFE0E4" Background="White" > +                        <Grid.ColumnDefinitions> +                            <ColumnDefinition Width="200" /> +                            <ColumnDefinition/> +                        </Grid.ColumnDefinitions> + +                        <Image +                                Margin="5" +                                Source="{Binding Pictures[0].Picture}" +                                Stretch="Fill"> +                        </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/ApartmentDefectPage.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs index 21bc90e..9ff9dd4 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs @@ -23,22 +23,17 @@ namespace ApartmentManager.View      /// </summary>      public sealed partial class ApartmentDefectPage : Page      { -        private ApartmentViewModel vm;          public ApartmentDefectPage()          {              this.InitializeComponent(); -            vm = new ApartmentViewModel(); -            DataContext = vm; +                      } -          private void NavigateNewDefect(object sender, RoutedEventArgs e)          {              Frame.Navigate(typeof(ApartmentNewDefect));          } - -        private void NavigateDefect(object sender, RoutedEventArgs e) +        private void NavigateDefectViewPage(object sender, SelectionChangedEventArgs e)          { -            vm.DefectInfo.Execute(null);                         Frame.Navigate(typeof(ApartmentDefectViewPagexaml));          }      } diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml index 38a2e50..9052d3a 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml @@ -12,6 +12,18 @@          <ViewModel:ApartmentViewModel />      </Page.DataContext> +    <Page.BottomAppBar> +        <CommandBar> +            <CommandBar.Content> +                <Grid /> +            </CommandBar.Content> +            <AppBarButton +                Icon="back" +                Label="Create Defect" Click="BackToDefectPage" > +            </AppBarButton> +        </CommandBar> +    </Page.BottomAppBar> +          <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">          <ScrollViewer>              <StackPanel> @@ -24,7 +36,7 @@                      <TextBlock                          Margin="10,0,0,0"                          FontSize="30" -                        Text="{Binding CatalogSingleton.Defect.Name}" /> +                        Text="{Binding CatalogSingleton.SelectedDefect.Name}" />                      <TextBlock                          Margin="700,0,0,0"                          FontSize="30" @@ -33,14 +45,14 @@                      <TextBlock                          Margin="10,0,0,0"                          FontSize="30" -                        Text="{Binding CatalogSingleton.Defect.Status}" /> +                        Text="{Binding CatalogSingleton.SelectedDefect.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.DefectPictures, Mode=TwoWay}"> +                            ItemsSource="{Binding CatalogSingleton.SelectedDefect.Pictures, Mode=TwoWay}">                              <GridView.ItemTemplate>                                  <DataTemplate>                                      <Image @@ -62,7 +74,7 @@                              <TextBlock                                  Height="400"                                  Margin="10" -                                Text="{Binding CatalogSingleton.Defect.Description, Mode=TwoWay}" +                                Text="{Binding CatalogSingleton.SelectedDefect.Description, Mode=TwoWay}"                                  TextWrapping="WrapWholeWords" />                          </Grid> @@ -82,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" @@ -91,7 +103,7 @@                      </StackPanel> -                    <ListView ItemsSource="{Binding CatalogSingleton.DefectComments}"> +                    <ListView ItemsSource="{Binding CatalogSingleton.SelectedDefect.Comments}">                          <ListView.ItemContainerStyle>                              <Style TargetType="ListViewItem">                                  <Setter Property="HorizontalContentAlignment" Value="Stretch" /> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml.cs index 7abaf26..6225ebc 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml.cs @@ -30,5 +30,10 @@ namespace ApartmentManager.View              vm = new ApartmentViewModel();              DataContext = vm;          } + +        private void BackToDefectPage(object sender, RoutedEventArgs e) +        { +            Frame.Navigate(typeof(ApartmentDefectPage)); +        }      }  } 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 ab919b6..4743bd3 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml @@ -8,6 +8,17 @@      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"      mc:Ignorable="d"> +    <Page.BottomAppBar> +        <CommandBar> +            <CommandBar.Content> +                <Grid /> +            </CommandBar.Content> +            <AppBarButton +                Icon="back" +                Label="Create Defect" Click="BackToDefectPage"> +            </AppBarButton> +        </CommandBar> +    </Page.BottomAppBar>      <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> @@ -25,7 +36,7 @@                      <ListView                          Width="500"                          Height="600" -                        ItemsSource="{Binding CatalogSingleton.DefectPictures, Mode=TwoWay}" +                        ItemsSource="{Binding NewDefect.Pictures, Mode=TwoWay}"                          SelectedItem="{Binding SelectedDefectPicture, Mode=TwoWay}">                          <ListView.ItemTemplate>                              <DataTemplate> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs index aed6e6e..31ce2a2 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs @@ -40,5 +40,10 @@ namespace ApartmentManager.View                  Frame.Navigate(typeof(ApartmentDefectPage));              }          } + +        private void BackToDefectPage(object sender, RoutedEventArgs e) +        { +            Frame.Navigate(typeof(ApartmentDefectPage)); +        }      }  } 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/BmDefectsPage.xaml b/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml index 46150d3..b6c9759 100644 --- a/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/BmDefectsPage.xaml @@ -39,9 +39,11 @@              <Setter Property="VerticalAlignment" Value="Top" />          </Style>      </Page.Resources> +          <Page.DataContext>          <vm:BmDefectsViewModel />      </Page.DataContext> +          <Page.BottomAppBar>          <CommandBar>              <CommandBar.Content> @@ -58,6 +60,7 @@              </AppBarButton>          </CommandBar>      </Page.BottomAppBar> +          <Grid Background="#E9EBEE">          <Grid.RowDefinitions>              <RowDefinition Height="40" /> @@ -75,6 +78,7 @@                  Text="Apartment number: " />              <TextBox Height="32" />          </StackPanel> +                  <ListView              x:Name="DefectsList"              Grid.Row="1" 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 6048db4..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; } @@ -40,22 +45,31 @@ namespace ApartmentManager.ViewModel          public ICommand DeleteDefectPicture { get; set; }          public ICommand UploadDefectPicture { get; set; }          public ICommand CreateDefect { get; set; } -        public ICommand DefectInfo { 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); @@ -68,10 +82,14 @@ namespace ApartmentManager.ViewModel              UploadDefectPicture = new RelayCommand(ApartmentHandler.UploadDefectPhoto);              DeleteDefectPicture = new RelayCommand(ApartmentHandler.DeleteDefectPicture);              CreateDefect = new RelayCommand(ApartmentHandler.CreateDefect, ApartmentHandler.CreateDefect_CanExecute); -            DefectInfo = new RelayCommand(ApartmentHandler.GetDefectInfo);              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; @@ -90,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;          } diff --git a/Diagrams/DefectCommentVisio.vsdx b/Diagrams/DefectCommentVisio.vsdxBinary files differ new file mode 100644 index 0000000..55a6037 --- /dev/null +++ b/Diagrams/DefectCommentVisio.vsdx diff --git a/Diagrams/DefectPictureVisio.vsdx b/Diagrams/DefectPictureVisio.vsdxBinary files differ new file mode 100644 index 0000000..778e415 --- /dev/null +++ b/Diagrams/DefectPictureVisio.vsdx diff --git a/Diagrams/DefectVisio.vsdx b/Diagrams/DefectVisio.vsdxBinary files differ new file mode 100644 index 0000000..a77b653 --- /dev/null +++ b/Diagrams/DefectVisio.vsdx diff --git a/Diagrams/Porters.vsdx b/Diagrams/Porters.vsdxBinary files differ new file mode 100644 index 0000000..1276cd8 --- /dev/null +++ b/Diagrams/Porters.vsdx diff --git a/Diagrams/ResidentVisio.vsdx b/Diagrams/ResidentVisio.vsdxBinary files differ new file mode 100644 index 0000000..83e1f6d --- /dev/null +++ b/Diagrams/ResidentVisio.vsdx diff --git a/Diagrams/SWOT.vsdx b/Diagrams/SWOT.vsdxBinary files differ new file mode 100644 index 0000000..899ce11 --- /dev/null +++ b/Diagrams/SWOT.vsdx diff --git a/Diagrams/UserVisio.vsdx b/Diagrams/UserVisio.vsdxBinary files differ new file mode 100644 index 0000000..6968201 --- /dev/null +++ b/Diagrams/UserVisio.vsdx |