public static bool MatchesFilter(SubmissionMetaDataModel model, SearchTermModel filter)
        {
            switch (filter.OperatorProperty)
            {
            case FilterConstants.CommonFieldOperators.Equal:
            {
                return(IsEqual(model, filter.FieldValue));
            }

            case FilterConstants.CommonFieldOperators.NotEqual:
            {
                return(!IsEqual(model, filter.FieldValue));
            }

            case FilterConstants.CommonFieldOperators.Empty:
            {
                return(string.IsNullOrEmpty(model?.Value));
            }

            case FilterConstants.CommonFieldOperators.NotEmpty:
            {
                return(!string.IsNullOrEmpty(model?.Value));
            }

            case FilterConstants.StringFieldOperators.Contains:
            {
                return(IsContains(model, filter.FieldValue));
            }

            case FilterConstants.StringFieldOperators.NotContains:
            {
                return(!IsContains(model, filter.FieldValue));
            }

            case FilterConstants.StringFieldOperators.EndsWith:
            {
                return(IsEndsWith(model, filter.FieldValue));
            }

            case FilterConstants.StringFieldOperators.NotEndsWith:
            {
                return(!IsEndsWith(model, filter.FieldValue));
            }

            case FilterConstants.StringFieldOperators.StartsWith:
            {
                return(IsStartsWith(model, filter.FieldValue));
            }

            case FilterConstants.StringFieldOperators.NotStartsWith:
            {
                return(!IsStartsWith(model, filter.FieldValue));
            }

            default:
            {
                throw new NotImplementedException($"Filter for FieldName [{filter.FieldName}] has invalid OperatorProperty [{filter.OperatorProperty}]");
            }
            }
        }
Beispiel #2
0
        public static string GetFieldType(SearchTermModel filter)
        {
            switch (filter.FieldType)
            {
            case FilterConstants.FilterFieldTypes.BooleanType:
            {
                return(nameof(Boolean));
            }

            case FilterConstants.FilterFieldTypes.DateType:
            {
                return(nameof(DateTime));
            }

            case FilterConstants.FilterFieldTypes.NumericalType:
            {
                return(nameof(Double));
            }

            case FilterConstants.FilterFieldTypes.StringType:
            {
                return(nameof(String));
            }

            default:
            {
                throw new NotImplementedException($"Filter for FieldName [{filter.FieldName}] has invalid FieldType [{filter.FieldType}]");
            }
            }
        }
        public static bool MatchesFilter(SubmissionMetaDataModel model, SearchTermModel filter)
        {
            var modelValue  = GetNumericalValue(model?.Value);
            var filterValue = GetNumericalValue(filter?.FieldValue);

            switch (filter.OperatorProperty)
            {
            case FilterConstants.CommonFieldOperators.Equal:
                return(modelValue == filterValue);

            case FilterConstants.CommonFieldOperators.NotEqual:
                return(modelValue != filterValue);

            case FilterConstants.CommonFieldOperators.Empty:
                return(modelValue == null);

            case FilterConstants.CommonFieldOperators.NotEmpty:
                return(modelValue != null);

            case FilterConstants.NumericalFieldOperators.GreaterThan:
                return(modelValue > filterValue);

            case FilterConstants.NumericalFieldOperators.GreaterThanOrEqualTo:
                return(modelValue >= filterValue);

            case FilterConstants.NumericalFieldOperators.LessThan:
                return(modelValue < filterValue);

            case FilterConstants.NumericalFieldOperators.LessThanOrEqualTo:
                return(modelValue <= filterValue);

            default: throw new NotImplementedException($"Filter for FieldName [{filter.FieldName}] has invalid OperatorProperty [{filter.OperatorProperty}]");
            }
        }
Beispiel #4
0
        private bool MatchesFilterTest(string filterType, string fieldValue)
        {
            var fieldName = "Test";

            var filter = new SearchTermModel()
            {
                FieldName        = fieldName,
                FieldType        = filterType,
                FieldValue       = fieldValue,
                OperatorProperty = FilterConstants.CommonFieldOperators.Equal
            };

            var submitContext = GetSubmitContext();

            submitContext.CoreMetaData.Add(
                new SubmissionMetaDataModel()
            {
                Name  = fieldName,
                Type  = FilterHelpers.GetFieldType(filter),
                Value = fieldValue
            }
                );

            return(FilterHelpers.MatchesFilter(submitContext, filter).Result);
        }
