diff options
author | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-03 20:54:01 +0200 |
---|---|---|
committer | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-03 20:54:01 +0200 |
commit | 6fd7dd5064f5baed732976b0cfc47101ae52f783 (patch) | |
tree | 08c030c23d64e0be1ac6c18d610e75d699acbb60 | |
parent | 71eb55ef1f2098a5543316f34bc2d820b412fae7 (diff) |
GET: api/Residents/1
m--------- | ApartmentAdmin | 0 | ||||
-rw-r--r-- | ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs | 15 | ||||
-rw-r--r-- | ApartmentManager/ApartmentManager/Model/CatalogSingleton.cs | 8 | ||||
-rw-r--r-- | ApartmentManager/HousingWebAPI/Controllers/ResidentsController.cs | 29 | ||||
-rw-r--r-- | ApartmentManager/HousingWebAPI/HousingWebAPI.csproj | 2 | ||||
-rw-r--r-- | ApartmentManager/HousingWebAPI/ResidentList.cs | 20 | ||||
-rw-r--r-- | ApartmentManager/HousingWebAPI/Web.config | 5 | ||||
-rw-r--r-- | ApartmentManager/HousingWebApi/Models/Resident.cs | 4 | ||||
-rw-r--r-- | HousingDatabase.ldf | bin | 8388608 -> 0 bytes | |||
-rw-r--r-- | HousingDatabase.mdf | bin | 8388608 -> 0 bytes |
10 files changed, 66 insertions, 17 deletions
diff --git a/ApartmentAdmin b/ApartmentAdmin new file mode 160000 +Subproject da22548164ed3a3a9b89f25b31780c35a89a3b3 diff --git a/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs b/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs index 6b6395e..77136fb 100644 --- a/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/ResidentsHandler.cs @@ -18,6 +18,7 @@ namespace ApartmentManager.Handler ApartmentViewModel = apartmenViewModel; } + public void CreateResident() { try @@ -109,7 +110,19 @@ namespace ApartmentManager.Handler new MessageDialog(e.Message).ShowAsync(); } } - + public void GetApartmentResidents() + { + //Resident resident = new Resident(); + //resident.ApartmentNr = ApartmentViewModel.ApartmentNumber; + + + //var roomslist = new PersistenceFacade().GetHotelRooms(roomNumber); + //HotelViewModel.RoomsCatalogSingleton.Rooms.Clear(); + //foreach (var room in roomslist) + //{ + // HotelViewModel.RoomsCatalogSingleton.Rooms.Add(room); + //} + } } diff --git a/ApartmentManager/ApartmentManager/Model/CatalogSingleton.cs b/ApartmentManager/ApartmentManager/Model/CatalogSingleton.cs index 26f7c2e..249a78f 100644 --- a/ApartmentManager/ApartmentManager/Model/CatalogSingleton.cs +++ b/ApartmentManager/ApartmentManager/Model/CatalogSingleton.cs @@ -23,10 +23,10 @@ namespace ApartmentManager.Model Apartment = new ObservableCollection<Apartment>(); Apartment.Add(new Apartment(1,"30 Square meters",2,"200",0,"adresas")); Residents = new ObservableCollection<Resident>(); - Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1)); - Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1)); - Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1)); - Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1)); + Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1,1)); + Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1,1)); + Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1,1)); + Residents.Add(new Resident("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 0, 0, 0), "Bibis@mail.com", 1,1)); } } } diff --git a/ApartmentManager/HousingWebAPI/Controllers/ResidentsController.cs b/ApartmentManager/HousingWebAPI/Controllers/ResidentsController.cs index b744392..e461b1a 100644 --- a/ApartmentManager/HousingWebAPI/Controllers/ResidentsController.cs +++ b/ApartmentManager/HousingWebAPI/Controllers/ResidentsController.cs @@ -22,17 +22,26 @@ namespace HousingWebApi.Controllers return db.Residents; } - // GET: api/Residents/5 - [ResponseType(typeof(Resident))] - public IHttpActionResult GetResident(int id) + // GET: api/Residents/1 + + [Route("api/Residents/{id}")] + [ResponseType(typeof(ResidentList))] + public IQueryable<ResidentList> GetResidents(int id) { - Resident resident = db.Residents.Find(id); - if (resident == null) - { - return NotFound(); - } - - return Ok(resident); + 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 diff --git a/ApartmentManager/HousingWebAPI/HousingWebAPI.csproj b/ApartmentManager/HousingWebAPI/HousingWebAPI.csproj index 462519c..c6e5113 100644 --- a/ApartmentManager/HousingWebAPI/HousingWebAPI.csproj +++ b/ApartmentManager/HousingWebAPI/HousingWebAPI.csproj @@ -199,6 +199,7 @@ <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Models\Resident.cs" /> <Compile Include="Models\User.cs" /> + <Compile Include="ResidentList.cs" /> </ItemGroup> <ItemGroup> <Content Include="Areas\HelpPage\HelpPage.css" /> @@ -254,6 +255,7 @@ </ItemGroup> <ItemGroup> <Folder Include="App_Data\" /> + <Folder Include="test\" /> </ItemGroup> <ItemGroup> <Content Include="fonts\glyphicons-halflings-regular.woff" /> diff --git a/ApartmentManager/HousingWebAPI/ResidentList.cs b/ApartmentManager/HousingWebAPI/ResidentList.cs new file mode 100644 index 0000000..1fd4b30 --- /dev/null +++ b/ApartmentManager/HousingWebAPI/ResidentList.cs @@ -0,0 +1,20 @@ +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 byte[] Picture { get; set; } + + } +}
\ No newline at end of file diff --git a/ApartmentManager/HousingWebAPI/Web.config b/ApartmentManager/HousingWebAPI/Web.config index 309aba0..f50089d 100644 --- a/ApartmentManager/HousingWebAPI/Web.config +++ b/ApartmentManager/HousingWebAPI/Web.config @@ -79,6 +79,7 @@ </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;App=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;App=EntityFramework" providerName="System.Data.SqlClient" /> + <add name="Model1" 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/ApartmentManager/HousingWebApi/Models/Resident.cs b/ApartmentManager/HousingWebApi/Models/Resident.cs index 367631c..4b07bd0 100644 --- a/ApartmentManager/HousingWebApi/Models/Resident.cs +++ b/ApartmentManager/HousingWebApi/Models/Resident.cs @@ -9,9 +9,13 @@ namespace HousingWebApi public partial class Resident { [Key] + [Column(Order = 0)] [DatabaseGenerated(DatabaseGeneratedOption.None)] public int ResidentNr { get; set; } + [Key] + [Column(Order = 1)] + [DatabaseGenerated(DatabaseGeneratedOption.None)] public int ApartmentNr { get; set; } [Required] diff --git a/HousingDatabase.ldf b/HousingDatabase.ldf Binary files differdeleted file mode 100644 index 80e00d5..0000000 --- a/HousingDatabase.ldf +++ /dev/null diff --git a/HousingDatabase.mdf b/HousingDatabase.mdf Binary files differdeleted file mode 100644 index 9fb615b..0000000 --- a/HousingDatabase.mdf +++ /dev/null |