diff options
13 files changed, 78 insertions, 376 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj index 373b8f7..f267a50 100644 --- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj +++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj @@ -118,7 +118,7 @@ <Compile Include="Properties\Annotations.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="ViewModel\BoardMemberViewModel.cs" /> - <Compile Include="ViewModel\ApartmenViewModel.cs" /> + <Compile Include="ViewModel\ApartmentViewModel.cs" /> <Compile Include="ViewModel\LoginViewModel.cs" /> <Compile Include="View\ApartmentDefectPage.xaml.cs"> <DependentUpon>ApartmentDefectPage.xaml</DependentUpon> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml index acf1cbc..6a3f6c1 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentPage.xaml @@ -35,7 +35,7 @@ <StackPanel Orientation="Horizontal"> <TextBlock Text="Apartment Number :" FontSize="20" Margin="0,0,10,0" FontWeight="Bold"/> - <TextBlock Text="{Binding CatalogSingleton.Apartment.ApartmentNumber}" FontSize="20"/> + <TextBlock Text="{Binding CatalogSingleton.Apartment.ApartmentId}" FontSize="20"/> </StackPanel> <StackPanel Orientation="Horizontal"> diff --git a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml index ff394b3..ea4711e 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentResidentsPage.xaml @@ -14,10 +14,53 @@ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Margin="10" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="top" > + <StackPanel> + <Grid Background="LightGray" Height="150" Width="800" Margin="0,0,0,5"> + + <Grid.ColumnDefinitions> + <ColumnDefinition Width="150"/> + <ColumnDefinition /> + </Grid.ColumnDefinitions> + + <Grid Grid.Column="0" Background="Gray" BorderThickness="0,0,2,0" BorderBrush="#CCFFFFFF" > + <Image Stretch="Fill" Source="{Binding Picture}"/> + </Grid> + + <Grid Grid.Column="1" Margin="3,3,3,3"> + + <StackPanel Margin="10"> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Full Name :" Margin="0,0,10,0" FontSize="30" FontWeight="Bold" ></TextBlock> + <TextBlock Text="{Binding UserSingleton.CurrentUser.FirstName}" Margin="0,0,10,0" FontSize="30"></TextBlock> + <TextBlock Text="{Binding UserSingleton.CurrentUser.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 UserSingleton.CurrentUser.Email}" Margin="0,0,10,0" FontSize="20"></TextBlock> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Phone Number :" Margin="0,0,10,0" FontSize="20" FontWeight="Bold"></TextBlock> + <TextBlock Text="{Binding UserSingleton.CurrentUser.Phone}" Margin="0,0,10,0" FontSize="20"></TextBlock> + </StackPanel> + + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Birth Date :" Margin="0,0,10,0" FontSize="20" FontWeight="Bold"></TextBlock> + <TextBlock Text="{Binding UserSingleton.CurrentUser.BirthDate}" FontSize="20"></TextBlock> + <TextBlock Text="-" FontSize="20"></TextBlock> + <TextBlock Text="{Binding BirthDate.Month}" FontSize="20"></TextBlock> + <TextBlock Text="-" FontSize="20"></TextBlock> + <TextBlock Text="{Binding BirthDate.Day}" FontSize="20"></TextBlock> + </StackPanel> + + </StackPanel> + </Grid> + </Grid> <ListView ItemsSource="{Binding CatalogSingleton.Residents}" Margin="10,10,10,116" SelectedItem="{Binding NewResident, Mode=TwoWay}" > - <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch"/> @@ -74,7 +117,7 @@ </ListView.ItemTemplate> </ListView> - + </StackPanel> <StackPanel Width="400" Margin="0,0,50,0"> diff --git a/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs b/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs index e247306..aa5f0c3 100644 --- a/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs @@ -14,6 +14,7 @@ using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; using ApartmentManager.Model; +using ApartmentManager.Singletons; // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 diff --git a/ApartmentManager/ApartmentManager/View/PersonalInfoPage.xaml b/ApartmentManager/ApartmentManager/View/PersonalInfoPage.xaml index 0886372..b7952a3 100644 --- a/ApartmentManager/ApartmentManager/View/PersonalInfoPage.xaml +++ b/ApartmentManager/ApartmentManager/View/PersonalInfoPage.xaml @@ -13,34 +13,27 @@ </Page.DataContext> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> - <StackPanel Margin="50" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top"> + <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"/> - <TextBlock Margin="0,10,0,10" Text="Name"/> - <TextBox Text="{Binding CatalogSingleton.User[0].Name, Mode=TwoWay}" /> - <TextBlock Margin="0,10,0,10" Text="Last Name"/> - <TextBox Text="{Binding CatalogSingleton.User[0].LastName, Mode=TwoWay}" /> - <TextBlock Margin="0,10,0,10" Text="Birthdate"/> - <DatePicker HorizontalAlignment="Stretch" Date="{Binding CatalogSingleton.User[0].BirthDate}"/> - <TextBlock Margin="0,10,0,10" Text="Email Address"/> - <TextBox Text="{Binding CatalogSingleton.User[0].Email, Mode=TwoWay}" /> - <TextBlock Margin="0,10,0,10" Text="Phone Number"/> - <TextBox Text="{Binding CatalogSingleton.User[0].Phone, Mode=TwoWay}" /> - <Button Margin="0,10,0,10" Content="Update" HorizontalAlignment="Stretch"/> - </StackPanel> - <StackPanel Width="400"> - <TextBlock Margin="0,10,0,10" Text="Second Contract Owner" HorizontalAlignment="Center" FontSize="20" FontWeight="Bold"/> - <TextBlock Margin="0,10,0,10" Text="Name"/> - <TextBox Text="{Binding CatalogSingleton.User[0].SecondName, Mode=TwoWay}" /> - <TextBlock Margin="0,10,0,10" Text="Last Name"/> - <TextBox Text="{Binding CatalogSingleton.User[0].SecondLastName, Mode=TwoWay}" /> - <TextBlock Margin="0,10,0,10" Text="Birthdate"/> - <DatePicker HorizontalAlignment="Stretch" Date="{Binding CatalogSingleton.User[0].SecondBirthDate}"/> - <TextBlock Margin="0,10,0,10" Text="Email Address"/> - <TextBox Text="{Binding CatalogSingleton.User[0].SecondEmail, Mode=TwoWay}" /> - <TextBlock Margin="0,10,0,10" Text="Phone Number"/> - <TextBox Text="{Binding CatalogSingleton.User[0].SecondPhone, Mode=TwoWay}" /> - <Button Margin="0,10,0,10" Content="Update" HorizontalAlignment="Stretch"/> + + <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> + + <TextBlock Margin="0,5,0,5" Text="Name"/> + <TextBox Text="{Binding UserSingleton.CurrentUser.FirstName, Mode=TwoWay}" /> + <TextBlock Margin="0,5,0,5" Text="Last Name"/> + <TextBox Text="{Binding UserSingleton.CurrentUser.LastName, Mode=TwoWay}" /> + <TextBlock Margin="0,5,0,5" Text="Birthdate"/> + <DatePicker HorizontalAlignment="Stretch" Date="{Binding UserSingleton.CurrentUser.BirthDate, Mode=TwoWay}"/> + <TextBlock Margin="0,5,0,5" Text="Email Address"/> + <TextBox Text="{Binding UserSingleton.CurrentUser.Email, Mode=TwoWay}" /> + <TextBlock Margin="0,5,0,5" Text="Phone Number"/> + <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"/> + </StackPanel> </StackPanel> </Grid> diff --git a/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs index eceed48..2e2e0ea 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs @@ -41,7 +41,7 @@ namespace ApartmentManager.ViewModel ApartmentHandler = new ApartmentHandler(this); CatalogSingleton = CatalogSingleton.Instance; UserSingleton = UserSingleton.Instance; - //ApartmentNumber = UserSingleton.CurrentUser.ApartmentNr; + ApartmentNumber = UserSingleton.CurrentUser.ApartmentId; UploadResidentPhoto = new RelayCommand(ApartmentHandler.UploadResidentPhoto); CreateResidentCommand = new RelayCommand(ApartmentHandler.CreateResident); diff --git a/ApartmentManager/HousingWebApi/Controllers/AllResidentsController.cs b/ApartmentManager/HousingWebApi/Controllers/AllResidentsController.cs deleted file mode 100644 index 046a385..0000000 --- a/ApartmentManager/HousingWebApi/Controllers/AllResidentsController.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Entity; -using System.Data.Entity.Infrastructure; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Web.Http; -using System.Web.Http.Description; -using HousingWebApi; - -namespace HousingWebApi.Controllers -{ - public class AllResidentsController : ApiController - { - private DataModel db = new DataModel(); - - // GET: api/AllResidents - public IQueryable<AllResident> GetAllResidents() - { - return db.AllResidents; - } - - // GET: api/AllResidents/5 - [ResponseType(typeof(AllResident))] - public IHttpActionResult GetAllResident(string id) - { - AllResident allResident = db.AllResidents.Find(id); - if (allResident == null) - { - return NotFound(); - } - - return Ok(allResident); - } - - // PUT: api/AllResidents/5 - [ResponseType(typeof(void))] - public IHttpActionResult PutAllResident(string id, AllResident allResident) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - if (id != allResident.FirstName) - { - return BadRequest(); - } - - db.Entry(allResident).State = EntityState.Modified; - - try - { - db.SaveChanges(); - } - catch (DbUpdateConcurrencyException) - { - if (!AllResidentExists(id)) - { - return NotFound(); - } - else - { - throw; - } - } - - return StatusCode(HttpStatusCode.NoContent); - } - - // POST: api/AllResidents - [ResponseType(typeof(AllResident))] - public IHttpActionResult PostAllResident(AllResident allResident) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - db.AllResidents.Add(allResident); - - try - { - db.SaveChanges(); - } - catch (DbUpdateException) - { - if (AllResidentExists(allResident.FirstName)) - { - return Conflict(); - } - else - { - throw; - } - } - - return CreatedAtRoute("DefaultApi", new { id = allResident.FirstName }, allResident); - } - - // DELETE: api/AllResidents/5 - [ResponseType(typeof(AllResident))] - public IHttpActionResult DeleteAllResident(string id) - { - AllResident allResident = db.AllResidents.Find(id); - if (allResident == null) - { - return NotFound(); - } - - db.AllResidents.Remove(allResident); - db.SaveChanges(); - - return Ok(allResident); - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - db.Dispose(); - } - base.Dispose(disposing); - } - - private bool AllResidentExists(string id) - { - return db.AllResidents.Count(e => e.FirstName == id) > 0; - } - } -}
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/ApartmentResidentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ApartmentResidentsController.cs deleted file mode 100644 index a754255..0000000 --- a/ApartmentManager/HousingWebApi/Controllers/ApartmentResidentsController.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Entity; -using System.Data.Entity.Infrastructure; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Web.Http; -using System.Web.Http.Description; -using HousingWebApi; - -namespace HousingWebApi.Controllers -{ - public class ApartmentResidentsController : ApiController - { - private DataModel db = new DataModel(); - - // GET: api/ApartmentResidents - public IQueryable<ApartmentResident> GetApartmentResidents() - { - return db.ApartmentResidents; - } - - // GET: api/ApartmentResidents/5 - [ResponseType(typeof(ApartmentResident))] - public IHttpActionResult GetApartmentResident(int id) - { - ApartmentResident apartmentResident = db.ApartmentResidents.Find(id); - if (apartmentResident == null) - { - return NotFound(); - } - - return Ok(apartmentResident); - } - - // PUT: api/ApartmentResidents/5 - [ResponseType(typeof(void))] - public IHttpActionResult PutApartmentResident(int id, ApartmentResident apartmentResident) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - if (id != apartmentResident.ApartmentNumber) - { - return BadRequest(); - } - - db.Entry(apartmentResident).State = EntityState.Modified; - - try - { - db.SaveChanges(); - } - catch (DbUpdateConcurrencyException) - { - if (!ApartmentResidentExists(id)) - { - return NotFound(); - } - else - { - throw; - } - } - - return StatusCode(HttpStatusCode.NoContent); - } - - // POST: api/ApartmentResidents - [ResponseType(typeof(ApartmentResident))] - public IHttpActionResult PostApartmentResident(ApartmentResident apartmentResident) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - db.ApartmentResidents.Add(apartmentResident); - - try - { - db.SaveChanges(); - } - catch (DbUpdateException) - { - if (ApartmentResidentExists(apartmentResident.ApartmentNumber)) - { - return Conflict(); - } - else - { - throw; - } - } - - return CreatedAtRoute("DefaultApi", new { id = apartmentResident.ApartmentNumber }, apartmentResident); - } - - // DELETE: api/ApartmentResidents/5 - [ResponseType(typeof(ApartmentResident))] - public IHttpActionResult DeleteApartmentResident(int id) - { - ApartmentResident apartmentResident = db.ApartmentResidents.Find(id); - if (apartmentResident == null) - { - return NotFound(); - } - - db.ApartmentResidents.Remove(apartmentResident); - db.SaveChanges(); - - return Ok(apartmentResident); - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - db.Dispose(); - } - base.Dispose(disposing); - } - - private bool ApartmentResidentExists(int id) - { - return db.ApartmentResidents.Count(e => e.ApartmentNumber == id) > 0; - } - } -}
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs index ebb0188..80d5741 100644 --- a/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Data; +using System.Data; using System.Data.Entity; using System.Data.Entity.Infrastructure; using System.Linq; using System.Net; -using System.Net.Http; using System.Web.Http; using System.Web.Http.Description; -using HousingWebApi; namespace HousingWebApi.Controllers { @@ -16,6 +12,15 @@ namespace HousingWebApi.Controllers { private DataModel db = new DataModel(); + [Route("api/ApartmentResidents/{id}")] + public IQueryable<Resident> GetResidents(int id) + { + var roomlist = from resident in db.Residents + where (resident.ApartmentId == id) + select resident; + return roomlist; + } + // GET: api/Residents public IQueryable<Resident> GetResidents() { diff --git a/ApartmentManager/HousingWebApi/DataModel.cs b/ApartmentManager/HousingWebApi/DataModel.cs index 0b953a6..00f4811 100644 --- a/ApartmentManager/HousingWebApi/DataModel.cs +++ b/ApartmentManager/HousingWebApi/DataModel.cs @@ -23,8 +23,6 @@ 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<AllResident> AllResidents { get; set; } - public virtual DbSet<ApartmentResident> ApartmentResidents { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { @@ -172,22 +170,6 @@ namespace HousingWebApi modelBuilder.Entity<User>() .Property(e => e.Email) .IsUnicode(false); - - modelBuilder.Entity<AllResident>() - .Property(e => e.FirstName) - .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.Email) - .IsUnicode(false); } } } diff --git a/ApartmentManager/HousingWebApi/HousingWebApi.csproj b/ApartmentManager/HousingWebApi/HousingWebApi.csproj index 18a8c73..117dc9d 100644 --- a/ApartmentManager/HousingWebApi/HousingWebApi.csproj +++ b/ApartmentManager/HousingWebApi/HousingWebApi.csproj @@ -151,12 +151,8 @@ </Reference>
</ItemGroup>
<ItemGroup>
- <Compile Include="Controllers\AllResidentsController.cs" />
- <Compile Include="Controllers\ApartmentResidentsController.cs" />
- <Compile Include="Models\AllResident.cs" />
<Compile Include="Models\Apartment.cs" />
<Compile Include="Models\ApartmentChange.cs" />
- <Compile Include="Models\ApartmentResident.cs" />
<Compile Include="Models\ChangeComment.cs" />
<Compile Include="Models\ChangeDocument.cs" />
<Compile Include="App_Start\BundleConfig.cs" />
diff --git a/ApartmentManager/HousingWebApi/Models/AllResident.cs b/ApartmentManager/HousingWebApi/Models/AllResident.cs deleted file mode 100644 index 655ee84..0000000 --- a/ApartmentManager/HousingWebApi/Models/AllResident.cs +++ /dev/null @@ -1,15 +0,0 @@ -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 AllResident - { - [Key] - [StringLength(20)] - public string FirstName { get; set; } - } -} diff --git a/ApartmentManager/HousingWebApi/Models/ApartmentResident.cs b/ApartmentManager/HousingWebApi/Models/ApartmentResident.cs deleted file mode 100644 index 092c95f..0000000 --- a/ApartmentManager/HousingWebApi/Models/ApartmentResident.cs +++ /dev/null @@ -1,37 +0,0 @@ -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] - [Column(Order = 0)] - [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int ApartmentNumber { get; set; } - - [Key] - [Column(Order = 1)] - [StringLength(20)] - public string FirstName { get; set; } - - [Key] - [Column(Order = 2)] - [StringLength(20)] - public string LastName { get; set; } - - [Column(TypeName = "date")] - public DateTime? BirthDate { get; set; } - - public int? PhoneNo { get; set; } - - [StringLength(30)] - public string Email { get; set; } - - [Column(TypeName = "image")] - public byte[] Picture { get; set; } - } -} |