Beispiel #5
0
        public void GetField_CanGetSourceField()
        {
            var fieldName     = Guid.NewGuid().ToString();
            var submitContext = GetSubmitContext();

            submitContext.SourceMetaData.Add(
                new SubmissionMetaDataModel()
            {
                Name  = fieldName,
                Type  = nameof(String),
                Value = "Test"
            }
                );

            var filter = new SearchTermModel()
            {
                FieldName        = GetSourceFieldName(Guid.NewGuid(), fieldName, nameof(String)),
                FieldType        = nameof(String),
                FieldValue       = "Test",
                OperatorProperty = FilterConstants.CommonFieldOperators.Equal
            };

            var field = FilterHelpers.GetField(submitContext, filter, nameof(String));

            Assert.Equal(fieldName, field.Name);
        }
Beispiel #6
0
        public static bool MatchesFilter(SubmissionMetaDataModel model, SearchTermModel filter)
        {
            var fieldValue  = GetDateTimeValue(model?.Value);
            var filterValue = GetDateTimeValue(filter.FieldValue);

            switch (filter.OperatorProperty)
            {
            case FilterConstants.CommonFieldOperators.Equal:
            {
                if (fieldValue.HasValue && filterValue.HasValue)
                {
                    return(fieldValue.Value >= filterValue.Value && fieldValue < filterValue.Value.AddHours(24));
                }
                else
                {
                    return(fieldValue == filterValue);
                }
            }

            case FilterConstants.CommonFieldOperators.NotEqual:
            {
                if (fieldValue.HasValue && filterValue.HasValue)
                {
                    return(fieldValue.Value < filterValue.Value || fieldValue >= filterValue.Value.AddHours(24));
                }
                else
                {
                    return(fieldValue != filterValue);
                }
            }

            case FilterConstants.CommonFieldOperators.Empty:
            {
                return(fieldValue == null);
            }

            case FilterConstants.CommonFieldOperators.NotEmpty:
            {
                return(fieldValue != null);
            }

            case FilterConstants.DateFieldOperators.Before:
            {
                return(fieldValue < filterValue);
            }

            case FilterConstants.DateFieldOperators.After:
            {
                return(fieldValue > filterValue);
            }

            default:
            {
                throw new NotImplementedException($"Filter for FieldName [{filter.FieldName}] has invalid OperatorProperty [{filter.OperatorProperty}]");
            }
            }
        }
Beispiel #7
0
        public async Task <IActionResult> SearchAsync(SearchTermModel term)
        {
            var result = await searchService.SearchAsync(term.CustomerId);

            if (result.IsSuccess)
            {
                return(Ok(result.SearchResults));
            }
            return(NotFound());
        }
Beispiel #8
0
        public virtual async Task <ActionResult> Index(SearchTermModel model)
        {
            if (model.Query.IsNullOrWhiteSpace())
            {
                return(View());
            }

            if (Request.QueryString.AllKeys.Length == 1 && !string.IsNullOrWhiteSpace(Request.QueryString["Query"]))
            {
                model.SearchPlace = SearchPlace.Title;
            }

            var result = await _searchEngine.SearchAsync(model.Query, model.FilterByCategory, model.LanguageId ?? 0,
                                                         model.PostType, model.SearchPlace, model.OrderBy);

            if (result.HasError)
            {
                var errorCode = ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Error(result.Error, System.Web.HttpContext.Current));
                ViewBag.ErrorCode = errorCode;
                return(View("Error"));
            }

            model.Query    = model.Query.Trim();
            model.PageSize = model.PageSize ?? int.MaxValue;
            model.Page     = model.Page ?? 1;

            var currentUser = UserManager.FindById(User.Identity.GetUserId());
            var posts       = _postService.GetItemsById(result.Documents.Select(p => p.DocumentId).ToList(), model.Page.Value,
                                                        model.PageSize.Value);

            var viewModel = new SearchResultModel
            {
                TimeElapsed        = result.ElapsedMilliseconds,
                SearchTerm         = model,
                NumberOfItemsFound = posts.Count,
                SearchResult       = _postModelFactory.PreparePostCardViewModel(posts, currentUser, Url),
                SuggestSimilar     = result.SuggestSimilar,
                CardViewStyles     = ViewStyles.Normal
            };

            foreach (var document in result.Documents)
            {
                var post = viewModel.SearchResult.FirstOrDefault(p => p.Id == document.DocumentId);
                if (post != null)
                {
                    post.DescriptionTruncated = document.DocumentBody;
                    post.Title = document.DocumentTitle;
                }
            }

            return(View(viewModel));
        }
        public AddressDetails GetContactAddress(SearchTermModel searchTerm)
        {
            try
            {
                var addressContact = _addressBookEngine.RequestToRetrieveContact(searchTerm);

                return(addressContact);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to retrieve contact", ex);
            }
        }
