public bool Create(Organization organization)
        {
            IRestRequest request = new RestRequest("/api/Organization", Method.POST);
            string postData = JsonConvert.SerializeObject(organization);
            request.AddParameter("application/json; charset=utf-8", postData, ParameterType.RequestBody);
            request.RequestFormat = DataFormat.Json;

            IRestResponse response = Client.Post(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK) { OrganizationId = JsonConvert.DeserializeObject<string>(response.Content); return true; }
            else { this.setError(response); return false; }
        }
Exemplo n.º 2
0
        static void CreateOrganization()
        {
            ServiceFactory factory = new ServiceFactory();
            IOrganizationService oService = factory.CreateOrganizationService();

            var organization = new Organization()
            {
                Name = "Test Organizasyonum",
                Url = "localhost",
                Culture = "tr-TR",
                AllowAdvertisement = true,
                /*User informations*/
                AdministratorUsername = "******",
                AdministratorPassword = "******",
                AdministratorEmail = "*****@*****.**",
                AdministratorFirstname = "Test",
                AdministratorLastname = "Account",
                AdministratorGender = "Male"
            };

            bool success = oService.Create(organization);

            if (success) Console.WriteLine(string.Format("OrganizationGuid: {0}", oService.OrganizationId));
            else printError(oService.LastError);
        }