diff options
author | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-10 10:35:24 +0200 |
---|---|---|
committer | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-10 10:35:24 +0200 |
commit | 45a5a28f5331b1610917ba1ba229f050a3debf6d (patch) | |
tree | ef44ca57f5f30261c517c87e7cc8c3e6ebbbd178 | |
parent | c3bc0d682f6df802e9a865302a1e5d30408d9170 (diff) |
Editing Residents listview
17 files changed, 296 insertions, 94 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj index 0bf5485..8d1bb2b 100644 --- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj +++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj @@ -102,7 +102,7 @@ <Compile Include="Controls\NavMenuListView.cs" /> <Compile Include="Handler\BoardApartmentsHandler.cs" /> <Compile Include="Handler\LoginHandler.cs" /> - <Compile Include="Handler\ResidentsHandler.cs" /> + <Compile Include="Handler\ApartmentHandler.cs" /> <Compile Include="Model\Apartment.cs" /> <Compile Include="Persistency\ImgurPhotoUploader.cs" /> <Compile Include="Singletons\ApartmentsCatalogSingleton.cs" /> @@ -119,6 +119,9 @@ <Compile Include="ViewModel\ApartmentsViewModel.cs" /> <Compile Include="ViewModel\ApartmenViewModel.cs" /> <Compile Include="ViewModel\LoginViewModel.cs" /> + <Compile Include="View\ApartmentNewDefect.xaml.cs"> + <DependentUpon>ApartmentNewDefect.xaml</DependentUpon> + </Compile> <Compile Include="View\ApartmentPage.xaml.cs"> <DependentUpon>ApartmentPage.xaml</DependentUpon> </Compile> @@ -179,6 +182,10 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="View\ApartmentNewDefect.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="View\ApartmentPage.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> diff --git a/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs index d406880..7c27686 100644 --- a/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs @@ -12,11 +12,11 @@ using Newtonsoft.Json; namespace ApartmentManager.Handler { - public class ResidentsHandler + public class ApartmentHandler { public ApartmentViewModel ApartmentViewModel { get; set; } - public ResidentsHandler(ApartmentViewModel apartmenViewModel) + public ApartmentHandler(ApartmentViewModel apartmenViewModel) { ApartmentViewModel = apartmenViewModel; } @@ -36,6 +36,15 @@ namespace ApartmentManager.Handler } } + public void GetApartment() + { + string serializedApartment = ApiClient.GetData("api/Apartments/" + ApartmentViewModel.ApartmentNumber); + + Apartment apartment= JsonConvert.DeserializeObject<Apartment>(serializedApartment); + ApartmentViewModel.CatalogSingleton.Apartment = apartment; + + + } public void CreateResident() { diff --git a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs index 3a4c706..f2a45be 100644 --- a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs @@ -13,17 +13,13 @@ namespace ApartmentManager.Model public static CatalogSingleton Instance => instance; - public ObservableCollection<User> User { get; set; } - public ObservableCollection<Apartment> Apartment { get; set; } + + public Apartment Apartment { get; set; } public ObservableCollection<Resident> Residents { get; set; } private CatalogSingleton() - { - User = new ObservableCollection<User>(); - User.Add(new User("Bibis", "Kiausiai", "3214568", new DateTime(2017, 1, 5, 2, 27, 0), "Bibis@mail.com", 1)); - Apartment = new ObservableCollection<Apartment>(); - Apartment.Add(new Apartment(1,"30 Square meters",2,"200",0,"adresas")); - 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/Singletons/UserSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs index aa09cf2..24150c9 100644 --- a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace ApartmentManager.Model { - class UserSingleton + public class UserSingleton { private static UserSingleton instance; public static User CurrentUser; diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml new file mode 100644 index 0000000..b67aad6 --- /dev/null +++ b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml @@ -0,0 +1,48 @@ +<Page + x:Class="ApartmentManager.View.ApartmentNewDefect" + 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 Orientation="Vertical" HorizontalAlignment="Center"> + + <TextBlock Margin="0,10,0,10" Text="Defect Information" HorizontalAlignment="Center" FontSize="20" FontWeight="Bold"/> + + <StackPanel Orientation="Horizontal"> + <StackPanel Margin="0,5,30,0"> + + <StackPanel Orientation="Horizontal" > + <Image Height="200" Width="355" ></Image> + <Button Content="Upload Picture" Margin="30,0,0,0"></Button> + </StackPanel> + + <StackPanel Orientation="Horizontal" Margin="0,30,0,0"> + <Image Height="200" Width="355" ></Image> + <Button Content="Upload Picture" Margin="30,0,0,0"></Button> + </StackPanel> + + <StackPanel Orientation="Horizontal" Margin="0,30,0,0"> + <Image Height="200" Width="355" ></Image> + <Button Content="Upload Picture" Margin="30,0,0,0"></Button> + </StackPanel> + + </StackPanel> + + <StackPanel Width="400" Margin="0,0,50,0"> + <TextBlock Margin="0,10,0,10" Text="Name"/> + <TextBox Text="sa" /> + <TextBlock Margin="0,10,0,10" Text="Description"/> + <TextBox Text="j" Height="140" /> + <TextBlock Margin="0,10,0,10" Text="Comment"/> + <TextBox Text="asd" Height="300" /> + <Button Margin="0,20,0,0" Content="Create" HorizontalAlignment="Stretch"/> + </StackPanel> + + </StackPanel> + </StackPanel> + </Grid> +</Page> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.xaml.cs new file mode 100644 index 0000000..5e18b42 --- /dev/null +++ b/ApartmentManager/ApartmentManager/View/ApartmentNewDefect.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 ApartmentNewDefect : Page + { + public ApartmentNewDefect() + { + this.InitializeComponent(); + } + } +} diff --git a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml index 385e580..ac8aa40 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml @@ -13,42 +13,61 @@ </Page.DataContext> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> - <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Width="1000" Margin="50" > - <StackPanel Width="600" Height="300" VerticalAlignment="Top"> - <StackPanel Orientation="Horizontal"> - <TextBlock Text="Apartment Address :" FontSize="20" Margin="0,0,10,0" /> - <TextBlock Text="{Binding CatalogSingleton.Apartment[0].Address}" FontSize="20"/> - </StackPanel> - <StackPanel Orientation="Horizontal"> - <TextBlock Text="Floor :" FontSize="20" Margin="0,0,10,0" /> - <TextBlock Text="{Binding CatalogSingleton.Apartment[0].Floor}" FontSize="20"/> - </StackPanel> - <StackPanel Orientation="Horizontal"> - <TextBlock Text="Apartment Number :" FontSize="20" Margin="0,0,10,0"/> - <TextBlock Text="{Binding CatalogSingleton.Apartment[0].ApartmentNumber}" FontSize="20"/> - </StackPanel> - <StackPanel Orientation="Horizontal"> - <TextBlock Text="Size :" FontSize="20" Margin="0,0,10,0"/> - <TextBlock Text="{Binding CatalogSingleton.Apartment[0].Size}" FontSize="20" Margin="0,0,10,0"/> - <TextBlock Text="m2" FontSize="20"/> - </StackPanel> - <StackPanel Orientation="Horizontal"> - <TextBlock Text="Number of Rooms :" FontSize="20" Margin="0,0,10,0"/> - <TextBlock Text="{Binding CatalogSingleton.Apartment[0].NumberOfRooms}" FontSize="20"/> + <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="50" > + + <StackPanel VerticalAlignment="Top" Margin="50,0,20,0"> + <Image Source="ms-appx:///Assets/plan.jpg" ></Image> + </StackPanel> + + <StackPanel> + + <StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Apartment Address :" FontSize="20" Margin="0,0,10,0" /> + <TextBlock Text="{Binding CatalogSingleton.Apartment.Address}" FontSize="20"/> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Floor :" FontSize="20" Margin="0,0,10,0" /> + <TextBlock Text="{Binding CatalogSingleton.Apartment.Floor}" FontSize="20"/> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Apartment Number :" FontSize="20" Margin="0,0,10,0"/> + <TextBlock Text="{Binding CatalogSingleton.Apartment.ApartmentNumber}" FontSize="20"/> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Size :" FontSize="20" Margin="0,0,10,0"/> + <TextBlock Text="{Binding CatalogSingleton.Apartment.Size}" FontSize="20" Margin="0,0,10,0"/> + <TextBlock Text="m2" FontSize="20"/> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Number of Rooms :" FontSize="20" Margin="0,0,10,0"/> + <TextBlock Text="{Binding CatalogSingleton.Apartment.NumberOfRooms}" FontSize="20"/> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Monthly Charge:" FontSize="20" Margin="0,0,10,0"/> + <TextBlock Text="{Binding CatalogSingleton.Apartment.MonthlyCharge}" FontSize="20" Margin="0,0,10,0"/> + <TextBlock Text="DKK" FontSize="20"/> + </StackPanel> + </StackPanel> - <StackPanel Orientation="Horizontal"> - <TextBlock Text="Monthly Charge:" FontSize="20" Margin="0,0,10,0"/> - <TextBlock Text="{Binding CatalogSingleton.Apartment[0].MonthlyCharge}" FontSize="20" Margin="0,0,10,0"/> - <TextBlock Text="DKK" FontSize="20"/> + + <StackPanel Margin="0,20,0,0" Width="250" VerticalAlignment="Top" HorizontalAlignment="Left"> + <Button Margin="0,10,0,10" Content="Apartment Plan" HorizontalAlignment="Stretch" Click="click"/> + <Button Margin="0,10,0,10" Content="Personal Info" HorizontalAlignment="Stretch" Click="GotoPernalInfoPage"/> + <Button Margin="0,10,0,10" Content="Residents" HorizontalAlignment="Stretch" Click="ResidentPage"/> + <Button Margin="0,10,0,10" Content="Apartment Changes" HorizontalAlignment="Stretch"/> + <Button Margin="0,10,0,10" Content="Apartment Defects" HorizontalAlignment="Stretch"/> </StackPanel> + </StackPanel> - <StackPanel Width="400" Height="300" VerticalAlignment="Top" HorizontalAlignment="Right"> - <Button Margin="0,10,0,10" Content="Apartment Plan" HorizontalAlignment="Stretch" Click="click"/> - <Button Margin="0,10,0,10" Content="Personal Info" HorizontalAlignment="Stretch" Click="GotoPernalInfoPage"/> - <Button Margin="0,10,0,10" Content="Residents" HorizontalAlignment="Stretch" Click="ResidentPage"/> - <Button Margin="0,10,0,10" Content="Apartment Changes" HorizontalAlignment="Stretch"/> - <Button Margin="0,10,0,10" Content="Apartment Defects" HorizontalAlignment="Stretch"/> - </StackPanel> + </StackPanel> + </Grid> </Page> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml index 348ba30..7997d39 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml @@ -14,8 +14,74 @@ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Margin="50" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="top" > - <ListView HorizontalAlignment="Left" Margin="0,50,50,0" VerticalAlignment="Top" ItemsSource="{Binding CatalogSingleton.Residents}" SelectedItem="{Binding NewResident, Mode=TwoWay}"/> + + <ListView ItemsSource="{Binding CatalogSingleton.Residents}" Margin="10,10,10,116" SelectedItem="{Binding NewResident}" > + + + <ListView.ItemContainerStyle> + <Style TargetType="ListViewItem"> + <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.ColumnDefinitions> + <ColumnDefinition Width="160"/> + <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"> + <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> + <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> + </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> + </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> + </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}" /> @@ -27,12 +93,15 @@ <TextBox Text="{Binding NewResident.Email, Mode=TwoWay}" /> <TextBlock Margin="0,10,0,10" Text="Phone Number"/> <TextBox Text="{Binding NewResident.Phone, Mode=TwoWay}" /> + <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 0df2861..b1272bb 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.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 @@ -24,7 +25,7 @@ namespace ApartmentManager.View { public ApartmentResidentsPage() { - this.InitializeComponent(); + this.InitializeComponent(); } } } diff --git a/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs index 3d76120..9d4b550 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs @@ -17,10 +17,11 @@ namespace ApartmentManager.ViewModel { public CatalogSingleton CatalogSingleton { get; set; } + private User _newUser; private Resident _newResident; public static int ApartmentNumber { get; set; } - public Handler.ResidentsHandler ResidentsHandler { get; set; } + public ApartmentHandler ApartmentHandler { get; set; } public ICommand CreateResidentCommand { get; set; } public ICommand DeleteResidentCommand { get; set; } @@ -30,13 +31,16 @@ namespace ApartmentManager.ViewModel { NewUser = new User(); NewResident = new Resident(); - ResidentsHandler = new Handler.ResidentsHandler(this); + ApartmentHandler = new ApartmentHandler(this); CatalogSingleton = CatalogSingleton.Instance; - ApartmentNumber = CatalogSingleton.User[0].ApartmentNr; - CreateResidentCommand = new RelayCommand(ResidentsHandler.CreateResident); - DeleteResidentCommand = new RelayCommand(ResidentsHandler.DeleteResident); - UpdateResidentCommand = new RelayCommand(ResidentsHandler.UpdateResident); - ResidentsHandler.GetApartmentResidents(); + ApartmentNumber = UserSingleton.CurrentUser.ApartmentNr; + CreateResidentCommand = new RelayCommand(ApartmentHandler.CreateResident); + DeleteResidentCommand = new RelayCommand(ApartmentHandler.DeleteResident); + UpdateResidentCommand = new RelayCommand(ApartmentHandler.UpdateResident); + ApartmentHandler.GetApartmentResidents(); + ApartmentHandler.GetApartment(); + + } public User NewUser diff --git a/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs index f100211..65e796a 100644 --- a/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs @@ -36,25 +36,25 @@ namespace HousingWebApi.Controllers } // GET: api/Residents/1 - [Route("api/ApartmentResidents/{id}")] - [ResponseType(typeof(ResidentList))] - public IQueryable<ResidentList> GetResidents(int id) - { - var roomlist = from resident in db.Residents - where (resident.ApartmentNr == id) - select new ResidentList - { - ResidentNr = resident.ResidentNr, - ApartmentNr = resident.ApartmentNr, - FirstName = resident.FirstName, - LastName = resident.LastName, - BirthDate = resident.BirthDate, - Phone = resident.Phone, - Email = resident.Email, - Picture = resident.Picture - }; - return roomlist; - } + //[Route("api/ApartmentResidents/{id}")] + //[ResponseType(typeof(ResidentList))] + //public IQueryable<ResidentList> GetResidents(int id) + //{ + // var roomlist = from resident in db.Residents + // where (resident.ApartmentNr == id) + // select new ResidentList + // { + // ResidentNr = resident.ResidentNr, + // ApartmentNr = resident.ApartmentNr, + // FirstName = resident.FirstName, + // LastName = resident.LastName, + // BirthDate = resident.BirthDate, + // Phone = resident.Phone, + // Email = resident.Email, + // Picture = resident.Picture + // }; + // return roomlist; + //} // PUT: api/Residents/5 [ResponseType(typeof(void))] diff --git a/ApartmentManager/HousingWebApi/DataModel.cs b/ApartmentManager/HousingWebApi/DataModel.cs index 6fe5c68..a867884 100644 --- a/ApartmentManager/HousingWebApi/DataModel.cs +++ b/ApartmentManager/HousingWebApi/DataModel.cs @@ -10,7 +10,6 @@ namespace HousingWebApi public DataModel() : base("name=DataModel") { - base.Configuration.ProxyCreationEnabled = false; } public virtual DbSet<Apartment> Apartments { get; set; } @@ -27,11 +26,15 @@ namespace HousingWebApi modelBuilder.Entity<Apartment>() .Property(e => e.MonthlyCharge) - .IsFixedLength(); + .IsUnicode(false); modelBuilder.Entity<Apartment>() .Property(e => e.Address) - .IsFixedLength(); + .IsUnicode(false); + + modelBuilder.Entity<Apartment>() + .Property(e => e.PlanPicture) + .IsUnicode(false); modelBuilder.Entity<Apartment>() .HasMany(e => e.Defects) @@ -51,7 +54,19 @@ namespace HousingWebApi modelBuilder.Entity<Defect>() .Property(e => e.Name) - .IsFixedLength(); + .IsUnicode(false); + + modelBuilder.Entity<Defect>() + .Property(e => e.Picture) + .IsUnicode(false); + + modelBuilder.Entity<Defect>() + .Property(e => e.Picture2) + .IsUnicode(false); + + modelBuilder.Entity<Defect>() + .Property(e => e.Picture3) + .IsUnicode(false); modelBuilder.Entity<Defect>() .Property(e => e.Description) @@ -63,7 +78,7 @@ namespace HousingWebApi modelBuilder.Entity<Defect>() .Property(e => e.Status) - .IsFixedLength(); + .IsUnicode(false); modelBuilder.Entity<PastContractOwner>() .Property(e => e.ApartmentNr) @@ -81,6 +96,10 @@ namespace HousingWebApi .Property(e => e.Email) .IsUnicode(false); + modelBuilder.Entity<Resident>() + .Property(e => e.Picture) + .IsUnicode(false); + modelBuilder.Entity<User>() .Property(e => e.Username) .IsUnicode(false); diff --git a/ApartmentManager/HousingWebApi/HousingWebAPI.csproj b/ApartmentManager/HousingWebApi/HousingWebAPI.csproj index 63d4995..97c15b8 100644 --- a/ApartmentManager/HousingWebApi/HousingWebAPI.csproj +++ b/ApartmentManager/HousingWebApi/HousingWebAPI.csproj @@ -152,6 +152,8 @@ </ItemGroup> <ItemGroup> <Compile Include="Models\Apartment.cs" /> + <Compile Include="DataModel.cs" /> + <Compile Include="Models\Defect.cs" /> <Compile Include="Controllers\ApartmentsController.cs" /> <Compile Include="Controllers\DefectsController.cs" /> <Compile Include="Controllers\PastContractOwnersController.cs" /> @@ -190,15 +192,12 @@ <Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" /> <Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" /> <Compile Include="Controllers\HomeController.cs" /> - <Compile Include="DataModel.cs" /> - <Compile Include="Models\Defect.cs" /> <Compile Include="Global.asax.cs"> <DependentUpon>Global.asax</DependentUpon> </Compile> <Compile Include="Models\PastContractOwner.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Models\Resident.cs" /> - <Compile Include="Models\ResidentList.cs" /> <Compile Include="Models\User.cs" /> </ItemGroup> <ItemGroup> diff --git a/ApartmentManager/HousingWebApi/Models/Apartment.cs b/ApartmentManager/HousingWebApi/Models/Apartment.cs index 16d884d..7481344 100644 --- a/ApartmentManager/HousingWebApi/Models/Apartment.cs +++ b/ApartmentManager/HousingWebApi/Models/Apartment.cs @@ -31,6 +31,9 @@ namespace HousingWebApi [StringLength(50)] public string Address { get; set; } + [StringLength(200)] + public string PlanPicture { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection<Defect> Defects { get; set; } diff --git a/ApartmentManager/HousingWebApi/Models/Defect.cs b/ApartmentManager/HousingWebApi/Models/Defect.cs index 4336393..b439078 100644 --- a/ApartmentManager/HousingWebApi/Models/Defect.cs +++ b/ApartmentManager/HousingWebApi/Models/Defect.cs @@ -21,15 +21,15 @@ namespace HousingWebApi [Column(TypeName = "date")] public DateTime DateUploaded { get; set; } - [Column(TypeName = "image")] [Required] - public byte[] Picture { get; set; } + [StringLength(200)] + public string Picture { get; set; } - [Column(TypeName = "image")] - public byte[] Picture2 { get; set; } + [StringLength(200)] + public string Picture2 { get; set; } - [Column(TypeName = "image")] - public byte[] Picture3 { get; set; } + [StringLength(200)] + public string Picture3 { get; set; } [Column(TypeName = "text")] [Required] diff --git a/ApartmentManager/HousingWebApi/Models/Resident.cs b/ApartmentManager/HousingWebApi/Models/Resident.cs index a34cf80..319a697 100644 --- a/ApartmentManager/HousingWebApi/Models/Resident.cs +++ b/ApartmentManager/HousingWebApi/Models/Resident.cs @@ -29,8 +29,8 @@ namespace HousingWebApi [StringLength(30)] public string Email { get; set; } - [Column(TypeName = "image")] - public byte[] Picture { get; set; } + [StringLength(220)] + public string Picture { get; set; } public virtual Apartment Apartment { get; set; } } diff --git a/ApartmentManager/HousingWebApi/Web.config b/ApartmentManager/HousingWebApi/Web.config index 8ea32e7..8261278 100644 --- a/ApartmentManager/HousingWebApi/Web.config +++ b/ApartmentManager/HousingWebApi/Web.config @@ -79,7 +79,5 @@ <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> </providers> </entityFramework> - <connectionStrings> - - <add name="DataModel" connectionString="data source=housingdb.database.windows.net;initial catalog=housingdb;persist security info=True;user id=deltaadmin;password=Delta123!;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.SqlClient" /></connectionStrings> -</configuration>
\ No newline at end of file + +<connectionStrings><add name="DataModel" connectionString="data source=housingdb.database.windows.net;initial catalog=housingdb;persist security info=True;user id=deltaadmin;password=Delta123!;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.SqlClient" /></connectionStrings></configuration>
\ No newline at end of file |