HasNoVersion() public static method

public static HasNoVersion ( IKey key ) : void
key IKey
return void
コード例 #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
 private static void ValidateKey(Key key, bool includeVersion = false)
 {
     Validate.HasTypeName(key);
     Validate.HasResourceId(key);
     if (includeVersion)
     {
         Validate.HasVersion(key);
     }
     else
     {
         Validate.HasNoVersion(key);
     }
     Validate.Key(key);
 }
コード例 #3
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);

            Entry current = fhirStore.Get(key);

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

                Store(deleted);
            }
            return(Respond.WithCode(HttpStatusCode.NoContent));
        }
コード例 #4
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));
        }
コード例 #5
0
        /// <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));
        }
コード例 #6
0
        /// <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));
        }
コード例 #7
0
        public FhirResponse Read(Key key)
        {
            Validate.HasTypeName(key);
            Validate.HasResourceId(key);
            Validate.HasNoVersion(key);
            Validate.Key(key);

            var interaction = store.Get(key);

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