Example #1
0
        public Bundle History(string collection, string id, DateTimeOffset?since)
        {
            RequestValidator.ValidateCollectionName(collection);
            RequestValidator.ValidateId(id);

            if (since == null)
            {
                since = DateTimeOffset.MinValue;
            }
            string  title = String.Format("History for updates on '{0}' resource '{1}' since {2}", collection, id, since);
            RestUrl self  = new RestUrl(this.Endpoint).AddPath(collection, id, RestOperation.HISTORY);

            if (!entryExists(collection, id))
            {
                throw new SparkException(HttpStatusCode.NotFound, "There is no history because there is no {0} resource with id {1}.", collection, id);
            }

            var identity = ResourceIdentity.Build(collection, id).OperationPath;
            IEnumerable <BundleEntry> entries = _store.ListVersionsById(identity, since, Const.MAX_HISTORY_RESULT_SIZE);
            Bundle bundle = BundleEntryFactory.CreateBundleWithEntries(title, self.Uri, Const.AUTHOR, Settings.AuthorUri, entries);

            return(exportPagedBundle(bundle));
        }