diff options
-rw-r--r-- | ApartmentManager/HousingWebApi/Controllers/DefectPicturesController.cs | 37 | ||||
-rw-r--r-- | ApartmentManager/HousingWebApi/HousingWebApi.csproj | 2 |
2 files changed, 15 insertions, 24 deletions
diff --git a/ApartmentManager/HousingWebApi/Controllers/DefectPicturesController.cs b/ApartmentManager/HousingWebApi/Controllers/DefectPicturesController.cs index 2c42471..f149bfe 100644 --- a/ApartmentManager/HousingWebApi/Controllers/DefectPicturesController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/DefectPicturesController.cs @@ -16,15 +16,21 @@ namespace HousingWebApi.Controllers { private DataModel db = new DataModel(); - [Route("api/DefectPictures/{id}")] - public IQueryable<DefectPicture> GetResidents(int id) + //GET: api/DefectPicturesById + [Route("api/DefectPicturesById/{id}")] + public IQueryable<DefectPicture> GetDefectPicturesById(int id) { - var pictureslist = from defectPicture in db.DefectPictures - where (defectPicture.DefectId == id) - select defectPicture; - return pictureslist; + var picturesList = from defectPicture in db.DefectPictures + where (defectPicture.DefectId == id) + select defectPicture; + return picturesList; + } + + // GET: api/DefectPictures + public IQueryable<DefectPicture> GetDefectPictures() + { + return db.DefectPictures; } - // GET: api/DefectPictures/5 [ResponseType(typeof(DefectPicture))] @@ -84,22 +90,7 @@ namespace HousingWebApi.Controllers } db.DefectPictures.Add(defectPicture); - - try - { - db.SaveChanges(); - } - catch (DbUpdateException) - { - if (DefectPictureExists(defectPicture.PictureId)) - { - return Conflict(); - } - else - { - throw; - } - } + db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = defectPicture.PictureId }, defectPicture); } diff --git a/ApartmentManager/HousingWebApi/HousingWebApi.csproj b/ApartmentManager/HousingWebApi/HousingWebApi.csproj index b009a06..407d4b0 100644 --- a/ApartmentManager/HousingWebApi/HousingWebApi.csproj +++ b/ApartmentManager/HousingWebApi/HousingWebApi.csproj @@ -151,6 +151,7 @@ </Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="Controllers\DefectPicturesController.cs" />
<Compile Include="Models\Apartment.cs" />
<Compile Include="Models\ApartmentChange.cs" />
<Compile Include="Models\ApartmentResident.cs" />
@@ -193,7 +194,6 @@ <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="Controllers\PastUsersController.cs" />
|