/// <summary>
        /// Updates or creates a resource based on the resource identifier. The PUT operation is used to update or create a resource by identifier.  If the resource doesn't exist, the resource will be created using that identifier.  Additionally, natural key values cannot be changed using this operation, and will not be modified in the database.  If the resource &quot;id&quot; is provided in the JSON body, it will be ignored as well.
        /// </summary>
        /// <param name="id">A resource identifier specifying the resource to be updated.</param>
        /// <param name="IfMatch">The ETag header value used to prevent the PUT from updating a resource modified by another consumer.</param>
        /// <param name="body">The JSON representation of the &quot;countryDescriptor&quot; resource to be updated.</param>
        /// <returns>A RestSharp <see cref="IRestResponse"/> instance containing the API response details.</returns>
        public IRestResponse PutCountryDescriptor(string id, string IfMatch, CountryDescriptor body)
        {
            var request = new RestRequest("/countryDescriptors/{id}", Method.PUT);

            request.RequestFormat = DataFormat.Json;

            request.AddUrlSegment("id", id);
            // verify required params are set
            if (id == null || body == null)
            {
                throw new ArgumentException("API method call is missing required parameters");
            }
            request.AddHeader("If-Match", IfMatch);
            request.AddBody(body);
            request.Parameters.First(param => param.Type == ParameterType.RequestBody).Name = "application/json";
            var response = client.Execute(request);

            var location = response.Headers.FirstOrDefault(x => x.Name == "Location");

            if (location != null && !string.IsNullOrWhiteSpace(location.Value.ToString()))
            {
                body.id = location.Value.ToString().Split('/').Last();
            }
            return(response);
        }
Example #2
0
 void Awake()
 {
     area = gameObject.GetComponentInChildren<Area>();
     border = gameObject.GetComponentInChildren<CountryBorder>();
     state = gameObject.GetComponentInChildren<CountryState>();
     provinces = gameObject.GetComponentInChildren<Provinces>();
     descriptor = gameObject.GetComponent<CountryDescriptor>();
 }
Example #3
0
    public static CountryDescriptorData fromComponent(CountryDescriptor descriptor)
    {
        if (descriptor == null) {
            return null;
        }

        CountryDescriptorData descriptorData = new CountryDescriptorData();
        descriptorData.id = descriptor.id;
        descriptorData.countryName = descriptor.countryName;
        return descriptorData;
    }
    public static void AddCountry(CountryDescriptor countryDescriptor, Country country)
    {
        if (!countryDescriptor.isValid()) {
            GameLogger.printRed(string.Format("DynamicObjectRegistry:: Cannot add invalid {0} country descriptor!", countryDescriptor.countryName));
            return;
        }

        if (COUNTRIES.ContainsKey(countryDescriptor.countryName)) {
            GameLogger.printRed(string.Format("DynamicObjectRegistry:: Country {0} already present!", countryDescriptor.countryName));
            return;
        }

        COUNTRIES.Add(countryDescriptor.countryName, country);
    }
Example #5
0
        /// <summary>
        /// Creates or updates resources based on the natural key values of the supplied resource. The POST operation can be used to create or update resources. In database terms, this is often referred to as an &quot;upsert&quot; operation (insert + update).  Clients should NOT include the resource &quot;id&quot; in the JSON body because it will result in an error (you must use a PUT operation to update a resource by &quot;id&quot;). The web service will identify whether the resource already exists based on the natural key values provided, and update or create the resource appropriately.
        /// </summary>
        /// <param name="body">The JSON representation of the &quot;countryDescriptor&quot; resource to be created or updated.</param>
        /// <returns>A RestSharp <see cref="IRestResponse"/> instance containing the API response details.</returns>
        public IRestResponse PostCountryDescriptors(CountryDescriptor body)
        {
            var request = new RestRequest("/countryDescriptors", Method.POST);

            request.RequestFormat = DataFormat.Json;

            // verify required params are set
            if (body == null)
            {
                throw new ArgumentException("API method call is missing required parameters");
            }
            request.AddBody(body);
            var response = client.Execute(request);

            var location = response.Headers.FirstOrDefault(x => x.Name == "Location");

            if (location != null && !string.IsNullOrWhiteSpace(location.Value.ToString()))
            {
                body.id = location.Value.ToString().Split('/').Last();
            }
            return(response);
        }
    public static Country GetCountry(CountryDescriptor countryDescriptor)
    {
        if (!countryDescriptor.isValid()) {
            return null;
        }

        if (!COUNTRIES.ContainsKey(countryDescriptor.countryName)) {
            GameLogger.printRed(string.Format("DynamicObjectRegistry:: country {0} not found", countryDescriptor.countryName));
            return null;
        }

        return COUNTRIES[countryDescriptor.countryName];
    }
