/// <summary> /// Create a new resource with a server assigned id. /// </summary> /// <param name="collection">The resource type, in lowercase</param> /// <param name="resource">The data for the Resource to be created</param> /// <returns> /// Returns /// 201 Created - on successful creation /// </returns> public FhirResponse Create(IKey key, Resource resource) { Validate.Key(key); Validate.ResourceType(key, resource); Validate.HasTypeName(key); Validate.HasNoResourceId(key); Validate.HasNoVersion(key); Interaction interaction = Interaction.POST(key, resource); transfer.Internalize(interaction); Store(interaction); // API: The api demands a body. This is wrong Interaction result = store.Get(interaction.Key); transfer.Externalize(result); return(Respond.WithResource(HttpStatusCode.Created, interaction)); }
/// <summary> /// Create a new resource with a server assigned id. /// </summary> /// <param name="collection">The resource type, in lowercase</param> /// <param name="resource">The data for the Resource to be created</param> /// <returns> /// Returns /// 201 Created - on successful creation /// </returns> public FhirResponse Create(IKey key, Resource resource) { Validate.Key(key); Validate.ResourceType(key, resource); Validate.HasTypeName(key); Validate.HasNoResourceId(key); Validate.HasNoVersion(key); Entry entry = Entry.POST(key, resource); transfer.Internalize(entry); Store(entry); // API: The api demands a body. This is wrong //CCR: The documentations specifies that servers should honor the Http return preference header Entry result = fhirStore.Get(entry.Key); transfer.Externalize(result); return(Respond.WithResource(HttpStatusCode.Created, result)); }