Пример #1
0
        /// <summary>
        /// Delete a resource.
        /// </summary>
        /// <param name="collection">The resource type, in lowercase</param>
        /// <param name="id">The id part of a Resource id</param>
        /// <remarks>
        /// Upon successful deletion the server should return
        ///   * 204 (No Content).
        ///   * If the resource does not exist on the server, the server must return 404 (Not found).
        ///   * Performing this operation on a resource that is already deleted has no effect, and should return 204 (No Content).
        /// </remarks>
        public FhirResponse Delete(IKey key)
        {
            Validate.Key(key);
            Validate.HasNoVersion(key);

            Interaction current = store.Get(key);

            if (current == null)
            {
                return(Respond.NotFound(key));
            }

            if (current.IsPresent)
            {
                // Add a new deleted-entry to mark this entry as deleted
                //Entry deleted = importer.ImportDeleted(location);
                key = generator.NextHistoryKey(key);
                Interaction deleted = Interaction.DELETE(key, DateTimeOffset.UtcNow);

                Store(deleted);
                return(Respond.WithCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(Respond.Gone(current));
            }
        }
Пример #2
0
        public FhirResponse GetFhirResponse(Key key, IEnumerable <object> parameters = null)
        {
            Entry entry = fhirStore.Get(key);

            if (entry == null)
            {
                return(Respond.NotFound(key));
            }
            return(GetFhirResponse(entry, parameters));
        }
        public FhirResponse GetFhirResponse(Key key, IEnumerable <object> parameters = null)
        {
            Interaction interaction = fhirStore.Get(key);

            if (interaction == null)
            {
                return(Respond.NotFound(key));
            }
            return(GetFhirResponse(interaction, parameters));
        }
Пример #4
0
        public decimal GetBasketPrice([FromRoute] Guid basketId)
        {
            IBasket basket = basketCalculator.Baskets.SingleOrDefault(b => b.Id == basketId);

            if (basket == null)
            {
                Respond.NotFound();
            }

            return(basketCalculator.CalculateBasketPrice(basket));
        }
Пример #5
0
        public FhirResponse History(IKey key, HistoryParameters parameters)
        {
            IResourceStorageService storageService = GetFeature <IResourceStorageService>();

            if (storageService.Get(key) == null)
            {
                return(Respond.NotFound(key));
            }
            IHistoryService historyExtension = this.GetFeature <IHistoryService>();

            return(CreateSnapshotResponse(historyExtension.History(key, parameters)));
        }
Пример #6
0
        public ServerFhirResponse GetMetadataResponse(Entry entry, IKey key = null)
        {
            if (entry == null)
            {
                return(Respond.NotFound(key));
            }
            else if (entry.IsDeleted())
            {
                return(Respond.Gone(entry));
            }

            return(Respond.WithMeta(entry));
        }
Пример #7
0
        public ServerFhirResponse GetFhirResponse(Entry entry, IKey key = null, IEnumerable <object> parameters = null)
        {
            if (entry == null)
            {
                return(Respond.NotFound(key));
            }
            if (entry.IsDeleted())
            {
                return(Respond.Gone(entry));
            }

            ServerFhirResponse response = null;

            return(response ?? Respond.WithResource(entry));
        }
Пример #8
0
        public FhirResponse History(Key key, HistoryParameters parameters)
        {
            if (!fhirStore.Exists(key))
            {
                return(Respond.NotFound(key));
            }

            Uri link = localhost.Uri(key);

            IEnumerable <string> keys = fhirStore.History(key, parameters.Since);
            var    snapshot           = pager.CreateSnapshot(Bundle.BundleType.History, link, keys, parameters.SortBy, parameters.Count);
            Bundle bundle             = pager.GetFirstPage(snapshot);

            return(Respond.WithResource(key, bundle));
        }
Пример #9
0
        public FhirResponse History(Key key, DateTimeOffset?since, string sortby)
        {
            if (!store.Exists(key))
            {
                return(Respond.NotFound(key));
            }

            Uri link = localhost.Uri(key);

            IEnumerable <string> keys = store.History(key, since);
            var    snapshot           = pager.CreateSnapshot(Bundle.BundleType.History, link, keys, sortby);
            Bundle bundle             = pager.GetFirstPage(snapshot);

            bundle.Base = localhost.Base.AbsoluteUri;

            return(Respond.WithResource(key, bundle));
        }
Пример #10
0
        public FhirResponse AddMeta(Key key, Parameters parameters)
        {
            Entry entry = fhirStore.Get(key);

            if (entry == null)
            {
                return(Respond.NotFound(key));
            }
            else if (entry.IsDeleted())
            {
                return(Respond.Gone(entry));
            }

            entry.Resource.AffixTags(parameters);
            Store(entry);

            return(Respond.WithMeta(entry));
        }
Пример #11
0
        public FhirResponse AddMeta(Key key, Parameters parameters)
        {
            Interaction interaction = fhirStore.Get(key);

            if (interaction == null)
            {
                return(Respond.NotFound(key));
            }
            else if (interaction.IsDeleted())
            {
                return(Respond.Gone(interaction));
            }

            interaction.Resource.AffixTags(parameters);
            Store(interaction);

            return(Respond.WithMeta(interaction));
        }
Пример #12
0
        public FhirResponse ReadMeta(Key key)
        {
            _log.ServiceMethodCalled("readmeta");

            ValidateKey(key);

            Entry entry = fhirStore.Get(key);

            if (entry == null)
            {
                return(Respond.NotFound(key));
            }
            else if (entry.IsDeleted())
            {
                return(Respond.Gone(entry));
            }

            return(Respond.WithMeta(entry));
        }
Пример #13
0
        public FhirResponse ReadMeta(Key key)
        {
            _log.ServiceMethodCalled("readmeta");

            ValidateKey(key);

            Interaction interaction = fhirStore.Get(key);

            if (interaction == null)
            {
                return(Respond.NotFound(key));
            }
            else if (interaction.IsDeleted())
            {
                return(Respond.Gone(interaction));
            }

            return(Respond.WithMeta(interaction));
        }
Пример #14
0
        public FhirResponse GetFhirResponse(Entry entry, IKey key = null, IEnumerable <object> parameters = null)
        {
            if (entry == null)
            {
                return(Respond.NotFound(key));
            }
            if (entry.IsDeleted())
            {
                return(Respond.Gone(entry));
            }

            FhirResponse response = null;

            if (parameters != null)
            {
                response = interceptorRunner.RunInterceptors(entry, parameters);
            }

            return(response ?? Respond.WithResource(entry));
        }
Пример #15
0
        public FhirResponse ReadMeta(Key key)
        {
            Validate.HasTypeName(key);
            Validate.HasResourceId(key);
            Validate.HasNoVersion(key);
            Validate.Key(key);

            Interaction interaction = store.Get(key);

            if (interaction == null)
            {
                return(Respond.NotFound(key));
            }
            else if (interaction.IsDeleted())
            {
                return(Respond.Gone(interaction));
            }

            return(Respond.WithMeta(interaction));
        }
Пример #16
0
        /// <summary>
        /// Read the state of a specific version of the resource.
        /// </summary>
        /// <param name="collectionName">The resource type, in lowercase</param>
        /// <param name="id">The id part of a version-specific reference</param>
        /// <param name="vid">The version part of a version-specific reference</param>
        /// <returns>A Result containing the resource, or an Issue</returns>
        /// <remarks>
        /// If the version referred to is actually one where the resource was deleted, the server should return a
        /// 410 status code.
        /// </remarks>
        public FhirResponse VersionRead(Key key)
        {
            Validate.HasTypeName(key);
            Validate.HasResourceId(key);
            Validate.HasVersion(key);
            Validate.Key(key);

            Interaction interaction = store.Get(key);

            if (interaction == null)
            {
                return(Respond.NotFound(key));
            }

            else if (interaction.IsDeleted())
            {
                return(Respond.Gone(interaction));
            }

            transfer.Externalize(interaction);
            return(Respond.WithResource(interaction));
        }