private bool DeleteProcessing(Bundle.EntryComponent DeleteEntry, int DeleteEntryIndex) { IRequestMeta RequestMeta = IRequestMetaFactory.CreateRequestMeta().Set(DeleteEntry.Request); RequestMeta.RequestHeader.Prefer = _RequestHeader.Prefer; IResourceServiceOutcome ResourceServiceOutcome = null; if (RequestMeta.SearchParameterGeneric.ParameterList.Count > 0) { ResourceServiceOutcome = IResourceServices.ConditionalDelete(RequestMeta); } else { ResourceServiceOutcome = IResourceServices.Delete(RequestMeta.PyroRequestUri.FhirRequestUri.ResourceId, RequestMeta); } if (ResourceServiceOutcome.SuccessfulTransaction) { DeleteEntry.Response = new Bundle.ResponseComponent(); DeleteEntry.Response.Status = FormatHTTPStatusCodeAsString(ResourceServiceOutcome.HttpStatusCode); DeleteEntry.FullUrl = null; if (ResourceServiceOutcome.ResourceResult != null) { if (ResourceServiceOutcome.ResourceResult.ResourceType == ResourceType.OperationOutcome) { DeleteEntry.Response.Outcome = ResourceServiceOutcome.ResourceResult; } else { DeleteEntry.Resource = ResourceServiceOutcome.ResourceResult; } } if (ResourceServiceOutcome.LastModified != null && ResourceServiceOutcome.ResourceVersionNumber != null) { DeleteEntry.Response.Etag = HttpHeaderSupport.GetEntityTagHeaderValueFromVersion(ResourceServiceOutcome.ResourceVersionNumber).ToString(); DeleteEntry.Response.LastModified = ResourceServiceOutcome.LastModified; } return(true); } else { if (ResourceServiceOutcome.ResourceResult != null && ResourceServiceOutcome.ResourceResult is OperationOutcome Op) { IdentifieBatchEntityToClient(Op, DeleteEntry.FullUrl, "DELETE", DeleteEntryIndex); } _ServiceOperationOutcome = ResourceServiceOutcome; return(false); } }
public IResourceServiceOutcome Delete(string BaseRequestUri, HttpRequestMessage Request, string ResourceName, string id) { using (DbContextTransaction Transaction = IUnitOfWork.BeginTransaction()) { try { IRequestServiceRootValidate.Validate(BaseRequestUri); IRequestMeta RequestMeta = IRequestMetaFactory.CreateRequestMeta().Set(Request); IResourceServiceOutcome ResourceServiceOutcome = IResourceApiServices.Delete(id, RequestMeta); ResourceServiceOutcome.SummaryType = RequestMeta.SearchParameterGeneric.SummaryType; Transaction.Commit(); return(ResourceServiceOutcome); } catch (Exception Exec) { Transaction.Rollback(); ILog.Error(Exec, $"PyroService.Delete, Request: {Request.RequestUri.OriginalString}"); throw new PyroException(System.Net.HttpStatusCode.InternalServerError, Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Error, OperationOutcome.IssueType.Exception, Exec.Message), Exec.Message); } } }