Beispiel #10
0
        public IActionResult SearchTermEditor(int searchTermId)
        {
            var searchTerm = searchTermId > 0 ? _searchTermService.Get(searchTermId) : new SearchTerm();
            var model      = new SearchTermModel()
            {
                Id           = searchTermId,
                Score        = searchTerm.Score,
                Term         = searchTerm.Term,
                TermCategory = searchTerm.TermCategory
            };

            return(R.Success.With("searchTerm", model).Result);
        }
Beispiel #11
0
        public void SaveSearchTest_WhenUpdate()
        {
            var target       = GetTarget();
            var targetSearch = new SearchModel();

            targetSearch.SearchName   = Guid.NewGuid().ToString();
            targetSearch.CreatedOnUtc = System.DateTime.UtcNow;
            var t1 = new SearchTermModel();

            t1.Term  = "Static";
            t1.Score = 1;
            var t2 = new SearchTermModel();

            t2.Term  = "Dynamic";
            t2.Score = 2;
            targetSearch.SearchTerms = new List <ISearchTerm>();
            targetSearch.SearchTerms.Add(t1);
            targetSearch.SearchTerms.Add(t2);
            target.SaveSearch(targetSearch);

            //check existing
            using (var ctx = new SearcherEntities())
            {
                var existing = ctx.Searches.Single(x => x.SearchName == targetSearch.SearchName);

                var existingT1 = existing.SearchTerms.Single(x => x.Term == t1.Term);
                var existingT2 = existing.SearchTerms.Single(x => x.Term == t2.Term);
                Assert.AreEqual(t1.Score, existingT1.Score, "First Term Scores do not match");
                Assert.AreEqual(t2.Score, existingT2.Score, "Second Term Scores do not match");

                targetSearch.Id = existing.Id;
            }
            var t3 = new SearchTermModel();

            t3.Term  = "Brand New";
            t3.Score = 3;

            targetSearch.SearchTerms.Remove(t1);
            t2.Score = 100;
            targetSearch.SearchTerms.Add(t3);
            target.SaveSearch(targetSearch);
            using (var ctx = new SearcherEntities())
            {
                var existing = ctx.Searches.Single(x => x.Id == targetSearch.Id);
                var newTerm  = existing.SearchTerms.Single(x => x.Term == t3.Term);
                var deleted  = existing.SearchTerms.SingleOrDefault(x => x.Term == t1.Term);
                Assert.IsNull(deleted, "Deleted Term exists in Database");
                var existingTerm = existing.SearchTerms.SingleOrDefault(x => x.Term == t2.Term);
                Assert.IsTrue(existingTerm.Score == t2.Score, "Updated Score does not match");
            }
        }
 public void SaveSearchTest_WhenDuplicateTerms()
 {
     var target = GetTarget();
     var targetSearch = new SearchModel();
     targetSearch.SearchName = Guid.NewGuid().ToString();
     var t1 = new SearchTermModel();
     t1.Term = "Duplicate";
     t1.Score = 1;
     var t2 = new SearchTermModel();
     t2.Term = "Duplicate";
     t2.Score = 2;
     targetSearch.SearchTerms = new List<ISearchTerm> {t1, t2};
     target.SaveSearch(targetSearch);
 }
