/// <summary>Snippet for SearchProfiles</summary>
 public void SearchProfilesRequestObject()
 {
     // Snippet: SearchProfiles(SearchProfilesRequest, CallSettings)
     // Create client
     ProfileServiceClient profileServiceClient = ProfileServiceClient.Create();
     // Initialize request argument(s)
     SearchProfilesRequest request = new SearchProfilesRequest
     {
         ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
         RequestMetadata    = new RequestMetadata(),
         ProfileQuery       = new ProfileQuery(),
         PageSize           = 0,
         PageToken          = "",
         Offset             = 0,
         DisableSpellCheck  = false,
         OrderBy            = "",
         CaseSensitiveSort  = false,
         HistogramQueries   =
         {
             new HistogramQuery(),
         },
         ResultSetId          = "",
         StrictKeywordsSearch = false,
     };
     // Make the request
     SearchProfilesResponse response = profileServiceClient.SearchProfiles(request);
     // End snippet
 }
        /// <summary>Snippet for SearchProfiles</summary>
        public void SearchProfiles_RequestObject()
        {
            // Snippet: SearchProfiles(SearchProfilesRequest,CallSettings)
            // Create client
            ProfileServiceClient profileServiceClient = ProfileServiceClient.Create();
            // Initialize request argument(s)
            SearchProfilesRequest request = new SearchProfilesRequest
            {
                ParentAsCompanyName = new CompanyName("[PROJECT]", "[COMPANY]"),
                RequestMetadata     = new RequestMetadata(),
            };
            // Make the request
            PagedEnumerable <SearchProfilesResponse, HistogramQueryResult> response =
                profileServiceClient.SearchProfiles(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (HistogramQueryResult item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (SearchProfilesResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (HistogramQueryResult item in page)
                {
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <HistogramQueryResult> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (HistogramQueryResult item in singlePage)
            {
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
Example #3
0
        static void Main(string[] args)
        {
            ProfileServiceClient client = new ProfileServiceClient("WSHttpBinding_ProfileService");

            // AddProfile
            Profile newProfile = new Profile()
            {
                Username = "******",
                Password = "******",
                Name = "Guillermo",
                Surname = "Schlereth Lamas",
                Email = "*****@*****.**",
                DateOfBirth = DateTime.Parse("12/06/1972"),
                Description = "Hola soy Guillermo",
                Gender = Gender.Male,
                Address = new Address() { Street = "Federico Mompou, 3", City = "Torremolinos", PostalCode = "29620" }
            };

            Guid guilleID = client.AddProfile(newProfile);

            newProfile = new Profile()
            {
                Username = "******",
                Password = "******",
                Name = "Lidia",
                Surname = "Lluch Fuentes",
                Email = "*****@*****.**",
                DateOfBirth = DateTime.Parse("21/07/1973"),
                Description = "Hola soy Lidia",
                Gender = Gender.Female,
                Address = new Address() { Street = "Federico Mompou, 3", City = "Torremolinos", PostalCode = "29620" }
            };

            Guid lidiaID = client.AddProfile(newProfile);

            newProfile = new Profile()
            {
                Username = "******",
                Password = "******",
                Name = "Liam",
                Surname = "Schlereth Lluch",
                Email = "*****@*****.**",
                DateOfBirth = DateTime.Parse("25/03/2008"),
                Description = "Hola soy Liam",
                Gender = Gender.Male,
                Address = new Address() { Street = "Federico Mompou, 3", City = "Torremolinos", PostalCode = "29620" }
            };

            Guid liamID = client.AddProfile(newProfile);

            // CreateProfile
            Guid sergioID = client.CreateProfile("sergio", "admin123", "*****@*****.**", "Sergio", "Schlereth Lamas");
            Guid mariaID = client.CreateProfile("mariluz", "admin123", "*****@*****.**", "Mariluz", "Schlereth Lamas");
            Guid pericoID = client.CreateProfile("perico", "admin123", "*****@*****.**", "Pedro", "Delgado");

            // GetAllProfiles
            List<Profile> allProfiles = client.GetAllProfiles();
            WriteProfiles(allProfiles, "All profiles -->");

            // GetProfileByID and GetProfileByCredentials
            Profile liamProfile = client.GetProfileByID(liamID);
            Profile sergioProfile = client.GetProfileByID(sergioID);
            Profile lidiaProfile = client.GetProfileByCredentials("lidia", "admin123");

            List<Profile> selectProfiles = new List<Profile>();
            selectProfiles.Add(liamProfile);
            selectProfiles.Add(sergioProfile);
            selectProfiles.Add(lidiaProfile);
            WriteProfiles(selectProfiles, "Liam, Sergio and Lidia profiles -->");

            // ModifyProfile
            sergioProfile.Description = "Hola soy Sergio ...";
            sergioProfile.Email = "*****@*****.**";
            sergioProfile.DateOfBirth = DateTime.Parse("25/06/1986");
            sergioProfile.Gender = Gender.Male;
            sergioProfile.Address = new Address
            {
                Street = "Avda. Bellamina, 3",
                City = "Torremolinos",
                PostalCode = "29620"
            };

            client.ModifyProfile(sergioProfile);
            WriteProfiles(new List<Profile>() { client.GetProfileByID(sergioID) }, "Sergio profile modified -->");

            // DeleteProfile
            client.DeleteProfile(pericoID);
            WriteProfiles(client.GetAllProfiles(), "Perico profile deleted -->");

            // SearchProfiles
            ProfileFilter filter = new ProfileFilter()
            {
                Street = "Mompou"
            };

            List<Profile> searchResult = client.SearchProfiles(filter);
            WriteProfiles(searchResult, "Profiles living in Mompou street -->");

            // AddContact
            client.AddContact(guilleID, lidiaID);
            client.AddContact(guilleID, liamID);

            // AddContacts
            client.AddContacts(guilleID, new List<Guid>() { sergioID, mariaID });

            // GetContacts
            WriteProfiles(client.GetContacts(guilleID), "Guille contacts -->");

            // RemoveContact
            client.RemoveContact(guilleID, sergioID);
            WriteProfiles(client.GetContacts(guilleID), "Sergio removed from guille contacts -->");

            // RemoveAllContacts
            client.RemoveAllContacts(guilleID);
            WriteProfiles(client.GetContacts(guilleID), "Guille contacts removed -->");

            // Delete Profiles
            client.DeleteProfile(guilleID);
            client.DeleteProfile(lidiaID);
            client.DeleteProfile(sergioID);
            client.DeleteProfile(mariaID);
            client.DeleteProfile(liamID);

            WriteProfiles(client.GetAllProfiles(), "All contacts deleted -->");

            Console.ReadLine();
        }