public async Task <IActionResult> OnPostAsync(string specificationId, string subPolicyId) { Guard.IsNullOrWhiteSpace(specificationId, nameof(specificationId)); (Specification specification, IActionResult error)specificationQuery = await GetSpecification(specificationId); if (specificationQuery.error != null) { return(specificationQuery.error); } IsAuthorizedToEdit = await _authorizationHelper.DoesUserHavePermission(User, specificationQuery.specification, SpecificationActionTypes.CanEditSpecification); if (!IsAuthorizedToEdit) { return(new ForbidResult()); } if (!ModelState.IsValid) { PopulateSpecificationProperites(specificationQuery.specification); return(Page()); } EditSubPolicyModel updateSubPolicyModel = _mapper.Map <EditSubPolicyModel>(EditSubPolicyViewModel); updateSubPolicyModel.SpecificationId = specificationId; ValidatedApiResponse <Policy> updateSubPolicyResult = await _specsClient.UpdateSubPolicy(specificationId, subPolicyId, updateSubPolicyModel); if (updateSubPolicyResult.StatusCode == HttpStatusCode.OK) { return(Redirect($"/specs/policies/{specificationId}?operationType=SubpolicyUpdated&operationId={updateSubPolicyResult.Content.Id}")); } else if (updateSubPolicyResult.StatusCode == HttpStatusCode.BadRequest) { updateSubPolicyResult.AddValidationResultErrors(ModelState); Specification specification = specificationQuery.specification; PopulateSpecificationProperites(specification); return(Page()); } else { return(new InternalServerErrorResult($"Unable to update policy. API returned {updateSubPolicyResult.StatusCode}")); } }