Beispiel #13
0
        public IActionResult SaveSearchTerm(SearchTermModel searchTermModel)
        {
            var searchTerm = searchTermModel.Id > 0 ? _searchTermService.Get(searchTermModel.Id) : new SearchTerm();

            if (searchTerm == null)
            {
                return(NotFound());
            }

            _modelMapper.Map(searchTermModel, searchTerm);
            _searchTermService.InsertOrUpdate(searchTerm);

            return(R.Success.With("id", searchTerm.Id).Result);
        }
        public void SaveSearchTest_WhenUpdate()
        {
            var target = GetTarget();
            var targetSearch = new SearchModel();
            targetSearch.SearchName = Guid.NewGuid().ToString();
            targetSearch.CreatedOnUtc = System.DateTime.UtcNow;
            var t1 = new SearchTermModel();
            t1.Term = "Static";
            t1.Score = 1;
            var t2 = new SearchTermModel();
            t2.Term = "Dynamic";
            t2.Score = 2;
            targetSearch.SearchTerms = new List<ISearchTerm>();
            targetSearch.SearchTerms.Add(t1);
            targetSearch.SearchTerms.Add(t2);
            target.SaveSearch(targetSearch);

            //check existing
            using (var ctx = new SearcherEntities())
            {
                var existing = ctx.Searches.Single(x => x.SearchName == targetSearch.SearchName);

                var existingT1 = existing.SearchTerms.Single(x => x.Term == t1.Term);
                var existingT2 = existing.SearchTerms.Single(x => x.Term == t2.Term);
                Assert.AreEqual(t1.Score, existingT1.Score, "First Term Scores do not match");
                Assert.AreEqual(t2.Score, existingT2.Score, "Second Term Scores do not match");

                targetSearch.Id = existing.Id;

            }
            var t3 = new SearchTermModel();
            t3.Term = "Brand New";
            t3.Score = 3;

            targetSearch.SearchTerms.Remove(t1);
            t2.Score = 100;
            targetSearch.SearchTerms.Add(t3);
            target.SaveSearch(targetSearch);
            using (var ctx = new SearcherEntities())
            {
                var existing = ctx.Searches.Single(x => x.Id == targetSearch.Id);
                var newTerm = existing.SearchTerms.Single(x => x.Term == t3.Term);
                var deleted = existing.SearchTerms.SingleOrDefault(x => x.Term == t1.Term);
                Assert.IsNull(deleted, "Deleted Term exists in Database");
                var existingTerm = existing.SearchTerms.SingleOrDefault(x => x.Term == t2.Term);
                Assert.IsTrue(existingTerm.Score == t2.Score, "Updated Score does not match");
            }
        }
Beispiel #15
0
        public static SubmissionMetaDataModel GetField(SubmitContext submitContext, SearchTermModel filter, string expectedFieldType)
        {
            // Format of a source field name in Records365: S|<ConnectorTypeId>|<DataType>|<FieldName>
            if (filter.FieldName.StartsWith(_sourceFieldPrefix))
            {
                // Avoiding String.Split due to performance concerns. Not using LastIndexOf in case a Field name contains a pipe.
                // We want to skip over S|<ConnectorTypeId>|, which has a known length (39 characters), then find the index of the first pipe following that.
                // After that pipe, the rest should be the Source property's field name
                var lastPipeIndex   = filter.FieldName.IndexOf(_separator, _indexAfterSeparator);
                var sourceFieldName = filter.FieldName.Substring(lastPipeIndex + 1);

                return(submitContext?.SourceMetaData?.FirstOrDefault(x => x.Name == sourceFieldName && x.Type == expectedFieldType));
            }

            return(submitContext?.CoreMetaData?.FirstOrDefault(x => x.Name == filter.FieldName));
        }
        private List <SearchTermModel> collectSearchTerms()
        {
            List <SearchTermModel> searchTerms = new List <SearchTermModel>();

            foreach (Control control in this.Controls)
            {
                if ((control is TextBox | control is ComboBox) & control.Text != "")
                {
                    SearchTermModel searchTerm = new SearchTermModel();
                    searchTerm.SearchTerm  = control.Tag.ToString();
                    searchTerm.SearchValue = control.Text;
                    searchTerms.Add(searchTerm);
                    searchTerm = null;
                }
            }
            return(searchTerms);
        }
Beispiel #17
0
        public AddressDetails GetContact(SearchTermModel searchTerm)
        {
            try
            {
                var filter = Builders <AddressDetails> .Filter.Eq(a => a.FirstName, searchTerm.FirstName);

                var addressContact = _addressCollection
                                     .Find(filter)
                                     .FirstOrDefault();

                return(addressContact);
            }
            catch (DbException ex)
            {
                throw;
            }
        }
Beispiel #18
0
        public void SaveSearchTest_WhenDuplicateTerms()
        {
            var target       = GetTarget();
            var targetSearch = new SearchModel();

            targetSearch.SearchName = Guid.NewGuid().ToString();
            var t1 = new SearchTermModel();

            t1.Term  = "Duplicate";
            t1.Score = 1;
            var t2 = new SearchTermModel();

            t2.Term  = "Duplicate";
            t2.Score = 2;
            targetSearch.SearchTerms = new List <ISearchTerm> {
                t1, t2
            };
            target.SaveSearch(targetSearch);
        }
