aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ApartmentManager/ApartmentManager/ApartmentManager.csproj6
-rw-r--r--ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs77
-rw-r--r--ApartmentManager/ApartmentManager/Persistency/ApiClient.cs4
-rw-r--r--ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs4
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml6
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs11
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml49
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml.cs (renamed from ApartmentManager/ApartmentManager/View/ApartmentDefectViewPagexaml.xaml.cs)4
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentDefectViewPagexaml.xaml37
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml8
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs10
-rw-r--r--ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs18
-rw-r--r--ApartmentManager/HousingWebApi/Controllers/DefectCommentsController.cs8
-rw-r--r--ApartmentManager/HousingWebApi/Controllers/DefectsController.cs3
-rw-r--r--ApartmentManager/HousingWebApi/DataModel.cs2
-rw-r--r--ApartmentManager/HousingWebApi/Models/Apartment.cs1
-rw-r--r--ApartmentManager/HousingWebApi/Models/Defect.cs1
-rw-r--r--ApartmentManager/HousingWebApi/Models/DefectComment.cs5
-rw-r--r--ApartmentManager/HousingWebApi/Models/DefectPicture.cs2
-rw-r--r--ApartmentManager/HousingWebApi/Models/Resident.cs1
-rw-r--r--ApartmentManager/HousingWebApi/Models/User.cs1
21 files changed, 180 insertions, 78 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj
index ac7b1f7..e6f14f6 100644
--- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj
+++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj
@@ -124,8 +124,8 @@
<Compile Include="View\ApartmentDefectPage.xaml.cs">
<DependentUpon>ApartmentDefectPage.xaml</DependentUpon>
</Compile>
- <Compile Include="View\ApartmentDefectViewPagexaml.xaml.cs">
- <DependentUpon>ApartmentDefectViewPagexaml.xaml</DependentUpon>
+ <Compile Include="View\ApartmentDefectViewPage.xaml.cs">
+ <DependentUpon>ApartmentDefectViewPage.xaml</DependentUpon>
</Compile>
<Compile Include="View\ApartmentNewDefect.xaml.cs">
<DependentUpon>ApartmentNewDefect.xaml</DependentUpon>
@@ -197,7 +197,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="View\ApartmentDefectViewPagexaml.xaml">
+ <Page Include="View\ApartmentDefectViewPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
diff --git a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
index 388cbaa..095ee73 100644
--- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
@@ -203,20 +203,24 @@ namespace ApartmentManager.Handler
Defect defect = new Defect();
defect.ApartmentId = ApartmentViewModel.ApartmentNumber;
- var residentsFromDatabase = ApiClient.GetData("api/ApartmentDefects/" + defect.ApartmentId);
- IEnumerable<Defect> defecttlist = JsonConvert.DeserializeObject<IEnumerable<Defect>>(residentsFromDatabase);
+ var defectsFromDatabase = ApiClient.GetData("api/ApartmentDefects/" + defect.ApartmentId);
+ IEnumerable<Defect> defecttlist = JsonConvert.DeserializeObject<IEnumerable<Defect>>(defectsFromDatabase);
foreach (var qwe in defecttlist)
{
var picturesFromDatabase = ApiClient.GetData("api/DefectPictures/" + qwe.DefectId);
- IEnumerable<DefectPicture> picturetlist = JsonConvert.DeserializeObject<IEnumerable<DefectPicture>>(picturesFromDatabase);
- ApartmentViewModel.CatalogSingleton.DefectPictures.Clear();
- foreach (var asd in picturetlist)
+ if (picturesFromDatabase != "[]")
{
+ IEnumerable<DefectPicture> picturetlist = JsonConvert.DeserializeObject<IEnumerable<DefectPicture>>(picturesFromDatabase);
+ ApartmentViewModel.CatalogSingleton.DefectPictures.Clear();
+ foreach (var asd in picturetlist)
+ {
- ApartmentViewModel.CatalogSingleton.DefectPictures.Add(asd);
+ ApartmentViewModel.CatalogSingleton.DefectPictures.Add(asd);
+ }
+ qwe.MainPicture = ApartmentViewModel.CatalogSingleton.DefectPictures[0].Picture;
}
- qwe.MainPicture = ApartmentViewModel.CatalogSingleton.DefectPictures[0].Picture;
+
}
@@ -227,6 +231,7 @@ namespace ApartmentManager.Handler
ApartmentViewModel.CatalogSingleton.Defects.Add(defect2);
}
+ ApartmentViewModel.CatalogSingleton.DefectPictures.Clear();
}
public void DeleteDefectPicture()
@@ -237,14 +242,66 @@ namespace ApartmentManager.Handler
{
try
{
+ ApartmentViewModel.SelectedDefectPicture = new DefectPicture();
+
ApartmentViewModel.SelectedDefectPicture.Picture = await ImgurPhotoUploader.UploadPhotoAsync();
ApartmentViewModel.CatalogSingleton.DefectPictures.Add(ApartmentViewModel.SelectedDefectPicture);
- var tmp = ApartmentViewModel.UserSingleton.CurrentUser;
- ApartmentViewModel.UserSingleton.CurrentUser = new User();
- ApartmentViewModel.UserSingleton.CurrentUser = tmp;
+
+ }
+ 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);
+ }
+
+ GetApartmentDefects();
+
}
catch (Exception e)
{
+ new MessageDialog(e.Message).ShowAsync();
+ }
+ }
+
+ public void GetDefectInfo()
+ {
+ var id = ApartmentViewModel.NewDefect.DefectId;
+ Defect defect = new Defect();
+ defect.DefectId = id;
+
+ var defectFromDatabase = ApiClient.GetData("api/defects/" + defect.DefectId);
+ var defect2 = JsonConvert.DeserializeObject<Defect>(defectFromDatabase);
+ ApartmentViewModel.CatalogSingleton.Defect = defect2;
+
+ var picturesFromDatabase = ApiClient.GetData("api/DefectPictures/" + defect.DefectId);
+ ApartmentViewModel.CatalogSingleton.DefectPictures2.Clear();
+ if (picturesFromDatabase != "[]")
+ {
+ IEnumerable<DefectPicture> picturetlist =
+ JsonConvert.DeserializeObject<IEnumerable<DefectPicture>>(picturesFromDatabase);
+ foreach (var asd in picturetlist)
+ {
+
+ ApartmentViewModel.CatalogSingleton.DefectPictures2.Add(asd);
+ }
+
+
}
}
}
diff --git a/ApartmentManager/ApartmentManager/Persistency/ApiClient.cs b/ApartmentManager/ApartmentManager/Persistency/ApiClient.cs
index 2faa07a..8ae0e1c 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.ViewModel;
namespace ApartmentManager.Persistency
{
@@ -67,7 +68,8 @@ namespace ApartmentManager.Persistency
{
string serializedData = JsonConvert.SerializeObject(objectToPost);
StringContent content = new StringContent(serializedData, Encoding.UTF8, "application/json");
- var response = client.PostAsync(url, content).Result;
+ var response = client.PostAsync(url, content).Result.Headers.Location.AbsolutePath.Remove(0,13);
+ ApartmentViewModel.ServerResponse = response;
}
catch (Exception)
{
diff --git a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs
index f158063..62bbae3 100644
--- a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs
+++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs
@@ -15,12 +15,16 @@ namespace ApartmentManager.Singletons
public ObservableCollection<Resident> Residents { get; set; }
public ObservableCollection<Defect> Defects { get; set; }
public ObservableCollection<DefectPicture> DefectPictures { get; set; }
+ public ObservableCollection<DefectPicture> DefectPictures2 { get; set; }
+ public Defect Defect { get; set; }
private CatalogSingleton()
{
+
Residents = new ObservableCollection<Resident>();
Defects = new ObservableCollection<Defect>();
DefectPictures = new ObservableCollection<DefectPicture>();
+ DefectPictures2 = new ObservableCollection<DefectPicture>();
}
}
}
diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml
index 5cff9d2..df052a6 100644
--- a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml
+++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml
@@ -8,9 +8,9 @@
x:Class="ApartmentManager.View.ApartmentDefectPage"
mc:Ignorable="d">
- <Page.DataContext>
+ <!--<Page.DataContext>
<ViewModel:ApartmentViewModel/>
- </Page.DataContext>
+ </Page.DataContext>-->
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Margin="10">
@@ -71,7 +71,7 @@
</ListView>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,15,0,0">
<Button Content="New Defect" Width="200" Margin="0,0,100,0" Click="NavigateNewDefect" ></Button>
- <Button Content="View Defect" Width="200" Margin="0,0,100,0" ></Button>
+ <Button Content="View Defect" Width="200" Margin="0,0,100,0" Click="NavigateDefect" ></Button>
</StackPanel>
</StackPanel>
diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs
index eef6323..ee53458 100644
--- a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs
+++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs
@@ -12,6 +12,7 @@ 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
@@ -22,14 +23,24 @@ 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)
+ {
+ vm.DefectInfo.Execute(null);
+ //vm.ApartmentHandler.GetDefectInfo();
+ Frame.Navigate(typeof(ApartmentDefectViewPagexaml));
+ }
}
}
diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml
new file mode 100644
index 0000000..0da2b73
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml
@@ -0,0 +1,49 @@
+<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.ApartmentDefectViewPagexaml"
+ mc:Ignorable="d">
+
+ <Page.DataContext>
+ <ViewModel:ApartmentViewModel/>
+ </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}">
+ <ListView.ItemTemplate>
+ <DataTemplate>
+ <Image Source="{Binding Picture}" Width="400" Margin="10"></Image>
+ </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>
+ </Grid>
+</Page>
diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPagexaml.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml.cs
index beffd9c..7abaf26 100644
--- a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPagexaml.xaml.cs
+++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml.cs
@@ -12,6 +12,7 @@ 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
@@ -22,9 +23,12 @@ namespace ApartmentManager.View
/// </summary>
public sealed partial class ApartmentDefectViewPagexaml : Page
{
+ private ApartmentViewModel vm;
public ApartmentDefectViewPagexaml()
{
this.InitializeComponent();
+ vm = new ApartmentViewModel();
+ DataContext = vm;
}
}
}
diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPagexaml.xaml b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPagexaml.xaml
deleted file mode 100644
index 42c48a2..0000000
--- a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPagexaml.xaml
+++ /dev/null
@@ -1,37 +0,0 @@
-<Page
- x:Class="ApartmentManager.View.ApartmentDefectViewPagexaml"
- 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"
- mc:Ignorable="d">
-
- <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>
- <TextBlock Text="Defect Name" FontSize="30" FontWeight="Bold" Margin="10,0,0,0"></TextBlock>
- <TextBlock Text="Status:" FontSize="30" FontWeight="Bold" Margin="400,0,0,0"></TextBlock>
- <TextBlock Text="Defect Status" FontSize="30" FontWeight="Bold" Margin="10,0,0,0"></TextBlock>
- </StackPanel>
- <StackPanel Orientation="Horizontal" Margin="20">
- <StackPanel Width="620">
- <TextBlock Text="Defect Pictures" FontSize="30" FontWeight="Bold" Margin="10,0,0,0"></TextBlock>
- <ListView ></ListView>
- </StackPanel>
- <StackPanel Width="620">
- <TextBlock Text="Description" FontSize="30" FontWeight="Bold" Margin="10,0,0,0"></TextBlock>
- <TextBox Height="400" Margin="0,10,0,0"></TextBox>
-
- </StackPanel>
-
-
- </StackPanel>
- <ListView Width="600" Height="200"></ListView>
-
-
-
- </StackPanel>
- </Grid>
-</Page>
diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml
index 9b22dc9..fa4862e 100644
--- a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml
+++ b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml
@@ -8,9 +8,7 @@
x:Class="ApartmentManager.View.ApartmentNewDefect"
mc:Ignorable="d">
- <Page.DataContext>
- <ViewModel:ApartmentViewModel/>
- </Page.DataContext>
+
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
@@ -29,7 +27,7 @@
</ListView>
<StackPanel Orientation="Horizontal" Margin="10" >
- <Button Content="Upload Picture" Margin="30,0,0,0"/>
+ <Button Content="Upload Picture" Margin="30,0,0,0" Command="{Binding UploadDefectPicture}"/>
<Button Content="Delete Picture" Margin="170,0,0,0" Command="{Binding DeleteDefectPicture}"/>
</StackPanel>
@@ -43,7 +41,7 @@
<TextBox Text="{Binding NewDefect.Name, Mode=TwoWay}" />
<TextBlock Margin="0,10,0,10" Text="Description"/>
<TextBox Text="{Binding NewDefect.Description, Mode=TwoWay}" Height="417" />
- <Button Margin="0,20,0,0" Content="Create" HorizontalAlignment="Stretch"/>
+ <Button Margin="0,20,0,0" Content="Create" HorizontalAlignment="Stretch" Click="Navigate"/>
</StackPanel>
</StackPanel>
diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs
index 5e18b42..ba7139d 100644
--- a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs
+++ b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs
@@ -12,6 +12,7 @@ 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
@@ -22,9 +23,18 @@ namespace ApartmentManager.View
/// </summary>
public sealed partial class ApartmentNewDefect : Page
{
+ private ApartmentViewModel vm;
public ApartmentNewDefect()
{
this.InitializeComponent();
+ vm = new ApartmentViewModel();
+ DataContext = vm;
+ }
+
+ private void Navigate(object sender, RoutedEventArgs e)
+ {
+ vm.CreateDefect.Execute(null);
+ Frame.Navigate(typeof(ApartmentDefectPage));
}
}
}
diff --git a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs
index 1b39e8f..f932f18 100644
--- a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs
+++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs
@@ -28,6 +28,7 @@ namespace ApartmentManager.ViewModel
public static int ApartmentNumber { get; set; }
+ public static string ServerResponse { get; set; }
public ICommand CreateResidentCommand { get; set; }
public ICommand DeleteResidentCommand { get; set; }
@@ -36,25 +37,34 @@ namespace ApartmentManager.ViewModel
public ICommand UploadUserPhoto { get; set; }
public ICommand UpdateUser { get; set; }
public ICommand DeleteDefectPicture { get; set; }
+ public ICommand UploadDefectPicture { get; set; }
+ public ICommand CreateDefect { get; set; }
+ public ICommand DefectInfo { get; set; }
+
public ApartmentViewModel()
{
NewUser = new User();
NewResident = new Resident();
-
+ NewDefect = new Defect();
+ SelectedDefectPicture = new DefectPicture();
+
ApartmentHandler = new ApartmentHandler(this);
CatalogSingleton = CatalogSingleton.Instance;
UserSingleton = UserSingleton.Instance;
ApartmentNumber = UserSingleton.CurrentUser.ApartmentId;
-
+ ////////// User relay commands//////////
UpdateUser = new RelayCommand(ApartmentHandler.UpdateUser);
UploadUserPhoto = new RelayCommand(ApartmentHandler.UploadUserPhoto);
-
+ ////////// Resident relay commands//////////
UploadResidentPhoto = new RelayCommand(ApartmentHandler.UploadResidentPhoto);
CreateResidentCommand = new RelayCommand(ApartmentHandler.CreateResident);
DeleteResidentCommand = new RelayCommand(ApartmentHandler.DeleteResident);
UpdateResidentCommand = new RelayCommand(ApartmentHandler.UpdateResident);
-
+ ////////// 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();
diff --git a/ApartmentManager/HousingWebApi/Controllers/DefectCommentsController.cs b/ApartmentManager/HousingWebApi/Controllers/DefectCommentsController.cs
index ae5222d..a4fc8e8 100644
--- a/ApartmentManager/HousingWebApi/Controllers/DefectCommentsController.cs
+++ b/ApartmentManager/HousingWebApi/Controllers/DefectCommentsController.cs
@@ -44,7 +44,7 @@ namespace HousingWebApi.Controllers
return BadRequest(ModelState);
}
- if (id != defectComment.PictureId)
+ if (id != defectComment.CommentId)
{
return BadRequest();
}
@@ -87,7 +87,7 @@ namespace HousingWebApi.Controllers
}
catch (DbUpdateException)
{
- if (DefectCommentExists(defectComment.PictureId))
+ if (DefectCommentExists(defectComment.CommentId))
{
return Conflict();
}
@@ -97,7 +97,7 @@ namespace HousingWebApi.Controllers
}
}
- return CreatedAtRoute("DefaultApi", new { id = defectComment.PictureId }, defectComment);
+ return CreatedAtRoute("DefaultApi", new { id = defectComment.CommentId }, defectComment);
}
// DELETE: api/DefectComments/5
@@ -127,7 +127,7 @@ namespace HousingWebApi.Controllers
private bool DefectCommentExists(int id)
{
- return db.DefectComments.Count(e => e.PictureId == id) > 0;
+ return db.DefectComments.Count(e => e.CommentId == id) > 0;
}
}
} \ No newline at end of file
diff --git a/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs b/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs
index c5bb0ac..1ec5ca3 100644
--- a/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs
+++ b/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs
@@ -75,7 +75,7 @@ namespace HousingWebApi.Controllers
}
}
- return StatusCode(HttpStatusCode.NoContent);
+ return StatusCode(HttpStatusCode.Created);
}
// POST: api/Defects
@@ -106,6 +106,7 @@ namespace HousingWebApi.Controllers
}
return CreatedAtRoute("DefaultApi", new { id = defect.DefectId }, defect);
+
}
// DELETE: api/Defects/5
diff --git a/ApartmentManager/HousingWebApi/DataModel.cs b/ApartmentManager/HousingWebApi/DataModel.cs
index 26b2608..64826a3 100644
--- a/ApartmentManager/HousingWebApi/DataModel.cs
+++ b/ApartmentManager/HousingWebApi/DataModel.cs
@@ -113,7 +113,7 @@ namespace HousingWebApi
.WillCascadeOnDelete(false);
modelBuilder.Entity<DefectComment>()
- .Property(e => e.Picture)
+ .Property(e => e.Comment)
.IsUnicode(false);
modelBuilder.Entity<DefectPicture>()
diff --git a/ApartmentManager/HousingWebApi/Models/Apartment.cs b/ApartmentManager/HousingWebApi/Models/Apartment.cs
index 1aa381d..9e703bd 100644
--- a/ApartmentManager/HousingWebApi/Models/Apartment.cs
+++ b/ApartmentManager/HousingWebApi/Models/Apartment.cs
@@ -33,7 +33,6 @@ namespace HousingWebApi
[StringLength(100)]
public string Address { get; set; }
-
public string PlanPicture { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
diff --git a/ApartmentManager/HousingWebApi/Models/Defect.cs b/ApartmentManager/HousingWebApi/Models/Defect.cs
index 5200124..07ed227 100644
--- a/ApartmentManager/HousingWebApi/Models/Defect.cs
+++ b/ApartmentManager/HousingWebApi/Models/Defect.cs
@@ -16,7 +16,6 @@ namespace HousingWebApi
DefectPictures = new HashSet<DefectPicture>();
}
- [DatabaseGenerated(DatabaseGeneratedOption.None)]
public int DefectId { get; set; }
public int ApartmentId { get; set; }
diff --git a/ApartmentManager/HousingWebApi/Models/DefectComment.cs b/ApartmentManager/HousingWebApi/Models/DefectComment.cs
index b05f790..c65bac2 100644
--- a/ApartmentManager/HousingWebApi/Models/DefectComment.cs
+++ b/ApartmentManager/HousingWebApi/Models/DefectComment.cs
@@ -10,12 +10,11 @@ namespace HousingWebApi
public partial class DefectComment
{
[Key]
- [DatabaseGenerated(DatabaseGeneratedOption.None)]
- public int PictureId { get; set; }
+ public int CommentId { get; set; }
public int DefectId { get; set; }
- public string Picture { get; set; }
+ public string Comment { get; set; }
public virtual Defect Defect { get; set; }
}
diff --git a/ApartmentManager/HousingWebApi/Models/DefectPicture.cs b/ApartmentManager/HousingWebApi/Models/DefectPicture.cs
index 5d27ba3..faab22d 100644
--- a/ApartmentManager/HousingWebApi/Models/DefectPicture.cs
+++ b/ApartmentManager/HousingWebApi/Models/DefectPicture.cs
@@ -10,12 +10,10 @@ namespace HousingWebApi
public partial class DefectPicture
{
[Key]
- [DatabaseGenerated(DatabaseGeneratedOption.None)]
public int PictureId { get; set; }
public int DefectId { get; set; }
- [StringLength(50)]
public string Picture { get; set; }
public virtual Defect Defect { get; set; }
diff --git a/ApartmentManager/HousingWebApi/Models/Resident.cs b/ApartmentManager/HousingWebApi/Models/Resident.cs
index 7c0fa24..4ed302c 100644
--- a/ApartmentManager/HousingWebApi/Models/Resident.cs
+++ b/ApartmentManager/HousingWebApi/Models/Resident.cs
@@ -28,7 +28,6 @@ namespace HousingWebApi
[StringLength(50)]
public string Email { get; set; }
-
public string Picture { get; set; }
public virtual Apartment Apartment { get; set; }
diff --git a/ApartmentManager/HousingWebApi/Models/User.cs b/ApartmentManager/HousingWebApi/Models/User.cs
index 3ff1099..b8762ca 100644
--- a/ApartmentManager/HousingWebApi/Models/User.cs
+++ b/ApartmentManager/HousingWebApi/Models/User.cs
@@ -36,7 +36,6 @@ namespace HousingWebApi
[StringLength(50)]
public string Email { get; set; }
-
public string Picture { get; set; }
[Column(TypeName = "date")]