/// <summary> /// Deletes a specified resource. /// </summary> /// <param name="id">The identifier.</param> /// <param name="mode">The mode.</param> /// <returns>FhirOperationResult.</returns> /// <exception cref="System.ArgumentNullException">id</exception> /// <exception cref="System.ArgumentException"></exception> public Resource Delete(string id, TransactionMode mode) { if (String.IsNullOrEmpty(id)) { this.m_traceSource.TraceError($"Argument {nameof(id)} is null or empty"); throw new ArgumentNullException(this.m_localizationService.GetString("error.type.ArgumentNullException")); } this.m_traceSource.TraceInfo("Deleting resource {0}/{1}", this.ResourceType, id); // Delete var guidId = Guid.Empty; if (!Guid.TryParse(id, out guidId)) { throw new ArgumentException(m_localizationService.FormatString("error.type.ArgumentException", new { param = "id" })); } // Do the deletion var result = this.Delete(guidId); // Return fhir operation result var retVal = this.MapToFhir(result); return(ExtensionUtil.ExecuteBeforeSendResponseBehavior(TypeRestfulInteraction.Delete, this.ResourceType, retVal)); }
/// <summary> /// Get the message processor type based on resource name /// </summary> public static IFhirResourceHandler GetResourceHandler(string resourceType) { if (string.IsNullOrEmpty(resourceType)) { throw new ArgumentNullException(); } var rtEnum = EnumUtility.ParseLiteral <ResourceType>(resourceType); if (rtEnum.HasValue) { return(GetResourceHandler(rtEnum.Value)); } s_tracer.TraceError($"Resource type {resourceType} is invalid"); throw new KeyNotFoundException(s_localizationService.FormatString("error.messaging.fhir.handlers.invalidResourceType", new { param = resourceType })); }