Beispiel #19
0
        public void OperatorPropertyNull_MatchesBoolFilterTest()
        {
            var expectedValue = new SubmissionMetaDataModel()
            {
                DisplayName = nameof(String),
                Name        = nameof(String),
                Type        = nameof(String),
                Value       = nameof(String),
            };

            var filterValue = new SearchTermModel()
            {
                FieldName        = FilterConstants.FilterFieldTypes.StringType,
                FieldType        = FilterConstants.FilterFieldTypes.BooleanType,
                FieldValue       = FilterConstants.FilterFieldTypes.StringType,
                OperatorProperty = null
            };

            Assert.Throws <NotImplementedException>(() => BooleanFilter.MatchesFilter(expectedValue, filterValue));
        }
Beispiel #20
0
        public void InvalidDateTimeFilterTests(string submitValue, string filterFieldValue, string operatorType)
        {
            var expectedValue = new SubmissionMetaDataModel()
            {
                DisplayName = nameof(String),
                Name        = nameof(String),
                Type        = nameof(String),
                Value       = submitValue
            };

            var filterValue = new SearchTermModel()
            {
                FieldName        = FilterConstants.FilterFieldTypes.StringType,
                FieldType        = FilterConstants.FilterFieldTypes.DateType,
                FieldValue       = filterFieldValue,
                OperatorProperty = operatorType
            };

            Assert.Throws <ValidationException>(() => DateTimeFilter.MatchesFilter(expectedValue, filterValue));
        }
        public static bool MatchesFilter(SubmissionMetaDataModel model, SearchTermModel filter)
        {
            switch (filter.OperatorProperty)
            {
            case FilterConstants.CommonFieldOperators.Equal:
            {
                return(IsEqual(model, filter.FieldValue));
            }

            case FilterConstants.CommonFieldOperators.NotEqual:
            {
                return(!IsEqual(model, filter.FieldValue));
            }

            default:
            {
                throw new NotImplementedException($"Filter for FieldName [{filter.FieldName}] has invalid OperatorProperty [{filter.OperatorProperty}]");
            }
            }
        }
        private bool MatchesFilterTest(string filterfieldValue, string modelValue, string operatorProperty)
        {
            var fieldName = "Test";

            var filter = new SearchTermModel()
            {
                FieldName        = fieldName,
                FieldType        = FilterConstants.FilterFieldTypes.StringType,
                FieldValue       = filterfieldValue,
                OperatorProperty = operatorProperty
            };

            var model = new SubmissionMetaDataModel()
            {
                Name  = fieldName,
                Type  = FilterHelpers.GetFieldType(filter),
                Value = modelValue
            };

            return(StringFilter.MatchesFilter(model, filter));
        }
Beispiel #23
0
        public void ValidDateTimeFilterTests(string submitValue, string filterFieldValue, string operatorType, bool expectedResult)
        {
            var expectedValue = new SubmissionMetaDataModel()
            {
                DisplayName = nameof(String),
                Name        = nameof(String),
                Type        = nameof(String),
                Value       = submitValue
            };

            var filterValue = new SearchTermModel()
            {
                FieldName        = FilterConstants.FilterFieldTypes.StringType,
                FieldType        = FilterConstants.FilterFieldTypes.DateType,
                FieldValue       = filterFieldValue,
                OperatorProperty = operatorType
            };

            var result = DateTimeFilter.MatchesFilter(expectedValue, filterValue);

            Assert.Equal(expectedResult, result);
        }
Beispiel #24
0
        public void DoesNotMatchBoolFilterTest(string submitValue, string fieldValue, bool expectedResult)
        {
            var expectedValue = new SubmissionMetaDataModel()
            {
                DisplayName = nameof(String),
                Name        = nameof(String),
                Type        = nameof(String),
                Value       = submitValue
            };

            var filterValue = new SearchTermModel()
            {
                FieldName        = FilterConstants.FilterFieldTypes.StringType,
                FieldType        = FilterConstants.FilterFieldTypes.BooleanType,
                FieldValue       = fieldValue,
                OperatorProperty = FilterConstants.CommonFieldOperators.NotEqual
            };

            var result = BooleanFilter.MatchesFilter(expectedValue, filterValue);

            Assert.Equal(expectedResult, result);
        }
