Exemple #1
0
        public ActionResult GetPropertyValues([FromBody] PropertyDictionaryValueSearchCriteria criteria)
        {
            //Need to return PropertyValue as it's more convenient in UI
            var result = _propertySearchService.SearchPropertyDictionaryValues(criteria);

            return(Ok(result));
        }
Exemple #2
0
        public GenericSearchResult <PropertyDictionaryValue> SearchPropertyDictionaryValues(PropertyDictionaryValueSearchCriteria criteria)
        {
            var result = new GenericSearchResult <PropertyDictionaryValue>();

            using (var repository = _repositoryFactory())
            {
                //Optimize performance and CPU usage
                repository.DisableChangesTracking();

                var query = repository.PropertyDictionaryValues;
                if (!string.IsNullOrEmpty(criteria.PropertyId))
                {
                    query = query.Where(x => x.PropertyId == criteria.PropertyId);
                }
                if (!string.IsNullOrEmpty(criteria.Keyword))
                {
                    query = query.Where(x => x.Value.Contains(criteria.Keyword) || x.Alias.Contains(criteria.Keyword));
                }

                var sortInfos = criteria.SortInfos;
                if (sortInfos.IsNullOrEmpty())
                {
                    sortInfos = new[] { new SortInfo {
                                            SortColumn = "Value"
                                        } };
                }
                query             = query.OrderBySortInfos(sortInfos);
                result.TotalCount = query.Count();
                result.Results    = query.Skip(criteria.Skip).Take(criteria.Take).Select(x => x.ToModel(AbstractTypeFactory <PropertyDictionaryValue> .TryCreateInstance())).ToList();
            }
            return(result);
        }