/// <summary>
        /// Serialize the <see cref="SiteDirectoryDataAnnotation"/>
        /// </summary>
        /// <param name="siteDirectoryDataAnnotation">The <see cref="SiteDirectoryDataAnnotation"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(SiteDirectoryDataAnnotation siteDirectoryDataAnnotation)
        {
            var jsonObject = new JObject();

            jsonObject.Add("author", this.PropertySerializerMap["author"](siteDirectoryDataAnnotation.Author));
            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), siteDirectoryDataAnnotation.ClassKind)));
            jsonObject.Add("content", this.PropertySerializerMap["content"](siteDirectoryDataAnnotation.Content));
            jsonObject.Add("createdOn", this.PropertySerializerMap["createdOn"](siteDirectoryDataAnnotation.CreatedOn));
            jsonObject.Add("discussion", this.PropertySerializerMap["discussion"](siteDirectoryDataAnnotation.Discussion.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](siteDirectoryDataAnnotation.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](siteDirectoryDataAnnotation.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](siteDirectoryDataAnnotation.Iid));
            jsonObject.Add("languageCode", this.PropertySerializerMap["languageCode"](siteDirectoryDataAnnotation.LanguageCode));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](siteDirectoryDataAnnotation.ModifiedOn));
            jsonObject.Add("primaryAnnotatedThing", this.PropertySerializerMap["primaryAnnotatedThing"](siteDirectoryDataAnnotation.PrimaryAnnotatedThing));
            jsonObject.Add("relatedThing", this.PropertySerializerMap["relatedThing"](siteDirectoryDataAnnotation.RelatedThing.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](siteDirectoryDataAnnotation.RevisionNumber));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](siteDirectoryDataAnnotation.ThingPreference));
            return(jsonObject);
        }
 /// <summary>
 /// Add an Annotation row view model to the list of <see cref="Annotation"/>
 /// </summary>
 /// <param name="annotation">
 /// The <see cref="Annotation"/> that is to be added
 /// </param>
 private SiteDirectoryDataAnnotationRowViewModel AddAnnotationRowViewModel(SiteDirectoryDataAnnotation annotation)
 {
     return(new SiteDirectoryDataAnnotationRowViewModel(annotation, this.Session, this));
 }
        /// <summary>
        /// Persist the <see cref="SiteDirectoryDataAnnotation"/> containment tree to the ORM layer. Update if it already exists.
        /// This is typically used during the import of existing data to the Database.
        /// </summary>
        /// <param name="transaction">
        /// The current <see cref="NpgsqlTransaction"/> to the database.
        /// </param>
        /// <param name="partition">
        /// The database partition (schema) where the requested resource will be stored.
        /// </param>
        /// <param name="siteDirectoryDataAnnotation">
        /// The <see cref="SiteDirectoryDataAnnotation"/> instance to persist.
        /// </param>
        /// <returns>
        /// True if the persistence was successful.
        /// </returns>
        private bool UpsertContainment(NpgsqlTransaction transaction, string partition, SiteDirectoryDataAnnotation siteDirectoryDataAnnotation)
        {
            var results = new List <bool>();

            foreach (var discussion in this.ResolveFromRequestCache(siteDirectoryDataAnnotation.Discussion))
            {
                results.Add(this.DiscussionService.UpsertConcept(transaction, partition, discussion, siteDirectoryDataAnnotation));
            }

            foreach (var relatedThing in this.ResolveFromRequestCache(siteDirectoryDataAnnotation.RelatedThing))
            {
                results.Add(this.RelatedThingService.UpsertConcept(transaction, partition, relatedThing, siteDirectoryDataAnnotation));
            }

            return(results.All(x => x));
        }