Beispiel #25
0
        public virtual async Task <ActionResult> Tag(string tag, int?page)
        {
            if (tag.IsNullOrWhiteSpace())
            {
                return(View("Index"));
            }

            var result = await _searchEngine.SearchAsync($"\"{tag}\"", null, 0, null, SearchPlace.Tags,
                                                         SearchResultSortType.Score, 1000, true);

            if (result.HasError)
            {
                var errorCode = ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Error(result.Error, System.Web.HttpContext.Current));
                ViewBag.ErrorCode = errorCode;
                return(View("Error"));
            }

            var searchTerm = new SearchTermModel {
                Query = tag.Trim(), Page = page ?? 1, PageSize = 20
            };

            var currentUser = UserManager.FindById(User.Identity.GetUserId());
            var posts       = _postService.GetItemsById(result.Documents.Select(p => p.DocumentId).ToList(),
                                                        searchTerm.Page.Value, searchTerm.PageSize.Value);

            var viewModel = new SearchResultModel
            {
                TimeElapsed             = result.ElapsedMilliseconds,
                SearchTerm              = searchTerm,
                NumberOfItemsFound      = posts.Count,
                SearchResult            = _postModelFactory.PreparePostCardViewModel(posts, currentUser, Url),
                ShowAdvancedSearchPanel = false,
                CardViewStyles          = ViewStyles.Small,
            };

            return(View("Index", viewModel));
        }
Beispiel #26
0
        public void GetField_CanGetFieldOfCorrectType()
        {
            var fieldName     = Guid.NewGuid().ToString();
            var submitContext = GetSubmitContext();

            foreach (var fieldType in FieldTypes)
            {
                submitContext.SourceMetaData.Add(
                    new SubmissionMetaDataModel()
                {
                    Name  = fieldName,
                    Type  = fieldType,
                    Value = "Test"
                }
                    );
            }

            foreach (var filterType in FilterTypes)
            {
                var fieldType = FilterHelpers.GetFieldType(new SearchTermModel()
                {
                    FieldType = filterType
                });

                var filter = new SearchTermModel()
                {
                    FieldName        = GetSourceFieldName(Guid.NewGuid(), fieldName, fieldType),
                    FieldType        = filterType,
                    FieldValue       = "Test",
                    OperatorProperty = FilterConstants.CommonFieldOperators.Equal
                };

                var field = FilterHelpers.GetField(submitContext, filter, fieldType);
                Assert.Equal(fieldName, field.Name);
                Assert.Equal(fieldType, field.Type);
            }
        }
Beispiel #27
0
        public static MatchResult MatchesFilter(SubmitContext submitContext, SearchTermModel filter)
        {
            var fieldType = GetFieldType(filter);
            var field     = GetField(submitContext, filter, fieldType);

            if (field != null && field.Type != fieldType)
            {
                throw new ValidationException($"Field [{field.Name}] has FieldType [{field.Type}] and does not match Filter's FieldType [{filter.FieldType}]");
            }

            var result = false;

            switch (filter.FieldType)
            {
            case FilterConstants.FilterFieldTypes.BooleanType:
            {
                result = BooleanFilter.MatchesFilter(field, filter);
                break;
            }

            case FilterConstants.FilterFieldTypes.DateType:
            {
                result = DateTimeFilter.MatchesFilter(field, filter);
                break;
            }

            case FilterConstants.FilterFieldTypes.NumericalType:
            {
                result = NumericalFilter.MatchesFilter(field, filter);
                break;
            }

            case FilterConstants.FilterFieldTypes.StringType:
            {
                result = StringFilter.MatchesFilter(field, filter);
                break;
            }

            default:
            {
                throw new NotImplementedException($"Filter for FieldName [{filter.FieldName}] has invalid FieldType [{filter.FieldType}]");
            }
            }

            if (!result)
            {
                return(new MatchResult()
                {
                    Result = false,
                    MatchReason = $"Field [{field?.Name ?? "<Null>"}] " +
                                  $"Value [{field?.Value ?? "<Null>"}] " +
                                  $"failed to match Filter: " +
                                  $"Field Name {filter.FieldName} " +
                                  $"Type [{filter.FieldType}] " +
                                  $"Operator [{filter.OperatorProperty}] " +
                                  $"Value [{filter?.FieldValue ?? "<Null>"}]"
                });
            }

            return(new MatchResult()
            {
                Result = true,
                MatchReason = $"Field [{field?.Name ?? "<Null>"}] " +
                              $"Value [{field?.Value ?? "<Null>"}] " +
                              $"matched Filter: " +
                              $"Field Name {filter.FieldName} " +
                              $"Type [{filter.FieldType}] " +
                              $"Operator [{filter.OperatorProperty}] " +
                              $"Value [{filter?.FieldValue ?? "<Null>"}]"
            });
        }