public async Task <FhirResponse> Create(IKey key, Resource resource) { Validate.Key(key); Validate.HasTypeName(key); Validate.ResourceType(key, resource); key = key.CleanupForCreate(); var result = await Store(Entry.Post(key, resource)).ConfigureAwait(false); return(Respond.WithResource(HttpStatusCode.Created, result)); }
public FhirResponse Create(IKey key, Resource resource) { Validate.Key(key); Validate.HasTypeName(key); Validate.ResourceType(key, resource); Validate.HasNoResourceId(key); Validate.HasNoVersion(key); Entry result = Store(Entry.POST(key, resource)); return(Respond.WithResource(HttpStatusCode.Created, result)); }
public FhirResponse Put(Entry entry) { Validate.Key(entry.Key); Validate.ResourceType(entry.Key, entry.Resource); Validate.HasTypeName(entry.Key); Validate.HasResourceId(entry.Key); var storageService = GetFeature <IResourceStorageService>(); Entry current = storageService.Get(entry.Key.WithoutVersion()); Entry result = Store(entry); return(Respond.WithResource(current != null ? HttpStatusCode.OK : HttpStatusCode.Created, result)); }
public FhirResponse Create(Entry entry) { Validate.Key(entry.Key); Validate.HasTypeName(entry.Key); Validate.ResourceType(entry.Key, entry.Resource); if (entry.State != EntryState.Internal) { Validate.HasNoResourceId(entry.Key); Validate.HasNoVersion(entry.Key); } Entry result = Store(entry); return(Respond.WithResource(HttpStatusCode.Created, result)); }
public FhirResponse ValidateOperation(IKey key, Resource resource) { if (resource == null) { throw Error.BadRequest("Validate needs a Resource in the body payload"); } Validate.ResourceType(key, resource); // DSTU2: validation var outcome = Validate.AgainstSchema(resource); if (outcome == null) { return(Respond.WithCode(HttpStatusCode.OK)); } else { return(Respond.WithResource(422, outcome)); } }