/// <summary> /// Retrieves the current contents of a resource. /// </summary> /// <param name="collection">The resource type, in lowercase</param> /// <param name="id">The id part of a Resource id</param> /// <returns>A Result containing the resource, or an Issue</returns> /// <remarks> /// Note: Unknown resources and deleted resources are treated differently on a read: /// * A deleted resource returns a 410 status code /// * an unknown resource returns 404. /// </remarks> public ResourceEntry Read(string collection, string id) { Uri key = BuildKey(collection, id); BundleEntry entry = store.Get(key); if (entry == null) { throwNotFound("Cannot read resource", collection, id); } else if (entry is DeletedEntry) { var deletedentry = (entry as DeletedEntry); var message = String.Format("A {0} resource with id {1} existed, but was deleted on {2} (version {3}).", collection, id, deletedentry.When, new ResourceIdentity(deletedentry.Links.SelfLink).VersionId); throw new SparkException(HttpStatusCode.Gone, message); } ResourceEntry result = (ResourceEntry)entry; exporter.Externalize(result); return(result); }
public Bundle CreateBundle(Snapshot snapshot, int start, int count) { Bundle bundle = new Bundle(); bundle.Title = snapshot.FeedTitle; bundle.TotalResults = snapshot.Count; bundle.Id = Key.NewUuid(); bundle.AuthorName = "Furore Spark FHIR server"; bundle.AuthorUri = "http://fhir.furore.com"; bundle.Links = new UriLinkList(); bundle.Links.SelfLink = new Uri(snapshot.FeedSelfLink); bundle.LastUpdated = snapshot.WhenCreated; IEnumerable <Uri> keys = snapshot.Keys.Skip(start).Take(count); bundle.Entries = store.Get(keys, snapshot.SortBy).ToList(); Include(bundle, snapshot.Includes); buildLinks(bundle, snapshot, start, count); exporter.Externalize(bundle); return(bundle); }