diff options
-rw-r--r-- | ApartmentManager/ApartmentManager/ApartmentManager.csproj | 2 | ||||
-rw-r--r-- | ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs (renamed from ApartmentManager/ApartmentManager/ViewModel/ApartmenViewModel.cs) | 2 | ||||
-rw-r--r-- | ApartmentManager/HousingWebApi/Controllers/AllResidentsController.cs | 133 | ||||
-rw-r--r-- | ApartmentManager/HousingWebApi/Controllers/ApartmentResidentsController.cs | 133 | ||||
-rw-r--r-- | ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs | 15 | ||||
-rw-r--r-- | ApartmentManager/HousingWebApi/DataModel.cs | 18 | ||||
-rw-r--r-- | ApartmentManager/HousingWebApi/HousingWebApi.csproj | 4 | ||||
-rw-r--r-- | ApartmentManager/HousingWebApi/Models/AllResident.cs | 15 | ||||
-rw-r--r-- | ApartmentManager/HousingWebApi/Models/ApartmentResident.cs | 37 |
9 files changed, 12 insertions, 347 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/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; } - } -} |