Esempio n. 1
0
        /// <summary>
        /// Update a PSet.
        /// </summary>
        /// <param name="updatedPSet">The updated PSet (which contains the updated properties).</param>
        /// <returns>The updated PSet.</returns>
        private async Task <PSet> UpdatePSet(PSet updatedPSet)
        {
            if (updatedPSet != null)
            {
                var updatePSetRequest = new PutPSetRequest // In case of PSets the PutPSetRequest is used both for creation and for updating
                {
                    LibraryId    = updatedPSet.LibraryId,
                    DefinitionId = updatedPSet.DefinitionId,
                    Link         = updatedPSet.Link,
                    Props        = updatedPSet.Props,
                };

                Console.Write($"Updating PSet with LibraryId={updatePSetRequest.LibraryId}, DefinitionId={updatePSetRequest.DefinitionId}, Link={updatePSetRequest.Link}...");
                foreach (var prop in updatePSetRequest.Props)
                {
                    Console.Write($" {prop.Key}={prop.Value}");
                }

                Console.WriteLine("...");

                PSet pset = await this.psetClient.PutPSetAsync(updatePSetRequest).ConfigureAwait(false);

                Console.Write($"Updated PSet: ");
                this.PrintPSet(pset);
                Console.WriteLine();

                return(pset);
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Create a PSet for a given definition.
        /// </summary>
        /// <param name="definition">The definition for which the PSet is created.</param>
        /// <param name="props">The properties of the PSet.</param>
        /// <returns>The created PSet.</returns>
        private async Task <PSet> CreatePSet(Definition definition, JObject props)
        {
            if (definition != null)
            {
                var createPSetRequest = new PutPSetRequest // In case of PSets the PutPSetRequest is used both for creation and for updating
                {
                    LibraryId    = definition.LibraryId,
                    DefinitionId = definition.Id,
                    Link         = $"CDMServicesDemo:PSet:PSet-{Guid.NewGuid().ToString()}",
                    Props        = props,
                };

                Console.Write($"Creating PSet with LibraryId={createPSetRequest.LibraryId}, DefinitionId={createPSetRequest.DefinitionId}, Link={createPSetRequest.Link}, Props:");
                foreach (var prop in createPSetRequest.Props)
                {
                    Console.Write($" {prop.Key}={prop.Value}");
                }

                Console.WriteLine("...");

                PSet pset = await this.psetClient.PutPSetAsync(createPSetRequest).ConfigureAwait(false);

                Console.Write($"Created PSet: ");
                this.PrintPSet(pset);
                Console.WriteLine();

                return(pset);
            }

            return(null);
        }