aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ApartmentManager/ApartmentManager/ApartmentManager.csproj1
-rw-r--r--ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs52
-rw-r--r--ApartmentManager/ApartmentManager/Model/DefectComments.cs18
-rw-r--r--ApartmentManager/ApartmentManager/Model/User.cs9
-rw-r--r--ApartmentManager/ApartmentManager/Persistency/ApiClient.cs15
-rw-r--r--ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs7
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs3
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml78
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml2
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml4
-rw-r--r--ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs10
11 files changed, 128 insertions, 71 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/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
index e59d75f..52310cc 100644
--- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
@@ -65,7 +65,7 @@ namespace ApartmentManager.Handler
Resident resident = new Resident();
resident = ApartmentViewModel.NewResident;
resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId;
-
+
ApiClient.PostData("api/residents/", resident);
var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId);
@@ -91,7 +91,7 @@ namespace ApartmentManager.Handler
Resident resident = new Resident();
resident = ApartmentViewModel.NewResident;
resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId;
-
+
ApiClient.DeleteData("api/residents/" + resident.ResidentId);
var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId);
@@ -116,7 +116,7 @@ namespace ApartmentManager.Handler
{
Resident resident = new Resident();
resident = ApartmentViewModel.NewResident;
- resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId;
+ resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId;
ApiClient.PutData("api/residents/" + resident.ResidentId, resident);
var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId);
@@ -157,7 +157,7 @@ namespace ApartmentManager.Handler
try
{
ApartmentViewModel.UserSingleton.CurrentUser.Picture = await ImgurPhotoUploader.UploadPhotoAsync();
-
+
}
catch (Exception e)
{
@@ -170,7 +170,7 @@ namespace ApartmentManager.Handler
{
User user = new User();
user = ApartmentViewModel.UserSingleton.CurrentUser;
- ApiClient.PutData("api/users/" + user.Username, user);
+ ApiClient.PutData("api/users/" + user.Username, user);
}
catch (Exception e)
{
@@ -202,7 +202,7 @@ namespace ApartmentManager.Handler
}
qwe.MainPicture = ApartmentViewModel.CatalogSingleton.DefectPictures[0].Picture;
}
-
+
}
@@ -224,9 +224,9 @@ namespace ApartmentManager.Handler
try
{
ApartmentViewModel.SelectedDefectPicture = new DefectPicture();
-
+
ApartmentViewModel.SelectedDefectPicture.Picture = await ImgurPhotoUploader.UploadPhotoAsync();
- ApartmentViewModel.CatalogSingleton.DefectPictures.Add(ApartmentViewModel.SelectedDefectPicture);
+ ApartmentViewModel.CatalogSingleton.DefectPictures.Add(ApartmentViewModel.SelectedDefectPicture);
}
catch (Exception e)
{
@@ -234,23 +234,23 @@ namespace ApartmentManager.Handler
}
///////////////////////////////////////////////////////////////////////////////////////////////////
public void CreateDefect()
- {
- Defect defect = new Defect();
- defect = ApartmentViewModel.NewDefect;
- defect.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId;
- defect.Status = "New";
- defect.UploadDate = DateTime.Now;
-
- ApiClient.PostData("api/defects/", defect);
- defect.DefectId = 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;
+
+ var response = ApiClient.PostData("api/defects/", defect);
+ var defectResponse = JsonConvert.DeserializeObject<Defect>(response);
+ defect.DefectId = defectResponse.DefectId;
- GetApartmentDefects();
-
+ foreach (var picture in ApartmentViewModel.CatalogSingleton.DefectPictures)
+ {
+ picture.DefectId = defect.DefectId;
+ ApiClient.PostData("api/defectpictures/", picture);
+ }
+ GetApartmentDefects();
}
///////////////////////////////////////////////////////////////////////////////////////////////////
public bool CreateDefect_CanExecute()
@@ -276,13 +276,13 @@ 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/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 8543833..e7e43ec 100644
--- a/ApartmentManager/ApartmentManager/Model/User.cs
+++ b/ApartmentManager/ApartmentManager/Model/User.cs
@@ -10,7 +10,7 @@ using ApartmentManager.Annotations;
namespace ApartmentManager.Model
{
- public class User: INotifyPropertyChanged
+ public class User : INotifyPropertyChanged
{
public string Username { get; set; }
public int ApartmentId { get; set; }
@@ -21,13 +21,14 @@ namespace ApartmentManager.Model
public DateTime BirthDate { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
- private 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;
@@ -38,7 +39,7 @@ namespace ApartmentManager.Model
public string Picture
{
- get { return _picture; }
+ get => _picture;
set
{
_picture = value;
diff --git a/ApartmentManager/ApartmentManager/Persistency/ApiClient.cs b/ApartmentManager/ApartmentManager/Persistency/ApiClient.cs
index 78a5a55..b99f582 100644
--- a/ApartmentManager/ApartmentManager/Persistency/ApiClient.cs
+++ b/ApartmentManager/ApartmentManager/Persistency/ApiClient.cs
@@ -57,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))
@@ -69,15 +69,14 @@ namespace ApartmentManager.Persistency
{
string serializedData = JsonConvert.SerializeObject(objectToPost);
StringContent content = new StringContent(serializedData, Encoding.UTF8, "application/json");
- var response = new HttpResponseMessage();
- response = client.PostAsync(url, content).Result;
- var def = JsonConvert.DeserializeObject<Defect>(response.Content.ReadAsStringAsync().Result);
- //var response = client.PostAsync(url, content).Result.Headers.Location.AbsolutePath.Remove(0,13);
- ApartmentViewModel.ServerResponse = def.DefectId;
+
+ var response = client.PostAsync(url, content).Result;
+ string result = response.Content.ReadAsStringAsync().Result;
+ return result;
}
catch (Exception)
{
-
+ return null;
}
}
}
@@ -92,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 050987d..a14c7d5 100644
--- a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs
+++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs
@@ -19,11 +19,16 @@ namespace ApartmentManager.Singletons
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>();
DefectPictures = new ObservableCollection<DefectPicture>();
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/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 618f27e..dad140a 100644
--- a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs
+++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs
@@ -30,13 +30,15 @@ namespace ApartmentManager.ViewModel
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; }
@@ -47,9 +49,10 @@ 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;
@@ -65,8 +68,7 @@ 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);
-
+ DefectInfo = new RelayCommand(ApartmentHandler.GetDefectInfo);
}