コード例 #1
0
        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
        }
コード例 #2
0
        public HttpResponseMessage Delete(string ResourceName, string id)
        {
            System.Diagnostics.Trace.WriteLine("DELETE: " + this.ControllerContext.Request.RequestUri.OriginalString);
            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 = model.Delete(id, null);

            Request.Properties.Add(Const.ResourceIdentityKey, deletedIdentity);

            var msg = Request.CreateResponse(HttpStatusCode.NoContent);

            if (!string.IsNullOrEmpty(deletedIdentity))
            {
                ResourceIdentity ri = new ResourceIdentity(deletedIdentity);
                msg.Headers.Add("ETag", String.Format("W/\"{0}\"", ri.VersionId));
            }
            return(msg);
            // for an OperationOutcome return would need to return accepted
        }
コード例 #3
0
        public HttpResponseMessage Delete(string ResourceName)
        {
            System.Diagnostics.Trace.WriteLine("DELETE: " + this.ControllerContext.Request.RequestUri.OriginalString);
            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 oo;
                return(Request.CreateResponse(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 = model.Delete(null, ifMatch);

            Request.Properties.Add(Const.ResourceIdentityKey, deletedIdentity);

            var msg = Request.CreateResponse(HttpStatusCode.NoContent);

            if (!string.IsNullOrEmpty(deletedIdentity))
            {
                ResourceIdentity ri = new ResourceIdentity(deletedIdentity);
                msg.Headers.Add("ETag", String.Format("W/\"{0}\"", ri.VersionId));
            }
            return(msg);
            // for an OperationOutcome return would need to return accepted
        }
コード例 #4
0
        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
        }