Example #1
0
 public SearchResult(IEnumerable <T> results, DTO.SearchFilter filters, int rowCount)
 {
     this.Results     = new List <T>(results);
     this.Skip        = !filters.Skip.IsNull() ? filters.Skip.Value : 1;
     this.Take        = !filters.Take.IsNull() ? filters.Take.Value : 10;
     this.TotalResult = rowCount;
 }
Example #2
0
        public VO.SearchResult <Store> Search(DTO.SearchFilter filter)
        {
#if DEBUG
            Context.Database.Log = (s) => Debug.WriteLine(s);
#endif
            IQueryable <Store> result = Collection.AsQueryable();

            if (!filter.Code.IsNull() && !filter.Code.IsEmpty())
            {
                result = result.Where(store => store.Code == filter.Code);
            }

            if (!filter.Document.IsNullOrWhiteSpace())
            {
                result = result.Where(store => store.Cnpj == filter.Document);
            }

            if (!filter.Term.IsNullOrWhiteSpace())
            {
                result = result.Where(store => store.Name.ToLower().Contains(filter.Term.ToLower()));
            }

            result = result.OrderBy(i => i.SaveDate);

            var count = result.Count();

            result = result.Skip((filter.Skip.Value) * filter.Take.Value);

            result = result.Take(filter.Take.Value);

            return(new VO.SearchResult <Store>(result.ToList(), filter, count));
        }
Example #3
0
        public DTO.SearchResult Search(DTO.SearchFilter filter)
        {
            var result = metadataFieldRepository.Search(filter as DTO.SearchFilterMetadataField);

            var fields = result.Results.Select(d => new DTO.MetadataField(d)).ToList();

            return(new DTO.SearchResult(fields).SetResult <MetadataField>(result));
        }
Example #4
0
        public DTO.SearchResult Search(DTO.SearchFilter filter)
        {
            filter.Document = filter.Document.ClearStrings().AsString("").Trim();
            filter.Term     = filter.Term.ClearStrings().AsString("").Trim();

            if (filter.Code.IsEmpty() && filter.Document.IsNullorEmpty() && filter.Term.IsNullorEmpty())
            {
                throw new ArgumentException("Nenhum parametro informado para pesquisa!");
            }

            var result = storeRepository.Search(filter);
            var stores = result.Results.Select(s => new DTO.Store(s));

            return(new DTO.SearchResult(stores).SetResult <Store>(result));
        }
Example #5
0
        public DTO.SearchResult Search(DTO.SearchFilter filter)
        {
            var _filter = filter as DTO.SearchFilterAccount;

            if (_filter.Code.IsEmpty() && _filter.Document.IsNullorEmpty() && _filter.Email.IsNullorEmpty())
            {
                return(null);
            }

            _filter.Email    = _filter.Email.AsString("").Trim();
            _filter.Document = _filter.Document.ClearStrings().AsString("").Trim();

            var result   = accountRepository.Search(_filter);
            var accounts = result.Results.Select(a => new DTO.Account(a));

            return(new DTO.SearchResult(accounts).SetResult <Account>(result));
        }