diff options
7 files changed, 89 insertions, 4 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj index f267a50..8726694 100644 --- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj +++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj @@ -98,6 +98,7 @@ <Compile Include="AppShell.xaml.cs"> <DependentUpon>AppShell.xaml</DependentUpon> </Compile> + <Compile Include="Common\ByteArrayToImageConverter.cs" /> <Compile Include="Common\RelayCommand.cs" /> <Compile Include="Controls\NavMenuListView.cs" /> <Compile Include="Handler\BoardMemberHandler.cs" /> diff --git a/ApartmentManager/ApartmentManager/Common/ByteArrayToImageConverter.cs b/ApartmentManager/ApartmentManager/Common/ByteArrayToImageConverter.cs new file mode 100644 index 0000000..e1d2400 --- /dev/null +++ b/ApartmentManager/ApartmentManager/Common/ByteArrayToImageConverter.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.Storage.Streams; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Media.Imaging; + +namespace ApartmentManager.Common +{ + class ByteArrayToImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + if (value != null) + { + BitmapImage image = new BitmapImage(); + using (InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream()) + { + stream.AsStreamForWrite().Write((byte[])value, 0, ((byte[])value).Length); + image.SetSource(stream); + } + return image; + } + else return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } +} diff --git a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml index ea4711e..a9d341e 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml @@ -78,7 +78,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 Picture, Converter={StaticResource ByteArrayToImageConverter}}"/> </Grid> <Grid Grid.Column="1" Margin="3,3,3,3"> diff --git a/ApartmentManager/HousingWebApi/DataModel.cs b/ApartmentManager/HousingWebApi/DataModel.cs index 00f4811..485c697 100644 --- a/ApartmentManager/HousingWebApi/DataModel.cs +++ b/ApartmentManager/HousingWebApi/DataModel.cs @@ -23,6 +23,7 @@ namespace HousingWebApi public virtual DbSet<PastUser> PastUsers { get; set; } public virtual DbSet<Resident> Residents { get; set; } public virtual DbSet<User> Users { get; set; } + public virtual DbSet<ApartmentResident> ApartmentResidents { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { @@ -170,6 +171,22 @@ namespace HousingWebApi modelBuilder.Entity<User>() .Property(e => e.Email) .IsUnicode(false); + + modelBuilder.Entity<ApartmentResident>() + .Property(e => e.FirstName) + .IsUnicode(false); + + modelBuilder.Entity<ApartmentResident>() + .Property(e => e.LastName) + .IsUnicode(false); + + modelBuilder.Entity<ApartmentResident>() + .Property(e => e.Phone) + .IsUnicode(false); + + modelBuilder.Entity<ApartmentResident>() + .Property(e => e.Email) + .IsUnicode(false); } } } diff --git a/ApartmentManager/HousingWebApi/HousingWebApi.csproj b/ApartmentManager/HousingWebApi/HousingWebApi.csproj index 117dc9d..b009a06 100644 --- a/ApartmentManager/HousingWebApi/HousingWebApi.csproj +++ b/ApartmentManager/HousingWebApi/HousingWebApi.csproj @@ -153,8 +153,7 @@ <ItemGroup>
<Compile Include="Models\Apartment.cs" />
<Compile Include="Models\ApartmentChange.cs" />
- <Compile Include="Models\ChangeComment.cs" />
- <Compile Include="Models\ChangeDocument.cs" />
+ <Compile Include="Models\ApartmentResident.cs" />
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
@@ -187,6 +186,8 @@ <Compile Include="Areas\HelpPage\SampleGeneration\SampleDirection.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" />
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.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" />
diff --git a/ApartmentManager/HousingWebApi/Models/ApartmentResident.cs b/ApartmentManager/HousingWebApi/Models/ApartmentResident.cs new file mode 100644 index 0000000..9936a5e --- /dev/null +++ b/ApartmentManager/HousingWebApi/Models/ApartmentResident.cs @@ -0,0 +1,32 @@ +namespace HousingWebApi +{ + using System; + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using System.ComponentModel.DataAnnotations.Schema; + using System.Data.Entity.Spatial; + + public partial class ApartmentResident + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public int ApartmentId { get; set; } + + [StringLength(30)] + public string FirstName { get; set; } + + [StringLength(30)] + public string LastName { get; set; } + + [Column(TypeName = "date")] + public DateTime? BirthDate { get; set; } + + [StringLength(20)] + public string Phone { get; set; } + + [StringLength(50)] + public string Email { get; set; } + + public byte[] Picture { get; set; } + } +} diff --git a/ApartmentManager/HousingWebApi/Models/Resident.cs b/ApartmentManager/HousingWebApi/Models/Resident.cs index c9a698f..0509d40 100644 --- a/ApartmentManager/HousingWebApi/Models/Resident.cs +++ b/ApartmentManager/HousingWebApi/Models/Resident.cs @@ -9,7 +9,6 @@ namespace HousingWebApi [Table("Resident")] public partial class Resident { - [DatabaseGenerated(DatabaseGeneratedOption.None)] public int ResidentId { get; set; } public int ApartmentId { get; set; } |