コード例 #1
0
ファイル: ClassificationTests.cs プロジェクト: hiarcdb/hiarc
        public async void FindClassifications()
        {
            var md = TestMetadata;
            var c1 = await _hiarc.CreateClassification(md);

            md["quotaCarrying"] = false;
            await _hiarc.CreateClassification(md);

            await _hiarc.CreateClassification();

            var query = new List <Dictionary <string, object> >
            {
                new Dictionary <string, object>
                {
                    { "prop", "department" },
                    { "op", "starts with" },
                    { "value", "sal" }
                },
                new Dictionary <string, object>
                {
                    { "bool", "and" }
                },
                new Dictionary <string, object>
                {
                    { "parens", "(" }
                },
                new Dictionary <string, object>
                {
                    { "prop", "targetRate" },
                    { "op", ">=" },
                    { "value", 4.22 }
                },
                new Dictionary <string, object>
                {
                    { "bool", "and" }
                },
                new Dictionary <string, object>
                {
                    { "prop", "quotaCarrying" },
                    { "op", "=" },
                    { "value", true }
                },
                new Dictionary <string, object>
                {
                    { "parens", ")" }
                }
            };

            var request = new FindClassificationsRequest {
                Query = query
            };
            var foundClassifications = await _hiarc.FindClassifications(request);

            Assert.Single(foundClassifications);
            Assert.Equal(c1, foundClassifications[0], new EntityComparer());
        }
コード例 #2
0
ファイル: HiarcClient.cs プロジェクト: hiarcdb/hiarc
        public async Task <List <Classification> > FindClassifications(FindClassificationsRequest request, string asUserKey = null, string bearerToken = null, bool logToConsole = true)
        {
            var foundClassifications = await Post <FindClassificationsRequest, List <Classification> >(request, "classifications/find", asUserKey, bearerToken);

            if (logToConsole)
            {
                Console.WriteLine($"Found {foundClassifications.Count} Classifications: {ToJson(foundClassifications)}");
            }
            ;
            return(foundClassifications);
        }
コード例 #3
0
        public async Task <IActionResult> FindClassifications([FromBody] FindClassificationsRequest request)
        {
            try
            {
                var matchingClassifications = await _hiarcDatabase.FindClassifications(request);

                return(Ok(matchingClassifications));
            }
            catch (Exception ex)
            {
                return(BuildErrorResponse(ex, _logger));
            }
        }