PersonRepository.Archive Method

Archive existing person. All child persons in tree are archived too.

Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public void Archive(
	SimplePersonV1 person
)

Parameters

person  SimplePersonV1
The person.

Implements

ISimpleClientPersonRepositoryV1.Archive(SimplePersonV1)
Example
The following example illustrates how the SimpleClient Archives company with children
C#
using System;
using Gamanet.C4.SDK;
using Gamanet.C4.SimpleInterfaces;

public class Example
{
    static void Main()
    {
        // Create instance of simple client
        var client = new SimpleClient(ConnectorConfiguration.HttpClient);

        ConnectionInfoV1 token;
        // Connect to local server
        var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support", out token);

        if (connectionResult != ConnectionResult.Successful)
        {
            Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult);
            return;
        }

        Console.WriteLine("Connection result: {0}", connectionResult);
        Console.WriteLine();

        // create new instance of SimplePerson
        var company = new SimplePersonV1(
            Guid.NewGuid(),
            EntityRoot.Person,
            PersonCategory.Company);
        company.Data["Surname"] = "Company";

        // create company
        client.Persons.Create(company);

        // create new instance of SimplePerson
        var department = new SimplePersonV1(
            Guid.NewGuid(),
            company.Id,
            PersonCategory.Department);
        department.Data["Surname"] = "Department";

        // create department
        client.Persons.Create(department);

        // create new instance of SimplePerson
        var person = new SimplePersonV1(
            Guid.NewGuid(),
            department.Id,
            PersonCategory.Person);

        person.Data["Surname"] = "Johnson";

        // create person
        client.Persons.Create(person);

        // Check all persons
        var allPersons = client.Persons.GetAll(company.Id, Properties.All, true);
        foreach (var child in allPersons)
        {
            Console.WriteLine($"Name of the person/company: {child.Name}   Is archived: {child.Archived}");
        }
        var loadedCompanyToArchive = client.Persons.Get(company.Id, Properties.All);

        // archive company and all children
        client.Persons.Archive(loadedCompanyToArchive);

        var companyAndChildren = client.Persons.GetAll(company.Id, Properties.All, true);
        foreach (var child in companyAndChildren)
        {
            Console.WriteLine($"Name of the person/company: {child.Name}   Is archived: {child.Archived}");
        }

        // Disconnect from server
        client.Disconnect();
    }
}
The following example illustrates how the SimpleClient archives the single person.
C#
using System;
using Gamanet.C4.SDK;
using Gamanet.C4.SimpleInterfaces;

public class Example
{
    static void Main()
    {
        // Create instance of simple client
        var client = new SimpleClient(ConnectorConfiguration.HttpClient);

        ConnectionInfoV1 token;
        // Connect to local server
        var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support", out token);

        if (connectionResult != ConnectionResult.Successful)
        {
            Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult);
            return;
        }

        Console.WriteLine("Connection result: {0}", connectionResult);
        Console.WriteLine();

        // Create new Example Person
        var examplePerson = new SimplePersonV1(
            Guid.NewGuid(),
            EntityRoot.Person,
            PersonCategory.Person);
        examplePerson.Data["Surname"] = "Example";

        // Create examplePerson in database
        client.Persons.Create(examplePerson);

        //Get person to archive
        var personToArchive = client.Persons.Get(examplePerson.Id, Properties.All);

        // Check person Archived status
        Console.WriteLine(personToArchive.Archived);

        // Archive chosen person
        client.Persons.Archive(personToArchive);

        // Check result
        var result = client.Persons.Get(examplePerson.Id, Properties.All);
        Console.WriteLine(result.Archived);

        // Disconnect from server
        client.Disconnect();
    }
}
See Also

Reference

PersonRepository Class
Gamanet.C4.SDK Namespace
SimplePersonV1