diff options
author | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-10 16:17:05 +0200 |
---|---|---|
committer | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-10 16:17:05 +0200 |
commit | 8be8bd9b1131d1866778f47d206f9b475bc209b7 (patch) | |
tree | 6112046d7385ca03f65d04be108fd4681677d549 | |
parent | 5f31eabf99bfce7f39bb205bfec97ab232c28394 (diff) |
Updated residence list design, upload photo feature
10 files changed, 180 insertions, 72 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj index f15b399..340ba6c 100644 --- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj +++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj @@ -120,6 +120,9 @@ <Compile Include="ViewModel\ApartmentsViewModel.cs" /> <Compile Include="ViewModel\ApartmenViewModel.cs" /> <Compile Include="ViewModel\LoginViewModel.cs" /> + <Compile Include="View\ApartmentDefectPage.xaml.cs"> + <DependentUpon>ApartmentDefectPage.xaml</DependentUpon> + </Compile> <Compile Include="View\ApartmentNewDefect.xaml.cs"> <DependentUpon>ApartmentNewDefect.xaml</DependentUpon> </Compile> @@ -183,6 +186,10 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="View\ApartmentDefectPage.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="View\ApartmentNewDefect.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> diff --git a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs index 7c27686..0310f80 100644 --- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs @@ -138,6 +138,20 @@ namespace ApartmentManager.Handler { new MessageDialog(e.Message).ShowAsync(); } - } + } + + public async void UploadResidentPhoto() + { + try + { + ApartmentViewModel.NewResident.Picture = await ImgurPhotoUploader.UploadPhotoAsync(); + } + catch (Exception e) + { + + + } + + } } } diff --git a/ApartmentManager/ApartmentManager/Model/Resident.cs b/ApartmentManager/ApartmentManager/Model/Resident.cs index e9f39cd..e5ee2fb 100644 --- a/ApartmentManager/ApartmentManager/Model/Resident.cs +++ b/ApartmentManager/ApartmentManager/Model/Resident.cs @@ -12,26 +12,27 @@ namespace ApartmentManager.Model public string FirstName { get; set; } public string LastName { get; set; } public int Phone { get; set; } - public DateTime BirthDate { get; set; } + public DateTimeOffset BirthDate { get; set; } public string Email { get; set; } - public Image Picture { get; set; } + public string Picture { get; set; } public int ApartmentNr { get; set; } public int ResidentNr { get; set; } - + public Resident() { } - public Resident(string FirstName, string LastName, int Phone, DateTime BirthDate, string Email, int ApartmentNr ,int ResidentNr) - { - this.FirstName = FirstName; - this.LastName = LastName; - this.Phone = Phone; - this.BirthDate = BirthDate; - this.Email = Email; - this.ApartmentNr = ApartmentNr; - this.ResidentNr = ResidentNr; - } - public override string ToString() + public Resident(string firstName, string lastName, int phone, DateTimeOffset birthDate, string email, int apartmentNr ,int residentNr, string picture) { - return string.Format($"Name: {FirstName}, LastName: {LastName}, Birth Date: {BirthDate}, Phone {Phone}, Email {Email} "); + FirstName = firstName; + LastName = lastName; + Phone = phone; + BirthDate = birthDate; + Email = email; + ApartmentNr = apartmentNr; + ResidentNr = residentNr; + Picture = picture; } + //public override string ToString() + //{ + // return string.Format($"Name: {FirstName}, LastName: {LastName}, Birth Date: {BirthDate.Date}, Phone {Phone}, Email {Email} "); + //} } } diff --git a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs index f2a45be..998bfb3 100644 --- a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.ObjectModel; +using ApartmentManager.Model; -namespace ApartmentManager.Model +namespace ApartmentManager.Singletons { public class CatalogSingleton { @@ -18,8 +14,8 @@ namespace ApartmentManager.Model public ObservableCollection<Resident> Residents { get; set; } private CatalogSingleton() { + Residents = new ObservableCollection<Resident>(); - Residents.Add(new Resident("Donis","banana",12345,new DateTime(1990,07,26,0,0,0,0), "Donis@donis.lt",1,1)); } } } diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml new file mode 100644 index 0000000..405576c --- /dev/null +++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml @@ -0,0 +1,51 @@ +<Page + x:Class="ApartmentManager.View.ApartmentDefectPage" + 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}"> + + <Grid Background="LightGray" Height="170" Margin="0,0,0,5"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="170"/> + <ColumnDefinition /> + </Grid.ColumnDefinitions> + <Grid Grid.Column="0" Background="Gray" BorderThickness="0,0,2,0" BorderBrush="#CCFFFFFF" > + <Image Stretch="Fill"/> + </Grid> + <Grid Grid.Column="1" Margin="3,3,3,3"> + <StackPanel Margin="10"> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="First Name :" Margin="0,0,10,0" FontSize="30"></TextBlock> + <TextBlock Text="First Name :" Margin="0,0,10,0" FontSize="30"></TextBlock> + <TextBlock Text="Last Name :" Margin="0,0,10,0" FontSize="30"></TextBlock> + <TextBlock Text="Last Name :" Margin="0,0,10,0" FontSize="30"></TextBlock> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Email Address :" Margin="0,0,10,0" FontSize="25"></TextBlock> + <TextBlock Text="Last Name :" Margin="0,0,10,0" FontSize="25"></TextBlock> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Phone Number :" Margin="0,0,10,0" FontSize="25"></TextBlock> + <TextBlock Text="Last Name :" Margin="0,0,10,0" FontSize="25"></TextBlock> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Birth Date :" Margin="0,0,10,0" FontSize="25"></TextBlock> + <TextBlock Text="Last Name :" Margin="0,0,10,0" FontSize="25"></TextBlock> + </StackPanel> + + </StackPanel> + + + </Grid> + </Grid> + </Grid> +</Page> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs new file mode 100644 index 0000000..7a157ab --- /dev/null +++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectPage.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 + +namespace ApartmentManager.View +{ + /// <summary> + /// An empty page that can be used on its own or navigated to within a Frame. + /// </summary> + public sealed partial class ApartmentDefectPage : Page + { + public ApartmentDefectPage() + { + this.InitializeComponent(); + } + } +} diff --git a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml index 7997d39..0214ba7 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml @@ -14,8 +14,8 @@ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Margin="50" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="top" > - - <ListView ItemsSource="{Binding CatalogSingleton.Residents}" Margin="10,10,10,116" SelectedItem="{Binding NewResident}" > + + <ListView ItemsSource="{Binding CatalogSingleton.Residents}" Margin="10,10,10,116" SelectedItem="{Binding NewResident, Mode=TwoWay}" > <ListView.ItemContainerStyle> @@ -23,65 +23,57 @@ <Setter Property="HorizontalContentAlignment" Value="Stretch"/> </Style> </ListView.ItemContainerStyle> - + <ListView.ItemTemplate> + <DataTemplate> - <Grid Background="DodgerBlue" MinWidth="800" BorderBrush="#CCFFFFFF" BorderThickness="2" Margin="0,0,0,5"> + <Grid Background="LightGray" Height="150" Width="800" Margin="0,0,0,5"> + <Grid.ColumnDefinitions> - <ColumnDefinition Width="160"/> + <ColumnDefinition Width="150"/> <ColumnDefinition /> </Grid.ColumnDefinitions> + <Grid Grid.Column="0" Background="Gray" BorderThickness="0,0,2,0" BorderBrush="#CCFFFFFF" > - <Image Stretch="Fill"/> + <Image Stretch="Fill" Source="{Binding Picture}"/> </Grid> + <Grid Grid.Column="1" Margin="3,3,3,3"> - <Grid.RowDefinitions> - <RowDefinition /> - <RowDefinition Height="30" /> - <RowDefinition Height="92"/> - </Grid.RowDefinitions> - <Grid Margin="0,0,0,4"> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="61*"/> - <ColumnDefinition Width="23*"/> - </Grid.ColumnDefinitions> - <StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left"> - <TextBlock Text="name" FontSize="28" TextWrapping="NoWrap" TextLineBounds="Tight" Foreground="White" FontWeight="Bold" Margin="0,3,3,0" /> - <TextBlock TextLineBounds="Tight" Text="{Binding FirstName}" Foreground="White" HorizontalAlignment="Left" Margin="0,0,2,0" VerticalAlignment="Center" /> + + <StackPanel Margin="10"> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Full Name :" Margin="0,0,10,0" FontSize="30" FontWeight="Bold" ></TextBlock> + <TextBlock Text="{Binding FirstName}" Margin="0,0,10,0" FontSize="30"></TextBlock> + <TextBlock Text="{Binding LastName}" Margin="0,0,10,0" FontSize="30"></TextBlock> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Email Address :" Margin="0,0,10,0" FontSize="20" FontWeight="Bold"></TextBlock> + <TextBlock Text="{Binding Email}" Margin="0,0,10,0" FontSize="20"></TextBlock> </StackPanel> - <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right"> - <TextBlock TextLineBounds="Tight" Foreground="White" HorizontalAlignment="Right" Margin="0,0,2,0" VerticalAlignment="Center">Review score: <Run Text="review"/></TextBlock> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Phone Number :" Margin="0,0,10,0" FontSize="20" FontWeight="Bold"></TextBlock> + <TextBlock Text="{Binding Phone}" Margin="0,0,10,0" FontSize="20"></TextBlock> </StackPanel> - </Grid> - <Grid Grid.Row="1"> - <Grid.ColumnDefinitions> - <ColumnDefinition/> - <ColumnDefinition/> - </Grid.ColumnDefinitions> - <TextBlock Text="{Binding FirstName}" Foreground="White" TextLineBounds="Tight" HorizontalAlignment="Left" Margin="2,0,0,0"/> - <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" > - <TextBlock FontSize="40" Foreground="White" HorizontalAlignment="Right" Margin="0,0,2,0" TextLineBounds="Tight"><Run Text="asd"/> €</TextBlock> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Birth Date :" Margin="0,0,10,0" FontSize="20" FontWeight="Bold"></TextBlock> + <TextBlock Text="{Binding BirthDate}" Margin="0,0,10,0" FontSize="20"></TextBlock> </StackPanel> - </Grid> - <Grid Grid.Row="2"> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="134*"/> - <ColumnDefinition Width="35*"/> - </Grid.ColumnDefinitions> - <TextBlock Grid.Column="0" FontSize="16" Text="{Binding ApartmentNr}" Foreground="White" HorizontalAlignment="Left" Margin="0,3,5,0" TextWrapping="WrapWholeWords" /> - <Grid Grid.Column="1"> - - </Grid> - </Grid> + + </StackPanel> </Grid> </Grid> </DataTemplate> + </ListView.ItemTemplate> </ListView> - - + + <StackPanel Width="400" Margin="0,0,50,0"> - + <TextBlock Margin="0,10,0,10" Text="Resident Info" HorizontalAlignment="Center" FontSize="20" FontWeight="Bold"/> <TextBlock Margin="0,10,0,10" Text="Name"/> <TextBox Text="{Binding NewResident.FirstName, Mode=TwoWay}" /> @@ -93,15 +85,19 @@ <TextBox Text="{Binding NewResident.Email, Mode=TwoWay}" /> <TextBlock Margin="0,10,0,10" Text="Phone Number"/> <TextBox Text="{Binding NewResident.Phone, Mode=TwoWay}" /> - + <Button Content="Upload Picture" HorizontalAlignment="Stretch" Margin="0,10,0,0" Command="{Binding UploadResidentPhoto}" ></Button> + <StackPanel Orientation="Horizontal"> <Button Margin="0,10,12,10" Content="Create" Width="125" Command="{Binding CreateResidentCommand}"/> <Button Margin="0,10,0,10" Content="Delete" Width="125" Command="{Binding DeleteResidentCommand}"/> <Button Margin="13,10,0,10" Content="Update" Width="125" Command="{Binding UpdateResidentCommand}"/> </StackPanel> - + </StackPanel> - + + </StackPanel> + </Grid> + </Page> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml.cs index b1272bb..b90815c 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml.cs @@ -27,5 +27,10 @@ namespace ApartmentManager.View { this.InitializeComponent(); } + + private void OpenFilePicker(object sender, RoutedEventArgs e) + { + + } } } diff --git a/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs index 9d4b550..6379de0 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs @@ -10,6 +10,8 @@ using ApartmentManager.Annotations; using ApartmentManager.Common; using ApartmentManager.Handler; using ApartmentManager.Model; +using ApartmentManager.Persistency; +using ApartmentManager.Singletons; namespace ApartmentManager.ViewModel { @@ -17,7 +19,7 @@ namespace ApartmentManager.ViewModel { public CatalogSingleton CatalogSingleton { get; set; } - + public UserSingleton UserSingleton { get; set; } private User _newUser; private Resident _newResident; public static int ApartmentNumber { get; set; } @@ -26,14 +28,19 @@ namespace ApartmentManager.ViewModel public ICommand CreateResidentCommand { get; set; } public ICommand DeleteResidentCommand { get; set; } public ICommand UpdateResidentCommand { get; set; } + public ICommand UploadResidentPhoto { get; set; } public ApartmentViewModel() { NewUser = new User(); NewResident = new Resident(); + ApartmentHandler = new ApartmentHandler(this); CatalogSingleton = CatalogSingleton.Instance; + UserSingleton = UserSingleton.Instance; ApartmentNumber = UserSingleton.CurrentUser.ApartmentNr; + + UploadResidentPhoto = new RelayCommand(ApartmentHandler.UploadResidentPhoto); CreateResidentCommand = new RelayCommand(ApartmentHandler.CreateResident); DeleteResidentCommand = new RelayCommand(ApartmentHandler.DeleteResident); UpdateResidentCommand = new RelayCommand(ApartmentHandler.UpdateResident); diff --git a/ApartmentManager/HousingWebApi/DataModel.cs b/ApartmentManager/HousingWebApi/DataModel.cs index a867884..a07e1fc 100644 --- a/ApartmentManager/HousingWebApi/DataModel.cs +++ b/ApartmentManager/HousingWebApi/DataModel.cs @@ -10,6 +10,7 @@ namespace HousingWebApi public DataModel() : base("name=DataModel") { + base.Configuration.ProxyCreationEnabled = false; } public virtual DbSet<Apartment> Apartments { get; set; } |