diff options
16 files changed, 561 insertions, 32 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj index 0bf5485..de07d8e 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\ResidentsHandler.cs" /> <Compile Include="Model\Apartment.cs" /> 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/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/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/Web.config b/ApartmentManager/HousingWebApi/Web.config index 8ea32e7..cab739c 100644 --- a/ApartmentManager/HousingWebApi/Web.config +++ b/ApartmentManager/HousingWebApi/Web.config @@ -80,6 +80,9 @@ </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> + <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 |