Exemple #1
0
        public PagedResultDto <DemoModelDto> GetDemoModels(DemoModelFilter input)
        {
            var query = demoModelRepository.GetAll().Where(x => x.IsDelete == false);

            // filter by value
            if (input.Value != null)
            {
                query = query.Where(x => x.Value == input.Value);
            }

            // filter by Date
            if (input.Date != null)
            {
                query = query.Where(x => x.Date == input.Date);
            }

            var totalCount = query.Count();

            // sorting
            if (!string.IsNullOrWhiteSpace(input.Sorting))
            {
                query = query.OrderBy(input.Sorting);
            }

            // paging
            var items = query.PageBy(input).ToList();

            // result
            return(new PagedResultDto <DemoModelDto>(
                       totalCount,
                       items.Select(item => ObjectMapper.Map <DemoModelDto>(item)).ToList()));
        }
 public PagedResultDto <DemoModelDto> GetDemoModelsByFilter(DemoModelFilter demoModelFilter)
 {
     return(demoModelAppService.GetDemoModels(demoModelFilter));
 }