Skip to content

Commit d7efb91

Browse files
committed
RE1-T40 PR#292 fixes
1 parent b496745 commit d7efb91

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

Web/Resgrid.Web/Areas/User/Controllers/DocumentsController.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public async Task<IActionResult> GetDocument(int documentId)
7676
{
7777
var document = await _documentsService.GetDocumentByIdAsync(documentId);
7878

79+
if (document == null)
80+
return NotFound();
81+
7982
if (document.DepartmentId != DepartmentId)
8083
return Unauthorized();
8184

@@ -94,6 +97,9 @@ public async Task<IActionResult> DeleteDocument(int documentId, CancellationToke
9497
{
9598
var document = await _documentsService.GetDocumentByIdAsync(documentId);
9699

100+
if (document == null)
101+
return NotFound();
102+
97103
if (document.DepartmentId != DepartmentId)
98104
return Unauthorized();
99105

@@ -200,6 +206,9 @@ public async Task<IActionResult> EditDocument(int documentId)
200206

201207
var document = await _documentsService.GetDocumentByIdAsync(documentId);
202208

209+
if (document == null)
210+
return NotFound();
211+
203212
if (document.DepartmentId != DepartmentId)
204213
return Unauthorized();
205214

@@ -231,6 +240,9 @@ public async Task<IActionResult> EditDocument(EditDocumentView model, IFormFile
231240
{
232241
var document = await _documentsService.GetDocumentByIdAsync(model.DocumentId);
233242

243+
if (document == null)
244+
return NotFound();
245+
234246
if (document.DepartmentId != DepartmentId)
235247
return Unauthorized();
236248

Web/Resgrid.Web/Areas/User/Controllers/MappingController.cs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ public async Task<IActionResult> ViewType(int poiTypeId)
102102

103103
var type = await _mappingService.GetTypeByIdAsync(poiTypeId);
104104

105-
if (type == null || type.DepartmentId != DepartmentId)
105+
if (type == null)
106+
return NotFound();
107+
108+
if (type.DepartmentId != DepartmentId)
106109
return Unauthorized();
107110

108111
model.Type = type;
@@ -210,7 +213,10 @@ public async Task<IActionResult> EditLayer(string layerId)
210213
model.CenterCoordinates = await _departmentSettingsService.GetMapCenterCoordinatesAsync(model.Department);
211214
var layer = await _mappingService.GetMapLayersByIdAsync(layerId);
212215

213-
if (layer == null || layer.DepartmentId != DepartmentId || layer.IsDeleted)
216+
if (layer == null || layer.IsDeleted)
217+
return NotFound();
218+
219+
if (layer.DepartmentId != DepartmentId)
214220
return Unauthorized();
215221

216222
var feature = layer.Data.Convert();
@@ -262,7 +268,10 @@ public async Task<IActionResult> DeleteLayer(string layerId)
262268

263269
var layer = await _mappingService.GetMapLayersByIdAsync(layerId);
264270

265-
if (layer == null || layer.DepartmentId != DepartmentId || layer.IsDeleted)
271+
if (layer == null || layer.IsDeleted)
272+
return NotFound();
273+
274+
if (layer.DepartmentId != DepartmentId)
266275
return Unauthorized();
267276

268277
layer.IsDeleted = true;
@@ -621,7 +630,10 @@ public async Task<IActionResult> GetTypesMapData(int poiTypeId)
621630

622631
var poiType = await _mappingService.GetTypeByIdAsync(poiTypeId);
623632

624-
if (poiType == null || poiType.DepartmentId != DepartmentId)
633+
if (poiType == null)
634+
return NotFound();
635+
636+
if (poiType.DepartmentId != DepartmentId)
625637
return Unauthorized();
626638

627639
foreach (var poi in poiType.Pois)
@@ -648,7 +660,10 @@ public async Task<IActionResult> GetPoisForType(int poiTypeId)
648660

649661
var poiType = await _mappingService.GetTypeByIdAsync(poiTypeId);
650662

651-
if (poiType == null || poiType.DepartmentId != DepartmentId)
663+
if (poiType == null)
664+
return NotFound();
665+
666+
if (poiType.DepartmentId != DepartmentId)
652667
return Unauthorized();
653668

654669
foreach (var poi in poiType.Pois)
@@ -700,9 +715,15 @@ public async Task<IActionResult> StationRouting(int stationId, int callId)
700715
var station = await _departmentGroupsService.GetGroupByIdAsync(stationId);
701716
var call = await _callsService.GetCallByIdAsync(callId);
702717

718+
if (station == null)
719+
return NotFound();
720+
703721
if (station.DepartmentId != DepartmentId)
704722
return Unauthorized();
705723

724+
if (call == null)
725+
return NotFound();
726+
706727
if (call.DepartmentId != DepartmentId)
707728
return Unauthorized();
708729

0 commit comments

Comments
 (0)