public async Task <IActionResult> PostPredicate(NamedPredicateVm namedPredicateVm) { Parameters parameters = _parametersProcessorService.ProcessParameters(Request.RouteValues, Request.QueryString); string?query = _sparqlFactoryService.GetFinalPostQueryForPredicate(parameters, namedPredicateVm); if (query != null) { bool successful = await _endpointService.ExecuteUpdateSparqlQueryAsync( parameters.RouteParameters.Endpoint, parameters.RouteParameters.Graph, query); if (successful) { return(Created(new Uri(Request.GetEncodedUrl() + "/" + namedPredicateVm.PredicateCurie), namedPredicateVm)); } } return(BadRequest(new ValidationErrorVm() { CustomError = new CustomErrorVm() { CustomErrorMessage = $"Predicate could not have been created! Check selected endpoint configuration at {UrlHelperClass.GetEndpointUrl(Request.GetEncodedUrl())}.", GeneratedQuery = query } })); }
public string?GetFinalPostQueryForPredicate(Parameters parameters, NamedPredicateVm namedPredicateVm) { string resourceCurie = parameters.RouteParameters.Resource; string predicateCurie = namedPredicateVm.PredicateCurie; if (_namespaceFactoryService.GetAbsoluteUriFromQname(resourceCurie, out string resourceAbsoluteUri) && _namespaceFactoryService.GetAbsoluteUriFromQname(predicateCurie, out string predicateAbsoluteUri)) { string?insertQuery = ConstructInsertPredicateQueryString(namedPredicateVm, resourceAbsoluteUri, predicateAbsoluteUri); if (string.IsNullOrEmpty(insertQuery)) { return(null); } insertQuery = ImplementFromGraphClauseToInsertDeleteQuery(insertQuery, parameters); return(insertQuery); } return(null); }