diff options
18 files changed, 222 insertions, 116 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj index e6f14f6..81f44b5 100644 --- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj +++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj @@ -105,6 +105,7 @@      <Compile Include="Handler\LoginHandler.cs" />      <Compile Include="Handler\ApartmentHandler.cs" />      <Compile Include="Model\Apartment.cs" /> +    <Compile Include="Model\DefectComments.cs" />      <Compile Include="Model\DefectPicture.cs" />      <Compile Include="Persistency\ImgurPhotoUploader.cs" />      <Compile Include="Singletons\BoardMemberCatalogSingleton.cs" /> diff --git a/ApartmentManager/ApartmentManager/App.xaml.cs b/ApartmentManager/ApartmentManager/App.xaml.cs index 297bf9d..140776a 100644 --- a/ApartmentManager/ApartmentManager/App.xaml.cs +++ b/ApartmentManager/ApartmentManager/App.xaml.cs @@ -30,7 +30,7 @@ namespace ApartmentManager          public App()          {              this.InitializeComponent(); -            this.Suspending += OnSuspending; +            this.Suspending += OnSuspending;                   }          /// <summary> diff --git a/ApartmentManager/ApartmentManager/AppShell.xaml.cs b/ApartmentManager/ApartmentManager/AppShell.xaml.cs index dec5cf7..b1a88c6 100644 --- a/ApartmentManager/ApartmentManager/AppShell.xaml.cs +++ b/ApartmentManager/ApartmentManager/AppShell.xaml.cs @@ -6,6 +6,7 @@ using System.Linq;  using Windows.UI.Xaml;  using Windows.UI.Xaml.Controls;  using Windows.UI.Xaml.Navigation; +using ApartmentManager.Singletons;  namespace ApartmentManager  { diff --git a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs index 095ee73..52310cc 100644 --- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs @@ -12,6 +12,7 @@ using Newtonsoft.Json;  using Windows.Storage;  using ApartmentManager.Common;  using Windows.Storage.Pickers; +using ApartmentManager.View;  namespace ApartmentManager.Handler  { @@ -31,7 +32,7 @@ namespace ApartmentManager.Handler          public void GetApartment()          { -            string serializedApartment = ApiClient.GetData("api/Apartments/" + ApartmentViewModel.ApartmentNumber); +            string serializedApartment = ApiClient.GetData("api/Apartments/" + ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId);              Apartment apartment = JsonConvert.DeserializeObject<Apartment>(serializedApartment);              ApartmentViewModel.CatalogSingleton.Apartment = apartment; @@ -43,7 +44,7 @@ namespace ApartmentManager.Handler          public void GetApartmentResidents()          {              Resident resident = new Resident(); -            resident.ApartmentId = ApartmentViewModel.ApartmentNumber; +            resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId;              var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId);              IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); @@ -56,19 +57,14 @@ namespace ApartmentManager.Handler              }          } - +        ///////////////////////////////////////////////////////////////////////////////////////////////////          public void CreateResident()          {              try              {                  Resident resident = new Resident(); -                resident.ApartmentId = ApartmentViewModel.ApartmentNumber; -                resident.FirstName = ApartmentViewModel.NewResident.FirstName; -                resident.LastName = ApartmentViewModel.NewResident.LastName; -                resident.BirthDate = ApartmentViewModel.NewResident.BirthDate; -                resident.Email = ApartmentViewModel.NewResident.Email; -                resident.Picture = ApartmentViewModel.NewResident.Picture; -                resident.Phone = ApartmentViewModel.NewResident.Phone; +                resident = ApartmentViewModel.NewResident; +                resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId;                  ApiClient.PostData("api/residents/", resident); @@ -87,20 +83,14 @@ namespace ApartmentManager.Handler                  new MessageDialog(e.Message).ShowAsync();              }          } - +        ///////////////////////////////////////////////////////////////////////////////////////////////////          public void DeleteResident()          {              try              {                  Resident resident = new Resident(); -                resident.ResidentId = ApartmentViewModel.NewResident.ResidentId; -                resident.ApartmentId = ApartmentViewModel.ApartmentNumber; -                resident.FirstName = ApartmentViewModel.NewResident.FirstName; -                resident.LastName = ApartmentViewModel.NewResident.LastName; -                resident.BirthDate = ApartmentViewModel.NewResident.BirthDate; -                resident.Email = ApartmentViewModel.NewResident.Email; -                resident.Picture = ApartmentViewModel.NewResident.Picture; -                resident.Phone = ApartmentViewModel.NewResident.Phone; +                resident = ApartmentViewModel.NewResident; +                resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId;                  ApiClient.DeleteData("api/residents/" + resident.ResidentId); @@ -119,20 +109,14 @@ namespace ApartmentManager.Handler                  new MessageDialog(e.Message).ShowAsync();              }          } - +        ///////////////////////////////////////////////////////////////////////////////////////////////////          public void UpdateResident()          {              try              {                  Resident resident = new Resident(); -                resident.ResidentId = ApartmentViewModel.NewResident.ResidentId; -                resident.ApartmentId = ApartmentViewModel.ApartmentNumber; -                resident.FirstName = ApartmentViewModel.NewResident.FirstName; -                resident.LastName = ApartmentViewModel.NewResident.LastName; -                resident.BirthDate = ApartmentViewModel.NewResident.BirthDate; -                resident.Email = ApartmentViewModel.NewResident.Email; -                resident.Picture = ApartmentViewModel.NewResident.Picture; -                resident.Phone = ApartmentViewModel.NewResident.Phone; +                resident = ApartmentViewModel.NewResident; +                resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId;                  ApiClient.PutData("api/residents/" + resident.ResidentId, resident);                  var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); @@ -150,7 +134,7 @@ namespace ApartmentManager.Handler                  new MessageDialog(e.Message).ShowAsync();              }          } - +        ///////////////////////////////////////////////////////////////////////////////////////////////////          public async void UploadResidentPhoto()          {              try @@ -173,15 +157,13 @@ namespace ApartmentManager.Handler              try              {                  ApartmentViewModel.UserSingleton.CurrentUser.Picture = await ImgurPhotoUploader.UploadPhotoAsync(); -                var tmp = ApartmentViewModel.UserSingleton.CurrentUser; -                ApartmentViewModel.UserSingleton.CurrentUser = new User(); -                ApartmentViewModel.UserSingleton.CurrentUser = tmp; +              }              catch (Exception e)              {              }          } - +        ///////////////////////////////////////////////////////////////////////////////////////////////////          public void UpdateUser()          {              try @@ -201,7 +183,7 @@ namespace ApartmentManager.Handler          public void GetApartmentDefects()          {              Defect defect = new Defect(); -            defect.ApartmentId = ApartmentViewModel.ApartmentNumber; +            defect.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId;              var defectsFromDatabase = ApiClient.GetData("api/ApartmentDefects/" + defect.ApartmentId);              IEnumerable<Defect> defecttlist = JsonConvert.DeserializeObject<IEnumerable<Defect>>(defectsFromDatabase); @@ -220,7 +202,7 @@ namespace ApartmentManager.Handler                      }                      qwe.MainPicture = ApartmentViewModel.CatalogSingleton.DefectPictures[0].Picture;                  } -                 +              } @@ -228,12 +210,11 @@ namespace ApartmentManager.Handler              ApartmentViewModel.NewResident = new Resident();              foreach (var defect2 in defecttlist)              { -                  ApartmentViewModel.CatalogSingleton.Defects.Add(defect2);              }              ApartmentViewModel.CatalogSingleton.DefectPictures.Clear();          } - +        ///////////////////////////////////////////////////////////////////////////////////////////////////          public void DeleteDefectPicture()          {              ApartmentViewModel.CatalogSingleton.DefectPictures.Remove(ApartmentViewModel.SelectedDefectPicture); @@ -243,42 +224,43 @@ namespace ApartmentManager.Handler              try              {                  ApartmentViewModel.SelectedDefectPicture = new DefectPicture(); -                 +                  ApartmentViewModel.SelectedDefectPicture.Picture = await ImgurPhotoUploader.UploadPhotoAsync();                  ApartmentViewModel.CatalogSingleton.DefectPictures.Add(ApartmentViewModel.SelectedDefectPicture); -                              }              catch (Exception e)              {              }          } +        ///////////////////////////////////////////////////////////////////////////////////////////////////          public void CreateDefect()          { -            try -            { -                Defect defect = new Defect(); -                defect = ApartmentViewModel.NewDefect; -                defect.ApartmentId = ApartmentViewModel.ApartmentNumber; -                defect.Status = "New"; -                defect.UploadDate = DateTime.Now; -                 -                ApiClient.PostData("api/defects/", defect); -                defect.DefectId = Int32.Parse(ApartmentViewModel.ServerResponse); -                foreach (var picture in ApartmentViewModel.CatalogSingleton.DefectPictures) -                { -                    picture.DefectId = defect.DefectId; -                    ApiClient.PostData("api/defectpictures/", picture); -                } +            Defect defect = new Defect(); +            defect = ApartmentViewModel.NewDefect; +            defect.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; +            defect.Status = "New"; +            defect.UploadDate = DateTime.Now; -                GetApartmentDefects(); -                 -            } -            catch (Exception e) +            var response = ApiClient.PostData("api/defects/", defect); +            var defectResponse = JsonConvert.DeserializeObject<Defect>(response); +            defect.DefectId = defectResponse.DefectId; + +            foreach (var picture in ApartmentViewModel.CatalogSingleton.DefectPictures)              { -                new MessageDialog(e.Message).ShowAsync(); +                picture.DefectId = defect.DefectId; +                ApiClient.PostData("api/defectpictures/", picture);              } +            GetApartmentDefects();          } - +        /////////////////////////////////////////////////////////////////////////////////////////////////// +        public bool CreateDefect_CanExecute() +        { +            if (string.IsNullOrEmpty(ApartmentViewModel.NewDefect.Description) || string.IsNullOrEmpty(ApartmentViewModel.NewDefect.Name)) +                return false; +            else +                return true; +        } +        ///////////////////////////////////////////////////////////////////////////////////////////////////          public void GetDefectInfo()          {              var id = ApartmentViewModel.NewDefect.DefectId; @@ -294,15 +276,16 @@ namespace ApartmentManager.Handler              if (picturesFromDatabase != "[]")              {                  IEnumerable<DefectPicture> picturetlist = -                JsonConvert.DeserializeObject<IEnumerable<DefectPicture>>(picturesFromDatabase);                +                JsonConvert.DeserializeObject<IEnumerable<DefectPicture>>(picturesFromDatabase);                  foreach (var asd in picturetlist)                  {                      ApartmentViewModel.CatalogSingleton.DefectPictures2.Add(asd);                  } - -              }          } +        /////////////////////////////////////////////////////////////////////////////////////////////////// + +      }  } diff --git a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs index e952e0b..65efeca 100644 --- a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs @@ -2,6 +2,8 @@  using ApartmentManager.Persistency;  using Newtonsoft.Json;  using System; +using ApartmentManager.Singletons; +using ApartmentManager.ViewModel;  namespace ApartmentManager.Handler  { @@ -16,7 +18,9 @@ namespace ApartmentManager.Handler                      if (user.Password == password)                      {                          UserSingleton.Instance.CurrentUser = user; -                    } +                         + +                }                      else throw new Exception("Wrong password!");                  }                  else throw new Exception("Wrong username!"); diff --git a/ApartmentManager/ApartmentManager/Model/DefectComments.cs b/ApartmentManager/ApartmentManager/Model/DefectComments.cs new file mode 100644 index 0000000..a1e6d1e --- /dev/null +++ b/ApartmentManager/ApartmentManager/Model/DefectComments.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ApartmentManager.Model +{ +    public class DefectComments +    { +         +        public int CommentId { get; set; } +        public int DefectId { get; set; } +        public string Comment { get; set; } +        public string Name { get; set; } +        public DateTimeOffset Date { get; set; } +    } +} diff --git a/ApartmentManager/ApartmentManager/Model/User.cs b/ApartmentManager/ApartmentManager/Model/User.cs index 42964af..e7e43ec 100644 --- a/ApartmentManager/ApartmentManager/Model/User.cs +++ b/ApartmentManager/ApartmentManager/Model/User.cs @@ -1,13 +1,16 @@  using System;  using System.Collections.Generic; +using System.ComponentModel;  using System.Linq; +using System.Runtime.CompilerServices;  using System.Text;  using System.Threading.Tasks;  using Windows.UI.Xaml.Controls; +using ApartmentManager.Annotations;  namespace ApartmentManager.Model  { -   public class User +    public class User : INotifyPropertyChanged      {          public string Username { get; set; }          public int ApartmentId { get; set; } @@ -18,13 +21,14 @@ namespace ApartmentManager.Model          public DateTime BirthDate { get; set; }          public string Phone { get; set; }          public string Email { get; set; } -        public string Picture { get; set; } +        public string _picture { get; set; }          public DateTime? MoveInDate { get; set; }          public DateTime? MoveOutDate { get; set; } +          public User() { } -        public User(string FirstName, string LastName, string Phone, DateTime BirthDate, string Email, int ApartmentNr) +        public User(string FirstName, string LastName, string Phone, DateTime BirthDate, string Email)          {              this.FirstName = FirstName;              this.LastName = LastName; @@ -33,10 +37,29 @@ namespace ApartmentManager.Model              this.Email = Email;          } +        public string Picture +        { +            get => _picture; +            set +            { +                _picture = value; +                OnPropertyChanged(nameof(Picture)); +            } +        }          public override string ToString()          {              return string.Format($"First name {FirstName} Last name {LastName} Phone {Phone}");          } + + +        public event PropertyChangedEventHandler PropertyChanged; + +        [NotifyPropertyChangedInvocator] +        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) +        { +            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + +        }      }  } diff --git a/ApartmentManager/ApartmentManager/Persistency/ApiClient.cs b/ApartmentManager/ApartmentManager/Persistency/ApiClient.cs index 8ae0e1c..b99f582 100644 --- a/ApartmentManager/ApartmentManager/Persistency/ApiClient.cs +++ b/ApartmentManager/ApartmentManager/Persistency/ApiClient.cs @@ -3,6 +3,7 @@ using System;  using System.Net.Http;  using System.Net.Http.Headers;  using System.Text; +using ApartmentManager.Model;  using ApartmentManager.ViewModel;  namespace ApartmentManager.Persistency @@ -56,7 +57,7 @@ namespace ApartmentManager.Persistency              }          } -        public static void PostData(string url, object objectToPost) +        public static string  PostData(string url, object objectToPost)          {              HttpClientHandler handler = new HttpClientHandler() { UseDefaultCredentials = true };              using (var client = new HttpClient(handler)) @@ -68,11 +69,14 @@ namespace ApartmentManager.Persistency                  {                      string serializedData = JsonConvert.SerializeObject(objectToPost);                      StringContent content = new StringContent(serializedData, Encoding.UTF8, "application/json"); -                    var response = client.PostAsync(url, content).Result.Headers.Location.AbsolutePath.Remove(0,13); -                    ApartmentViewModel.ServerResponse = response; + +                    var response = client.PostAsync(url, content).Result; +                    string result = response.Content.ReadAsStringAsync().Result; +                    return result;                                    }                  catch (Exception)                  { +                    return null;                  }              }          } @@ -87,7 +91,7 @@ namespace ApartmentManager.Persistency                  client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));                  try                  { -                    var response = client.DeleteAsync(url).Result; +                    var response =client.DeleteAsync(url).Result;                  }                  catch (Exception)                  { diff --git a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs index 62bbae3..a14c7d5 100644 --- a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs @@ -1,10 +1,13 @@  using System;  using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using ApartmentManager.Annotations;  using ApartmentManager.Model;  namespace ApartmentManager.Singletons  { -    public class CatalogSingleton +    public class CatalogSingleton : INotifyPropertyChanged      {          private static CatalogSingleton instance = new CatalogSingleton(); @@ -13,18 +16,41 @@ namespace ApartmentManager.Singletons          public Apartment Apartment { get; set; }          public ObservableCollection<Resident> Residents { get; set; } -        public ObservableCollection<Defect> Defects { get; set; } +        public ObservableCollection<Defect> defects { get; set; }          public ObservableCollection<DefectPicture> DefectPictures { get; set; }          public ObservableCollection<DefectPicture> DefectPictures2 { get; set; } +        public ObservableCollection<DefectComments> DefectComments { get; set; }          public Defect Defect { get; set; }          private CatalogSingleton()          { -             +            DefectComments = new ObservableCollection<DefectComments>(); +            DefectComments.Add(new DefectComments( ){Date = DateTimeOffset.Now, Comment = "Comment",CommentId = 1,DefectId = 1,Name = "Name"} ); +            DefectComments.Add(new DefectComments() { Date = DateTimeOffset.Now, Comment = "Comment", CommentId = 1, DefectId = 1, Name = "Name" }); +            DefectComments.Add(new DefectComments() { Date = DateTimeOffset.Now, Comment = "Comment", CommentId = 1, DefectId = 1, Name = "Name" }); +            DefectComments.Add(new DefectComments() { Date = DateTimeOffset.Now, Comment = "Comment", CommentId = 1, DefectId = 1, Name = "Name" });              Residents = new ObservableCollection<Resident>(); -            Defects = new ObservableCollection<Defect>(); +            defects = new ObservableCollection<Defect>();              DefectPictures = new ObservableCollection<DefectPicture>();              DefectPictures2 = new ObservableCollection<DefectPicture>();          } +        public ObservableCollection<Defect> Defects +        { +            get => this.defects; +            set +            { +                this.defects = value; +                OnPropertyChanged(nameof(Defect)); + +            } +        } + +        public event PropertyChangedEventHandler PropertyChanged; + +        [NotifyPropertyChangedInvocator] +        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) +        { +            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); +        }      }  } diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs index ee53458..21bc90e 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs @@ -38,8 +38,7 @@ namespace ApartmentManager.View          private void NavigateDefect(object sender, RoutedEventArgs e)          { -            vm.DefectInfo.Execute(null); -            //vm.ApartmentHandler.GetDefectInfo(); +            vm.DefectInfo.Execute(null);                         Frame.Navigate(typeof(ApartmentDefectViewPagexaml));          }      } diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml index 0da2b73..2c7e322 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml @@ -13,37 +13,69 @@      </Page.DataContext>      <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> -        <StackPanel> -            <StackPanel Orientation="Horizontal" Margin="10,10,10,0"> -                <TextBlock Text="Name:" FontSize="30" FontWeight="Bold" Margin="100,0,0,0"/> -                <TextBlock Text="{Binding CatalogSingleton.DefectPictures[0].Picture}" FontSize="30" FontWeight="Bold" Margin="10,0,0,0"/> -                <TextBlock Text="Status:" FontSize="30" FontWeight="Bold" Margin="400,0,0,0"/> -                <TextBlock Text="{Binding CatalogSingleton.Defect.Status}" FontSize="30" FontWeight="Bold" Margin="10,0,0,0"/> -            </StackPanel> -            <StackPanel Orientation="Horizontal" Margin="20"> -                <StackPanel Width="620"> -                    <TextBlock Text="Defect Pictures" FontSize="30" FontWeight="Bold" Margin="10,0,0,0"/> -                    <ListView    ItemsSource="{Binding CatalogSingleton.DefectPictures2, Mode=TwoWay}"  Height="500" Width="400" SelectedItem="{Binding SelectedDefectPicture, Mode=TwoWay}"> +        <ScrollViewer> +            <StackPanel> +                <StackPanel Orientation="Horizontal" Margin="10,10,10,0"> +                    <TextBlock Text="Name :" FontSize="30" FontWeight="Bold" Margin="100,0,0,0"/> +                    <TextBlock Text="{Binding CatalogSingleton.Defect.Name}" FontSize="30" Margin="10,0,0,0"/> +                    <TextBlock Text="Status :" FontSize="30" FontWeight="Bold" Margin="700,0,0,0"/> +                    <TextBlock Text="{Binding CatalogSingleton.Defect.Status}" FontSize="30" Margin="10,0,0,0"/> +                </StackPanel> +                <StackPanel Orientation="Horizontal" Margin="20,0,20,20"> +                    <StackPanel Width="620" Margin="0,50,0,0"> +                        <GridView    ItemsSource="{Binding CatalogSingleton.DefectPictures2, Mode=TwoWay}"  Height="420" Width="500" > +                            <GridView.ItemTemplate> +                                <DataTemplate> +                                    <Image Source="{Binding Picture}"  Width="220" Margin="10,0,10,10"></Image> +                                </DataTemplate> +                            </GridView.ItemTemplate> + +                        </GridView> +                    </StackPanel> +                    <StackPanel Width="620"> +                        <TextBlock Text="Description" FontSize="30" FontWeight="Bold" Margin="10,0,0,10"/> +                        <Grid BorderThickness="1" BorderBrush="Black"> +                            <TextBlock  Height="400" Margin="10" TextWrapping="WrapWholeWords" Text="{Binding CatalogSingleton.Defect.Description, Mode=TwoWay}"/> +                        </Grid> + + +                    </StackPanel> + + +                </StackPanel> +                <StackPanel Width="600" Margin="0,20,0,0"> +                    <TextBlock Text="Comments" FontSize="30" FontWeight="Bold" Margin="10,0,0,10"/> +                    <StackPanel Orientation="Horizontal"> + +                        <TextBox Width="500" Height="80" TextWrapping="Wrap"></TextBox> +                        <Button Content="Comment" Margin="10,0,0,0"></Button> +                    </StackPanel> + + +                    <ListView    ItemsSource="{Binding CatalogSingleton.DefectComments}"> +                        <ListView.ItemContainerStyle> +                            <Style TargetType="ListViewItem"> +                                <Setter Property="HorizontalContentAlignment" Value="Stretch"/> +                            </Style> +                        </ListView.ItemContainerStyle> +                          <ListView.ItemTemplate>                              <DataTemplate> -                                <Image Source="{Binding Picture}"  Width="400" Margin="10"></Image> +                                <Grid Height="150" Margin="0,10,0,10"> +                                    <StackPanel> +                                        <TextBlock Text="Full Name" FontWeight="Bold" Margin="5,0,0,0"></TextBlock> +                                        <TextBlock Height="90" Margin="5" TextWrapping="WrapWholeWords" Text="Žmonija sparčiai naudoja Žemės naudingųjų iškasenų atsargas. Mokslininkai mus perspėja - jei taip ir toliau, kai kurių dalykų greitai pradės trūksti. Tiesa, dažniausiai taip kalbama apie naftą, nors, kaip ima aiškėti, greitai pritrūksime kur kas paprastesnės medžiagos."></TextBlock> +                                        <TextBlock Text="Comment Date" HorizontalAlignment="Right" Margin="5" FontWeight="Bold"></TextBlock> +                                    </StackPanel> + +                                </Grid>                              </DataTemplate>                          </ListView.ItemTemplate> -                      </ListView> -                </StackPanel> -                <StackPanel Width="620"> -                    <TextBlock Text="Description" FontSize="30" FontWeight="Bold" Margin="10,0,0,0"/> -                    <TextBlock  Height="400" Margin="0,10,0,0" Text="{Binding CatalogSingleton.Defect.Description, Mode=TwoWay}"/>                  </StackPanel> -              </StackPanel> -            <ListView Width="600" Height="200"/> - - - -        </StackPanel> +        </ScrollViewer>      </Grid>  </Page> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml index fa4862e..c68a36d 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml @@ -40,7 +40,7 @@                      <TextBlock Margin="0,10,0,10" Text="Name"/>                      <TextBox Text="{Binding NewDefect.Name, Mode=TwoWay}" />                      <TextBlock Margin="0,10,0,10" Text="Description"/> -                    <TextBox Text="{Binding NewDefect.Description, Mode=TwoWay}" Height="417" /> +                    <TextBox Text="{Binding NewDefect.Description, Mode=TwoWay}" Height="417" TextWrapping="Wrap"/>                      <Button  Margin="0,20,0,0" Content="Create" HorizontalAlignment="Stretch" Click="Navigate"/>                  </StackPanel> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs index ba7139d..aed6e6e 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs @@ -29,12 +29,16 @@ namespace ApartmentManager.View              this.InitializeComponent();              vm = new ApartmentViewModel();              DataContext = vm; +                      }          private void Navigate(object sender, RoutedEventArgs e)          {              vm.CreateDefect.Execute(null); -            Frame.Navigate(typeof(ApartmentDefectPage)); +            if (vm.CreateDefect.CanExecute(null)) +            { +                Frame.Navigate(typeof(ApartmentDefectPage)); +            }          }      }  } diff --git a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml index 3e57b2a..8535d91 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml @@ -14,8 +14,8 @@      </Page.DataContext>      <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> -        <StackPanel Margin="10" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="top" > -            <StackPanel> +        <StackPanel Margin="10" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="top"  > +            <StackPanel Margin="10">                  <Grid Background="LightGray"  Height="150" Width="800" Margin="0,0,0,5">                      <Grid.ColumnDefinitions> diff --git a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs index f932f18..dad140a 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs @@ -21,21 +21,24 @@ namespace ApartmentManager.ViewModel          public CatalogSingleton CatalogSingleton { get; set; }          public UserSingleton UserSingleton { get; set; } +          private User _newUser;          private Resident _newResident;          private Defect _newDefect;          private DefectPicture _selectedDefectPicture; -        public static int ApartmentNumber { get; set; } -        public static string ServerResponse { get; set; } - +         +        public static int ServerResponse { get; set; } +        ////////// Resident relay commands//////////          public ICommand CreateResidentCommand { get; set; }          public ICommand DeleteResidentCommand { get; set; }          public ICommand UpdateResidentCommand { get; set; }          public ICommand UploadResidentPhoto { get; set; } +        ////////// User relay commands//////////          public ICommand UploadUserPhoto { get; set; }          public ICommand UpdateUser { get; set; } +        ////////// Defect relay commands//////////          public ICommand DeleteDefectPicture { get; set; }          public ICommand UploadDefectPicture { get; set; }          public ICommand CreateDefect { get; set; } @@ -46,12 +49,13 @@ namespace ApartmentManager.ViewModel              NewUser = new User();              NewResident = new Resident();              NewDefect = new Defect(); -            SelectedDefectPicture = new DefectPicture(); +            SelectedDefectPicture = new DefectPicture();              ApartmentHandler = new ApartmentHandler(this); +            ////////// Singletons //////////              CatalogSingleton = CatalogSingleton.Instance;              UserSingleton = UserSingleton.Instance; -            ApartmentNumber = UserSingleton.CurrentUser.ApartmentId; +                          ////////// User relay commands//////////              UpdateUser = new RelayCommand(ApartmentHandler.UpdateUser);              UploadUserPhoto = new RelayCommand(ApartmentHandler.UploadUserPhoto); @@ -63,12 +67,10 @@ namespace ApartmentManager.ViewModel              ////////// Defect relay commands//////////              UploadDefectPicture = new RelayCommand(ApartmentHandler.UploadDefectPhoto);              DeleteDefectPicture = new RelayCommand(ApartmentHandler.DeleteDefectPicture); -            CreateDefect = new RelayCommand(ApartmentHandler.CreateDefect); -            DefectInfo = new RelayCommand(ApartmentHandler.GetDefectInfo); -            ApartmentHandler.GetApartmentResidents(); -            ApartmentHandler.GetApartment(); -            ApartmentHandler.GetApartmentDefects(); +            CreateDefect = new RelayCommand(ApartmentHandler.CreateDefect, ApartmentHandler.CreateDefect_CanExecute); +            DefectInfo = new RelayCommand(ApartmentHandler.GetDefectInfo);                    } +                  public Defect NewDefect          { diff --git a/ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs index fc2c838..db80503 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs @@ -9,6 +9,7 @@ using System.Windows.Input;  using ApartmentManager.Annotations;  using ApartmentManager.Common;  using ApartmentManager.Model; +using ApartmentManager.Singletons;  namespace ApartmentManager.ViewModel  { diff --git a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs index 5f3c1b7..0031061 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs @@ -7,6 +7,7 @@ using System.Windows.Input;  using Windows.UI.Popups;  using Windows.UI.Xaml;  using Windows.UI.Xaml.Controls; +using ApartmentManager.Singletons;  namespace ApartmentManager.ViewModel  { @@ -69,7 +70,14 @@ namespace ApartmentManager.ViewModel                  // When the navigation stack isn't restored, navigate to the first page                  // suppressing the initial entrance animation.                  if (UserSingleton.Instance.CurrentUser.IsBm) appShell.AppFrame.Navigate(typeof(BoardMembersMainPage)); -                else appShell.AppFrame.Navigate(typeof(ApartmentPage)); +                else +                { +                    ApartmentViewModel asd = new ApartmentViewModel(); +                    asd.ApartmentHandler.GetApartmentResidents(); +                    asd.ApartmentHandler.GetApartment(); +                    asd.ApartmentHandler.GetApartmentDefects(); +                    appShell.AppFrame.Navigate(typeof(ApartmentPage)); +                }              }              // Ensure the current window is active diff --git a/Use cases.odt b/Use cases.odt Binary files differindex 5085eae..c66e8bc 100644 --- a/Use cases.odt +++ b/Use cases.odt  |