aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ApartmentAdmin.odtbin25200 -> 0 bytes
-rw-r--r--ApartmentManager/ApartmentManager/ApartmentManager.csproj1
-rw-r--r--ApartmentManager/ApartmentManager/AppShell.xaml.cs6
-rw-r--r--ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs133
-rw-r--r--ApartmentManager/ApartmentManager/Handler/LoginHandler.cs9
-rw-r--r--ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs2
-rw-r--r--ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml38
-rw-r--r--ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs5
-rw-r--r--ApartmentManager/ApartmentManager/View/BoardMembersPage.xaml24
-rw-r--r--ApartmentManager/ApartmentManager/View/BoardMembersPage.xaml.cs10
-rw-r--r--ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml2
-rw-r--r--ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs2
-rw-r--r--ApartmentManager/HousingWebAPI/ApartmentResident.cs37
-rw-r--r--ApartmentManager/HousingWebAPI/Controllers/ApartmentResidentsController.cs133
-rw-r--r--ApartmentManager/HousingWebAPI/Models/ApartmentResident.cs37
-rw-r--r--ApartmentManager/HousingWebAPI/Models/ListApartmentResidents.cs42
-rw-r--r--ApartmentManager/HousingWebAPI/Models/database_firewall_rules.cs38
-rw-r--r--ApartmentManager/HousingWebAPI/ViewContext.cs41
-rw-r--r--ApartmentManager/HousingWebAPI/database_firewall_rules.cs38
-rw-r--r--ApartmentManager/HousingWebApi/HousingWebAPI.csproj7
-rw-r--r--ApartmentManager/HousingWebApi/HousingWebApi.csproj7
-rw-r--r--ApartmentManager/HousingWebApi/Web.config9
-rw-r--r--Diagrams/Add-remove-edit apartment SSD.vsdxbin0 -> 46730 bytes
-rw-r--r--Diagrams/Add-remove-edit resident SSD.vsdxbin0 -> 46594 bytes
-rw-r--r--Diagrams/Add-remove-edit user SSD.vsdxbin0 -> 46514 bytes
-rw-r--r--Diagrams/Domain Model.vsdxbin0 -> 38859 bytes
-rw-r--r--Diagrams/Use Case Diagram.vsdxbin0 -> 26390 bytes
-rw-r--r--Report.odtbin0 -> 27672 bytes
-rw-r--r--Test queries/deleteapartmentanduser.sql2
-rw-r--r--Test queries/insertapartmentanduser.sql2
-rw-r--r--Test queries/selectapartmentanduser.sql1
-rw-r--r--Test queries/updateapartmentanduser.sql2
-rw-r--r--Use cases.odtbin0 -> 6884 bytes
33 files changed, 584 insertions, 44 deletions
diff --git a/ApartmentAdmin.odt b/ApartmentAdmin.odt
deleted file mode 100644
index 470dcd5..0000000
--- a/ApartmentAdmin.odt
+++ /dev/null
Binary files differ
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj
index 8d1bb2b..f15b399 100644
--- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj
+++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj
@@ -101,6 +101,7 @@
<Compile Include="Common\RelayCommand.cs" />
<Compile Include="Controls\NavMenuListView.cs" />
<Compile Include="Handler\BoardApartmentsHandler.cs" />
+ <Compile Include="Handler\BoardResidentsHandler.cs" />
<Compile Include="Handler\LoginHandler.cs" />
<Compile Include="Handler\ApartmentHandler.cs" />
<Compile Include="Model\Apartment.cs" />
diff --git a/ApartmentManager/ApartmentManager/AppShell.xaml.cs b/ApartmentManager/ApartmentManager/AppShell.xaml.cs
index 9d4abe5..121989c 100644
--- a/ApartmentManager/ApartmentManager/AppShell.xaml.cs
+++ b/ApartmentManager/ApartmentManager/AppShell.xaml.cs
@@ -102,14 +102,14 @@ namespace ApartmentManager
{
InitializeComponent();
- if (UserSingleton.CurrentUser.Type == "B") navMenuItems = boardMemberMenuItems;
+ if (UserSingleton.Instance.CurrentUser.Type == "B") navMenuItems = boardMemberMenuItems;
else navMenuItems = normalUserMenuItems;
List<NavMenuItem> topNavMenuItems = navMenuItems.GetRange(0, navMenuItems.Count);
- // List<NavMenuItem> bottomNavMenuItems = navMenuItems.GetRange(3, 2);
+ //List<NavMenuItem> bottomNavMenuItems = navMenuItems.GetRange(3, 2);
NavMenuList.ItemsSource = topNavMenuItems;
- // NavMenuList2.ItemsSource = bottomNavMenuItems;
+ //NavMenuList2.ItemsSource = bottomNavMenuItems;
}
public Frame AppFrame { get { return Frame; } }
diff --git a/ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs b/ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs
new file mode 100644
index 0000000..d33d3a3
--- /dev/null
+++ b/ApartmentManager/ApartmentManager/Handler/BoardResidentsHandler.cs
@@ -0,0 +1,133 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Windows.UI.Popups;
+using ApartmentManager.Model;
+using ApartmentManager.Persistency;
+using ApartmentManager.ViewModel;
+using Newtonsoft.Json;
+
+namespace ApartmentManager.Handler
+{
+ class BoardResidentsHandler
+ {
+ public ApartmentsViewModel ApartmentsViewModel { get; set; }
+
+ public BoardResidentsHandler(ApartmentsViewModel apartmentsViewModel)
+ {
+ ApartmentsViewModel = apartmentsViewModel;
+ }
+ public void GetApartmentsResidents()
+ {
+ Resident resident = new Resident();
+ resident.ApartmentNr = ApartmentsViewModel.ApartmentsNumber;
+
+ var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr);
+ IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase);
+
+ ApartmentsViewModel.ApartmentsCatalogSingleton.Residents.Clear();
+ ApartmentsViewModel.NewResident = new Resident();
+ foreach (var resident2 in residentlist)
+ {
+ ApartmentsViewModel.ApartmentsCatalogSingleton.Residents.Add(resident2);
+ }
+
+ }
+
+ public void CreateResident()
+ {
+ try
+ {
+ Resident resident = new Resident();
+
+ resident.ApartmentNr = ApartmentsViewModel.ApartmentsNumber;
+ resident.FirstName = ApartmentsViewModel.NewResident.FirstName;
+ resident.LastName = ApartmentsViewModel.NewResident.LastName;
+ resident.BirthDate = ApartmentsViewModel.NewResident.BirthDate;
+ resident.Email = ApartmentsViewModel.NewResident.Email;
+ resident.Picture = ApartmentsViewModel.NewResident.Picture;
+ resident.Phone = ApartmentsViewModel.NewResident.Phone;
+
+ ApiClient.PostData("api/residents/", resident);
+
+ var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr);
+ IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase);
+
+ ApartmentsViewModel.ApartmentsCatalogSingleton.Residents.Clear();
+ ApartmentsViewModel.NewResident = new Resident();
+ foreach (var resident2 in residentlist)
+ {
+ ApartmentsViewModel.ApartmentsCatalogSingleton.Residents.Add(resident2);
+ }
+ }
+ catch (Exception e)
+ {
+ new MessageDialog(e.Message).ShowAsync();
+ }
+ }
+
+ public void DeleteResident()
+ {
+ try
+ {
+ Resident resident = new Resident();
+ resident.ResidentNr = ApartmentsViewModel.NewResident.ResidentNr;
+ resident.ApartmentNr = ApartmentsViewModel.ApartmentsNumber;
+ resident.FirstName = ApartmentsViewModel.NewResident.FirstName;
+ resident.LastName = ApartmentsViewModel.NewResident.LastName;
+ resident.BirthDate = ApartmentsViewModel.NewResident.BirthDate;
+ resident.Email = ApartmentsViewModel.NewResident.Email;
+ resident.Picture = ApartmentsViewModel.NewResident.Picture;
+ resident.Phone = ApartmentsViewModel.NewResident.Phone;
+
+ ApiClient.DeleteData("api/residents/" + resident.ResidentNr);
+
+ var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr);
+ IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase);
+
+ ApartmentsViewModel.ApartmentsCatalogSingleton.Residents.Clear();
+ ApartmentsViewModel.NewResident = new Resident();
+ foreach (var resident2 in residentlist)
+ {
+ ApartmentsViewModel.ApartmentsCatalogSingleton.Residents.Add(resident2);
+ }
+ }
+ catch (Exception e)
+ {
+ new MessageDialog(e.Message).ShowAsync();
+ }
+ }
+ public void UpdateResident()
+ {
+ try
+ {
+ Resident resident = new Resident();
+ resident.ResidentNr = ApartmentsViewModel.NewResident.ResidentNr;
+ resident.ApartmentNr = ApartmentsViewModel.ApartmentsNumber;
+ resident.FirstName = ApartmentsViewModel.NewResident.FirstName;
+ resident.LastName = ApartmentsViewModel.NewResident.LastName;
+ resident.BirthDate = ApartmentsViewModel.NewResident.BirthDate;
+ resident.Email = ApartmentsViewModel.NewResident.Email;
+ resident.Picture = ApartmentsViewModel.NewResident.Picture;
+ resident.Phone = ApartmentsViewModel.NewResident.Phone;
+
+ ApiClient.PutData("api/residents/" + resident.ResidentNr, resident);
+ var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentNr);
+ IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase);
+
+ ApartmentsViewModel.ApartmentsCatalogSingleton.Residents.Clear();
+ ApartmentsViewModel.NewResident = new Resident();
+ foreach (var resident2 in residentlist)
+ {
+ ApartmentsViewModel.ApartmentsCatalogSingleton.Residents.Add(resident2);
+ }
+ }
+ catch (Exception e)
+ {
+ new MessageDialog(e.Message).ShowAsync();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
index a91fc2b..4cf5fed 100644
--- a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
+++ b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs
@@ -2,10 +2,6 @@
using ApartmentManager.Persistency;
using Newtonsoft.Json;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ApartmentManager.Handler
{
@@ -13,14 +9,13 @@ namespace ApartmentManager.Handler
{
public static void LogIn(string username, string password)
{
-
string serializedUser = ApiClient.GetData($"api/Users/by-username/{username}");
if (serializedUser != null)
{
User user = JsonConvert.DeserializeObject<User>(serializedUser);
if (user.Password == password)
{
- UserSingleton.CurrentUser = user;
+ UserSingleton.Instance.CurrentUser = user;
}
else throw new Exception("Wrong password!");
}
@@ -30,7 +25,7 @@ namespace ApartmentManager.Handler
public static void LogOut()
{
- UserSingleton.CurrentUser = null;
+ UserSingleton.Instance.CurrentUser = null;
}
}
}
diff --git a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs
index 24150c9..e5ca71e 100644
--- a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs
+++ b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs
@@ -9,7 +9,7 @@ namespace ApartmentManager.Model
public class UserSingleton
{
private static UserSingleton instance;
- public static User CurrentUser;
+ public User CurrentUser { get; set; }
private UserSingleton() { }
diff --git a/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml b/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml
index 5deab23..ce8577b 100644
--- a/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml
+++ b/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml
@@ -16,16 +16,36 @@
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
- <StackPanel Margin="0 0" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="top" >
- <Image Source="ms-appx:///Assets/plan.jpg" Margin="0 0" Width="400"></Image>
- <Frame Background="Bisque">
- <ListView HorizontalAlignment="Left" Margin="0,0,50,0" VerticalAlignment="Top" ItemsSource="{Binding ApartmentsCatalogSingleton.Apartment}" SelectedItem="{Binding NewApartment, Mode=TwoWay}"/>
- </Frame>
- <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 100">
- <Button Width="150" Content="New apartment" VerticalAlignment="Bottom" HorizontalAlignment="Center"></Button>
- <Button Width="150" Margin="50 0" Content="Delete apartment" VerticalAlignment="Bottom" HorizontalAlignment="Center"></Button>
- <Button Width="150" Content="Update apartment" VerticalAlignment="Bottom" HorizontalAlignment="Center"></Button>
+ <StackPanel Margin="0 0" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="top" Width="1100" >
+ <StackPanel Orientation="Vertical">
+ <!--<Image Source="ms-appx:///Assets/plan.jpg" HorizontalAlignment="Left" Margin="0 0" Width="600"></Image>-->
+ <!--<StackPanel HorizontalAlignment="Right" Orientation="Vertical" VerticalAlignment="Top">
+ <TextBlock Margin="0,10,0,10" Text="Apartment information:" HorizontalAlignment="Center" FontSize="20" FontWeight="Bold"/>
+ <TextBlock Margin="0,10,0,10" Text="Apartment size:"/>
+ <TextBox Text="{Binding NewApartment.ApartmentNumber, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Square meters:"/>
+ <TextBox Text="{Binding NewApartment.Size, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Number of rooms:"/>
+ <TextBox Text="{Binding NewApartment.NumberOfRooms}"></TextBox>
+ <TextBlock Margin="0,10,0,10" Text="Monthly charge:"/>
+ <TextBox Text="{Binding NewApartment.MonthlyCharge, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Floor:"/>
+ <TextBox Text="{Binding NewApartment.Floor, Mode=TwoWay}" />
+ <TextBlock Margin="0,10,0,10" Text="Address:" ></TextBlock>
+ <TextBox Text="{Binding NewApartment.Floor, Mode=TwoWay}"></TextBox>
+ </StackPanel>-->
+ <Frame Background="Bisque">
+ <ListView HorizontalAlignment="Left" VerticalAlignment="Top" Width="1100" ItemsSource="{Binding ApartmentsCatalogSingleton.Apartment}" SelectedItem="{Binding NewApartment, Mode=TwoWay}" Height="567"/>
+ </Frame>
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 0">
+ <Button Width="150" Margin="50 0" Content="View residents" Click="ButtonBase_OnClick"></Button>
+ <Button Width="150" Content="New apartment" VerticalAlignment="Bottom" HorizontalAlignment="Center"></Button>
+ <Button Width="150" Margin="50 0" Content="Delete apartment" VerticalAlignment="Bottom" HorizontalAlignment="Center"></Button>
+ <Button Width="150" Content="Update apartment" VerticalAlignment="Bottom" HorizontalAlignment="Center"></Button>
+ </StackPanel>
</StackPanel>
+
+
</StackPanel>
</Grid>
</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs b/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs
index c291b8b..fe460a4 100644
--- a/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs
+++ b/ApartmentManager/ApartmentManager/View/BoardMemberManageApartment.xaml.cs
@@ -26,5 +26,10 @@ namespace ApartmentManager.View
{
this.InitializeComponent();
}
+
+ private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.Frame.Navigate(typeof(InfoForBoardMembers));
+ }
}
}
diff --git a/ApartmentManager/ApartmentManager/View/BoardMembersPage.xaml b/ApartmentManager/ApartmentManager/View/BoardMembersPage.xaml
index b606754..8c72de5 100644
--- a/ApartmentManager/ApartmentManager/View/BoardMembersPage.xaml
+++ b/ApartmentManager/ApartmentManager/View/BoardMembersPage.xaml
@@ -13,23 +13,17 @@
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
-
<StackPanel Orientation="Vertical">
- <TextBlock Text="Welcome to board memeber page" HorizontalAlignment="Center" FontSize="20" Margin="0 10"></TextBlock>
- <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="top" >
- <Image Source="../Assets/Ostbanehus.jpg" Margin="0 0 0 0" Width="450"/>
- <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="270 0">
- <Button Width="150" Height="60" Content="Residents" Click="Apartment" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
- <Button Width="150" Height="60" Margin="0 20" Content="Defects" Click="Defect" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
- <Button Width="150" Height="60" Content="Apartment" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
+ <TextBlock Text="Welcome to board memeber page" HorizontalAlignment="Center" FontSize="30" Margin="0 10"></TextBlock>
+ <StackPanel Orientation="Vertical" HorizontalAlignment="Right" VerticalAlignment="top" >
+ <Image Source="../Assets/Ostbanehus.jpg" Margin="0 0 0 40" Width="600"/>
+ <TextBlock Text="Manage:" FontSize="30" HorizontalAlignment="Center" Margin="0 20"></TextBlock>
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="270 0">
+ <!--<Button Width="150" Height="80" Content="Residents" Click="Residents" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>-->
+ <Button Width="150" Height="80" Margin="150 0" Content="Defects" Click="Defects" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
+ <Button Width="150" Height="80" Margin="100 0" Content="Apartments" Click="Apartments" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
+ </StackPanel>
</StackPanel>
</StackPanel>
- <StackPanel Orientation="Vertical" VerticalAlignment="Center">
- <Frame BorderThickness="50" Background="Bisque">
- <ListView HorizontalAlignment="Left" VerticalAlignment="Center" ItemsSource="{Binding ApartmentsCatalogSingleton.Apartment}" SelectedItem="{Binding NewApartment, Mode=TwoWay}"/>
- </Frame>
- <Button Content="Manage apartment" Width="200" Height="80" Click="ApartmentManage" HorizontalAlignment="Left" Margin="200 0"></Button>
- </StackPanel>
- </StackPanel>
</Grid>
</Page>
diff --git a/ApartmentManager/ApartmentManager/View/BoardMembersPage.xaml.cs b/ApartmentManager/ApartmentManager/View/BoardMembersPage.xaml.cs
index b7eb548..dbf2f45 100644
--- a/ApartmentManager/ApartmentManager/View/BoardMembersPage.xaml.cs
+++ b/ApartmentManager/ApartmentManager/View/BoardMembersPage.xaml.cs
@@ -27,19 +27,19 @@ namespace ApartmentManager.View
this.InitializeComponent();
}
- private void Defect(object sender, RoutedEventArgs e)
+ private void Defects(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(BoardMembersDefectsPage));
}
- private void Apartment(object sender, RoutedEventArgs e)
+ private void Apartments(object sender, RoutedEventArgs e)
{
- this.Frame.Navigate(typeof(InfoForBoardMembers));
+ this.Frame.Navigate(typeof(BoardMemberManageApartment));
}
- private void ApartmentManage(object sender, RoutedEventArgs e)
+ private void Residents(object sender, RoutedEventArgs e)
{
- this.Frame.Navigate(typeof(BoardMemberManageApartment));
+ this.Frame.Navigate(typeof(ApartmentResidentsPage));
}
}
}
diff --git a/ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml b/ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml
index 6ff3559..69d5930 100644
--- a/ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml
+++ b/ApartmentManager/ApartmentManager/View/InfoForBoardMembers.xaml
@@ -17,7 +17,7 @@
<StackPanel Width="650">
<StackPanel>
- <ListView ItemsSource="{Binding ApartmentsCatalogSingleton.Residents}" SelectedItem="{Binding NewResident, Mode=TwoWay}"></ListView>
+ <ListView Width="700" Height="500" ItemsSource="{Binding ApartmentsCatalogSingleton.Residents}" SelectedItem="{Binding NewResident, Mode=TwoWay}"></ListView>
</StackPanel>
</StackPanel>
<StackPanel Margin="50" Orientation="Horizontal" HorizontalAlignment="Right">
diff --git a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs
index 0290053..cb8dfbb 100644
--- a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs
+++ b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs
@@ -69,7 +69,7 @@ namespace ApartmentManager.ViewModel
{
// When the navigation stack isn't restored, navigate to the first page
// suppressing the initial entrance animation.
- if (UserSingleton.CurrentUser.Type == "B") appShell.AppFrame.Navigate(typeof(BoardMembersPage));
+ if (UserSingleton.Instance.CurrentUser.Type == "B") appShell.AppFrame.Navigate(typeof(BoardMembersPage));
else appShell.AppFrame.Navigate(typeof(ApartmentPage));
}
diff --git a/ApartmentManager/HousingWebAPI/ApartmentResident.cs b/ApartmentManager/HousingWebAPI/ApartmentResident.cs
new file mode 100644
index 0000000..092c95f
--- /dev/null
+++ b/ApartmentManager/HousingWebAPI/ApartmentResident.cs
@@ -0,0 +1,37 @@
+namespace HousingWebApi
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel.DataAnnotations;
+ using System.ComponentModel.DataAnnotations.Schema;
+ using System.Data.Entity.Spatial;
+
+ public partial class ApartmentResident
+ {
+ [Key]
+ [Column(Order = 0)]
+ [DatabaseGenerated(DatabaseGeneratedOption.None)]
+ public int ApartmentNumber { get; set; }
+
+ [Key]
+ [Column(Order = 1)]
+ [StringLength(20)]
+ public string FirstName { get; set; }
+
+ [Key]
+ [Column(Order = 2)]
+ [StringLength(20)]
+ public string LastName { get; set; }
+
+ [Column(TypeName = "date")]
+ public DateTime? BirthDate { get; set; }
+
+ public int? PhoneNo { get; set; }
+
+ [StringLength(30)]
+ public string Email { get; set; }
+
+ [Column(TypeName = "image")]
+ public byte[] Picture { get; set; }
+ }
+}
diff --git a/ApartmentManager/HousingWebAPI/Controllers/ApartmentResidentsController.cs b/ApartmentManager/HousingWebAPI/Controllers/ApartmentResidentsController.cs
new file mode 100644
index 0000000..4b5c82a
--- /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 ViewContext db = new ViewContext();
+
+ // 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/Models/ApartmentResident.cs b/ApartmentManager/HousingWebAPI/Models/ApartmentResident.cs
new file mode 100644
index 0000000..f54e72b
--- /dev/null
+++ b/ApartmentManager/HousingWebAPI/Models/ApartmentResident.cs
@@ -0,0 +1,37 @@
+namespace HousingWebApi.Models
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel.DataAnnotations;
+ using System.ComponentModel.DataAnnotations.Schema;
+ using System.Data.Entity.Spatial;
+
+ public partial class ApartmentResident
+ {
+ [Key]
+ [Column(Order = 0)]
+ [DatabaseGenerated(DatabaseGeneratedOption.None)]
+ public int ApartmentNumber { get; set; }
+
+ [Key]
+ [Column(Order = 1)]
+ [StringLength(20)]
+ public string FirstName { get; set; }
+
+ [Key]
+ [Column(Order = 2)]
+ [StringLength(20)]
+ public string LastName { get; set; }
+
+ [Column(TypeName = "date")]
+ public DateTime? BirthDate { get; set; }
+
+ public int? PhoneNo { get; set; }
+
+ [StringLength(30)]
+ public string Email { get; set; }
+
+ [Column(TypeName = "image")]
+ public byte[] Picture { get; set; }
+ }
+}
diff --git a/ApartmentManager/HousingWebAPI/Models/ListApartmentResidents.cs b/ApartmentManager/HousingWebAPI/Models/ListApartmentResidents.cs
new file mode 100644
index 0000000..5d5bffd
--- /dev/null
+++ b/ApartmentManager/HousingWebAPI/Models/ListApartmentResidents.cs
@@ -0,0 +1,42 @@
+namespace HousingWebApi.Models
+{
+ using System;
+ using System.Data.Entity;
+ using System.ComponentModel.DataAnnotations.Schema;
+ using System.Linq;
+
+ public partial class ListApartmentResidents : DbContext
+ {
+ public ListApartmentResidents()
+ : base("name=ListApartmentResidents")
+ {
+ base.Configuration.ProxyCreationEnabled = false;
+ }
+
+ 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<ApartmentResident>()
+ .Property(e => e.FirstName)
+ .IsUnicode(false);
+
+ modelBuilder.Entity<ApartmentResident>()
+ .Property(e => e.LastName)
+ .IsUnicode(false);
+
+ modelBuilder.Entity<ApartmentResident>()
+ .Property(e => e.Email)
+ .IsUnicode(false);
+
+ 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/Models/database_firewall_rules.cs b/ApartmentManager/HousingWebAPI/Models/database_firewall_rules.cs
new file mode 100644
index 0000000..4ea6055
--- /dev/null
+++ b/ApartmentManager/HousingWebAPI/Models/database_firewall_rules.cs
@@ -0,0 +1,38 @@
+namespace HousingWebApi.Models
+{
+ 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/ViewContext.cs b/ApartmentManager/HousingWebAPI/ViewContext.cs
new file mode 100644
index 0000000..9b50fc3
--- /dev/null
+++ b/ApartmentManager/HousingWebAPI/ViewContext.cs
@@ -0,0 +1,41 @@
+namespace HousingWebApi
+{
+ using System;
+ using System.Data.Entity;
+ using System.ComponentModel.DataAnnotations.Schema;
+ using System.Linq;
+
+ public partial class ViewContext : DbContext
+ {
+ public ViewContext()
+ : base("name=ViewContext")
+ {
+ }
+
+ 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<ApartmentResident>()
+ .Property(e => e.FirstName)
+ .IsUnicode(false);
+
+ modelBuilder.Entity<ApartmentResident>()
+ .Property(e => e.LastName)
+ .IsUnicode(false);
+
+ modelBuilder.Entity<ApartmentResident>()
+ .Property(e => e.Email)
+ .IsUnicode(false);
+
+ 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/database_firewall_rules.cs b/ApartmentManager/HousingWebAPI/database_firewall_rules.cs
new file mode 100644
index 0000000..3b5d6a5
--- /dev/null
+++ b/ApartmentManager/HousingWebAPI/database_firewall_rules.cs
@@ -0,0 +1,38 @@
+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/HousingWebAPI.csproj b/ApartmentManager/HousingWebApi/HousingWebAPI.csproj
index 63d4995..da913ec 100644
--- a/ApartmentManager/HousingWebApi/HousingWebAPI.csproj
+++ b/ApartmentManager/HousingWebApi/HousingWebAPI.csproj
@@ -151,6 +151,9 @@
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="ApartmentResident.cs" />
+ <Compile Include="Controllers\ApartmentResidentsController.cs" />
+ <Compile Include="database_firewall_rules.cs" />
<Compile Include="Models\Apartment.cs" />
<Compile Include="Controllers\ApartmentsController.cs" />
<Compile Include="Controllers\DefectsController.cs" />
@@ -191,15 +194,19 @@
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="DataModel.cs" />
+ <Compile Include="Models\ApartmentResident.cs" />
+ <Compile Include="Models\database_firewall_rules.cs" />
<Compile Include="Models\Defect.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
+ <Compile Include="Models\ListApartmentResidents.cs" />
<Compile Include="Models\PastContractOwner.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Models\Resident.cs" />
<Compile Include="Models\ResidentList.cs" />
<Compile Include="Models\User.cs" />
+ <Compile Include="ViewContext.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Areas\HelpPage\HelpPage.css" />
diff --git a/ApartmentManager/HousingWebApi/HousingWebApi.csproj b/ApartmentManager/HousingWebApi/HousingWebApi.csproj
index 63d4995..da913ec 100644
--- a/ApartmentManager/HousingWebApi/HousingWebApi.csproj
+++ b/ApartmentManager/HousingWebApi/HousingWebApi.csproj
@@ -151,6 +151,9 @@
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="ApartmentResident.cs" />
+ <Compile Include="Controllers\ApartmentResidentsController.cs" />
+ <Compile Include="database_firewall_rules.cs" />
<Compile Include="Models\Apartment.cs" />
<Compile Include="Controllers\ApartmentsController.cs" />
<Compile Include="Controllers\DefectsController.cs" />
@@ -191,15 +194,19 @@
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="DataModel.cs" />
+ <Compile Include="Models\ApartmentResident.cs" />
+ <Compile Include="Models\database_firewall_rules.cs" />
<Compile Include="Models\Defect.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
+ <Compile Include="Models\ListApartmentResidents.cs" />
<Compile Include="Models\PastContractOwner.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Models\Resident.cs" />
<Compile Include="Models\ResidentList.cs" />
<Compile Include="Models\User.cs" />
+ <Compile Include="ViewContext.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Areas\HelpPage\HelpPage.css" />
diff --git a/ApartmentManager/HousingWebApi/Web.config b/ApartmentManager/HousingWebApi/Web.config
index 8261278..cab739c 100644
--- a/ApartmentManager/HousingWebApi/Web.config
+++ b/ApartmentManager/HousingWebApi/Web.config
@@ -79,5 +79,10 @@
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
-
-<connectionStrings><add name="DataModel" connectionString="data source=housingdb.database.windows.net;initial catalog=housingdb;persist security info=True;user id=deltaadmin;password=Delta123!;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.SqlClient" /></connectionStrings></configuration> \ No newline at end of file
+ <connectionStrings>
+ <add name="DataModel" connectionString="data source=housingdb.database.windows.net;initial catalog=housingdb;persist security info=True;user id=deltaadmin;password=Delta123!;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.SqlClient" />
+ <add name="ApartmentResidents" 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" />
+ <add name="ViewContext" 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" />
+ <add name="ListApartmentResidents" 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
diff --git a/Diagrams/Add-remove-edit apartment SSD.vsdx b/Diagrams/Add-remove-edit apartment SSD.vsdx
new file mode 100644
index 0000000..dc9670c
--- /dev/null
+++ b/Diagrams/Add-remove-edit apartment SSD.vsdx
Binary files differ
diff --git a/Diagrams/Add-remove-edit resident SSD.vsdx b/Diagrams/Add-remove-edit resident SSD.vsdx
new file mode 100644
index 0000000..d412812
--- /dev/null
+++ b/Diagrams/Add-remove-edit resident SSD.vsdx
Binary files differ
diff --git a/Diagrams/Add-remove-edit user SSD.vsdx b/Diagrams/Add-remove-edit user SSD.vsdx
new file mode 100644
index 0000000..3d9ed00
--- /dev/null
+++ b/Diagrams/Add-remove-edit user SSD.vsdx
Binary files differ
diff --git a/Diagrams/Domain Model.vsdx b/Diagrams/Domain Model.vsdx
new file mode 100644
index 0000000..e34c569
--- /dev/null
+++ b/Diagrams/Domain Model.vsdx
Binary files differ
diff --git a/Diagrams/Use Case Diagram.vsdx b/Diagrams/Use Case Diagram.vsdx
new file mode 100644
index 0000000..4eea820
--- /dev/null
+++ b/Diagrams/Use Case Diagram.vsdx
Binary files differ
diff --git a/Report.odt b/Report.odt
new file mode 100644
index 0000000..eb289fb
--- /dev/null
+++ b/Report.odt
Binary files differ
diff --git a/Test queries/deleteapartmentanduser.sql b/Test queries/deleteapartmentanduser.sql
new file mode 100644
index 0000000..754b098
--- /dev/null
+++ b/Test queries/deleteapartmentanduser.sql
@@ -0,0 +1,2 @@
+DELETE FROM Users WHERE ApartmentNr=3;
+DELETE FROM Apartments WHERE ApartmentNumber=3; \ No newline at end of file
diff --git a/Test queries/insertapartmentanduser.sql b/Test queries/insertapartmentanduser.sql
new file mode 100644
index 0000000..af06738
--- /dev/null
+++ b/Test queries/insertapartmentanduser.sql
@@ -0,0 +1,2 @@
+INSERT INTO Apartments VALUES(3,30,2,'200Dkk',1,'Adres')
+INSERT INTO Users(ApartmentNr,Username,Password,Type,FirstName,LastName,BirthDate,Phone,Email) VALUES(3,'nuser','pass','N','Jan','Kowalski','01/01/1970','34567890','jan@onet.pl') \ No newline at end of file
diff --git a/Test queries/selectapartmentanduser.sql b/Test queries/selectapartmentanduser.sql
new file mode 100644
index 0000000..a3f7ffd
--- /dev/null
+++ b/Test queries/selectapartmentanduser.sql
@@ -0,0 +1 @@
+SELECT * FROM Apartments LEFT JOIN Users ON Apartments.ApartmentNumber=Users.ApartmentNr WHERE Users.LastName='Kowalski' \ No newline at end of file
diff --git a/Test queries/updateapartmentanduser.sql b/Test queries/updateapartmentanduser.sql
new file mode 100644
index 0000000..3ab4192
--- /dev/null
+++ b/Test queries/updateapartmentanduser.sql
@@ -0,0 +1,2 @@
+UPDATE Apartments SET MonthlyCharge='5000' WHERE Size=30
+UPDATE Users SET LastName='Nowak' WHERE ApartmentNr=3; \ No newline at end of file
diff --git a/Use cases.odt b/Use cases.odt
new file mode 100644
index 0000000..5085eae
--- /dev/null
+++ b/Use cases.odt
Binary files differ