/// <summary>
        /// Adds a discussion to the current collection.
        /// </summary>
        /// <param name="discussion">The discussion.</param>
        /// <param name="options">The options to apply before executing the REST API call.</param>
        /// <returns>
        /// A <see cref="DiscussionState"/> instance containing the REST API response.
        /// </returns>
        /// <exception cref="Gx.Rs.Api.GedcomxApplicationException">Thrown if a link to the required resource cannot be found.</exception>
        public DiscussionState AddDiscussion(Discussion discussion, params IStateTransitionOption[] options)
        {
            Link link = GetLink(Rel.DISCUSSIONS);
            if (link == null || link.Href == null)
            {
                throw new GedcomxApplicationException("Unable to add discussion: missing link.");
            }

            FamilySearchPlatform entity = new FamilySearchPlatform();
            entity.AddDiscussion(discussion);
            IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).SetEntity(entity).Build(link.Href, Method.POST);
            return ((FamilySearchStateFactory)this.stateFactory).NewDiscussionState(request, Invoke(request, options), this.Client, this.CurrentAccessToken);
        }
Example #2
0
        public override void Embed(Gedcomx gedcomx)
        {
            FamilySearchPlatform value = gedcomx as FamilySearchPlatform;

            base.Embed(gedcomx);

            if (value != null)
            {
                List <ChildAndParentsRelationship> relationships = value.ChildAndParentsRelationships;
                if (relationships != null)
                {
                    foreach (ChildAndParentsRelationship relationship in relationships)
                    {
                        bool found = false;
                        if (relationship.Id != null)
                        {
                            if (ChildAndParentsRelationships != null)
                            {
                                foreach (ChildAndParentsRelationship target in ChildAndParentsRelationships)
                                {
                                    if (relationship.Id.Equals(target.Id))
                                    {
                                        target.EmbedInt(relationship);
                                        found = true;
                                        break;
                                    }
                                }
                            }
                        }

                        if (!found)
                        {
                            AddChildAndParentsRelationship(relationship);
                        }
                    }
                }

                List <Discussion> discussions = value.Discussions;
                if (discussions != null)
                {
                    foreach (Discussion discussion in discussions)
                    {
                        bool found = false;
                        if (discussion.Id != null)
                        {
                            if (Discussions != null)
                            {
                                foreach (Discussion target in Discussions)
                                {
                                    if (discussion.Id.Equals(target.Id))
                                    {
                                        target.EmbedInt(discussion);
                                        found = true;
                                        break;
                                    }
                                }
                            }
                        }

                        if (!found)
                        {
                            AddDiscussion(discussion);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Adds the child and parents relationships to the collection.
        /// </summary>
        /// <param name="chaps">The child and parent relationships to add.</param>
        /// <param name="options">The options to apply before executing the REST API call.</param>
        /// <returns>
        /// A <see cref="RelationshipsState"/> instance containing the REST API response.
        /// </returns>
        /// <exception cref="Gx.Rs.Api.GedcomxApplicationException">Thrown if a link to the required resource cannot be found.</exception>
        public RelationshipsState AddChildAndParentsRelationships(List<ChildAndParentsRelationship> chaps, params IStateTransitionOption[] options)
        {
            Link link = GetLink(Rel.RELATIONSHIPS);
            if (link == null || link.Href == null)
            {
                throw new GedcomxApplicationException(String.Format("FamilySearch Family Tree at {0} didn't provide a 'relationships' link.", GetUri()));
            }

            FamilySearchPlatform entity = new FamilySearchPlatform();
            entity.ChildAndParentsRelationships = chaps;
            IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(link.Href, Method.POST);
            request.SetEntity(entity);
            return ((FamilyTreeStateFactory)this.stateFactory).NewRelationshipsStateInt(request, Invoke(request, options), this.Client, this.CurrentAccessToken);
        }
 /// <summary>
 /// Adds a child and parents relationship to the current relationships collection.
 /// </summary>
 /// <param name="chap">The relationship to add to the current relationships collection, with the father, mother, and child set as desired.</param>
 /// <param name="options">The options to apply before executing the REST API call.</param>
 /// <returns>
 /// A <see cref="ChildAndParentsRelationshipState"/> instance containing the REST API response.
 /// </returns>
 public ChildAndParentsRelationshipState AddChildAndParentsRelationship(ChildAndParentsRelationship chap, params IStateTransitionOption[] options)
 {
     FamilySearchPlatform entity = new FamilySearchPlatform();
     entity.ChildAndParentsRelationships = new List<ChildAndParentsRelationship>() { chap };
     IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(GetSelfUri(), Method.POST);
     return ((FamilyTreeStateFactory)this.stateFactory).NewChildAndParentsRelationshipState(request, Invoke(request, options), this.Client, this.CurrentAccessToken);
 }