public async Task <IActionResult> Delete(string ResourceName, string id) { System.Diagnostics.Debug.WriteLine("DELETE: " + this.Request.GetDisplayUrl()); var buri = this.CalculateBaseURI("{ResourceName}"); var Inputs = GetInputs(buri); if (ResourceName == "AuditEvent") { // depends on the AuditEvent, if was created by the server, then it will get an unauthorized exception report // otherwise externally reported events can be updated! //throw new FhirServerException(HttpStatusCode.MethodNotAllowed, "Cannot DELETE a AuditEvent"); } IFhirResourceServiceSTU3 model = GetResourceModel(ResourceName, GetInputs(buri)); string deletedIdentity = await model.Delete(id, null); // Request.Properties.Add(Const.ResourceIdentityKey, deletedIdentity); if (!string.IsNullOrEmpty(deletedIdentity)) { ResourceIdentity ri = new ResourceIdentity(deletedIdentity); return(FhirObjectResult.FhirDeletedResult(ri.VersionId)); } return(FhirObjectResult.FhirDeletedResult()); // for an OperationOutcome return would need to return accepted }
public async Task <IActionResult> Delete(string ResourceName) { System.Diagnostics.Debug.WriteLine("DELETE: " + this.Request.GetDisplayUrl()); var buri = this.CalculateBaseURI("{ResourceName}"); var Inputs = GetInputs(buri); if (Request.TupledParameters(false).Count() == 0) { var oo = new OperationOutcome() { Text = Utility.CreateNarative("Precondition Error") }; oo.Issue = new List <OperationOutcome.IssueComponent> { new OperationOutcome.IssueComponent() { Details = new CodeableConcept(null, null, "Conditionally deleting a " + ResourceName + " requires parameters"), Severity = OperationOutcome.IssueSeverity.Fatal } }; return(new FhirObjectResult(HttpStatusCode.BadRequest, oo)); } if (ResourceName == "AuditEvent") { // depends on the AuditEvent, if was created by the server, then it will get an unauthorized exception report // otherwise externally reported events can be updated! //throw new FhirServerException(HttpStatusCode.MethodNotAllowed, "Cannot DELETE a AuditEvent"); } IFhirResourceServiceSTU3 model = GetResourceModel(ResourceName, GetInputs(buri)); string ifMatch = Request.RequestUri().Query; if (ifMatch.StartsWith("?")) { ifMatch = ifMatch.Substring(1); } string deletedIdentity = await model.Delete(null, ifMatch); // Request.Properties.Add(Const.ResourceIdentityKey, deletedIdentity); if (!string.IsNullOrEmpty(deletedIdentity)) { ResourceIdentity ri = new ResourceIdentity(deletedIdentity); return(FhirObjectResult.FhirDeletedResult(ri.VersionId)); } return(FhirObjectResult.FhirDeletedResult()); // for an OperationOutcome return would need to return accepted }