Example #7
0
 public static void toComponent(CountryDescriptorData descriptorData, CountryDescriptor descriptor)
 {
     descriptor.id = descriptorData.id;
     descriptor.countryName = descriptorData.countryName;
 }
Example #8
0
        public void SetUp()
        {
            CountryTestDescriptor1 = new CountryDescriptor
            {
                Namespace          = "uri://namespace1/CountryDescriptor",
                CodeValue          = "Test Country Descriptor 1",
                ShortDescription   = "Test Country Descriptor 1",
                Description        = "Test Country Descriptor 1",
                EffectiveBeginDate = DateTime.Now
            };

            CountryTestDescriptor2 = new CountryDescriptor
            {
                Namespace          = "uri://namespace1/CountryDescriptor",
                CodeValue          = "Test Country Descriptor 2",
                ShortDescription   = "Test Country Descriptor 2",
                Description        = "Test Country Descriptor 2",
                EffectiveBeginDate = DateTime.Now
            };

            CountryTestDescriptor3 = new CountryDescriptor
            {
                Namespace          = "uri://namespace2/CountryDescriptor",
                CodeValue          = "Test Country Descriptor 1",
                ShortDescription   = "Test Country Descriptor 1",
                Description        = "Test Country Descriptor 1",
                EffectiveBeginDate = DateTime.Now
            };

            AssessmentPeriodTestDescriptor1 = new AssessmentPeriodDescriptor
            {
                Namespace          = "uri://namespace1/AssessmentPeriodDescriptor",
                CodeValue          = "Test Assessment Period Descriptor 1",
                ShortDescription   = "Test Assessment Period Descriptor 1",
                Description        = "Test Assessment Period Descriptor 1",
                EffectiveBeginDate = DateTime.Now
            };

            using (var session = SessionFactory.OpenSession())
            {
                session.Save(CountryTestDescriptor1);
                session.Save(CountryTestDescriptor2);
                session.Save(CountryTestDescriptor3);
                session.Save(AssessmentPeriodTestDescriptor1);
            }

            var domainModelBuilder = new DomainModelBuilder();

            domainModelBuilder.AddSchema(new SchemaDefinition("Ed-Fi", "edfi"));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("edfi", "AssessmentPeriodDescriptor"),
                    new FullName[] { }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "edfi",
                    "AssessmentPeriodDescriptor",
                    new EntityPropertyDefinition[] { },
                    new EntityIdentifierDefinition[] { }));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("edfi", "CountryDescriptor"),
                    new FullName[] { }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "edfi",
                    "CountryDescriptor",
                    new EntityPropertyDefinition[] { },
                    new EntityIdentifierDefinition[] { }));

            var domainModelProvider = MockRepository.GenerateMock <IDomainModelProvider>();

            domainModelProvider.Stub(x => x.GetDomainModel())
            .Return(domainModelBuilder.Build());

            DescriptorLookupProvider = new DescriptorLookupProvider(
                SessionFactory, new EdFiDescriptorReflectionProvider(domainModelProvider));
        }