aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <marcin@zelent.net>2017-05-30 10:56:11 +0200
committermarcinzelent <marcin@zelent.net>2017-05-30 10:56:11 +0200
commit30f9eae5903c4eaf99523cbfc49c0eeaef35520d (patch)
tree4b5f6673a1d29f0193495f52ffd4bb512ca555ea
parent8d651eff96f623cba3e75d5474a7e69736962db5 (diff)
Fixed deleting defect pictures.
-rw-r--r--ApartmentManager/HousingWebApi/Controllers/DefectPicturesController.cs37
-rw-r--r--ApartmentManager/HousingWebApi/HousingWebApi.csproj2
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" />