Example #1
0
        public PagedResultDto <ClientDto> GetClientBySearchQuery(ClientSearchInput input)
        {
            if (input.MaxResultCount <= 0)
            {
                input.MaxResultCount = AppConsts.MaxResultCount;
            }

            if (String.IsNullOrEmpty(input.Sorting))
            {
                input.Sorting = AppConsts.DefaultSortingField;
            }

            var clients = this.Repository.GetAll()
                          .WhereIf(!String.IsNullOrEmpty(input.SearchText), t => t.Name.Contains(input.SearchText) || t.CardCode.Contains(input.SearchText) || t.ContactPerson.Contains(input.SearchText))
                          .WhereIf(input.TenantId.HasValue, w => w.TenantId == input.TenantId)
                          .OrderBy(input.Sorting)
                          .PageBy(input)
                          .ToList();

            var itemsCount = clients.Count();

            return(new PagedResultDto <ClientDto>
            {
                TotalCount = itemsCount,
                Items = clients.MapTo <List <ClientDto> >()
            });
        }
Example #2
0
        public async Task <PagedResultDto <GetAllClientInput> > GetAllBySearchCriteria(ClientSearchInput input)
        {
            var clients = await _repository.GetAllListAsync(a => a.Name.Contains(input.Name) ||
                                                            a.Code.Contains(input.Code));

            return(new PagedResultDto <GetAllClientInput>
            {
                TotalCount = clients.Count(),
                Items = ObjectMapper.Map <List <GetAllClientInput> >(clients)
            });
        }