aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonatas Adamonis <dona0169@edu.easj.dk>2017-05-23 19:54:01 +0200
committerDonatas Adamonis <dona0169@edu.easj.dk>2017-05-23 19:54:01 +0200
commit09c247c6a72a59076b8a05bcad9fd8ef169d9a96 (patch)
treeaf8856a5e46ffe2498267007154895d5f3493ade
parent4fb953b9df93be797201349d70cfb7a25ee0194f (diff)
User Info Update
-rw-r--r--ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs39
-rw-r--r--ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml2
-rw-r--r--ApartmentManager/ApartmentManager/View/PersonalInfoPage.xaml8
-rw-r--r--ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs6
-rw-r--r--ApartmentManager/HousingWebApi/HousingWebApi.csproj23
-rw-r--r--ApartmentManager/HousingWebApi/Models/Apartment.cs2
-rw-r--r--ApartmentManager/HousingWebApi/Models/Resident.cs2
-rw-r--r--ApartmentManager/HousingWebApi/Models/User.cs2
8 files changed, 64 insertions, 20 deletions
diff --git a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
index c5dd6f0..61fd912 100644
--- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs
@@ -23,6 +23,11 @@ namespace ApartmentManager.Handler
{
ApartmentViewModel = apartmenViewModel;
}
+
+
+ /// <summary>
+ /// APARTMENT HANDLERS
+ /// </summary>
public void GetApartmentResidents()
{
Resident resident = new Resident();
@@ -47,6 +52,9 @@ namespace ApartmentManager.Handler
ApartmentViewModel.CatalogSingleton.Apartment = apartment;
}
+ /// <summary>
+ /// RESIDENT HANDLERS
+ /// </summary>
public void CreateResident()
{
try
@@ -109,6 +117,7 @@ namespace ApartmentManager.Handler
new MessageDialog(e.Message).ShowAsync();
}
}
+
public void UpdateResident()
{
try
@@ -153,5 +162,35 @@ namespace ApartmentManager.Handler
{
}
}
+
+
+ /// <summary>
+ /// USER HANDLERS
+ /// </summary>
+ ///
+ public async void UploadUserPhoto()
+ {
+ try
+ {
+ ApartmentViewModel.UserSingleton.CurrentUser.Picture = await ImgurPhotoUploader.UploadPhotoAsync();
+
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ public void UpdateUser()
+ {
+ try
+ {
+ User user = new User();
+ user = ApartmentViewModel.UserSingleton.CurrentUser;
+ ApiClient.PutData("api/users/" + user.Username, user);
+ }
+ catch (Exception e)
+ {
+ new MessageDialog(e.Message).ShowAsync();
+ }
+ }
}
}
diff --git a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml
index ca92dd2..3e57b2a 100644
--- a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml
+++ b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml
@@ -24,7 +24,7 @@
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Background="Gray" BorderThickness="0,0,2,0" BorderBrush="#CCFFFFFF" >
- <Image Stretch="Fill" Source="{Binding Picture}"/>
+ <Image Stretch="Fill" Source="{Binding UserSingleton.CurrentUser.Picture}"/>
</Grid>
<Grid Grid.Column="1" Margin="3,3,3,3">
diff --git a/ApartmentManager/ApartmentManager/View/PersonalInfoPage.xaml b/ApartmentManager/ApartmentManager/View/PersonalInfoPage.xaml
index b7952a3..3747c00 100644
--- a/ApartmentManager/ApartmentManager/View/PersonalInfoPage.xaml
+++ b/ApartmentManager/ApartmentManager/View/PersonalInfoPage.xaml
@@ -16,9 +16,9 @@
<StackPanel Margin="20" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top">
<StackPanel Width="400" Margin="0,0,50,0">
<TextBlock Margin="0,10,0,10" Text="First Contract Owner" HorizontalAlignment="Center" FontSize="20" FontWeight="Bold"/>
-
- <Image Source="{Binding NewResident.Picture, Mode=TwoWay}" Height="150" Width="150" ></Image>
- <Button Content="Upload Picture" HorizontalAlignment="Stretch" Margin="0,10,0,0" Command="{Binding UploadResidentPhoto}" ></Button>
+
+ <Image Source="{Binding UserSingleton.CurrentUser.Picture, Mode=TwoWay}" Height="150" Width="150" ></Image>
+ <Button Content="Upload Picture" HorizontalAlignment="Stretch" Margin="0,10,0,0" Command="{Binding UploadUserPhoto}" ></Button>
<TextBlock Margin="0,5,0,5" Text="Name"/>
<TextBox Text="{Binding UserSingleton.CurrentUser.FirstName, Mode=TwoWay}" />
@@ -32,7 +32,7 @@
<TextBox Text="{Binding UserSingleton.CurrentUser.Phone, Mode=TwoWay}" />
<TextBlock Margin="0,5,0,5" Text="Password"/>
<TextBox Text="{Binding UserSingleton.CurrentUser.Password, Mode=TwoWay}" />
- <Button Margin="0,5,0,5" Content="Update" HorizontalAlignment="Stretch"/>
+ <Button Margin="0,5,0,5" Content="Update" HorizontalAlignment="Stretch" Command="{Binding UpdateUser}"/>
</StackPanel>
</StackPanel>
diff --git a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs
index 2e2e0ea..c668de2 100644
--- a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs
+++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs
@@ -32,6 +32,8 @@ namespace ApartmentManager.ViewModel
public ICommand DeleteResidentCommand { get; set; }
public ICommand UpdateResidentCommand { get; set; }
public ICommand UploadResidentPhoto { get; set; }
+ public ICommand UploadUserPhoto { get; set; }
+ public ICommand UpdateUser { get; set; }
public ApartmentViewModel()
{
@@ -43,10 +45,14 @@ namespace ApartmentManager.ViewModel
UserSingleton = UserSingleton.Instance;
ApartmentNumber = UserSingleton.CurrentUser.ApartmentId;
+ UpdateUser = new RelayCommand(ApartmentHandler.UpdateUser);
+ UploadUserPhoto = new RelayCommand(ApartmentHandler.UploadUserPhoto);
+
UploadResidentPhoto = new RelayCommand(ApartmentHandler.UploadResidentPhoto);
CreateResidentCommand = new RelayCommand(ApartmentHandler.CreateResident);
DeleteResidentCommand = new RelayCommand(ApartmentHandler.DeleteResident);
UpdateResidentCommand = new RelayCommand(ApartmentHandler.UpdateResident);
+
ApartmentHandler.GetApartmentResidents();
ApartmentHandler.GetApartment();
}
diff --git a/ApartmentManager/HousingWebApi/HousingWebApi.csproj b/ApartmentManager/HousingWebApi/HousingWebApi.csproj
index 4d60cac..b009a06 100644
--- a/ApartmentManager/HousingWebApi/HousingWebApi.csproj
+++ b/ApartmentManager/HousingWebApi/HousingWebApi.csproj
@@ -151,9 +151,9 @@
</Reference>
</ItemGroup>
<ItemGroup>
- <Compile Include="Apartment.cs" />
- <Compile Include="ApartmentChange.cs" />
- <Compile Include="ApartmentResident.cs" />
+ <Compile Include="Models\Apartment.cs" />
+ <Compile Include="Models\ApartmentChange.cs" />
+ <Compile Include="Models\ApartmentResident.cs" />
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
@@ -186,8 +186,8 @@
<Compile Include="Areas\HelpPage\SampleGeneration\SampleDirection.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" />
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />
- <Compile Include="ChangeComment.cs" />
- <Compile Include="ChangeDocument.cs" />
+ <Compile Include="Models\ChangeComment.cs" />
+ <Compile Include="Models\ChangeDocument.cs" />
<Compile Include="Controllers\ApartmentChangesController.cs" />
<Compile Include="Controllers\ApartmentsController.cs" />
<Compile Include="Controllers\ChangeCommentsController.cs" />
@@ -200,16 +200,16 @@
<Compile Include="Controllers\ResidentsController.cs" />
<Compile Include="Controllers\UsersController.cs" />
<Compile Include="DataModel.cs" />
- <Compile Include="Defect.cs" />
- <Compile Include="DefectComment.cs" />
- <Compile Include="DefectPicture.cs" />
+ <Compile Include="Models\Defect.cs" />
+ <Compile Include="Models\DefectComment.cs" />
+ <Compile Include="Models\DefectPicture.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
- <Compile Include="PastUser.cs" />
+ <Compile Include="Models\PastUser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Resident.cs" />
- <Compile Include="User.cs" />
+ <Compile Include="Models\Resident.cs" />
+ <Compile Include="Models\User.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Areas\HelpPage\HelpPage.css" />
@@ -267,7 +267,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
- <Folder Include="Models\" />
</ItemGroup>
<ItemGroup>
<Content Include="fonts\glyphicons-halflings-regular.woff" />
diff --git a/ApartmentManager/HousingWebApi/Models/Apartment.cs b/ApartmentManager/HousingWebApi/Models/Apartment.cs
index 94c9b11..1aa381d 100644
--- a/ApartmentManager/HousingWebApi/Models/Apartment.cs
+++ b/ApartmentManager/HousingWebApi/Models/Apartment.cs
@@ -33,7 +33,7 @@ namespace HousingWebApi
[StringLength(100)]
public string Address { get; set; }
- [StringLength(50)]
+
public string PlanPicture { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
diff --git a/ApartmentManager/HousingWebApi/Models/Resident.cs b/ApartmentManager/HousingWebApi/Models/Resident.cs
index 4d29f16..7c0fa24 100644
--- a/ApartmentManager/HousingWebApi/Models/Resident.cs
+++ b/ApartmentManager/HousingWebApi/Models/Resident.cs
@@ -28,7 +28,7 @@ namespace HousingWebApi
[StringLength(50)]
public string Email { get; set; }
- [StringLength(50)]
+
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 12438c6..3ff1099 100644
--- a/ApartmentManager/HousingWebApi/Models/User.cs
+++ b/ApartmentManager/HousingWebApi/Models/User.cs
@@ -36,7 +36,7 @@ namespace HousingWebApi
[StringLength(50)]
public string Email { get; set; }
- [StringLength(50)]
+
public string Picture { get; set; }
[Column(TypeName = "date")]