diff options
27 files changed, 1310 insertions, 286 deletions
diff --git a/ApartmentManager/HousingWebApi/Controllers/AllResidentsController.cs b/ApartmentManager/HousingWebApi/Controllers/AllResidentsController.cs new file mode 100644 index 0000000..046a385 --- /dev/null +++ b/ApartmentManager/HousingWebApi/Controllers/AllResidentsController.cs @@ -0,0 +1,133 @@ +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/ApartmentChangesController.cs b/ApartmentManager/HousingWebApi/Controllers/ApartmentChangesController.cs new file mode 100644 index 0000000..f96385a --- /dev/null +++ b/ApartmentManager/HousingWebApi/Controllers/ApartmentChangesController.cs @@ -0,0 +1,133 @@ +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 ApartmentChangesController : ApiController + { + private DataModel db = new DataModel(); + + // GET: api/ApartmentChanges + public IQueryable<ApartmentChange> GetApartmentChanges() + { + return db.ApartmentChanges; + } + + // GET: api/ApartmentChanges/5 + [ResponseType(typeof(ApartmentChange))] + public IHttpActionResult GetApartmentChange(int id) + { + ApartmentChange apartmentChange = db.ApartmentChanges.Find(id); + if (apartmentChange == null) + { + return NotFound(); + } + + return Ok(apartmentChange); + } + + // PUT: api/ApartmentChanges/5 + [ResponseType(typeof(void))] + public IHttpActionResult PutApartmentChange(int id, ApartmentChange apartmentChange) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != apartmentChange.ChangeId) + { + return BadRequest(); + } + + db.Entry(apartmentChange).State = EntityState.Modified; + + try + { + db.SaveChanges(); + } + catch (DbUpdateConcurrencyException) + { + if (!ApartmentChangeExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return StatusCode(HttpStatusCode.NoContent); + } + + // POST: api/ApartmentChanges + [ResponseType(typeof(ApartmentChange))] + public IHttpActionResult PostApartmentChange(ApartmentChange apartmentChange) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + db.ApartmentChanges.Add(apartmentChange); + + try + { + db.SaveChanges(); + } + catch (DbUpdateException) + { + if (ApartmentChangeExists(apartmentChange.ChangeId)) + { + return Conflict(); + } + else + { + throw; + } + } + + return CreatedAtRoute("DefaultApi", new { id = apartmentChange.ChangeId }, apartmentChange); + } + + // DELETE: api/ApartmentChanges/5 + [ResponseType(typeof(ApartmentChange))] + public IHttpActionResult DeleteApartmentChange(int id) + { + ApartmentChange apartmentChange = db.ApartmentChanges.Find(id); + if (apartmentChange == null) + { + return NotFound(); + } + + db.ApartmentChanges.Remove(apartmentChange); + db.SaveChanges(); + + return Ok(apartmentChange); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + db.Dispose(); + } + base.Dispose(disposing); + } + + private bool ApartmentChangeExists(int id) + { + return db.ApartmentChanges.Count(e => e.ChangeId == id) > 0; + } + } +}
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/ApartmentResidentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ApartmentResidentsController.cs new file mode 100644 index 0000000..a754255 --- /dev/null +++ b/ApartmentManager/HousingWebApi/Controllers/ApartmentResidentsController.cs @@ -0,0 +1,133 @@ +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/ApartmentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ApartmentsController.cs index a3de905..90af553 100644 --- a/ApartmentManager/HousingWebApi/Controllers/ApartmentsController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/ApartmentsController.cs @@ -44,7 +44,7 @@ namespace HousingWebApi.Controllers return BadRequest(ModelState); } - if (id != apartment.ApartmentNumber) + if (id != apartment.ApartmentId) { return BadRequest(); } @@ -87,7 +87,7 @@ namespace HousingWebApi.Controllers } catch (DbUpdateException) { - if (ApartmentExists(apartment.ApartmentNumber)) + if (ApartmentExists(apartment.ApartmentId)) { return Conflict(); } @@ -97,7 +97,7 @@ namespace HousingWebApi.Controllers } } - return CreatedAtRoute("DefaultApi", new { id = apartment.ApartmentNumber }, apartment); + return CreatedAtRoute("DefaultApi", new { id = apartment.ApartmentId }, apartment); } // DELETE: api/Apartments/5 @@ -127,7 +127,7 @@ namespace HousingWebApi.Controllers private bool ApartmentExists(int id) { - return db.Apartments.Count(e => e.ApartmentNumber == id) > 0; + return db.Apartments.Count(e => e.ApartmentId == id) > 0; } } }
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs new file mode 100644 index 0000000..bebff8e --- /dev/null +++ b/ApartmentManager/HousingWebApi/Controllers/ChangeCommentsController.cs @@ -0,0 +1,133 @@ +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 ChangeCommentsController : ApiController + { + private DataModel db = new DataModel(); + + // GET: api/ChangeComments + public IQueryable<ChangeComment> GetChangeComments() + { + return db.ChangeComments; + } + + // GET: api/ChangeComments/5 + [ResponseType(typeof(ChangeComment))] + public IHttpActionResult GetChangeComment(int id) + { + ChangeComment changeComment = db.ChangeComments.Find(id); + if (changeComment == null) + { + return NotFound(); + } + + return Ok(changeComment); + } + + // PUT: api/ChangeComments/5 + [ResponseType(typeof(void))] + public IHttpActionResult PutChangeComment(int id, ChangeComment changeComment) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != changeComment.CommentId) + { + return BadRequest(); + } + + db.Entry(changeComment).State = EntityState.Modified; + + try + { + db.SaveChanges(); + } + catch (DbUpdateConcurrencyException) + { + if (!ChangeCommentExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return StatusCode(HttpStatusCode.NoContent); + } + + // POST: api/ChangeComments + [ResponseType(typeof(ChangeComment))] + public IHttpActionResult PostChangeComment(ChangeComment changeComment) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + db.ChangeComments.Add(changeComment); + + try + { + db.SaveChanges(); + } + catch (DbUpdateException) + { + if (ChangeCommentExists(changeComment.CommentId)) + { + return Conflict(); + } + else + { + throw; + } + } + + return CreatedAtRoute("DefaultApi", new { id = changeComment.CommentId }, changeComment); + } + + // DELETE: api/ChangeComments/5 + [ResponseType(typeof(ChangeComment))] + public IHttpActionResult DeleteChangeComment(int id) + { + ChangeComment changeComment = db.ChangeComments.Find(id); + if (changeComment == null) + { + return NotFound(); + } + + db.ChangeComments.Remove(changeComment); + db.SaveChanges(); + + return Ok(changeComment); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + db.Dispose(); + } + base.Dispose(disposing); + } + + private bool ChangeCommentExists(int id) + { + return db.ChangeComments.Count(e => e.CommentId == id) > 0; + } + } +}
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs new file mode 100644 index 0000000..406ab33 --- /dev/null +++ b/ApartmentManager/HousingWebApi/Controllers/ChangeDocumentsController.cs @@ -0,0 +1,133 @@ +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 ChangeDocumentsController : ApiController + { + private DataModel db = new DataModel(); + + // GET: api/ChangeDocuments + public IQueryable<ChangeDocument> GetChangeDocuments() + { + return db.ChangeDocuments; + } + + // GET: api/ChangeDocuments/5 + [ResponseType(typeof(ChangeDocument))] + public IHttpActionResult GetChangeDocument(int id) + { + ChangeDocument changeDocument = db.ChangeDocuments.Find(id); + if (changeDocument == null) + { + return NotFound(); + } + + return Ok(changeDocument); + } + + // PUT: api/ChangeDocuments/5 + [ResponseType(typeof(void))] + public IHttpActionResult PutChangeDocument(int id, ChangeDocument changeDocument) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != changeDocument.DocumentId) + { + return BadRequest(); + } + + db.Entry(changeDocument).State = EntityState.Modified; + + try + { + db.SaveChanges(); + } + catch (DbUpdateConcurrencyException) + { + if (!ChangeDocumentExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return StatusCode(HttpStatusCode.NoContent); + } + + // POST: api/ChangeDocuments + [ResponseType(typeof(ChangeDocument))] + public IHttpActionResult PostChangeDocument(ChangeDocument changeDocument) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + db.ChangeDocuments.Add(changeDocument); + + try + { + db.SaveChanges(); + } + catch (DbUpdateException) + { + if (ChangeDocumentExists(changeDocument.DocumentId)) + { + return Conflict(); + } + else + { + throw; + } + } + + return CreatedAtRoute("DefaultApi", new { id = changeDocument.DocumentId }, changeDocument); + } + + // DELETE: api/ChangeDocuments/5 + [ResponseType(typeof(ChangeDocument))] + public IHttpActionResult DeleteChangeDocument(int id) + { + ChangeDocument changeDocument = db.ChangeDocuments.Find(id); + if (changeDocument == null) + { + return NotFound(); + } + + db.ChangeDocuments.Remove(changeDocument); + db.SaveChanges(); + + return Ok(changeDocument); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + db.Dispose(); + } + base.Dispose(disposing); + } + + private bool ChangeDocumentExists(int id) + { + return db.ChangeDocuments.Count(e => e.DocumentId == id) > 0; + } + } +}
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/PastContractOwnersController.cs b/ApartmentManager/HousingWebApi/Controllers/DefectCommentsController.cs index d1f3e00..ae5222d 100644 --- a/ApartmentManager/HousingWebApi/Controllers/PastContractOwnersController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/DefectCommentsController.cs @@ -12,44 +12,44 @@ using HousingWebApi; namespace HousingWebApi.Controllers { - public class PastContractOwnersController : ApiController + public class DefectCommentsController : ApiController { private DataModel db = new DataModel(); - // GET: api/PastContractOwners - public IQueryable<PastContractOwner> GetPastContractOwners() + // GET: api/DefectComments + public IQueryable<DefectComment> GetDefectComments() { - return db.PastContractOwners; + return db.DefectComments; } - // GET: api/PastContractOwners/5 - [ResponseType(typeof(PastContractOwner))] - public IHttpActionResult GetPastContractOwner(int id) + // GET: api/DefectComments/5 + [ResponseType(typeof(DefectComment))] + public IHttpActionResult GetDefectComment(int id) { - PastContractOwner pastContractOwner = db.PastContractOwners.Find(id); - if (pastContractOwner == null) + DefectComment defectComment = db.DefectComments.Find(id); + if (defectComment == null) { return NotFound(); } - return Ok(pastContractOwner); + return Ok(defectComment); } - // PUT: api/PastContractOwners/5 + // PUT: api/DefectComments/5 [ResponseType(typeof(void))] - public IHttpActionResult PutPastContractOwner(int id, PastContractOwner pastContractOwner) + public IHttpActionResult PutDefectComment(int id, DefectComment defectComment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } - if (id != pastContractOwner.Id) + if (id != defectComment.PictureId) { return BadRequest(); } - db.Entry(pastContractOwner).State = EntityState.Modified; + db.Entry(defectComment).State = EntityState.Modified; try { @@ -57,7 +57,7 @@ namespace HousingWebApi.Controllers } catch (DbUpdateConcurrencyException) { - if (!PastContractOwnerExists(id)) + if (!DefectCommentExists(id)) { return NotFound(); } @@ -70,16 +70,16 @@ namespace HousingWebApi.Controllers return StatusCode(HttpStatusCode.NoContent); } - // POST: api/PastContractOwners - [ResponseType(typeof(PastContractOwner))] - public IHttpActionResult PostPastContractOwner(PastContractOwner pastContractOwner) + // POST: api/DefectComments + [ResponseType(typeof(DefectComment))] + public IHttpActionResult PostDefectComment(DefectComment defectComment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } - db.PastContractOwners.Add(pastContractOwner); + db.DefectComments.Add(defectComment); try { @@ -87,7 +87,7 @@ namespace HousingWebApi.Controllers } catch (DbUpdateException) { - if (PastContractOwnerExists(pastContractOwner.Id)) + if (DefectCommentExists(defectComment.PictureId)) { return Conflict(); } @@ -97,23 +97,23 @@ namespace HousingWebApi.Controllers } } - return CreatedAtRoute("DefaultApi", new { id = pastContractOwner.Id }, pastContractOwner); + return CreatedAtRoute("DefaultApi", new { id = defectComment.PictureId }, defectComment); } - // DELETE: api/PastContractOwners/5 - [ResponseType(typeof(PastContractOwner))] - public IHttpActionResult DeletePastContractOwner(int id) + // DELETE: api/DefectComments/5 + [ResponseType(typeof(DefectComment))] + public IHttpActionResult DeleteDefectComment(int id) { - PastContractOwner pastContractOwner = db.PastContractOwners.Find(id); - if (pastContractOwner == null) + DefectComment defectComment = db.DefectComments.Find(id); + if (defectComment == null) { return NotFound(); } - db.PastContractOwners.Remove(pastContractOwner); + db.DefectComments.Remove(defectComment); db.SaveChanges(); - return Ok(pastContractOwner); + return Ok(defectComment); } protected override void Dispose(bool disposing) @@ -125,9 +125,9 @@ namespace HousingWebApi.Controllers base.Dispose(disposing); } - private bool PastContractOwnerExists(int id) + private bool DefectCommentExists(int id) { - return db.PastContractOwners.Count(e => e.Id == id) > 0; + return db.DefectComments.Count(e => e.PictureId == id) > 0; } } }
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/DefectPicturesController.cs b/ApartmentManager/HousingWebApi/Controllers/DefectPicturesController.cs new file mode 100644 index 0000000..288a660 --- /dev/null +++ b/ApartmentManager/HousingWebApi/Controllers/DefectPicturesController.cs @@ -0,0 +1,133 @@ +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 DefectPicturesController : ApiController + { + private DataModel db = new DataModel(); + + // GET: api/DefectPictures + public IQueryable<DefectPicture> GetDefectPictures() + { + return db.DefectPictures; + } + + // GET: api/DefectPictures/5 + [ResponseType(typeof(DefectPicture))] + public IHttpActionResult GetDefectPicture(int id) + { + DefectPicture defectPicture = db.DefectPictures.Find(id); + if (defectPicture == null) + { + return NotFound(); + } + + return Ok(defectPicture); + } + + // PUT: api/DefectPictures/5 + [ResponseType(typeof(void))] + public IHttpActionResult PutDefectPicture(int id, DefectPicture defectPicture) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != defectPicture.PictureId) + { + return BadRequest(); + } + + db.Entry(defectPicture).State = EntityState.Modified; + + try + { + db.SaveChanges(); + } + catch (DbUpdateConcurrencyException) + { + if (!DefectPictureExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return StatusCode(HttpStatusCode.NoContent); + } + + // POST: api/DefectPictures + [ResponseType(typeof(DefectPicture))] + public IHttpActionResult PostDefectPicture(DefectPicture defectPicture) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + db.DefectPictures.Add(defectPicture); + + try + { + db.SaveChanges(); + } + catch (DbUpdateException) + { + if (DefectPictureExists(defectPicture.PictureId)) + { + return Conflict(); + } + else + { + throw; + } + } + + return CreatedAtRoute("DefaultApi", new { id = defectPicture.PictureId }, defectPicture); + } + + // DELETE: api/DefectPictures/5 + [ResponseType(typeof(DefectPicture))] + public IHttpActionResult DeleteDefectPicture(int id) + { + DefectPicture defectPicture = db.DefectPictures.Find(id); + if (defectPicture == null) + { + return NotFound(); + } + + db.DefectPictures.Remove(defectPicture); + db.SaveChanges(); + + return Ok(defectPicture); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + db.Dispose(); + } + base.Dispose(disposing); + } + + private bool DefectPictureExists(int id) + { + return db.DefectPictures.Count(e => e.PictureId == id) > 0; + } + } +}
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs b/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs index aa6f519..c5f2909 100644 --- a/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs @@ -44,7 +44,7 @@ namespace HousingWebApi.Controllers return BadRequest(ModelState); } - if (id != defect.DefectNumber) + if (id != defect.DefectId) { return BadRequest(); } @@ -87,7 +87,7 @@ namespace HousingWebApi.Controllers } catch (DbUpdateException) { - if (DefectExists(defect.DefectNumber)) + if (DefectExists(defect.DefectId)) { return Conflict(); } @@ -97,7 +97,7 @@ namespace HousingWebApi.Controllers } } - return CreatedAtRoute("DefaultApi", new { id = defect.DefectNumber }, defect); + return CreatedAtRoute("DefaultApi", new { id = defect.DefectId }, defect); } // DELETE: api/Defects/5 @@ -127,7 +127,7 @@ namespace HousingWebApi.Controllers private bool DefectExists(int id) { - return db.Defects.Count(e => e.DefectNumber == id) > 0; + return db.Defects.Count(e => e.DefectId == id) > 0; } } }
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/PastUsersController.cs b/ApartmentManager/HousingWebApi/Controllers/PastUsersController.cs new file mode 100644 index 0000000..7c2cf0e --- /dev/null +++ b/ApartmentManager/HousingWebApi/Controllers/PastUsersController.cs @@ -0,0 +1,133 @@ +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 PastUsersController : ApiController + { + private DataModel db = new DataModel(); + + // GET: api/PastUsers + public IQueryable<PastUser> GetPastUsers() + { + return db.PastUsers; + } + + // GET: api/PastUsers/5 + [ResponseType(typeof(PastUser))] + public IHttpActionResult GetPastUser(string id) + { + PastUser pastUser = db.PastUsers.Find(id); + if (pastUser == null) + { + return NotFound(); + } + + return Ok(pastUser); + } + + // PUT: api/PastUsers/5 + [ResponseType(typeof(void))] + public IHttpActionResult PutPastUser(string id, PastUser pastUser) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != pastUser.Username) + { + return BadRequest(); + } + + db.Entry(pastUser).State = EntityState.Modified; + + try + { + db.SaveChanges(); + } + catch (DbUpdateConcurrencyException) + { + if (!PastUserExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return StatusCode(HttpStatusCode.NoContent); + } + + // POST: api/PastUsers + [ResponseType(typeof(PastUser))] + public IHttpActionResult PostPastUser(PastUser pastUser) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + db.PastUsers.Add(pastUser); + + try + { + db.SaveChanges(); + } + catch (DbUpdateException) + { + if (PastUserExists(pastUser.Username)) + { + return Conflict(); + } + else + { + throw; + } + } + + return CreatedAtRoute("DefaultApi", new { id = pastUser.Username }, pastUser); + } + + // DELETE: api/PastUsers/5 + [ResponseType(typeof(PastUser))] + public IHttpActionResult DeletePastUser(string id) + { + PastUser pastUser = db.PastUsers.Find(id); + if (pastUser == null) + { + return NotFound(); + } + + db.PastUsers.Remove(pastUser); + db.SaveChanges(); + + return Ok(pastUser); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + db.Dispose(); + } + base.Dispose(disposing); + } + + private bool PastUserExists(string id) + { + return db.PastUsers.Count(e => e.Username == id) > 0; + } + } +}
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs b/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs index 9cd3932..ebb0188 100644 --- a/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/ResidentsController.cs @@ -22,7 +22,7 @@ namespace HousingWebApi.Controllers return db.Residents; } - // GET: api/Users/5 + // GET: api/Residents/5 [ResponseType(typeof(Resident))] public IHttpActionResult GetResident(int id) { @@ -34,27 +34,6 @@ namespace HousingWebApi.Controllers return Ok(resident); } - //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; - } // PUT: api/Residents/5 [ResponseType(typeof(void))] @@ -65,7 +44,7 @@ namespace HousingWebApi.Controllers return BadRequest(ModelState); } - if (id != resident.ResidentNr) + if (id != resident.ResidentId) { return BadRequest(); } @@ -108,7 +87,7 @@ namespace HousingWebApi.Controllers } catch (DbUpdateException) { - if (ResidentExists(resident.ResidentNr)) + if (ResidentExists(resident.ResidentId)) { return Conflict(); } @@ -118,7 +97,7 @@ namespace HousingWebApi.Controllers } } - return CreatedAtRoute("DefaultApi", new { id = resident.ResidentNr }, resident); + return CreatedAtRoute("DefaultApi", new { id = resident.ResidentId }, resident); } // DELETE: api/Residents/5 @@ -148,7 +127,7 @@ namespace HousingWebApi.Controllers private bool ResidentExists(int id) { - return db.Residents.Count(e => e.ResidentNr == id) > 0; + return db.Residents.Count(e => e.ResidentId == id) > 0; } } }
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Controllers/UsersController.cs b/ApartmentManager/HousingWebApi/Controllers/UsersController.cs index a8c03af..4db8e9d 100644 --- a/ApartmentManager/HousingWebApi/Controllers/UsersController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/UsersController.cs @@ -1,9 +1,14 @@ -using System.Data.Entity; +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 { @@ -17,23 +22,9 @@ namespace HousingWebApi.Controllers return db.Users; } - // GET: api/Users/by-username/username - [ResponseType(typeof(User))] - [Route("api/Users/by-username/{username}")] - public IHttpActionResult GetUserByUsername(string username) - { - User user = db.Users.SingleOrDefault(u => u.Username == username); - if (user == null) - { - return NotFound(); - } - - return Ok(user); - } - // GET: api/Users/5 [ResponseType(typeof(User))] - public IHttpActionResult GetUser(int id) + public IHttpActionResult GetUser(string id) { User user = db.Users.Find(id); if (user == null) @@ -46,14 +37,14 @@ namespace HousingWebApi.Controllers // PUT: api/Users/5 [ResponseType(typeof(void))] - public IHttpActionResult PutUser(int id, User user) + public IHttpActionResult PutUser(string id, User user) { if (!ModelState.IsValid) { return BadRequest(ModelState); } - if (id != user.ApartmentNr) + if (id != user.Username) { return BadRequest(); } @@ -96,7 +87,7 @@ namespace HousingWebApi.Controllers } catch (DbUpdateException) { - if (UserExists(user.ApartmentNr)) + if (UserExists(user.Username)) { return Conflict(); } @@ -106,12 +97,12 @@ namespace HousingWebApi.Controllers } } - return CreatedAtRoute("DefaultApi", new { id = user.ApartmentNr }, user); + return CreatedAtRoute("DefaultApi", new { id = user.Username }, user); } // DELETE: api/Users/5 [ResponseType(typeof(User))] - public IHttpActionResult DeleteUser(int id) + public IHttpActionResult DeleteUser(string id) { User user = db.Users.Find(id); if (user == null) @@ -134,9 +125,9 @@ namespace HousingWebApi.Controllers base.Dispose(disposing); } - private bool UserExists(int id) + private bool UserExists(string id) { - return db.Users.Count(e => e.ApartmentNr == id) > 0; + return db.Users.Count(e => e.Username == id) > 0; } } }
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/DataModel.cs b/ApartmentManager/HousingWebApi/DataModel.cs index fa16d44..0b953a6 100644 --- a/ApartmentManager/HousingWebApi/DataModel.cs +++ b/ApartmentManager/HousingWebApi/DataModel.cs @@ -14,62 +14,77 @@ namespace HousingWebApi } public virtual DbSet<Apartment> Apartments { get; set; } + public virtual DbSet<ApartmentChange> ApartmentChanges { get; set; } + public virtual DbSet<ChangeComment> ChangeComments { get; set; } + public virtual DbSet<ChangeDocument> ChangeDocuments { get; set; } public virtual DbSet<Defect> Defects { get; set; } - public virtual DbSet<PastContractOwner> PastContractOwners { get; set; } + public virtual DbSet<DefectComment> DefectComments { get; set; } + public virtual DbSet<DefectPicture> DefectPictures { get; set; } + 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; } - public virtual DbSet<database_firewall_rules> database_firewall_rules { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Apartment>() - .Property(e => e.Size) - .HasPrecision(18, 0); - - modelBuilder.Entity<Apartment>() - .Property(e => e.MonthlyCharge) - .IsUnicode(false); - - modelBuilder.Entity<Apartment>() .Property(e => e.Address) .IsUnicode(false); modelBuilder.Entity<Apartment>() - .Property(e => e.PlanPicture) - .IsUnicode(false); + .HasMany(e => e.ApartmentChanges) + .WithRequired(e => e.Apartment) + .WillCascadeOnDelete(false); modelBuilder.Entity<Apartment>() .HasMany(e => e.Defects) .WithRequired(e => e.Apartment) - .HasForeignKey(e => e.ApartmentNr) + .WillCascadeOnDelete(false); + + modelBuilder.Entity<Apartment>() + .HasMany(e => e.PastUsers) + .WithRequired(e => e.Apartment) .WillCascadeOnDelete(false); modelBuilder.Entity<Apartment>() .HasMany(e => e.Residents) .WithRequired(e => e.Apartment) - .HasForeignKey(e => e.ApartmentNr) .WillCascadeOnDelete(false); modelBuilder.Entity<Apartment>() - .HasOptional(e => e.User) - .WithRequired(e => e.Apartment); + .HasMany(e => e.Users) + .WithRequired(e => e.Apartment) + .WillCascadeOnDelete(false); - modelBuilder.Entity<Defect>() + modelBuilder.Entity<ApartmentChange>() .Property(e => e.Name) .IsUnicode(false); - modelBuilder.Entity<Defect>() - .Property(e => e.Picture) + modelBuilder.Entity<ApartmentChange>() + .Property(e => e.Description) .IsUnicode(false); - modelBuilder.Entity<Defect>() - .Property(e => e.Picture2) + modelBuilder.Entity<ApartmentChange>() + .Property(e => e.Status) + .IsUnicode(false); + + modelBuilder.Entity<ApartmentChange>() + .HasMany(e => e.ChangeComments) + .WithRequired(e => e.ApartmentChange) + .WillCascadeOnDelete(false); + + modelBuilder.Entity<ApartmentChange>() + .HasMany(e => e.ChangeDocuments) + .WithRequired(e => e.ApartmentChange) + .WillCascadeOnDelete(false); + + modelBuilder.Entity<ChangeComment>() + .Property(e => e.Comment) .IsUnicode(false); modelBuilder.Entity<Defect>() - .Property(e => e.Picture3) + .Property(e => e.Name) .IsUnicode(false); modelBuilder.Entity<Defect>() @@ -77,16 +92,46 @@ namespace HousingWebApi .IsUnicode(false); modelBuilder.Entity<Defect>() - .Property(e => e.Comment) + .Property(e => e.Status) .IsUnicode(false); modelBuilder.Entity<Defect>() - .Property(e => e.Status) + .HasMany(e => e.DefectComments) + .WithRequired(e => e.Defect) + .WillCascadeOnDelete(false); + + modelBuilder.Entity<Defect>() + .HasMany(e => e.DefectPictures) + .WithRequired(e => e.Defect) + .WillCascadeOnDelete(false); + + modelBuilder.Entity<DefectComment>() + .Property(e => e.Picture) .IsUnicode(false); - modelBuilder.Entity<PastContractOwner>() - .Property(e => e.ApartmentNr) - .IsFixedLength(); + modelBuilder.Entity<PastUser>() + .Property(e => e.Username) + .IsUnicode(false); + + modelBuilder.Entity<PastUser>() + .Property(e => e.Password) + .IsUnicode(false); + + modelBuilder.Entity<PastUser>() + .Property(e => e.FirstName) + .IsUnicode(false); + + modelBuilder.Entity<PastUser>() + .Property(e => e.LastName) + .IsUnicode(false); + + modelBuilder.Entity<PastUser>() + .Property(e => e.Phone) + .IsUnicode(false); + + modelBuilder.Entity<PastUser>() + .Property(e => e.Email) + .IsUnicode(false); modelBuilder.Entity<Resident>() .Property(e => e.FirstName) @@ -97,11 +142,11 @@ namespace HousingWebApi .IsUnicode(false); modelBuilder.Entity<Resident>() - .Property(e => e.Email) + .Property(e => e.Phone) .IsUnicode(false); modelBuilder.Entity<Resident>() - .Property(e => e.Picture) + .Property(e => e.Email) .IsUnicode(false); modelBuilder.Entity<User>() @@ -113,10 +158,6 @@ namespace HousingWebApi .IsUnicode(false); modelBuilder.Entity<User>() - .Property(e => e.Type) - .IsUnicode(false); - - modelBuilder.Entity<User>() .Property(e => e.FirstName) .IsUnicode(false); @@ -132,22 +173,6 @@ namespace HousingWebApi .Property(e => e.Email) .IsUnicode(false); - modelBuilder.Entity<User>() - .Property(e => e.SecondName) - .IsUnicode(false); - - modelBuilder.Entity<User>() - .Property(e => e.SecondLastName) - .IsUnicode(false); - - modelBuilder.Entity<User>() - .Property(e => e.SecondPhone) - .IsUnicode(false); - - modelBuilder.Entity<User>() - .Property(e => e.SecondEmail) - .IsUnicode(false); - modelBuilder.Entity<AllResident>() .Property(e => e.FirstName) .IsUnicode(false); @@ -163,14 +188,6 @@ namespace HousingWebApi modelBuilder.Entity<ApartmentResident>() .Property(e => e.Email) .IsUnicode(false); - - modelBuilder.Entity<database_firewall_rules>() - .Property(e => e.start_ip_address) - .IsUnicode(false); - - modelBuilder.Entity<database_firewall_rules>() - .Property(e => e.end_ip_address) - .IsUnicode(false); } } } diff --git a/ApartmentManager/HousingWebApi/HousingWebApi.csproj b/ApartmentManager/HousingWebApi/HousingWebApi.csproj index e47c402..18a8c73 100644 --- a/ApartmentManager/HousingWebApi/HousingWebApi.csproj +++ b/ApartmentManager/HousingWebApi/HousingWebApi.csproj @@ -151,14 +151,14 @@ </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="Controllers\ApartmentsController.cs" />
- <Compile Include="Controllers\DefectsController.cs" />
- <Compile Include="Controllers\PastContractOwnersController.cs" />
- <Compile Include="Controllers\ResidentsController.cs" />
- <Compile Include="Controllers\UsersController.cs" />
+ <Compile Include="Models\ChangeComment.cs" />
+ <Compile Include="Models\ChangeDocument.cs" />
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
@@ -191,16 +191,26 @@ <Compile Include="Areas\HelpPage\SampleGeneration\SampleDirection.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" />
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />
+ <Compile Include="Controllers\ApartmentChangesController.cs" />
+ <Compile Include="Controllers\ApartmentsController.cs" />
+ <Compile Include="Controllers\ChangeCommentsController.cs" />
+ <Compile Include="Controllers\ChangeDocumentsController.cs" />
+ <Compile Include="Controllers\DefectCommentsController.cs" />
+ <Compile Include="Controllers\DefectPicturesController.cs" />
+ <Compile Include="Controllers\DefectsController.cs" />
<Compile Include="Controllers\HomeController.cs" />
- <Compile Include="Models\database_firewall_rules.cs" />
+ <Compile Include="Controllers\PastUsersController.cs" />
+ <Compile Include="Controllers\ResidentsController.cs" />
+ <Compile Include="Controllers\UsersController.cs" />
<Compile Include="DataModel.cs" />
<Compile Include="Models\Defect.cs" />
+ <Compile Include="Models\DefectComment.cs" />
+ <Compile Include="Models\DefectPicture.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
- <Compile Include="Models\PastContractOwner.cs" />
+ <Compile Include="Models\PastUser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Models\ResidentList.cs" />
<Compile Include="Models\Resident.cs" />
<Compile Include="Models\User.cs" />
</ItemGroup>
diff --git a/ApartmentManager/HousingWebApi/Models/Apartment.cs b/ApartmentManager/HousingWebApi/Models/Apartment.cs index 7481344..d1ac1d5 100644 --- a/ApartmentManager/HousingWebApi/Models/Apartment.cs +++ b/ApartmentManager/HousingWebApi/Models/Apartment.cs @@ -6,40 +6,48 @@ namespace HousingWebApi using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.Spatial; + [Table("Apartment")] public partial class Apartment { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public Apartment() { + ApartmentChanges = new HashSet<ApartmentChange>(); Defects = new HashSet<Defect>(); + PastUsers = new HashSet<PastUser>(); Residents = new HashSet<Resident>(); + Users = new HashSet<User>(); } - [Key] [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int ApartmentNumber { get; set; } + public int ApartmentId { get; set; } - public decimal Size { get; set; } + public double? Size { get; set; } - public int NumberOfRooms { get; set; } + public int? NumberOfRooms { get; set; } - [StringLength(10)] - public string MonthlyCharge { get; set; } + public double? MonthlyCharge { get; set; } public int? Floor { get; set; } - [StringLength(50)] + [StringLength(100)] public string Address { get; set; } - [StringLength(200)] - public string PlanPicture { get; set; } + public byte[] PlanPicture { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection<ApartmentChange> ApartmentChanges { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection<Defect> Defects { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection<PastUser> PastUsers { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection<Resident> Residents { get; set; } - public virtual User User { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection<User> Users { get; set; } } } diff --git a/ApartmentManager/HousingWebApi/Models/ApartmentChange.cs b/ApartmentManager/HousingWebApi/Models/ApartmentChange.cs new file mode 100644 index 0000000..e14a35e --- /dev/null +++ b/ApartmentManager/HousingWebApi/Models/ApartmentChange.cs @@ -0,0 +1,44 @@ +namespace HousingWebApi +{ + using System; + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using System.ComponentModel.DataAnnotations.Schema; + using System.Data.Entity.Spatial; + + [Table("ApartmentChange")] + public partial class ApartmentChange + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public ApartmentChange() + { + ChangeComments = new HashSet<ChangeComment>(); + ChangeDocuments = new HashSet<ChangeDocument>(); + } + + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public int ChangeId { get; set; } + + public int ApartmentId { get; set; } + + [StringLength(50)] + public string Name { get; set; } + + [Column(TypeName = "date")] + public DateTime? UploadDate { get; set; } + + public string Description { get; set; } + + [StringLength(50)] + public string Status { get; set; } + + public virtual Apartment Apartment { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection<ChangeComment> ChangeComments { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection<ChangeDocument> ChangeDocuments { get; set; } + } +} diff --git a/ApartmentManager/HousingWebApi/Models/ChangeComment.cs b/ApartmentManager/HousingWebApi/Models/ChangeComment.cs new file mode 100644 index 0000000..3c5d8d8 --- /dev/null +++ b/ApartmentManager/HousingWebApi/Models/ChangeComment.cs @@ -0,0 +1,22 @@ +namespace HousingWebApi +{ + using System; + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using System.ComponentModel.DataAnnotations.Schema; + using System.Data.Entity.Spatial; + + [Table("ChangeComment")] + public partial class ChangeComment + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public int CommentId { get; set; } + + public int ChangeId { get; set; } + + public string Comment { get; set; } + + public virtual ApartmentChange ApartmentChange { get; set; } + } +} diff --git a/ApartmentManager/HousingWebApi/Models/ChangeDocument.cs b/ApartmentManager/HousingWebApi/Models/ChangeDocument.cs new file mode 100644 index 0000000..9e910dc --- /dev/null +++ b/ApartmentManager/HousingWebApi/Models/ChangeDocument.cs @@ -0,0 +1,22 @@ +namespace HousingWebApi +{ + using System; + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using System.ComponentModel.DataAnnotations.Schema; + using System.Data.Entity.Spatial; + + [Table("ChangeDocument")] + public partial class ChangeDocument + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public int DocumentId { get; set; } + + public int ChangeId { get; set; } + + public byte[] Document { get; set; } + + public virtual ApartmentChange ApartmentChange { get; set; } + } +} diff --git a/ApartmentManager/HousingWebApi/Models/Defect.cs b/ApartmentManager/HousingWebApi/Models/Defect.cs index b439078..5200124 100644 --- a/ApartmentManager/HousingWebApi/Models/Defect.cs +++ b/ApartmentManager/HousingWebApi/Models/Defect.cs @@ -6,41 +6,38 @@ namespace HousingWebApi using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.Spatial; + [Table("Defect")] public partial class Defect { - [Key] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Defect() + { + DefectComments = new HashSet<DefectComment>(); + DefectPictures = new HashSet<DefectPicture>(); + } + [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int DefectNumber { get; set; } + public int DefectId { get; set; } - public int ApartmentNr { get; set; } + public int ApartmentId { get; set; } - [Required] [StringLength(50)] public string Name { get; set; } [Column(TypeName = "date")] - public DateTime DateUploaded { get; set; } - - [Required] - [StringLength(200)] - public string Picture { get; set; } - - [StringLength(200)] - public string Picture2 { get; set; } - - [StringLength(200)] - public string Picture3 { get; set; } + public DateTime? UploadDate { get; set; } - [Column(TypeName = "text")] - [Required] public string Description { get; set; } - [Column(TypeName = "text")] - public string Comment { get; set; } - - [StringLength(10)] + [StringLength(50)] public string Status { get; set; } public virtual Apartment Apartment { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection<DefectComment> DefectComments { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection<DefectPicture> DefectPictures { get; set; } } } diff --git a/ApartmentManager/HousingWebApi/Models/PastContractOwner.cs b/ApartmentManager/HousingWebApi/Models/DefectComment.cs index 273952a..b05f790 100644 --- a/ApartmentManager/HousingWebApi/Models/PastContractOwner.cs +++ b/ApartmentManager/HousingWebApi/Models/DefectComment.cs @@ -6,12 +6,17 @@ namespace HousingWebApi using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.Spatial; - public partial class PastContractOwner + [Table("DefectComment")] + public partial class DefectComment { + [Key] [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int Id { get; set; } + public int PictureId { get; set; } - [StringLength(10)] - public string ApartmentNr { get; set; } + public int DefectId { get; set; } + + public string Picture { get; set; } + + public virtual Defect Defect { get; set; } } } diff --git a/ApartmentManager/HousingWebApi/Models/DefectPicture.cs b/ApartmentManager/HousingWebApi/Models/DefectPicture.cs new file mode 100644 index 0000000..6a83338 --- /dev/null +++ b/ApartmentManager/HousingWebApi/Models/DefectPicture.cs @@ -0,0 +1,22 @@ +namespace HousingWebApi +{ + using System; + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using System.ComponentModel.DataAnnotations.Schema; + using System.Data.Entity.Spatial; + + [Table("DefectPicture")] + public partial class DefectPicture + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public int PictureId { get; set; } + + public int DefectId { get; set; } + + public byte[] Picture { get; set; } + + public virtual Defect Defect { get; set; } + } +} diff --git a/ApartmentManager/HousingWebApi/Models/PastUser.cs b/ApartmentManager/HousingWebApi/Models/PastUser.cs new file mode 100644 index 0000000..f258d34 --- /dev/null +++ b/ApartmentManager/HousingWebApi/Models/PastUser.cs @@ -0,0 +1,49 @@ +namespace HousingWebApi +{ + using System; + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using System.ComponentModel.DataAnnotations.Schema; + using System.Data.Entity.Spatial; + + [Table("PastUser")] + public partial class PastUser + { + [Key] + [StringLength(30)] + public string Username { get; set; } + + public int ApartmentId { get; set; } + + [Required] + [StringLength(30)] + public string Password { get; set; } + + public bool IsBm { 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; } + + [Column(TypeName = "date")] + public DateTime? MoveInDate { get; set; } + + [Column(TypeName = "date")] + public DateTime? MoveOutDate { get; set; } + + public virtual Apartment Apartment { get; set; } + } +} diff --git a/ApartmentManager/HousingWebApi/Models/Resident.cs b/ApartmentManager/HousingWebApi/Models/Resident.cs index 319a697..c9a698f 100644 --- a/ApartmentManager/HousingWebApi/Models/Resident.cs +++ b/ApartmentManager/HousingWebApi/Models/Resident.cs @@ -6,31 +6,30 @@ namespace HousingWebApi using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.Spatial; + [Table("Resident")] public partial class Resident { - [Key] - public int ResidentNr { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public int ResidentId { get; set; } - public int ApartmentNr { get; set; } + public int ApartmentId { get; set; } - [Required] - [StringLength(20)] + [StringLength(30)] public string FirstName { get; set; } - [Required] - [StringLength(20)] + [StringLength(30)] public string LastName { get; set; } [Column(TypeName = "date")] public DateTime? BirthDate { get; set; } - public int? Phone { get; set; } + [StringLength(20)] + public string Phone { get; set; } - [StringLength(30)] + [StringLength(50)] public string Email { get; set; } - [StringLength(220)] - public string Picture { get; set; } + public byte[] Picture { get; set; } public virtual Apartment Apartment { get; set; } } diff --git a/ApartmentManager/HousingWebApi/Models/ResidentList.cs b/ApartmentManager/HousingWebApi/Models/ResidentList.cs deleted file mode 100644 index 9423bc1..0000000 --- a/ApartmentManager/HousingWebApi/Models/ResidentList.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace HousingWebApi -{ - public class ResidentList - { - public int ResidentNr { get; set; } - public int ApartmentNr { get; set; } - public string FirstName { get; set; } - public string LastName { get; set; } - public DateTime? BirthDate { get; set; } - public int? Phone { get; set; } - public string Email { get; set; } - public string Picture { get; set; } - - } -}
\ No newline at end of file diff --git a/ApartmentManager/HousingWebApi/Models/User.cs b/ApartmentManager/HousingWebApi/Models/User.cs index e260ede..019e788 100644 --- a/ApartmentManager/HousingWebApi/Models/User.cs +++ b/ApartmentManager/HousingWebApi/Models/User.cs @@ -6,58 +6,43 @@ namespace HousingWebApi using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.Spatial; + [Table("User")] public partial class User { [Key] - [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int ApartmentNr { get; set; } - - [Required] - [StringLength(15)] + [StringLength(30)] public string Username { get; set; } + public int ApartmentId { get; set; } + [Required] - [StringLength(15)] + [StringLength(30)] public string Password { get; set; } - [Required] - [StringLength(1)] - public string Type { get; set; } + public bool IsBm { get; set; } - [Required] - [StringLength(20)] + [StringLength(30)] public string FirstName { get; set; } - [Required] - [StringLength(20)] + [StringLength(30)] public string LastName { get; set; } [Column(TypeName = "date")] public DateTime? BirthDate { get; set; } - [StringLength(12)] + [StringLength(20)] public string Phone { get; set; } - [StringLength(30)] + [StringLength(50)] public string Email { get; set; } - [Column(TypeName = "image")] public byte[] Picture { get; set; } - [StringLength(20)] - public string SecondName { get; set; } - - [StringLength(20)] - public string SecondLastName { get; set; } - [Column(TypeName = "date")] - public DateTime? SecondBirthDate { get; set; } - - [StringLength(12)] - public string SecondPhone { get; set; } + public DateTime? MoveInDate { get; set; } - [StringLength(30)] - public string SecondEmail { get; set; } + [Column(TypeName = "date")] + public DateTime? MoveOutDate { get; set; } public virtual Apartment Apartment { get; set; } } diff --git a/ApartmentManager/HousingWebApi/Models/database_firewall_rules.cs b/ApartmentManager/HousingWebApi/Models/database_firewall_rules.cs deleted file mode 100644 index 3b5d6a5..0000000 --- a/ApartmentManager/HousingWebApi/Models/database_firewall_rules.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace HousingWebApi -{ - using System; - using System.Collections.Generic; - using System.ComponentModel.DataAnnotations; - using System.ComponentModel.DataAnnotations.Schema; - using System.Data.Entity.Spatial; - - [Table("sys.database_firewall_rules")] - public partial class database_firewall_rules - { - [Key] - [Column(Order = 0)] - public int id { get; set; } - - [Key] - [Column(Order = 1)] - public string name { get; set; } - - [Key] - [Column(Order = 2)] - [StringLength(45)] - public string start_ip_address { get; set; } - - [Key] - [Column(Order = 3)] - [StringLength(45)] - public string end_ip_address { get; set; } - - [Key] - [Column(Order = 4)] - public DateTime create_date { get; set; } - - [Key] - [Column(Order = 5)] - public DateTime modify_date { get; set; } - } -} diff --git a/ApartmentManager/HousingWebApi/Web.config b/ApartmentManager/HousingWebApi/Web.config index 8261278..d4ce313 100644 --- a/ApartmentManager/HousingWebApi/Web.config +++ b/ApartmentManager/HousingWebApi/Web.config @@ -79,5 +79,6 @@ <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;App=EntityFramework" providerName="System.Data.SqlClient" /></connectionStrings> +</configuration>
\ No newline at end of file |