diff options
42 files changed, 1399 insertions, 415 deletions
diff --git a/ApartmentManager/ApartmentManager/AppShell.xaml.cs b/ApartmentManager/ApartmentManager/AppShell.xaml.cs index 746f61e..dec5cf7 100644 --- a/ApartmentManager/ApartmentManager/AppShell.xaml.cs +++ b/ApartmentManager/ApartmentManager/AppShell.xaml.cs @@ -102,7 +102,7 @@ namespace ApartmentManager { InitializeComponent(); - if (UserSingleton.Instance.CurrentUser.Type == "B") navMenuItems = boardMemberMenuItems; + if (UserSingleton.Instance.CurrentUser.IsBm) navMenuItems = boardMemberMenuItems; else navMenuItems = normalUserMenuItems; List<NavMenuItem> topNavMenuItems = navMenuItems.GetRange(0, navMenuItems.Count); diff --git a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs index f3cc8b3..ded9732 100644 --- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs @@ -23,9 +23,9 @@ namespace ApartmentManager.Handler public void GetApartmentResidents() { Resident resident = new Resident(); - resident.ApartmentNr = ApartmentViewModel.ApartmentNumber; + resident.ApartmentId = ApartmentViewModel.ApartmentNumber; - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr); + var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); ApartmentViewModel.CatalogSingleton.Residents.Clear(); @@ -49,7 +49,7 @@ namespace ApartmentManager.Handler try { Resident resident = new Resident(); - resident.ApartmentNr = ApartmentViewModel.ApartmentNumber; + resident.ApartmentId = ApartmentViewModel.ApartmentNumber; resident.FirstName = ApartmentViewModel.NewResident.FirstName; resident.LastName = ApartmentViewModel.NewResident.LastName; resident.BirthDate = ApartmentViewModel.NewResident.BirthDate; @@ -59,7 +59,7 @@ namespace ApartmentManager.Handler ApiClient.PostData("api/residents/", resident); - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr); + var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); ApartmentViewModel.CatalogSingleton.Residents.Clear(); @@ -80,8 +80,8 @@ namespace ApartmentManager.Handler try { Resident resident = new Resident(); - resident.ResidentNr = ApartmentViewModel.NewResident.ResidentNr; - resident.ApartmentNr = ApartmentViewModel.ApartmentNumber; + resident.ResidentId = ApartmentViewModel.NewResident.ResidentId; + resident.ApartmentId = ApartmentViewModel.ApartmentNumber; resident.FirstName = ApartmentViewModel.NewResident.FirstName; resident.LastName = ApartmentViewModel.NewResident.LastName; resident.BirthDate = ApartmentViewModel.NewResident.BirthDate; @@ -89,9 +89,9 @@ namespace ApartmentManager.Handler resident.Picture = ApartmentViewModel.NewResident.Picture; resident.Phone = ApartmentViewModel.NewResident.Phone; - ApiClient.DeleteData("api/residents/" + resident.ResidentNr); + ApiClient.DeleteData("api/residents/" + resident.ResidentId); - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr); + var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); ApartmentViewModel.CatalogSingleton.Residents.Clear(); @@ -111,8 +111,8 @@ namespace ApartmentManager.Handler try { Resident resident = new Resident(); - resident.ResidentNr = ApartmentViewModel.NewResident.ResidentNr; - resident.ApartmentNr = ApartmentViewModel.ApartmentNumber; + resident.ResidentId = ApartmentViewModel.NewResident.ResidentId; + resident.ApartmentId = ApartmentViewModel.ApartmentNumber; resident.FirstName = ApartmentViewModel.NewResident.FirstName; resident.LastName = ApartmentViewModel.NewResident.LastName; resident.BirthDate = ApartmentViewModel.NewResident.BirthDate; @@ -120,8 +120,8 @@ namespace ApartmentManager.Handler resident.Picture = ApartmentViewModel.NewResident.Picture; resident.Phone = ApartmentViewModel.NewResident.Phone; - ApiClient.PutData("api/residents/" + resident.ResidentNr, resident); - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr); + ApiClient.PutData("api/residents/" + resident.ResidentId, resident); + var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); ApartmentViewModel.CatalogSingleton.Residents.Clear(); @@ -141,7 +141,7 @@ namespace ApartmentManager.Handler { try { - ApartmentViewModel.NewResident.Picture = await ImgurPhotoUploader.UploadPhotoAsync(); + //ApartmentViewModel.NewResident.Picture = await ImgurPhotoUploader.UploadPhotoAsync(); var tmp = ApartmentViewModel.NewResident; ApartmentViewModel.NewResident = new Resident(); ApartmentViewModel.NewResident = tmp; diff --git a/ApartmentManager/ApartmentManager/Handler/BoardMemberHandler.cs b/ApartmentManager/ApartmentManager/Handler/BoardMemberHandler.cs index db6223d..c642b02 100644 --- a/ApartmentManager/ApartmentManager/Handler/BoardMemberHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/BoardMemberHandler.cs @@ -25,7 +25,7 @@ namespace ApartmentManager.Handler public void GetApartments() { Apartment apartment= new Apartment(); - apartment.ApartmentNumber = BoardMemberViewModel.ApartmentsNumber; + apartment.ApartmentId = BoardMemberViewModel.ApartmentsNumber; var apartmentsFromDatabase = ApiClient.GetData("api/Apartments/"); IEnumerable<Apartment> apartmentslist = JsonConvert.DeserializeObject<IEnumerable<Apartment>>(apartmentsFromDatabase); @@ -43,7 +43,7 @@ namespace ApartmentManager.Handler try { Apartment apartment = new Apartment(); - apartment.ApartmentNumber = BoardMemberViewModel.ApartmentsNumber; + apartment.ApartmentId = BoardMemberViewModel.ApartmentsNumber; apartment.Address = BoardMemberViewModel.NewApartment.Address; apartment.Floor = BoardMemberViewModel.NewApartment.Floor; apartment.MonthlyCharge = BoardMemberViewModel.NewApartment.MonthlyCharge; @@ -52,7 +52,7 @@ namespace ApartmentManager.Handler ApiClient.PostData("api/Apartments/", apartment); - var apartmentsFromDatabase = ApiClient.GetData("api/Apartments/" + apartment.ApartmentNumber); + var apartmentsFromDatabase = ApiClient.GetData("api/Apartments/" + apartment.ApartmentId); IEnumerable<Apartment> apartmentlist = JsonConvert.DeserializeObject<IEnumerable<Apartment>>(apartmentsFromDatabase); BoardMemberViewModel.BoardMemberCatalogSingleton.Apartment.Clear(); @@ -72,15 +72,15 @@ namespace ApartmentManager.Handler try { Apartment apartment = new Apartment(); - apartment.ApartmentNumber = BoardMemberViewModel.ApartmentsNumber; + apartment.ApartmentId = BoardMemberViewModel.ApartmentsNumber; apartment.Address = BoardMemberViewModel.NewApartment.Address; apartment.Floor = BoardMemberViewModel.NewApartment.Floor; apartment.MonthlyCharge = BoardMemberViewModel.NewApartment.MonthlyCharge; apartment.NumberOfRooms = BoardMemberViewModel.NewApartment.NumberOfRooms; apartment.Size = BoardMemberViewModel.NewApartment.Size; - ApiClient.PutData("api/Apartments/" + apartment.ApartmentNumber, apartment); - var apartmentsFromDatabase = ApiClient.GetData("api/Apartments/" + apartment.ApartmentNumber); + ApiClient.PutData("api/Apartments/" + apartment.ApartmentId, apartment); + var apartmentsFromDatabase = ApiClient.GetData("api/Apartments/" + apartment.ApartmentId); IEnumerable<Apartment> apartmentslist = JsonConvert.DeserializeObject<IEnumerable<Apartment>>(apartmentsFromDatabase); BoardMemberViewModel.BoardMemberCatalogSingleton.Apartment.Clear(); @@ -100,16 +100,16 @@ namespace ApartmentManager.Handler try { Apartment apartment = new Apartment(); - apartment.ApartmentNumber = BoardMemberViewModel.ApartmentsNumber; + apartment.ApartmentId = BoardMemberViewModel.ApartmentsNumber; apartment.Address = BoardMemberViewModel.NewApartment.Address; apartment.Floor = BoardMemberViewModel.NewApartment.Floor; apartment.MonthlyCharge = BoardMemberViewModel.NewApartment.MonthlyCharge; apartment.NumberOfRooms = BoardMemberViewModel.NewApartment.NumberOfRooms; apartment.Size = BoardMemberViewModel.NewApartment.Size; - ApiClient.DeleteData("api/Apartments/" + apartment.ApartmentNumber); + ApiClient.DeleteData("api/Apartments/" + apartment.ApartmentId); - var apartmentsFromDatabase = ApiClient.GetData("api/Apartments/" + apartment.ApartmentNumber); + var apartmentsFromDatabase = ApiClient.GetData("api/Apartments/" + apartment.ApartmentId); IEnumerable<Apartment> apartmentslist = JsonConvert.DeserializeObject<IEnumerable<Apartment>>(apartmentsFromDatabase); BoardMemberViewModel.BoardMemberCatalogSingleton.Apartment.Clear(); diff --git a/ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs b/ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs index b012ce1..3f6086e 100644 --- a/ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs @@ -22,9 +22,9 @@ namespace ApartmentManager.Handler public void GetApartmentsResidents() { Resident resident = new Resident(); - resident.ApartmentNr = BoardMemberViewModel.ApartmentsNumber; + resident.ApartmentId = BoardMemberViewModel.ApartmentsNumber; - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr); + var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Clear(); @@ -41,7 +41,7 @@ namespace ApartmentManager.Handler { Resident resident = new Resident(); - resident.ApartmentNr = BoardMemberViewModel.ApartmentsNumber; + resident.ApartmentId = BoardMemberViewModel.ApartmentsNumber; resident.FirstName = BoardMemberViewModel.NewResident.FirstName; resident.LastName = BoardMemberViewModel.NewResident.LastName; resident.BirthDate = BoardMemberViewModel.NewResident.BirthDate; @@ -51,7 +51,7 @@ namespace ApartmentManager.Handler ApiClient.PostData("api/residents/", resident); - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr); + var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Clear(); @@ -72,8 +72,8 @@ namespace ApartmentManager.Handler try { Resident resident = new Resident(); - resident.ResidentNr = BoardMemberViewModel.NewResident.ResidentNr; - resident.ApartmentNr = BoardMemberViewModel.ApartmentsNumber; + resident.ResidentId = BoardMemberViewModel.NewResident.ResidentId; + resident.ApartmentId = BoardMemberViewModel.ApartmentsNumber; resident.FirstName = BoardMemberViewModel.NewResident.FirstName; resident.LastName = BoardMemberViewModel.NewResident.LastName; resident.BirthDate = BoardMemberViewModel.NewResident.BirthDate; @@ -81,9 +81,9 @@ namespace ApartmentManager.Handler resident.Picture = BoardMemberViewModel.NewResident.Picture; resident.Phone = BoardMemberViewModel.NewResident.Phone; - ApiClient.DeleteData("api/residents/" + resident.ResidentNr); + ApiClient.DeleteData("api/residents/" + resident.ResidentId); - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr); + var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Clear(); @@ -103,8 +103,8 @@ namespace ApartmentManager.Handler try { Resident resident = new Resident(); - resident.ResidentNr = BoardMemberViewModel.NewResident.ResidentNr; - resident.ApartmentNr = BoardMemberViewModel.ApartmentsNumber; + resident.ResidentId = BoardMemberViewModel.NewResident.ResidentId; + resident.ApartmentId = BoardMemberViewModel.ApartmentsNumber; resident.FirstName = BoardMemberViewModel.NewResident.FirstName; resident.LastName = BoardMemberViewModel.NewResident.LastName; resident.BirthDate = BoardMemberViewModel.NewResident.BirthDate; @@ -112,8 +112,8 @@ namespace ApartmentManager.Handler resident.Picture = BoardMemberViewModel.NewResident.Picture; resident.Phone = BoardMemberViewModel.NewResident.Phone; - ApiClient.PutData("api/residents/" + resident.ResidentNr, resident); - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr); + ApiClient.PutData("api/residents/" + resident.ResidentId, resident); + var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); BoardMemberViewModel.BoardMemberCatalogSingleton.Residents.Clear(); diff --git a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs index 4cf5fed..e952e0b 100644 --- a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs @@ -9,7 +9,7 @@ namespace ApartmentManager.Handler { public static void LogIn(string username, string password) { - string serializedUser = ApiClient.GetData($"api/Users/by-username/{username}"); + string serializedUser = ApiClient.GetData($"api/Users/{username}"); if (serializedUser != null) { User user = JsonConvert.DeserializeObject<User>(serializedUser); diff --git a/ApartmentManager/ApartmentManager/Model/Apartment.cs b/ApartmentManager/ApartmentManager/Model/Apartment.cs index 92f1501..06b427d 100644 --- a/ApartmentManager/ApartmentManager/Model/Apartment.cs +++ b/ApartmentManager/ApartmentManager/Model/Apartment.cs @@ -1,33 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ApartmentManager.Model +namespace ApartmentManager.Model { public class Apartment { - public int ApartmentNumber { get; set; } - public string Size { get; set; } - public int NumberOfRooms { get; set; } - public string MonthlyCharge { get; set; } - public int Floor { get; set; } + public int ApartmentId { get; set; } + public double? Size { get; set; } + public int? NumberOfRooms { get; set; } + public double? MonthlyCharge { get; set; } + public int? Floor { get; set; } public string Address { get; set; } - public string PlanPicture { get; set; } + public byte[] PlanPicture { get; set; } public Apartment() { } - public Apartment(int ApartmentNumber, string Size,int NumberOfRooms,string MonthlyCharge,int Floor, string Address) + public Apartment(int apartmentId, double? size, int? numberOfRooms, double? monthlyCharge, int? floor, string address) { - this.ApartmentNumber = ApartmentNumber; - this.Size = Size; - this.NumberOfRooms = NumberOfRooms; - this.MonthlyCharge = MonthlyCharge; - this.Floor = Floor; - this.Address = Address; - - + ApartmentId = apartmentId; + Size = size; + NumberOfRooms = numberOfRooms; + MonthlyCharge = monthlyCharge; + Floor = floor; + Address = address; } //public override string ToString() @@ -39,10 +31,7 @@ namespace ApartmentManager.Model public override string ToString() { - return string.Format( - $"Apartment No: {ApartmentNumber} Size: {Size} NoOfRooms: {NumberOfRooms}" + - $" MonthlyCharge: {MonthlyCharge} Floor: {Floor} Address {Address}" - ); + return string.Format($"Apartment number: {ApartmentId}, Size: {Size} Number of rooms: {NumberOfRooms}, Monthly charge: {MonthlyCharge}, Floor: {Floor}, Address: {Address}"); } } } diff --git a/ApartmentManager/ApartmentManager/Model/Defect.cs b/ApartmentManager/ApartmentManager/Model/Defect.cs index 5d97831..afb29e2 100644 --- a/ApartmentManager/ApartmentManager/Model/Defect.cs +++ b/ApartmentManager/ApartmentManager/Model/Defect.cs @@ -1,43 +1,30 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Windows.UI.Xaml.Controls; namespace ApartmentManager.Model { public class Defect { - public int DefectNumber { get; set; } - public int ApartmentNumber { get; set; } + public int DefectId { get; set; } + public int ApartmentId { get; set; } public string Name { get; set; } - public DateTime DateUploaded { get; set; } - public string Picture { get; set; } - public string Picture2 { get; set; } - public string Picture3 { get; set; } - public string Description { get; set; } - public string Comment { get; set; } + public DateTime? UploadDate { get; set; } + public string Description { get; set; } public string Status { get; set; } public Defect() { } - public Defect( int ApartmentNumber, string Name, DateTime DateUploaded, string Picture, string Picture2, string Picture3, string Description, string Comment, string Status) + public Defect(int defectId, int apartmentId, string name, DateTime? uploadDate, string description, string status) { - - this.ApartmentNumber = ApartmentNumber; - this.Name = Name; - this.DateUploaded = DateUploaded; - this.Picture = Picture; - this.Picture2 = Picture2; - this.Picture3 = Picture3; - this.Description = Description; - this.Comment = Comment; - this.Status = Status; + DefectId = defectId; + ApartmentId = apartmentId; + Name = name; + UploadDate = uploadDate; + Description = description; + Status = status; } public override string ToString() { - return string.Format($"Defect Number: {DefectNumber}, Apartment Number: {ApartmentNumber}, Name: {Name}, Date Uploaded {DateUploaded}, {Picture}, {Picture2}, {Picture3}, Description: {Description}, Comment: {Comment}, Status: {Status}"); + return string.Format($"Defect ID: {DefectId}, Apartment number: {ApartmentId}, Name: {Name}, Upload date: {UploadDate}, Description: {Description}, Status: {Status}"); } } } diff --git a/ApartmentManager/ApartmentManager/Model/Resident.cs b/ApartmentManager/ApartmentManager/Model/Resident.cs index 79bf6a1..d897d4b 100644 --- a/ApartmentManager/ApartmentManager/Model/Resident.cs +++ b/ApartmentManager/ApartmentManager/Model/Resident.cs @@ -1,42 +1,35 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Windows.UI.Xaml.Controls; namespace ApartmentManager.Model { public class Resident { + public int ResidentId { get; set; } + public int ApartmentId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } - public int Phone { get; set; } - public DateTimeOffset BirthDate { get; set; } + public DateTime? BirthDate { get; set; } + public string Phone { get; set; } public string Email { get; set; } - public string Picture { get; set; } - public int ApartmentNr { get; set; } - public int ResidentNr { get; set; } + public byte[] Picture { get; set; } public Resident() { - Picture = "https://tracker.moodle.org/secure/attachment/30912/f3.png"; - BirthDate = DateTimeOffset.Now; + BirthDate = DateTime.Now; } - public Resident(string firstName, string lastName, int phone, DateTimeOffset birthDate, string email, int apartmentNr ,int residentNr, string picture) + public Resident(int residentId, int apartmentId, string firstName, string lastName, DateTime birthDate, string phone, string email) { + ResidentId = residentId; + ApartmentId = apartmentId; FirstName = firstName; LastName = lastName; - Phone = phone; BirthDate = birthDate; + Phone = phone; Email = email; - ApartmentNr = apartmentNr; - ResidentNr = residentNr; - Picture = picture; } public override string ToString() { - return string.Format($"Name: {FirstName}, LastName: {LastName}, Birth Date: {BirthDate.Date}, Phone {Phone}, Email {Email} "); + return string.Format($"First name: {FirstName}, Last name: {LastName}, Birth date: {BirthDate.Value.Date}, Phone: {Phone}, Email: {Email} "); } } } diff --git a/ApartmentManager/ApartmentManager/Model/User.cs b/ApartmentManager/ApartmentManager/Model/User.cs index 65fd778..e506791 100644 --- a/ApartmentManager/ApartmentManager/Model/User.cs +++ b/ApartmentManager/ApartmentManager/Model/User.cs @@ -9,34 +9,28 @@ namespace ApartmentManager.Model { public class User { - public int ApartmentNr { get; set; } public string Username { get; set; } + public int ApartmentId { get; set; } public string Password { get; set; } - public string Type { get; set; } + public bool IsBm { get; set; } public string FirstName { get; set; } public string LastName { get; set; } - public DateTime BirthDate { get; set; } + public DateTime? BirthDate { get; set; } public string Phone { get; set; } public string Email { get; set; } - public Image Picture { get; set; } - public string SecondName { get; set; } - public string SecondLastName { get; set; } - public string SecondBirthDate { get; set; } - public string SecondPhone { get; set; } - public string SecondEmail { get; set; } - + public byte[] Picture { get; set; } + public DateTime? MoveInDate { get; set; } + public DateTime? MoveOutDate { get; set; } public User() { } - public User(string FirstName, string LastName, string Phone, DateTime BirthDate, string Email, int ApartmentNr) + public User(string FirstName, string LastName, string Phone, DateTime? BirthDate, string Email, int ApartmentNr) { this.FirstName = FirstName; this.LastName = LastName; - this.Phone = Phone; this.BirthDate = BirthDate; + this.Phone = Phone; this.Email = Email; - this.ApartmentNr = ApartmentNr; - } public override string ToString() diff --git a/ApartmentManager/ApartmentManager/Persistency/PersistenceFacade.cs b/ApartmentManager/ApartmentManager/Persistency/PersistenceFacade.cs index 4948e7d..3a6f85e 100644 --- a/ApartmentManager/ApartmentManager/Persistency/PersistenceFacade.cs +++ b/ApartmentManager/ApartmentManager/Persistency/PersistenceFacade.cs @@ -65,7 +65,7 @@ namespace ApartmentManager.Persistency client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { - string residentsBody = "api/residents/" + resident.ApartmentNr; + string residentsBody = "api/residents/" + resident.ApartmentId; var response = client.GetAsync(residentsBody).Result; if (response.IsSuccessStatusCode) diff --git a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs index 490ac49..95f2323 100644 --- a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs @@ -18,13 +18,10 @@ namespace ApartmentManager.Singletons { Residents = new ObservableCollection<Resident>(); Defects = new ObservableCollection<Defect>(); - Defects.Add(new Defect(1, "Broken Pipe", new DateTime(1988, 8, 8), "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "description", "comment", "status")); - Defects.Add(new Defect(1, "Broken Pipe", new DateTime(1988, 8, 8), "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "description", "comment", "status")); - Defects.Add(new Defect(1, "Broken Pipe", new DateTime(1988, 8, 8), "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "description", "comment", "status")); - Defects.Add(new Defect(1, "Broken Pipe", new DateTime(1988, 8, 8), "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "description", "comment", "status")); - - Defects.Add(new Defect(1, "Broken Pipe", new DateTime(1988, 8, 8), "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "https://cdn.theatlantic.com/assets/media/img/photo/2011/09/vladimir-putin-action-man/p34_DWI22303/main_900.jpg?1420519465", "description", "comment", "status")); - + Defects.Add(new Defect(1, 1, "Broken Pipe", new DateTime(1988, 8, 8), "description", "status")); + Defects.Add(new Defect(1, 1, "Broken Pipe", new DateTime(1988, 8, 8), "description", "status")); + Defects.Add(new Defect(1, 1, "Broken Pipe", new DateTime(1988, 8, 8), "description", "status")); + Defects.Add(new Defect(1, 1, "Broken Pipe", new DateTime(1988, 8, 8), "description", "status")); } } } diff --git a/ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs index 293e4bf..fc2c838 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/BoardMemberViewModel.cs @@ -44,7 +44,7 @@ namespace ApartmentManager.ViewModel BoardMemberHandler = new Handler.BoardMemberHandler(this); BoardMemberCatalogSingleton = BoardMemberCatalogSingleton.Instance; UserSingleton = UserSingleton.Instance; - ApartmentsNumber = UserSingleton.CurrentUser.ApartmentNr; + ApartmentsNumber = UserSingleton.CurrentUser.ApartmentId; CreateApartmentCommand = new RelayCommand(BoardMemberHandler.CreateApartment); DeleteApartmentCommand = new RelayCommand(BoardMemberHandler.DeleteApartment); diff --git a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs index cabee1b..5f3c1b7 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs @@ -68,7 +68,7 @@ namespace ApartmentManager.ViewModel { // When the navigation stack isn't restored, navigate to the first page // suppressing the initial entrance animation. - if (UserSingleton.Instance.CurrentUser.Type == "B") appShell.AppFrame.Navigate(typeof(BoardMembersMainPage)); + if (UserSingleton.Instance.CurrentUser.IsBm) appShell.AppFrame.Navigate(typeof(BoardMembersMainPage)); else appShell.AppFrame.Navigate(typeof(ApartmentPage)); } 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 diff --git a/Diagrams/DCD.vsdx b/Diagrams/DCD.vsdx Binary files differindex b1f8581..9f9e57e 100644 --- a/Diagrams/DCD.vsdx +++ b/Diagrams/DCD.vsdx diff --git a/Diagrams/DatabaseDiagram.vsdx b/Diagrams/DatabaseDiagram.vsdx Binary files differindex 2fc5846..7ff5ed6 100644 --- a/Diagrams/DatabaseDiagram.vsdx +++ b/Diagrams/DatabaseDiagram.vsdx |